setup dpage account
This commit is contained in:
@@ -63,8 +63,35 @@ export class DPageService {
|
||||
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} dpage`;
|
||||
async setupDpageAccount(dto: SetupAccountDto) {
|
||||
try {
|
||||
// 2. Login with userSubscriptionId
|
||||
const { data } = await firstValueFrom(
|
||||
this.httpService
|
||||
.post(`${this.config.baseUrl}/super-admin/business/setup`, dto,
|
||||
{
|
||||
headers: this.getHeaders(),
|
||||
})
|
||||
.pipe(
|
||||
catchError((err: AxiosError) => {
|
||||
this.logger.error(`Failed to perform setup account: ${err.message}`, err.stack);
|
||||
return throwError(() => err);
|
||||
}),
|
||||
),
|
||||
);
|
||||
return data;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof AxiosError && error.response) {
|
||||
this.logger.error(`External API error response:`, error.response.data);
|
||||
const errorResponse = {
|
||||
...error.response.data,
|
||||
message: error.response.data.error?.message || error.message,
|
||||
};
|
||||
throw new HttpException(errorResponse, error.response.status);
|
||||
}
|
||||
this.logger.error(`Error performing direct login: ${error instanceof Error ? error.message : "Unknown error"}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// update(id: number, updateDpageDto: UpdateDpageDto) {
|
||||
@@ -116,3 +143,13 @@ export class DPageService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class SetupAccountDto {
|
||||
danakSubscriptionId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
phone: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user