Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.

Commit ce7dcb8

Browse files
committed
added WebUserLink
1 parent 067d104 commit ce7dcb8

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {ApiDTO} from "../../../../core/dtos/api-dto";
2+
3+
class PacifistaWebUserLinkDTO extends ApiDTO {
4+
5+
funixProdUserId?: string;
6+
minecraftUuid?: string;
7+
linked?: boolean;
8+
linkKey?: string;
9+
10+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import {CrudHttpClient} from "../../../../core/components/requests/crud-http-client";
2+
import {environmentDev} from "../../../../../../environments/environment-dev";
3+
import {environment} from "../../../../../../environments/environment";
4+
import {PacifistaPaymentResponseDTO} from "../../shop/payment/dtos/responses/PacifistaPaymentResponseDTO";
5+
import {catchError, Observable, throwError} from "rxjs";
6+
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
7+
8+
export class PacifistaWebUserLinkService extends CrudHttpClient<PacifistaWebUserLinkService> {
9+
10+
publicUrl: string;
11+
12+
constructor(protected http: HttpClient, production: boolean) {
13+
super(
14+
http,
15+
production ? environment.pacifistaApiUrl : environmentDev.pacifistaApiUrl,
16+
"web/user/link"
17+
);
18+
this.publicUrl = super.domain + super.path + '/public';
19+
}
20+
21+
linkUser(minecraftUsername: string): Observable<PacifistaWebUserLinkService> {
22+
return this.httpClient.post<PacifistaPaymentResponseDTO>(this.publicUrl + "/link", minecraftUsername, {headers: super.getHeaders()})
23+
.pipe(
24+
catchError((error: HttpErrorResponse) => {
25+
return throwError(() => this.buildErrorDto(error));
26+
})
27+
);
28+
}
29+
30+
unlinkUser() {
31+
return this.httpClient.post(this.publicUrl + "/unlink", null, {headers: super.getHeaders()})
32+
.pipe(
33+
catchError((error: HttpErrorResponse) => {
34+
return throwError(() => this.buildErrorDto(error));
35+
})
36+
);
37+
}
38+
39+
getCurrentUserLink(): Observable<PacifistaPaymentResponseDTO> {
40+
return this.httpClient.get<PacifistaPaymentResponseDTO>(this.publicUrl + "/linked", {headers: super.getHeaders()})
41+
.pipe(
42+
catchError((error: HttpErrorResponse) => {
43+
return throwError(() => this.buildErrorDto(error));
44+
})
45+
);
46+
}
47+
48+
}

projects/funixproductions-requests/src/public-api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,6 @@ export * from './lib/services/pacifista-api/server/players/data/dtos/PacifistaPl
7777
export * from './lib/services/pacifista-api/server/players/data/service/PacifistaPlayerDataService';
7878
export * from './lib/services/pacifista-api/server/players/data/service/PacifistaPlayerSessionsService';
7979
export * from './lib/services/pacifista-api/server/players/data/service/PacifistaPlayerChatMessagesService';
80+
81+
export * from './lib/services/pacifista-api/web/user/dtos/PacifistaWebUserLinkDTO';
82+
export * from './lib/services/pacifista-api/web/user/services/PacifistaWebUserLinkService';

0 commit comments

Comments
 (0)