{ "version": 3, "sources": ["src/app/modules/profile/profile.service.ts"], "sourcesContent": ["import {EMPTY, Observable, of} from 'rxjs';\nimport {Injectable} from '@angular/core';\nimport {HttpClient, HttpErrorResponse, HttpParams} from '@angular/common/http';\nimport {ConfigurationService} from 'src/app/core/config/configuration.service';\nimport {IProfile} from 'src/app/interfaces/profile';\nimport {catchError, concatMap, map} from 'rxjs/operators';\nimport {IPartnerData} from 'src/app/interfaces/general/profile-definitions/partner-data.interface';\nimport {ItemPayload} from 'src/app/interfaces/general/responses/item-payload.interface';\nimport {ITermVersionCheck} from 'src/app/interfaces/general/member-definitions/term-version-check.interface';\nimport {IPropertyValue} from 'src/app/interfaces/general/profile-definitions/property-value.interface';\nimport {ValidateEmailResponse} from '../../interfaces/general/responses/validate-email-response.interface';\n\nexport const LANGS: {key: string; value: string}[] = [\n {key: 'en', value: 'english'},\n {key: 'de', value: 'german'},\n {key: 'it', value: 'italian'},\n {key: 'fr', value: 'french'},\n];\n\nexport const SALUTATIONS = [\n {key: 'Mrs', value: 'miss'},\n {key: 'Mr', value: 'mister'},\n {key: 'Child', value: 'child'},\n {key: 'Other', value: 'other'},\n];\n\nexport const GENDER: {key: string; value: string}[] = [\n {key: 'Female', value: 'female'},\n {key: 'Male', value: 'male'},\n {key: 'Diverse', value: 'diverse'},\n];\n\nexport const MARITAL_STATUS: {key: string; value: string}[] = [\n {key: 'Married', value: 'married'},\n {key: 'Single', value: 'single'},\n {key: 'Divorced', value: 'divorced'},\n {key: 'Widowed', value: 'widowed'},\n];\n\nexport const REDUCTION: {key: string; value: string}[] = [\n {key: 'none', value: 'none'},\n {key: 'ga-1st', value: 'ga-1st'},\n {key: 'ga-2nd', value: 'ga-2nd'},\n {key: 'half-fare', value: 'half-fare'},\n {key: 'junior-card', value: 'junior-card'},\n {key: 'child-card', value: 'child-card'},\n {key: 'swiss-half-fare-card', value: 'swiss-half-fare-card'},\n {key: 'swiss-travel-pass', value: 'swiss-travel-pass'},\n {key: 'student', value: 'student'},\n];\n\n@Injectable({\n providedIn: 'root',\n})\nexport class ProfileService {\n private readonly _profileApiUrl: string;\n\n constructor(\n private config: ConfigurationService,\n private http: HttpClient,\n ) {\n this._profileApiUrl = this.config.get('profileApiUrl');\n }\n\n public getProfile(): Observable {\n return this.http.get(`${this._profileApiUrl}/me`);\n }\n\n public getProfilePic(): Observable {\n return this.http\n .get(`${this._profileApiUrl}/me/profileimage`, {\n responseType: 'text',\n })\n .pipe(\n map((res) => 'data:image/png;base64,' + res),\n catchError(() => {\n return of(null);\n }),\n );\n }\n\n public deleteProfilePic(): Observable {\n return this.http.delete(`${this._profileApiUrl}/me/profileimage`);\n }\n\n public updateProfile(payload: Partial): Observable {\n return this.http.patch(`${this._profileApiUrl}/me`, payload);\n }\n\n public getAllImages(): Observable {\n return this.http.get(`${this._profileApiUrl}/media`);\n }\n\n public getPartnerData(\n top = 10000,\n additionalType?: string,\n ): Observable> {\n let params = new HttpParams().append('top', top);\n if (additionalType) {\n params = params.append('additionalType', additionalType);\n }\n return this.http.get>(`${this._profileApiUrl}/partnerdata`, {\n params,\n });\n }\n\n public getPartnerDataByName(name?: string): Observable {\n return this.http.get(`${this._profileApiUrl}/partnerdata/${name}`);\n }\n\n public createPartnerData(partnerData: any): Observable {\n return this.http.post(`${this._profileApiUrl}/partnerdata`, partnerData);\n }\n\n public updatePartnerData(name: string, partnerData: any): Observable {\n return this.http.put(`${this._profileApiUrl}/partnerdata/${name}`, partnerData);\n }\n\n public updatePartnerDataByName(\n name: string,\n propertyValue: Partial,\n ): Observable {\n return this.http.get(`${this._profileApiUrl}/partnerdata/${name}`).pipe(\n catchError((error: HttpErrorResponse) => {\n console.error(error);\n return EMPTY;\n }),\n concatMap((partnerData) => {\n const copy = [...(partnerData.additionalProperty ?? [])];\n const index = copy.findIndex((i) => i.propertyId === propertyValue.propertyId);\n if (index === -1) return EMPTY;\n copy[index] = propertyValue as IPropertyValue;\n partnerData.additionalProperty = copy;\n return this.updatePartnerData(name, partnerData);\n }),\n );\n }\n\n public removePartnerDataByNameAndId(name: string, id: string): Observable {\n return this.http.get(`${this._profileApiUrl}/partnerdata/${name}`).pipe(\n catchError((error: HttpErrorResponse) => {\n console.error(error);\n return EMPTY;\n }),\n concatMap((partnerData) => {\n partnerData.additionalProperty =\n partnerData.additionalProperty?.filter((t) => {\n return (t as any).propertyId !== id;\n }) ?? [];\n return this.updatePartnerData(name, partnerData);\n }),\n );\n }\n\n public sharePartnerData(name: string): Observable {\n return this.http.put(`${this._profileApiUrl}/partnerdata/${name}/share`, {});\n }\n\n public removePartnerDataSharing(name: string): Observable {\n return this.http.delete(`${this._profileApiUrl}/partnerdata/${name}/share`);\n }\n\n public initiateDeletionProfile(): Observable {\n return this.http.delete(`${this._profileApiUrl}/me`);\n }\n\n public cancelDeletionProfile(): Observable {\n return this.http.put(`${this._profileApiUrl}/me/cancelDelete`, {});\n }\n\n public confirmDeletionProfile(): Observable {\n return this.http.put(`${this._profileApiUrl}/me/confirmDelete`, {});\n }\n\n public verifyProfile(key: string): Observable {\n return this.http.put(`${this._profileApiUrl}/me/verify`, {verificationKey: key});\n }\n\n public resendVerificationMail(): Observable {\n return this.http.put(`${this._profileApiUrl}/me/verify/email`, {observe: 'response'});\n }\n\n public getTerms(termCode: string): Observable {\n return this.http.get(`${this._profileApiUrl}/terms/${termCode}`).pipe(\n catchError((err) => {\n console.error(err);\n return of(null);\n }),\n );\n }\n\n public validateEmail(request: {email: string}): Observable {\n return this.http.put(\n `${this.config.get('profileApiUrl')}/email/validate`,\n request,\n );\n }\n}\n"], "mappings": "0IAYO,IAAMA,EAAwC,CACjD,CAACC,IAAK,KAAMC,MAAO,SAAS,EAC5B,CAACD,IAAK,KAAMC,MAAO,QAAQ,EAC3B,CAACD,IAAK,KAAMC,MAAO,SAAS,EAC5B,CAACD,IAAK,KAAMC,MAAO,QAAQ,CAAC,EAGnBC,EAAc,CACvB,CAACF,IAAK,MAAOC,MAAO,MAAM,EAC1B,CAACD,IAAK,KAAMC,MAAO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G,IAAI,EACjB,CAAC,CAEV,CAEOgD,cAAcC,EAAwB,CACzC,OAAO,KAAK3D,KAAK6B,IACb,GAAG,KAAK9B,OAAOG,IAAI,eAAe,CAAC,kBACnCyD,CAAO,CAEf,iDA9IS9D,GAAc+D,EAAAC,CAAA,EAAAD,EAAAE,CAAA,CAAA,CAAA,CAAA,iCAAdjE,EAAckE,QAAdlE,EAAcmE,UAAAC,WAFX,MAAM,CAAA,CAAA,SAETpE,CAAc,GAAA", "names": ["LANGS", "key", "value", "SALUTATIONS", "GENDER", "MARITAL_STATUS", "REDUCTION", "ProfileService", "constructor", "config", "http", "_profileApiUrl", "get", "getProfile", "getProfilePic", "responseType", "pipe", "map", "res", "catchError", "of", "deleteProfilePic", "delete", "updateProfile", "payload", "patch", "getAllImages", "getPartnerData", "top", "additionalType", "params", "HttpParams", "append", "getPartnerDataByName", "name", "createPartnerData", "partnerData", "post", "updatePartnerData", "put", "updatePartnerDataByName", "propertyValue", "error", "console", "EMPTY", "concatMap", "copy", "additionalProperty", "index", "findIndex", "i", "propertyId", "removePartnerDataByNameAndId", "id", "filter", "t", "sharePartnerData", "removePartnerDataSharing", "initiateDeletionProfile", "cancelDeletionProfile", "confirmDeletionProfile", "verifyProfile", "verificationKey", "resendVerificationMail", "observe", "getTerms", "termCode", "err", "validateEmail", "request", "\u0275\u0275inject", "ConfigurationService", "HttpClient", "factory", "\u0275fac", "providedIn"] }