/** * 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 { AdminAccount } from '../models/admin-account.model'; import { AdminAccountInternal } from '../models/admin-account-internal.model'; import { AdminRole } from '../models/admin-role.model'; import { AdminRoleInternal } from '../models/admin-role-internal.model'; import { AdminSession2 } from '../models/admin-session2.model'; import { Credentials } from '../models/credentials.model'; import { PasswordChange } from '../models/password-change.model'; @Injectable() export class AdminsInternalService { constructor(protected httpClient: HttpClient) { } /** * Continues flow with mobile verification * * @param sessionId * @param code * @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 continueAuthWithMobileVerification(sessionId: string, code: string): Observable { if (sessionId === null || sessionId === undefined) { throw new Error('Required parameter sessionId was null or undefined when calling continueAuthWithMobileVerification.'); } if (code === null || code === undefined) { throw new Error('Required parameter code was null or undefined when calling continueAuthWithMobileVerification.'); } let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (code !== undefined) { queryParameters = queryParameters.set('code', code); } let headers = new HttpHeaders(); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminSessions/${encodeURIComponent(String(sessionId))}:continueWithMobileVerification`, { params: queryParameters, headers: headers, } ); } /** * Initiates the autentication flow * * @param sessionId * @param passwordChange * @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 continueAuthWithPasswordChange(sessionId: string, passwordChange: PasswordChange): Observable { if (sessionId === null || sessionId === undefined) { throw new Error('Required parameter sessionId was null or undefined when calling continueAuthWithPasswordChange.'); } if (passwordChange === null || passwordChange === undefined) { throw new Error('Required parameter passwordChange was null or undefined when calling continueAuthWithPasswordChange.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminSessions/${encodeURIComponent(String(sessionId))}:continueWithPasswordChange`, passwordChange, { headers: headers, } ); } /** * Creates a new admin account * * @param 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 createAdminAccount(account: AdminAccount): Observable { if (account === null || account === undefined) { throw new Error('Required parameter account was null or undefined when calling createAdminAccount.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins`, account, { headers: headers, } ); } /** * Creates a new admin role * * @param role * @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 createAdminRole(role: AdminRole): Observable { if (role === null || role === undefined) { throw new Error('Required parameter role was null or undefined when calling createAdminRole.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminRoles`, role, { headers: headers, } ); } /** * Will expire credentials and request user to change them on next login * * @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 expireAdminCredentials(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling expireAdminCredentials.'); } let headers = new HttpHeaders(); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins/${encodeURIComponent(String(accountId))}:expireCredentials`, { headers: headers, } ); } /** * Will expire mobile verification and request user a new confirmation on next login * * @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 expireAdminMobile(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling expireAdminMobile.'); } let headers = new HttpHeaders(); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins/${encodeURIComponent(String(accountId))}:expireMobile`, { headers: headers, } ); } /** * Initiates the autentication flow * * @param credentials * @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 initiateAuthFlow(credentials: Credentials): Observable { if (credentials === null || credentials === undefined) { throw new Error('Required parameter credentials was null or undefined when calling initiateAuthFlow.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.post(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminSessions`, credentials, { headers: headers, } ); } /** * Load single admin account * * @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 loadAdminAccount(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling loadAdminAccount.'); } let headers = new HttpHeaders(); return this.httpClient.get(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins/${encodeURIComponent(String(accountId))}`, { headers: headers, } ); } /** * Gets all admin accounts * * @param limit This is the maximum number of objects that may be returned. A query may return fewer than the value of `limit` once reached the end of the list of data. * @param after This is the cursor that points to the `end` of the page of data that has been returned. * @param before This is the cursor that points to the `start` of the page of data that has been returned. * @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 loadAdminAccounts(limit?: number, after?: string, before?: string): Observable> { let queryParameters = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()}); if (limit !== undefined) { queryParameters = queryParameters.set('limit', limit); } if (after !== undefined) { queryParameters = queryParameters.set('after', after); } if (before !== undefined) { queryParameters = queryParameters.set('before', before); } let headers = new HttpHeaders(); return this.httpClient.get>(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins`, { params: queryParameters, headers: headers, } ); } /** * updates an admin role * * @param roleId * @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 loadAdminRole(roleId: string): Observable { if (roleId === null || roleId === undefined) { throw new Error('Required parameter roleId was null or undefined when calling loadAdminRole.'); } let headers = new HttpHeaders(); return this.httpClient.get(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminRoles/${encodeURIComponent(String(roleId))}`, { headers: headers, } ); } /** * Gets all admin roles * * @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 loadAdminRoles(): Observable> { let headers = new HttpHeaders(); return this.httpClient.get>(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminRoles`, { headers: headers, } ); } /** * Will reset credentials and send by email * * @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 resetAdminCredentials(accountId: string): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling resetAdminCredentials.'); } let headers = new HttpHeaders(); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins/${encodeURIComponent(String(accountId))}:resetCredentials`, { headers: headers, } ); } /** * Updates an existing admin account * * @param accountId * @param 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 updateAdminAccount(accountId: string, account: AdminAccount): Observable { if (accountId === null || accountId === undefined) { throw new Error('Required parameter accountId was null or undefined when calling updateAdminAccount.'); } if (account === null || account === undefined) { throw new Error('Required parameter account was null or undefined when calling updateAdminAccount.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/admins/${encodeURIComponent(String(accountId))}`, account, { headers: headers, } ); } /** * updates an admin role * * @param roleId * @param role * @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 updateAdminRole(roleId: string, role: AdminRole): Observable { if (roleId === null || roleId === undefined) { throw new Error('Required parameter roleId was null or undefined when calling updateAdminRole.'); } if (role === null || role === undefined) { throw new Error('Required parameter role was null or undefined when calling updateAdminRole.'); } let headers = new HttpHeaders(); headers = headers.set("Content-Type", "application/json"); return this.httpClient.put(`https://admins-dot-nymos-dev.appspot.com/v1/admin/adminRoles/${encodeURIComponent(String(roleId))}`, role, { headers: headers, } ); } }