File

src/app/modules/manage/services/manage/manage.service.ts

Index

Properties
Methods

Constructor

constructor(configService: ConfigService, learnerService: LearnerService, httpClient: HttpClient)

for making upload api calls

Parameters :
Name Type Optional
configService ConfigService No
learnerService LearnerService No
httpClient HttpClient No

Methods

Public bulkOrgUpload
bulkOrgUpload(req)

This method is used to call upload api to upload organizations file

Parameters :
Name Optional
req No
getBulkUploadStatus
getBulkUploadStatus(processId)

This method is used to call status api to get the status of uploaded file

Parameters :
Name Optional
processId No
Returns : any
Public getData
getData(slug: any, fileName: any, downloadFileName?: string)
Parameters :
Name Type Optional
slug any No
fileName any No
downloadFileName string Yes
Returns : Observable<any>
updateRoles
updateRoles(requestParam)
Parameters :
Name Optional
requestParam No
Returns : any

Properties

Public configService
Type : ConfigService

reference of config service.

Public httpClient
Type : HttpClient
Public learnerService
Type : LearnerService

reference of learner service.

import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ConfigService, RequestParam, ServerResponse } from '@sunbird/shared';
import { LearnerService } from '../../../core/services/learner/learner.service';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { get } from 'lodash-es';
@Injectable({
  providedIn: 'root'
})
export class ManageService {

  /**
  * reference of config service.
  */
  public configService: ConfigService;
  /**
  * reference of learner service.
  */
  public learnerService: LearnerService;
  /**
  * for making upload api calls
  * @param {RequestParam} requestParam interface
  */
  constructor(configService: ConfigService, learnerService: LearnerService, public httpClient: HttpClient) {
    this.configService = configService;
    this.learnerService = learnerService;
  }

  /**
 * This method is used to call upload api to upload organizations file
 */
  public bulkOrgUpload(req): Observable<ServerResponse> {
    const httpOptions: RequestParam = {
      url: this.configService.urlConFig.URLS.ADMIN.BULK.ORGANIZATIONS_UPLOAD,
      data: req
    };
    return this.learnerService.post(httpOptions);
  }
  /**
  * This method is used to call status api to get the status of uploaded file
  */
  getBulkUploadStatus(processId) {
    const options = {
      url: this.configService.urlConFig.URLS.ADMIN.BULK.STATUS + '/' + processId
    };
    return this.learnerService.get(options);
  }

  public getData(slug: any, fileName: any, downloadFileName?: string): Observable<any> {
    let headers: HttpHeaders = new HttpHeaders();
    if (downloadFileName) {
      headers = new HttpHeaders({
        'Content-Disposition': 'attachment',
        'filename': downloadFileName
      });
    }
    return this.httpClient.get('/admin-reports/' + slug + '/' + fileName, {
      headers: headers
    })
      .pipe(
        map(res => {
          const result = {
            responseCode: 'OK'
          };
          result['result'] = get(res, 'result') || res;
          return result;
        })
      );
  }
  updateRoles(requestParam) {
    const option = {
      url: this.configService.urlConFig.URLS.ADMIN.UPDATE_USER_ORG_ROLES,
      data: {
          'request': {
            'userId': requestParam.userId,
            'organisationId': requestParam.orgId,
            'roles': requestParam.roles
          }
        }
    };

    return this.learnerService.post(option);
  }

}

results matching ""

    No results matching ""