setup dpage account

This commit is contained in:
2026-03-14 09:54:00 +03:30
parent 584e4d7981
commit 6002774400
5 changed files with 65 additions and 6 deletions
+39 -2
View File
@@ -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;
}