/** * NymOS Private API v1 * * The contents of this file are subject to the NymOS License, version 1.0. * It is forbidden the use of the codes included on this file, even partially, * for third parties, such as its copy, without express authorization of the * intelectual property and commercial rights owners. A copy of the license * may be obtained at http://nymos.io/source-license. The intelectual * property and comercial rights of this file and codes belong to NymOS S.A. * * Copyright (c) 2017. All rights reserved. * */ /* tslint:disable:no-unused-variable member-ordering */ import { Inject, Injectable, Optional } from '@angular/core'; import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { CustomHttpUrlEncodingCodec } from '../internal/encoder'; import { Account } from '../models/account.model'; import { AccountInfo } from '../models/account-info.model'; import { AccountLimit } from '../models/account-limit.model'; import { AccountNote } from '../models/account-note.model'; import { AccountNoteInternal } from '../models/account-note-internal.model'; import { AccountSettings } from '../models/account-settings.model'; import { Problem } from '../models/problem.model'; @Injectable() export class AccountsInternalService { constructor(protected httpClient: HttpClient) { } /** * Confirm email verification from website * The final step required to complete the `email` verification. Links similar to the bellow will be sent by email and if not intercepted by apps nymcard website should handle: `https://nymos.io/email-verification?email=<email>&hash=<UUID>` * @param email The user `email` sent by email as part of verification link. * @param hash The unique `hash` sent by email as part of verification link. * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public confirmEmailVerification(email: string, hash: string): Observable { if (email === null || email === undefined) { throw new Error('Required parameter email was null or undefined when calling confirmEmailVerification.'); } if (hash === null || hash === undefined) { throw new Error('Required parameter hash was null or undefined when calling confirmEmailVerification.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (email !== undefined) { queryParameters = queryParameters.set('email', email); } if (hash !== undefined) { queryParameters = queryParameters.set('hash', hash); } let headers = new HttpHeaders(); return this.httpClient.put(`https://accounts-dot-nymos-dev.appspot.com/v1/partner/account/email`, { params: queryParameters, headers: headers, } ); } /** * Create account related note * * @param accountId * @param note * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public createNote(accountId: string, note: AccountNote): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling createNote.'); } if (note === null || note === undefined) { throw new Error('Required parameter note was null or undefined when calling createNote.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://accounts-dot-nymos-dev.appspot.com/v1/admin/accounts/${encodeURIComponent(String(accountId))}/notes`, note, { headers: headers, } ); } /** * Gets the account id from the verified email * Gets the acocunt id from the verified email * @param email The email linked to an account * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public getAccountByEmail(email: string): Observable { if (email === null || email === undefined) { throw new Error('Required parameter email was null or undefined when calling getAccountByEmail.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (email !== undefined) { queryParameters = queryParameters.set('email', email); } let headers = new HttpHeaders(); return this.httpClient.get(`https://accounts-dot-nymos-dev.appspot.com/v1/internal/accounts:getAccountByEmail`, { params: queryParameters, headers: headers, } ); } /** * Gets the account id from the mobile number * Gets the acocunt id from the mobile number * @param mobile The mobile number linked to an account * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public getAccountByMobile(mobile: string): Observable { if (mobile === null || mobile === undefined) { throw new Error('Required parameter mobile was null or undefined when calling getAccountByMobile.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (mobile !== undefined) { queryParameters = queryParameters.set('mobile', mobile); } let headers = new HttpHeaders(); return this.httpClient.get(`https://accounts-dot-nymos-dev.appspot.com/v1/internal/accounts:getAccountByMobile`, { params: queryParameters, headers: headers, } ); } /** * Get account by its id * * @param accountId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public loadAccount(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling loadAccount.'); } let headers = new HttpHeaders(); return this.httpClient.get(`https://accounts-dot-nymos-dev.appspot.com/v1/internal/account/${encodeURIComponent(String(accountId))}`, { headers: headers, } ); } /** * Load user's limits by id * * @param accountId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public loadAccountLimits(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling loadAccountLimits.'); } let headers = new HttpHeaders(); return this.httpClient.get(`https://accounts-dot-nymos-dev.appspot.com/v1/internal/account/${encodeURIComponent(String(accountId))}/limits`, { headers: headers, } ); } /** * Load account related notes * * @param accountId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public loadNotes(accountId: string): Observable> { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling loadNotes.'); } let headers = new HttpHeaders(); return this.httpClient.get>(`https://accounts-dot-nymos-dev.appspot.com/v1/admin/accounts/${encodeURIComponent(String(accountId))}/notes`, { headers: headers, } ); } /** * Reset account passcode and generate new one * * @param accountId * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public resetPasscodeFromAdmin(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling resetPasscodeFromAdmin.'); } let headers = new HttpHeaders(); return this.httpClient.put(`https://accounts-dot-nymos-dev.appspot.com/v1/admin/accounts/${encodeURIComponent(String(accountId))}/passcode`, { headers: headers, } ); } /** * Update account settings * * @param accountId * @param settings * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. * @param reportProgress flag to report request and response progress. */ public updateSettings(accountId: string, settings: AccountSettings): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling updateSettings.'); } if (settings === null || settings === undefined) { throw new Error('Required parameter settings was null or undefined when calling updateSettings.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://accounts-dot-nymos-dev.appspot.com/v1/admin/accounts/${encodeURIComponent(String(accountId))}/settings`, settings, { headers: headers, } ); } }