@@ -19,58 +19,45 @@ import { JobSchedule } from "../../../types/jobs/JobSchedule.type";
19
19
20
20
export default class HTTPClientJobs implements IClientJobs {
21
21
22
- constructor ( private readonly httpClient : HTTPClient ) { }
23
-
24
- async schedule (
25
- jobName : string ,
26
- data : object | string ,
27
- schedule : JobSchedule | null = null ,
28
- dueTime : string | Date | null = null ,
29
- repeats : number | null = null ,
30
- ttl : string | null = null
31
- ) : Promise < void > {
32
-
33
- await this . httpClient . executeWithApiVersion (
34
- "v1.0-alpha1" ,
35
- `/jobs/${ jobName } ` ,
36
- {
37
- method : "POST" ,
38
- body : {
39
- data,
40
- schedule,
41
- dueTime,
42
- repeats,
43
- ttl,
44
- } ,
45
- headers : {
46
- "content-type" : "application/json" ,
47
- } ,
48
- } as THTTPExecuteParams
49
- ) ;
50
- }
51
-
52
- async get ( jobName : string ) : Promise < Job > ;
53
- async get < DataType > ( jobName : string ) : Promise < Job < DataType > > {
54
-
55
- const result = await this . httpClient . executeWithApiVersion (
56
- "v1.0-alpha1" ,
57
- `/jobs/${ jobName } ` ,
58
- {
59
- method : "GET" ,
60
- }
61
- ) ;
62
-
63
- return result as Job < DataType > ;
64
- }
65
-
66
- async delete ( jobName : string ) : Promise < void > {
67
-
68
- await this . httpClient . executeWithApiVersion (
69
- "v1.0-alpha1" ,
70
- `/jobs/${ jobName } ` ,
71
- {
72
- method : "DELETE"
73
- }
74
- ) ;
75
- }
76
- }
22
+ private static ApiVersion = "v1.0-alpha1" ;
23
+ private static Path = "jobs" ;
24
+
25
+ constructor ( private readonly httpClient : HTTPClient ) { }
26
+
27
+ async schedule (
28
+ jobName : string ,
29
+ data : object | string ,
30
+ schedule : JobSchedule | null = null ,
31
+ dueTime : string | Date | null = null ,
32
+ repeats : number | null = null ,
33
+ ttl : string | null = null ,
34
+ ) : Promise < void > {
35
+ await this . httpClient . executeWithApiVersion ( HTTPClientJobs . ApiVersion , `/${ HTTPClientJobs . Path } /${ jobName } ` , {
36
+ method : "POST" ,
37
+ body : {
38
+ data,
39
+ schedule,
40
+ dueTime,
41
+ repeats,
42
+ ttl,
43
+ } ,
44
+ headers : {
45
+ "content-type" : "application/json" ,
46
+ } ,
47
+ } as THTTPExecuteParams ) ;
48
+ }
49
+
50
+ async get < DataType > ( jobName : string ) : Promise < Job < DataType > > {
51
+ const result = await this . httpClient . executeWithApiVersion ( HTTPClientJobs . ApiVersion , `/${ HTTPClientJobs . Path } /${ jobName } ` , {
52
+ method : "GET" ,
53
+ } ) ;
54
+
55
+ return result as Job < DataType > ;
56
+ }
57
+
58
+ async delete ( jobName : string ) : Promise < void > {
59
+ await this . httpClient . executeWithApiVersion ( HTTPClientJobs . ApiVersion , `/${ HTTPClientJobs . Path } /${ jobName } ` , {
60
+ method : "DELETE" ,
61
+ } ) ;
62
+ }
63
+ }
0 commit comments