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

View File

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

View File

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

View File

@ -26,28 +26,29 @@ export interface NotificationFilter {
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class NotificationService { export class NotificationService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/notifications`;
getNotifications(filters?: NotificationFilter): Observable<Notification[]> { getNotifications(filters?: NotificationFilter): Observable<Notification[]> {
return this.http.post<Notification[]>( return this.http.post<Notification[]>(
`${environment.apiUrl}/notifications/list`, `${this.apiUrl}/list`,
filters filters
); );
} }
sendNotification(notification: Partial<Notification>): Observable<Notification> { sendNotification(notification: Partial<Notification>): Observable<Notification> {
return this.http.post<Notification>( return this.http.post<Notification>(
`${environment.apiUrl}/notifications/send`, `${this.apiUrl}/send`,
notification notification
); );
} }
getNotificationStats(): Observable<any> { getNotificationStats(): Observable<any> {
return this.http.get(`${environment.apiUrl}/notifications/stats`); return this.http.get(`${this.apiUrl}/stats`);
} }
retryNotification(notificationId: string): Observable<Notification> { retryNotification(notificationId: string): Observable<Notification> {
return this.http.post<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' }) @Injectable({ providedIn: 'root' })
export class OperatorService { export class OperatorService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/operators`;
getOperators(): Observable<Operator[]> { 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> { updateOperatorConfig(operatorId: string, config: OperatorConfig): Observable<Operator> {
return this.http.put<Operator>( return this.http.put<Operator>(
`${environment.apiUrl}/operators/${operatorId}/config`, `${this.apiUrl}/${operatorId}/config`,
config config
); );
} }
testConnection(operatorId: string): Observable<{ success: boolean; latency: number }> { testConnection(operatorId: string): Observable<{ success: boolean; latency: number }> {
return this.http.post<{ 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' }) @Injectable({ providedIn: 'root' })
export class OperatorStatsService { export class OperatorStatsService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/operators`;
getOperatorStats(operatorId: string): Observable<OperatorStats> { getOperatorStats(operatorId: string): Observable<OperatorStats> {
return this.http.get<OperatorStats>( return this.http.get<OperatorStats>(
`${environment.apiUrl}/operators/${operatorId}/stats` `${this.apiUrl}/${operatorId}/stats`
); );
} }
getOperatorsComparison(): Observable<any[]> { 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> { getPerformanceMetrics(operatorId: string, period: string): Observable<any> {
return this.http.get( 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' }) @Injectable({ providedIn: 'root' })
export class TransactionsService { export class TransactionsService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.apiUrl}/transactions`; private apiUrl = `${environment.localServiceTestApiUrl}/transactions`;
// === CRUD OPERATIONS === // === CRUD OPERATIONS ===
getTransactions(query: TransactionQuery): Observable<PaginatedTransactions> { getTransactions(query: TransactionQuery): Observable<PaginatedTransactions> {

View File

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

View File

@ -6,26 +6,27 @@ import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class WebhookRetryService { export class WebhookRetryService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/webhooks`;
retryWebhook(webhookId: string): Observable<{ success: boolean }> { retryWebhook(webhookId: string): Observable<{ success: boolean }> {
return this.http.post<{ 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 }> { bulkRetryWebhooks(webhookIds: string[]): Observable<{ success: number; failed: number }> {
return this.http.post<{ success: number; failed: number }>( return this.http.post<{ success: number; failed: number }>(
`${environment.apiUrl}/webhooks/bulk-retry`, `${this.apiUrl}/bulk-retry`,
{ webhookIds } { webhookIds }
); );
} }
getRetryConfig(): Observable<any> { 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> { 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' }) @Injectable({ providedIn: 'root' })
export class WebhookService { export class WebhookService {
private http = inject(HttpClient); private http = inject(HttpClient);
private apiUrl = `${environment.localServiceTestApiUrl}/webhooks`;
getWebhookHistory(filters?: WebhookFilter): Observable<WebhookEvent[]> { getWebhookHistory(filters?: WebhookFilter): Observable<WebhookEvent[]> {
return this.http.post<WebhookEvent[]>( return this.http.post<WebhookEvent[]>(
`${environment.apiUrl}/webhooks/history`, `${this.apiUrl}/history`,
filters filters
); );
} }
@ -39,6 +40,6 @@ export class WebhookService {
failed: number; failed: number;
pending: 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 = { export const environment = {
production: false, 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', dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB // Configuration DCB

View File

@ -1,6 +1,7 @@
export const environment = { export const environment = {
production: false, 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', dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB // Configuration DCB

View File

@ -1,6 +1,7 @@
export const environment = { export const environment = {
production: false, 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', dcbApiUrl: 'https://api.paymenthub.com/v2',
// Configuration DCB // Configuration DCB