feat: add DCB User Service API - Authentication system with KEYCLOAK - Modular architecture with services for each feature

This commit is contained in:
diallolatoile 2025-10-29 05:04:20 +00:00
parent dee63c7341
commit 1721adad29
13 changed files with 36 additions and 28 deletions

View File

@ -146,7 +146,7 @@ export class AuthService {
*/
login(username: string, password: string): Observable<AuthResponse> {
return this.http.post<AuthResponse>(
`${environment.apiUrl}/auth/login`,
`${environment.iamApiUrl}/auth/login`,
{ username, password }
).pipe(
tap(response => {
@ -170,7 +170,7 @@ export class AuthService {
}
return this.http.post<AuthResponse>(
`${environment.apiUrl}/auth/refresh`,
`${environment.iamApiUrl}/auth/refresh`,
{ refresh_token: refreshToken }
).pipe(
tap(response => {
@ -191,7 +191,7 @@ export class AuthService {
this.clearSession(redirect);
// Appel API optionnel (ne pas bloquer dessus)
this.http.post(`${environment.apiUrl}/auth/logout`, {}).subscribe({
this.http.post(`${environment.iamApiUrl}/auth/logout`, {}).subscribe({
error: () => {} // Ignorer silencieusement les erreurs de logout
});
}
@ -273,7 +273,7 @@ export class AuthService {
* Récupère les infos utilisateur depuis le backend
*/
getProfile(): Observable<any> {
return this.http.get(`${environment.apiUrl}/users/profile/me`).pipe(
return this.http.get(`${environment.iamApiUrl}/users/profile/me`).pipe(
catchError(error => {
return throwError(() => error);
})

View File

@ -8,7 +8,7 @@ import { environment } from '@environments/environment';
@Injectable({ providedIn: 'root' })
export class DcbDashboardService {
private http = inject(HttpClient);
private apiUrl = `${environment.apiUrl}/dcb-dashboard`;
private apiUrl = `${environment.localServiceTestApiUrl}/dcb-dashboard`;
// Données mockées pour le développement
private mockData: DcbDashboardData = {

View File

@ -12,7 +12,7 @@ import {
@Injectable({ providedIn: 'root' })
export class MerchantsService {
private http = inject(HttpClient);
private apiUrl = `${environment.apiUrl}/partners`;
private apiUrl = `${environment.localServiceTestApiUrl}/partners`;
// Enregistrement d'un nouveau merchant
registerMerchant(registration: MerchantRegistration): Observable<MerchantResponse> {
@ -42,7 +42,7 @@ export class MerchantsService {
// Test des webhooks
testWebhook(url: string, event: string): Observable<{ success: boolean; response: any; responseTime: number }> {
return this.http.post<{ success: boolean; response: any; responseTime: number }>(
`${environment.apiUrl}/webhooks/test`,
`${environment.iamApiUrl}/webhooks/test`,
{ url, event }
);
}

View File

@ -26,28 +26,29 @@ export interface NotificationFilter {
@Injectable({ providedIn: 'root' })
export class NotificationService {
private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/notifications`;
getNotifications(filters?: NotificationFilter): Observable<Notification[]> {
return this.http.post<Notification[]>(
`${environment.apiUrl}/notifications/list`,
`${this.apiUrl}/list`,
filters
);
}
sendNotification(notification: Partial<Notification>): Observable<Notification> {
return this.http.post<Notification>(
`${environment.apiUrl}/notifications/send`,
`${this.apiUrl}/send`,
notification
);
}
getNotificationStats(): Observable<any> {
return this.http.get(`${environment.apiUrl}/notifications/stats`);
return this.http.get(`${this.apiUrl}/stats`);
}
retryNotification(notificationId: string): Observable<Notification> {
return this.http.post<Notification>(
`${environment.apiUrl}/notifications/${notificationId}/retry`,
`${this.apiUrl}/${notificationId}/retry`,
{}
);
}

View File

@ -25,21 +25,22 @@ export interface OperatorConfig {
@Injectable({ providedIn: 'root' })
export class OperatorService {
private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/operators`;
getOperators(): Observable<Operator[]> {
return this.http.get<Operator[]>(`${environment.apiUrl}/operators`);
return this.http.get<Operator[]>(`${this.apiUrl}`);
}
updateOperatorConfig(operatorId: string, config: OperatorConfig): Observable<Operator> {
return this.http.put<Operator>(
`${environment.apiUrl}/operators/${operatorId}/config`,
`${this.apiUrl}/${operatorId}/config`,
config
);
}
testConnection(operatorId: string): Observable<{ success: boolean; latency: number }> {
return this.http.post<{ success: boolean; latency: number }>(
`${environment.apiUrl}/operators/${operatorId}/test-connection`,
`${this.apiUrl}/${operatorId}/test-connection`,
{}
);
}

View File

@ -24,20 +24,21 @@ export interface DailyStat {
@Injectable({ providedIn: 'root' })
export class OperatorStatsService {
private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/operators`;
getOperatorStats(operatorId: string): Observable<OperatorStats> {
return this.http.get<OperatorStats>(
`${environment.apiUrl}/operators/${operatorId}/stats`
`${this.apiUrl}/${operatorId}/stats`
);
}
getOperatorsComparison(): Observable<any[]> {
return this.http.get<any[]>(`${environment.apiUrl}/operators/comparison`);
return this.http.get<any[]>(`${this.apiUrl}/comparison`);
}
getPerformanceMetrics(operatorId: string, period: string): Observable<any> {
return this.http.get(
`${environment.apiUrl}/operators/${operatorId}/metrics?period=${period}`
`${this.apiUrl}/${operatorId}/metrics?period=${period}`
);
}
}

View File

@ -14,7 +14,7 @@ import {
@Injectable({ providedIn: 'root' })
export class TransactionsService {
private http = inject(HttpClient);
private apiUrl = `${environment.apiUrl}/transactions`;
private apiUrl = `${environment.localServiceTestApiUrl}/transactions`;
// === CRUD OPERATIONS ===
getTransactions(query: TransactionQuery): Observable<PaginatedTransactions> {

View File

@ -16,7 +16,7 @@ import {
@Injectable({ providedIn: 'root' })
export class UsersService {
private http = inject(HttpClient);
private apiUrl = `${environment.apiUrl}/users`;
private apiUrl = `${environment.localServiceTestApiUrl}/users`;
// === CRUD COMPLET ===
createUser(createUserDto: CreateUserDto): Observable<UserResponse> {

View File

@ -6,26 +6,27 @@ import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class WebhookRetryService {
private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/webhooks`;
retryWebhook(webhookId: string): Observable<{ success: boolean }> {
return this.http.post<{ success: boolean }>(
`${environment.apiUrl}/webhooks/${webhookId}/retry`,
`${this.apiUrl}/${webhookId}/retry`,
{}
);
}
bulkRetryWebhooks(webhookIds: string[]): Observable<{ success: number; failed: number }> {
return this.http.post<{ success: number; failed: number }>(
`${environment.apiUrl}/webhooks/bulk-retry`,
`${this.apiUrl}/bulk-retry`,
{ webhookIds }
);
}
getRetryConfig(): Observable<any> {
return this.http.get(`${environment.apiUrl}/webhooks/retry-config`);
return this.http.get(`${this.apiUrl}/retry-config`);
}
updateRetryConfig(config: any): Observable<any> {
return this.http.put(`${environment.apiUrl}/webhooks/retry-config`, config);
return this.http.put(`${this.apiUrl}/retry-config`, config);
}
}

View File

@ -25,10 +25,11 @@ export interface WebhookFilter {
@Injectable({ providedIn: 'root' })
export class WebhookService {
private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/webhooks`;
getWebhookHistory(filters?: WebhookFilter): Observable<WebhookEvent[]> {
return this.http.post<WebhookEvent[]>(
`${environment.apiUrl}/webhooks/history`,
`${this.apiUrl}/history`,
filters
);
}
@ -39,6 +40,6 @@ export class WebhookService {
failed: number;
pending: number;
}> {
return this.http.get<any>(`${environment.apiUrl}/webhooks/status`);
return this.http.get<any>(`${this.apiUrl}/status`);
}
}

View File

@ -1,6 +1,7 @@
export const environment = {
production: false,
apiUrl: "https://api-user-service.dcb.pixpay.sn/api/v1",
localServiceTestApiUrl: "https://backoffice.dcb.pixpay.sn/api/v1",
iamApiUrl: "https://api-user-service.dcb.pixpay.sn/api/v1",
dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB

View File

@ -1,6 +1,7 @@
export const environment = {
production: false,
apiUrl: "https://api-user-service.dcb.pixpay.sn/api/v1",
localServiceTestApiUrl: "https://backoffice.dcb.pixpay.sn/api/v1",
iamApiUrl: "https://api-user-service.dcb.pixpay.sn/api/v1",
dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB

View File

@ -1,6 +1,7 @@
export const environment = {
production: false,
apiUrl: "http://localhost:3000/api/v1",
localServiceTestApiUrl: "http://localhost:4200/api/v1",
iamApiUrl: "http://localhost:3000/api/v1",
dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB