Skip to content

Commit

Permalink
add endpoint bindings [#231]
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed May 12, 2021
1 parent b16f363 commit accd146
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions web/src/app/api/api.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,12 @@ export interface AccessTokenModel {
token: string;
expires: string;
}

export interface KarmaRule {
id: string;
guildid: string;
trigger: number;
value: number;
action: string;
argument: string;
}
39 changes: 39 additions & 0 deletions web/src/app/api/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
UserSettingsOTA,
GuildStarboardEntry,
AccessTokenModel,
KarmaRule,
} from './api.models';
import { environment } from 'src/environments/environment';
import { ToastService } from '../components/toast/toast.service';
Expand Down Expand Up @@ -121,6 +122,11 @@ export class APIService {
rc: string = ''
) => `${this.rcGuildSettingsKarma(guildID)}/blocklist${rc ? '/' + rc : ''}`;

private readonly rcGuildSettingsKarmaRules = (
guildID: string,
rc: string = ''
) => `${this.rcGuildSettingsKarma(guildID)}/rules${rc ? '/' + rc : ''}`;

private readonly rcGuildSettingsAntiraid = (guildID: string) =>
`${this.rcGuildSettings(guildID)}/antiraid`;

Expand Down Expand Up @@ -670,6 +676,39 @@ export class APIService {
.pipe(catchError(this.errorCatcher));
}

public getGuildSettingsKarmaRules(
guildID: string
): Observable<ListReponse<KarmaRule>> {
return this.http
.get(this.rcGuildSettingsKarmaRules(guildID), this.defopts())
.pipe(catchError(this.errorCatcher));
}

public createGuildSettingsKarmaRules(rule: KarmaRule): Observable<KarmaRule> {
return this.http
.post(this.rcGuildSettingsKarmaRules(rule.guildid), rule, this.defopts())
.pipe(catchError(this.errorCatcher));
}

public updateGuildSettingsKarmaRules(rule: KarmaRule): Observable<KarmaRule> {
return this.http
.post(
this.rcGuildSettingsKarmaRules(rule.guildid, rule.id),
rule,
this.defopts()
)
.pipe(catchError(this.errorCatcher));
}

public deleteGuildSettingsKarmaRules(rule: KarmaRule): Observable<KarmaRule> {
return this.http
.delete(
this.rcGuildSettingsKarmaRules(rule.guildid, rule.id),
this.defopts()
)
.pipe(catchError(this.errorCatcher));
}

public getGuildSettingsAntiraid(
guildID: string
): Observable<AntiraidSettings> {
Expand Down

0 comments on commit accd146

Please sign in to comment.