src/app/plugins/profile/services/profile/profile.service.ts
Properties |
|
Methods |
|
constructor(learnerService: LearnerService, userService: UserService, configService: ConfigService, formService: FormService)
|
|||||||||||||||
Parameters :
|
Public add | ||||
add(request)
|
||||
This method is used to add new skills
Parameters :
Returns :
any
|
Public declarations | ||||
declarations(request)
|
||||
This method invokes learner service to create/update user self declaration
Parameters :
Returns :
any
|
Public downloadCertificates | ||||
downloadCertificates(request)
|
||||
Parameters :
Returns :
any
|
Private formatRequest | ||||
formatRequest(request)
|
||||
This method is used to format the request
Parameters :
Returns :
{ params: {}; request: any; }
|
getFaqReportIssueForm | ||||||
getFaqReportIssueForm(orgId?: string)
|
||||||
Parameters :
Returns :
any
|
getPersonas | ||||||
getPersonas(orgId?: string)
|
||||||
Parameters :
Returns :
any
|
getPersonaTenantForm | ||||||
getPersonaTenantForm(orgId?: string)
|
||||||
Parameters :
Returns :
any
|
getSelfDeclarationForm | ||||||
getSelfDeclarationForm(orgId?: string)
|
||||||
Parameters :
Returns :
any
|
Public getSkills |
getSkills()
|
This method invokes learner service to get user respective skills
Returns :
any
|
Public getUserLocation | ||||
getUserLocation(request)
|
||||
Parameters :
Returns :
any
|
Public updatePrivateProfile | ||||
updatePrivateProfile(request)
|
||||
This method call portal backend API and invokes learner service to update user profile with private url
Parameters :
Returns :
any
|
Public updateProfile | ||||
updateProfile(request)
|
||||
This method invokes learner service to update user profile
Parameters :
Returns :
any
|
updateProfileFieldVisibility | ||||
updateProfileFieldVisibility(request)
|
||||
This method is used to update user profile visibility
Parameters :
Returns :
any
|
Public configService |
Type : ConfigService
|
Public formService |
Type : FormService
|
Public userService |
Type : UserService
|
import { map} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { UserService, LearnerService, FormService } from '@sunbird/core';
import { ConfigService, ServerResponse } from '@sunbird/shared';
@Injectable({
providedIn: 'root'
})
export class ProfileService {
constructor(private learnerService: LearnerService,
public userService: UserService, public configService: ConfigService, public formService: FormService) { }
/**
* This method invokes learner service to update user profile
*/
public updateProfile(request) {
const data = this.formatRequest(request);
const options = {
url: this.configService.urlConFig.URLS.USER.UPDATE_USER_PROFILE,
data: data
};
return this.learnerService.patch(options).pipe(map(
(res: ServerResponse) => {
setTimeout(() => {
this.userService.getUserProfile();
}, this.configService.appConfig.timeOutConfig.setTime);
return res;
}
));
}
/**
* This method call portal backend API and invokes learner service to update user profile with private url
*/
public updatePrivateProfile(request) {
const data = this.formatRequest(request);
const options = {
url: 'portal/user/v2/update',
data: data
};
return this.learnerService.patch(options);
}
/**
* This method is used to update user profile visibility
*/
updateProfileFieldVisibility(request) {
const data = this.formatRequest(request);
const options = {
url: this.configService.urlConFig.URLS.USER.UPDATE_PROF_VIS_FIELDS,
data: data
};
return this.learnerService.post(options);
}
/**
* This method is used to format the request
*/
private formatRequest(request) {
request.userId = request.userId ? request.userId : this.userService.userid;
return {
params: {},
request: request
};
}
/**
* This method is used to add new skills
*/
public add(request) {
const data = this.formatRequest(request);
const options = {
url: this.configService.urlConFig.URLS.USER.UPDATE_SKILLS,
data: data
};
return this.learnerService.post(options).pipe(map(
(res: ServerResponse) => {
setTimeout(() => {
this.userService.getUserProfile();
}, this.configService.appConfig.timeOutConfig.setTime);
return res;
}));
}
/**
* This method invokes learner service to get user respective skills
*/
public getSkills() {
const options = {
url: this.configService.urlConFig.URLS.USER.SKILLS
};
return this.learnerService.get(options);
}
public getUserLocation(request) {
const data = this.formatRequest(request);
const options = {
url: this.configService.urlConFig.URLS.USER.LOCATION_SEARCH,
data: data
};
return this.learnerService.post(options);
}
public downloadCertificates(request) {
const options = {
url: this.configService.urlConFig.URLS.USER.DOWNLOAD_CERTIFICATE,
data: request,
};
return this.learnerService.post(options);
}
/**
* This method invokes learner service to create/update user self declaration
*/
public declarations(request) {
const options = {
url: this.configService.urlConFig.URLS.USER.USER_DECLARATION,
data: {
params: {},
request: request
}
};
return this.learnerService.patch(options).pipe(map(
(res: ServerResponse) => {
setTimeout(() => {
this.userService.getUserProfile();
}, this.configService.appConfig.timeOutConfig.setTime);
return res;
}
));
}
getPersonas(orgId?: string) {
const formServiceInputParams = {
formType: 'user',
formAction: 'list',
contentType: 'personas',
component: 'portal'
};
return this.formService.getFormConfig(formServiceInputParams, orgId).pipe(map((response) => {
return response;
}));
}
getPersonaTenantForm(orgId?: string) {
const formServiceInputParams = {
formType: 'user',
formAction: 'get',
contentType: 'tenantPersonaInfo',
component: 'portal'
};
return this.formService.getFormConfig(formServiceInputParams, orgId).pipe(map((response) => {
return response;
}));
}
getSelfDeclarationForm(orgId?: string) {
const formServiceInputParams = {
formType: 'user',
formAction: 'submit',
contentType: 'selfDeclaration',
component: 'portal'
};
return this.formService.getFormConfig(formServiceInputParams, orgId).pipe(map((response) => {
return response;
}));
}
getFaqReportIssueForm(orgId?: string) {
const formServiceInputParams = {
formType: 'config',
formAction: 'reportIssue',
contentType: 'faq',
component: 'portal'
};
return this.formService.getFormConfig(formServiceInputParams, orgId).pipe(map((response) => {
return response;
}));
}
}