@@ -11,23 +11,58 @@ See the License for the specific language governing permissions and
1111limitations under the License.
1212*/
1313
14- import IClientJobs from "../../../interfaces/Client/IClientJobs" ;
14+ import IClientJobs , { JobSchedule } from "../../../interfaces/Client/IClientJobs" ;
1515import HTTPClient from "./HTTPClient" ;
16+ import { Logger } from "../../../logger/Logger" ;
17+ import { THTTPExecuteParams } from "../../../types/http/THTTPExecuteParams.type" ;
1618
1719export default class HTTPClientJobs implements IClientJobs {
1820
21+ private readonly logger : Logger ;
1922 private readonly httpClient : HTTPClient ;
2023
2124 constructor ( httpClient : HTTPClient ) {
25+ this . logger = new Logger ( "HTTPClient" , "Jobs" , httpClient . options . logger ) ;
2226 this . httpClient = httpClient ;
2327 }
2428
25- schedule ( ) : Promise < unknown > {
26- throw new Error ( "Not yet!" ) ;
29+ async schedule (
30+ jobName : string ,
31+ data : object | string ,
32+ schedule : JobSchedule | null = null ,
33+ dueTime : string | Date | null = null ,
34+ repeats : number | null = null ,
35+ ttl : string | null = null
36+ ) : Promise < void > {
37+
38+ try {
39+ await this . httpClient . executeWithApiVersion (
40+ "v1.0-alpha1" ,
41+ `/jobs/${ jobName } ` ,
42+ {
43+ method : "POST" ,
44+ body : {
45+ data,
46+ schedule,
47+ dueTime,
48+ repeats,
49+ ttl,
50+ } ,
51+ headers : {
52+ "content-type" : "application/json" ,
53+ } ,
54+ } as THTTPExecuteParams
55+ ) ;
56+ }
57+ catch ( e : any ) {
58+ this . logger . error ( e ) ;
59+ }
2760 }
61+
2862 get ( ) : Promise < unknown > {
2963 throw new Error ( "Not yet!" ) ;
3064 }
65+
3166 delete ( ) : Promise < unknown > {
3267 throw new Error ( "Not yet!" ) ;
3368 }
0 commit comments