feat: add new api
This commit is contained in:
76
src/api/v1/configuration/schedule.service.ts
Normal file
76
src/api/v1/configuration/schedule.service.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import {Injectable} from '@angular/core';
|
||||||
|
import ApiService, {AvailableVersion} from "@api/api.service";
|
||||||
|
import {CronUpdateScheduleResponse} from "@api/v1/configuration/cronUpdateScheduleResponse";
|
||||||
|
import {DateOnly} from "@model/dateOnly";
|
||||||
|
import {map} from "rxjs";
|
||||||
|
import CronUpdateSkip from "@model/cronUpdateSkip";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ScheduleService extends ApiService {
|
||||||
|
public readonly basePath = 'Configuration/Schedule';
|
||||||
|
public readonly version = AvailableVersion.v1;
|
||||||
|
|
||||||
|
public getCronUpdateSchedule() {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('CronUpdateSchedule')
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).get<CronUpdateScheduleResponse>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public postCronUpdateSchedule(cron: string) {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('CronUpdateSchedule')
|
||||||
|
.setQueryParams({cron: cron})
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).post<CronUpdateScheduleResponse>(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getStartTerm() {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('StartTerm')
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).get<string>(request).pipe(map(date => new DateOnly(date)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public postStartTerm(startTerm: DateOnly, force: boolean) {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('StartTerm')
|
||||||
|
.setQueryParams({force: force, startTerm: startTerm.toString()})
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).post(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCronUpdateSkip() {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('CronUpdateSkip')
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).get<{ date?: string, start?: string, end?: string }[]>(request)
|
||||||
|
.pipe(
|
||||||
|
map(data => {
|
||||||
|
return data.map(x => <CronUpdateSkip>{
|
||||||
|
date: x.date ? new DateOnly(x.date) : null,
|
||||||
|
start: x.start ? new DateOnly(x.start) : null,
|
||||||
|
end: x.end ? new DateOnly(x.end) : null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public postCronUpdateSkip(data: CronUpdateSkip[]) {
|
||||||
|
const request = this.createRequestBuilder()
|
||||||
|
.setEndpoint('CronUpdateSkip')
|
||||||
|
.setData(data.map(x => <any>{
|
||||||
|
start: x.start?.toString(),
|
||||||
|
end: x.end?.toString(),
|
||||||
|
date: x.date?.toString()
|
||||||
|
}))
|
||||||
|
.build;
|
||||||
|
|
||||||
|
return this.addAuth(request).post<any>(request);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,4 @@
|
|||||||
|
export interface CronUpdateScheduleResponse {
|
||||||
|
cron: string;
|
||||||
|
nextStart?: Date[];
|
||||||
|
}
|
7
src/shared/structs/cronUpdateSkip.ts
Normal file
7
src/shared/structs/cronUpdateSkip.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import {DateOnly} from "@model/dateOnly";
|
||||||
|
|
||||||
|
export default interface CronUpdateSkip {
|
||||||
|
start?: DateOnly;
|
||||||
|
end?: DateOnly;
|
||||||
|
date?: DateOnly;
|
||||||
|
}
|
Reference in New Issue
Block a user