File

src/app/modules/search/services/user-search/user-search.service.ts

Description

Service to get course consumption dashboard

It responsible to make http call

Index

Properties
Methods

Constructor

constructor(learnerService: LearnerService, config: ConfigService)
Parameters :
Name Type Optional
learnerService LearnerService No
config ConfigService No

Methods

deleteUser
deleteUser(requestParam)
Parameters :
Name Optional
requestParam No
Returns : any
getUserById
getUserById(requestParam)
Parameters :
Name Optional
requestParam No
Returns : any
getUserByIdV5
getUserByIdV5(requestParam)
Parameters :
Name Optional
requestParam No
Returns : any
getUserType
getUserType()
Returns : any
updateRoles
updateRoles(requestParam)
Parameters :
Name Optional
requestParam No
Returns : any

Properties

Public config
Type : ConfigService

To get api urls

userDeleteEvent
Default value : new EventEmitter()

To listen event

userDetailsObject
Type : any
import {map} from 'rxjs/operators';
import { Injectable, EventEmitter } from '@angular/core';
import { ConfigService } from '@sunbird/shared';
import { LearnerService } from '@sunbird/core';

/**
 * Service to get course consumption dashboard
 *
 * It responsible to make http call
 */
@Injectable()

/**
 * @class UserSearchService
 */
export class UserSearchService {

  userDetailsObject: any;

    /**
   * To listen event
   */
  userDeleteEvent = new EventEmitter();


  /**
   * To get api urls
   */
  public config: ConfigService;

  constructor(private learnerService: LearnerService,
  config: ConfigService) {
    this.config = config;
  }

  deleteUser(requestParam) {
    const option = {
      url: this.config.urlConFig.URLS.ADMIN.DELETE_USER,
      data: {
        'request': {
          'userId': requestParam.userId
        }
      }
    };

    return this.learnerService.post(option).pipe(map(data => {
      this.userDeleteEvent.emit(requestParam.userId);
      return data;
    }));
  }

  updateRoles(requestParam) {
    const option = {
      url: this.config.urlConFig.URLS.ADMIN.UPDATE_USER_ORG_ROLES,
      data: {
          'request': {
            'userId': requestParam.userId,
            'organisationId': requestParam.orgId,
            'roles': requestParam.roles
          }
        }
    };

    return this.learnerService.post(option);
  }

  getUserById(requestParam) {
    const option = {
      url: this.config.urlConFig.URLS.USER.GET_PROFILE + requestParam.userId + '?fields=organisations,roles,locations'
    };

    return this.learnerService.get(option);
  }

  getUserByIdV5(requestParam) {
    const option = {
      url: this.config.urlConFig.URLS.USER.GET_PROFILE_V5 + requestParam.userId + '?fields=organisations,roles,locations'
    };
    return this.learnerService.get(option);
  }

  getUserType() {
    const option = {
      url: this.config.urlConFig.URLS.USER.TYPE
    };

    return this.learnerService.get(option);
  }
}

results matching ""

    No results matching ""