Skip to content
This repository was archived by the owner on Aug 21, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@funixproductions/angular-core",
"version": "0.2.3",
"version": "0.2.4",
"description": "Package used in all FunixProductions Angular projects",
"scripts": {
"ng": "ng",
Expand Down
2 changes: 1 addition & 1 deletion projects/funixproductions-requests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@funixproductions/funixproductions-requests",
"version": "0.2.3",
"version": "0.2.4",
"description": "Package used in all FunixProductions Angular projects",
"peerDependencies": {
"@angular/common": "^17.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {ApiDTO} from "../../../../core/dtos/api-dto";

export class VoteDTO extends ApiDTO {
username: string;
voteWebsite: string;
voteValidationDate?: Date;
nextVoteDate?: Date;

constructor(username: string, voteWebsite: string) {
super();
this.username = username;
this.voteWebsite = voteWebsite;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class VoteWebsiteDTO {
enumName: string;
displayName: string;
urlVote: string;
coolDownInMinutes: number;

constructor(enumName: string, displayName: string, urlVote: string, coolDownInMinutes: number) {
this.enumName = enumName;
this.displayName = displayName;
this.urlVote = urlVote;
this.coolDownInMinutes = coolDownInMinutes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export class VotesCountDTO {
username: string;
votesCount: number;

constructor(username: string, votesCount: number) {
this.username = username;
this.votesCount = votesCount;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import {FunixprodHttpClient} from "../../../../core/components/requests/funixprod-http-client";
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
import {environment} from "../../../../../../environments/environment";
import {environmentDev} from "../../../../../../environments/environment-dev";
import {catchError, Observable, throwError} from "rxjs";
import {Paginated} from "../../../../core/dtos/paginated";
import {VoteDTO} from "../dtos/VoteDTO";
import {VotesCountDTO} from "../dtos/VotesCountDTO";
import {VoteWebsiteDTO} from "../dtos/VoteWebsiteDTO";

export class VoteService extends FunixprodHttpClient {

private readonly domain: string;
private readonly path: string = 'web/vote';
private readonly http: HttpClient;

constructor(httpClient: HttpClient, productionEnv: boolean) {
super();
this.http = httpClient;

if (productionEnv) {
this.domain = environment.pacifistaApiUrl;
} else {
this.domain = environmentDev.pacifistaApiUrl;
}
}

public getAll(page: number, username?: string, month?: number, year?: number): Observable<Paginated<VoteDTO>> {
return this.http.get<Paginated<VoteDTO>>(this.domain + this.path, {
headers: super.getHeaders(),
params: {
page: page.toString(),
username: username ?? "",
month: month?.toString() ?? "",
year: year?.toString() ?? ""
}
}).pipe(
catchError((error: HttpErrorResponse) => {
return throwError(() => this.buildErrorDto(error));
})
);
}

public getTopVoters(month: number, year: number): Observable<VotesCountDTO[]> {
return this.http.get<VotesCountDTO[]>(this.domain + this.path + "/check", {
headers: super.getHeaders(),
params: {
month: month.toString(),
year: year.toString()
}
}).pipe(
catchError((error: HttpErrorResponse) => {
return throwError(() => this.buildErrorDto(error));
})
);
}

public getVoteWebsites(): Observable<VoteWebsiteDTO[]> {
return this.http.get<VoteWebsiteDTO[]>(this.domain + this.path + "/websites", {
headers: super.getHeaders()
}).pipe(
catchError((error: HttpErrorResponse) => {
return throwError(() => this.buildErrorDto(error));
})
);
}

public checkVote(voteWebsite: string): Observable<VoteDTO> {
return this.http.get<VoteDTO>(this.domain + this.path + "/user/" + voteWebsite, {
headers: super.getHeaders()
}).pipe(
catchError((error: HttpErrorResponse) => {
return throwError(() => this.buildErrorDto(error));
})
);
}

public makeVote(voteWebsite: string, username: string): Observable<VoteDTO> {
return this.http.post<VoteDTO>(this.domain + this.path + "/user/" + voteWebsite, {}, {
headers: super.getHeaders(),
params: {
username: username
}
}).pipe(
catchError((error: HttpErrorResponse) => {
return throwError(() => this.buildErrorDto(error));
})
);
}

}
7 changes: 6 additions & 1 deletion projects/funixproductions-requests/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@ export * from './lib/services/pacifista-api/server/players/data/service/Pacifist
export * from './lib/services/pacifista-api/server/players/data/service/PacifistaPlayerChatMessagesService';

export * from './lib/services/pacifista-api/web/user/dtos/PacifistaWebUserLinkDTO';
export * from './lib/services/pacifista-api/web/user/services/PacifistaWebUserLinkService';
export * from './lib/services/pacifista-api/web/user/services/PacifistaWebUserLinkService';

export * from './lib/services/pacifista-api/web/vote/dtos/VoteDTO';
export * from './lib/services/pacifista-api/web/vote/dtos/VoteWebsiteDTO';
export * from './lib/services/pacifista-api/web/vote/dtos/VotesCountDTO';
export * from './lib/services/pacifista-api/web/vote/services/VoteService';