import { A_AUTH_AppInteractions_APIProvider } from "@adaas/a-auth/global/api-providers/A_AUTH_AppInteractions.api"; import { A_AUTH_APP_INTERACTIONS_TYPES__SignUpOrganizationRequest, A_AUTH_APP_INTERACTIONS_TYPES__SignUpOrganizationResponse, A_AUTH_APP_INTERACTIONS_TYPES__SignUpProfileRequest, A_AUTH_APP_INTERACTIONS_TYPES__SignUpProfileResponse, A_AUTH_APP_INTERACTIONS_TYPES__SignUpRequest, A_AUTH_APP_INTERACTIONS_TYPES__SignUpResponse } from "./A_AUTH_SignUp.types"; import { A_AUTH_ContextClass } from "@adaas/a-auth/global/A_AUTH_Context.class"; export class A_AUTH_APP_INTERACTIONS__SignUpAPI extends A_AUTH_AppInteractions_APIProvider { protected get baseURL(): string { return this.context.getConfigurationProperty('SSO_LOCATION'); } async signUp( /** * The new user to sign up */ newUser: A_AUTH_APP_INTERACTIONS_TYPES__SignUpRequest, /** * The meta object to pass through API call for error handling or response handling */ meta?: M ): Promise { this.loading = true const resp = await this.post(`/sign-up`, newUser, { meta, adaas: { auth: false } }); // Set the authenticator for the context this.context.setAuthenticator({ token: resp.token, refreshToken: resp.refreshToken, exp: resp.exp, }); return resp; } async signUpProfile( /** * user profile to sign up */ profile: A_AUTH_APP_INTERACTIONS_TYPES__SignUpProfileRequest, /** * The meta object to pass through API call for error handling or response handling */ meta?: M ): Promise { this.loading = true const resp = await this.post(`/sign-up/profile`, profile, { meta }); if ('token' in resp) { // Set the authenticator for the context this.context.setAuthenticator({ token: resp.token, refreshToken: resp.refreshToken, exp: resp.exp, }); } return resp; } async signUpOrganization( /** * The organization to sign up */ organization: A_AUTH_APP_INTERACTIONS_TYPES__SignUpOrganizationRequest, /** * The meta object to pass through API call for error handling or response handling */ meta?: M ): Promise { this.loading = true const resp = await this.post(`/sign-up/organization`, organization, { meta }); if ('token' in resp) { // Set the authenticator for the context this.context.setAuthenticator({ token: resp.token, refreshToken: resp.refreshToken, exp: resp.exp, }); } return resp; } }