diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile')
-rw-r--r-- | ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.spec.ts | 78 | ||||
-rw-r--r-- | ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.ts | 73 |
2 files changed, 151 insertions, 0 deletions
diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.spec.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.spec.ts new file mode 100644 index 00000000..70e8ac4b --- /dev/null +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.spec.ts @@ -0,0 +1,78 @@ +import { TestBed } from '@angular/core/testing'; + +import { ProfileService } from './profile.service'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { HttpClient } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +describe('ProfileService', () => { + + let service: ProfileService; + + beforeEach(() => {TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [HttpClient, ProfileService] + }) + service = TestBed.get(ProfileService); +}); + + it('should be created', () => { + const service: ProfileService = TestBed.get(ProfileService); + expect(service).toBeTruthy(); + }); + + it('should get getUserPagination', () => { + service.getUserPagination().subscribe((resp) => { + expect(resp).toBe(environment.getUserPagination); + }); + }); + + it('should get getPostSearch', () => { + let test : any; + service.getPostSearch(test).subscribe((resp) => { + expect(resp).toBe(environment.postSearch); + }); + }); + + it('should get importUser', () => { + let test : any; + service.importUser(test).subscribe((resp) => { + expect(resp).toBe(environment.importSearch); + }); +}); + +it('should get getPostProfile', () => { + service.getPostProfile().subscribe((resp) => { + expect(resp).toBe(environment.getPostProfile); + }); +}); + +it('should get getSelfProfile', () => { + service.getSelfProfile().subscribe((resp) => { + expect(resp).toBe(environment.getSelfProfile); + }); +}); + +it('should get removeRole', () => { + let data, id; + service.removeRole(data, id).subscribe((resp) => { + expect(resp).toBe(environment.removeUserRole); + }); +}); + +it('should get addUserRole', () => { + let data, id; + service.addUserRole(data, id).subscribe((resp) => { + expect(resp).toBe(environment.addUserRole); + }); +}); + +it('should get toggleProfileActive', () => { + let data, id; + service.toggleProfileActive(id).subscribe((resp) => { + expect(resp).toBe(environment); + }); +}); + +}); + diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.ts new file mode 100644 index 00000000..c40e7618 --- /dev/null +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/user-profile/profile/profile.service.ts @@ -0,0 +1,73 @@ +import { Injectable } from '@angular/core'; +import {HttpClient, HttpHeaders } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + +@Injectable({ + providedIn: 'root' +}) +export class ProfileService { + + constructor(private http: HttpClient) { + } + + getUserPagination(){ + return this.http.get(environment.getUserPagination); + } + + getAllUsers(){ + return this.http.get(environment.getAllUsers); + } + + getPostSearch(postSearchBean:any) + { + return this.http.post(environment.postSearch,JSON.stringify({postSearchBean: postSearchBean})); + + } + + importUser(postSearchBean:any) + { + return this.http.post(environment.importSearch,JSON.stringify({postSearchBean: postSearchBean})); + + } + + getPostProfile() + { + return this.http.get(environment.getPostProfile); + + } + + getSelfProfile() + { + return this.http.get(environment.getSelfProfile); + + } + + getProfileById(profileId){ + return this.http.get(environment.getProfileById+"?profile_id="+profileId); + } + + removeRole(data,profileId) + { + return this.http.post(environment.removeUserRole+'?profile_id='+profileId,JSON.stringify({role: data})); + } + + addUserRole(data,profileId) + { + return this.http.post(environment.addUserRole+'?profile_id='+profileId,JSON.stringify({role: data})); + } + + saveProfile(data, profileId) { + return this.http.post(environment.saveProfile + '?profile_id=' + profileId, JSON.stringify({ + profile: data.profile, + selectedCountry: data.selectedCountry, + selectedState: data.selectedState, + selectedTimeZone: data.selectedTimeZone + })); + + } + + toggleProfileActive(profileId){ + return this.http.get(environment.toggleProfileActive+profileId); + } + +} |