File

src/app/modules/core/services/cert-reg/cert-reg.service.ts

Extends

DataService

Index

Properties
Methods

Constructor

constructor(config: ConfigService, http: HttpClient)

constructor

Parameters :
Name Type Optional Description
config ConfigService No

ConfigService reference

http HttpClient No

HttpClient reference

Methods

Public addCertificateTemplate
addCertificateTemplate(request)
Parameters :
Name Optional
request No
Returns : any
Public checkCriteria
checkCriteria(batchData)
Parameters :
Name Optional
batchData No
Returns : boolean
Public fetchCertificates
fetchCertificates(params)
Parameters :
Name Optional
params No
Returns : any
Public getUserCertList
getUserCertList(userName, courseId, loggedInUser)
Parameters :
Name Optional
userName No
courseId No
loggedInUser No
Returns : any
Public reIssueCertificate
reIssueCertificate(request)
Parameters :
Name Optional
request No
Returns : any
delete
delete(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:161

for making delete api calls

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

get
get(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:82

for making get api calls

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

Private getDateDiff
getDateDiff(serverdate)
Inherited from DataService
Defined in DataService:234
Parameters :
Name Optional
serverdate No
Returns : number
Private getHeader
getHeader(headers?)
Inherited from DataService
Defined in DataService:196

for preparing headers

Parameters :
Name Optional
headers Yes
getWithHeaders
getWithHeaders(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:60

for making get api calls which needs headers in response headers are fetched to get server time using Date attribute in header

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

patch
patch(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:143

for making patch api calls

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

post
post(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:123

for making post api calls

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

postWithHeaders
postWithHeaders(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:102

for making post api calls with headers in response object

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

Returns : Observable<any>
put
put(requestParam: RequestParam)
Inherited from DataService
Defined in DataService:180

for making PUT api calls

Parameters :
Name Type Optional Description
requestParam RequestParam No

interface

Properties

baseUrl
Type : string
Inherited from DataService
Defined in DataService:14

base Url for cert-reg api

Public config
Type : ConfigService

reference of config service.

Public http
Type : HttpClient
Inherited from DataService
Defined in DataService:24

reference of lerner service.

appId
Type : string
Inherited from DataService
Defined in DataService:31

Contains appId

appVersion
Type : string
Inherited from DataService
Defined in DataService:48

Constructor

Parameters :
Name Description
http

HttpClient reference

channelId
Type : string
Inherited from DataService
Defined in DataService:27

Contains channel Id

deviceId
Type : string
Inherited from DataService
Defined in DataService:35

Contains devoce Id

rootOrgId
Type : string
Inherited from DataService
Defined in DataService:23

Contains rootOrg Id

Static sessionId
Type : string
Inherited from DataService
Defined in DataService:19
Static userId
Type : string
Inherited from DataService
Defined in DataService:18
import { Injectable } from '@angular/core';
import {ConfigService} from '@sunbird/shared';
import {DataService} from './../data/data.service';
import {HttpClient} from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class CertRegService extends DataService {

  /**
   * base Url for cert-reg api
   */
  baseUrl: string;

  /**
   * reference of config service.
   */
  public config: ConfigService;

  /**
   * reference of lerner service.
   */
  public http: HttpClient;

  /**
   * constructor
   * @param {ConfigService} config ConfigService reference
   * @param {HttpClient} http HttpClient reference
   */
  constructor(config: ConfigService, http: HttpClient) {
    super(http);
    this.config = config;
    this.baseUrl = this.config.urlConFig.URLS.CERT_REG_PREFIX;
  }

  public fetchCertificates(params) {
    const request = {
      request: {
        _source: ['data.badge.issuer.name', 'pdfUrl', 'data.issuedOn', 'data.badge.name'],
        query: {
          bool: {
            must: [
              {
                match_phrase: {
                  'recipient.id': params.userId
                }
              }
            ]
          }
        }
      }
    };
    if (params.certType && params.certType !== 'all') {
      request.request.query.bool.must[0].match_phrase['related.type'] = params.certType;
    }
    if (params.limit) {
      request.request['size'] = params.limit;
    }
    const options = {
      url: this.config.urlConFig.URLS.CERTIFICATE.FETCH_CERTIFICATES,
      data: request,
    };
    return this.post(options);
  }

  public getUserCertList(userName, courseId, loggedInUser) {
    const request = {
      request: {
        filters: {
          userName: userName,
          courseId: courseId,
          createdBy: loggedInUser,
        }
      }
    };
    const options = {
      url: this.config.urlConFig.URLS.CERTIFICATE.FETCH_USER,
      data: request,
    };
    return this.post(options);
  }

  public reIssueCertificate(request) {
    const options = {
      url: `${this.config.urlConFig.URLS.CERTIFICATE.REISSUE_CERTIFICATE}`,
      data: request,
    };
    return this.post(options);
  }

  public addCertificateTemplate(request) {
    const options = {
      url: `${this.config.urlConFig.URLS.CERTIFICATE.ATTACH_CERTIFICATE}`,
      data: request,
    };
    return this.patch(options);
  }

  public checkCriteria(batchData) {
    if (batchData.length && batchData[0].status === 2) {
      return true;
    }
    return false;
  }
}

results matching ""

    No results matching ""