Skip to content

Hubtel SchedulingEngine Quartz Api

Introduction

This is an api which enables a user to create a job. A job is providing details to a system to later execute a task at a designated time assigned for the task/action to run. Additionaly allows a user to create a job with a complete payload and when the job is due, it will send the complete payload to the designated callback url.

Architecture

How it Works

  1. Create Job
    • Enables a user to create a job.
    • All fields are required
    • Endpoint to create a Job with the model structure below
    • POST to {baseUrl}/api/jobs

1a. Create Job - Enables a user to create a job. - All fields are required - POST to {baseUrl}/api/jobs endpoint with the model structure below

JSON
{
  "name": "b6d5b86e678889ew3cs5ff6b6d5b86e678",
  "description": "This is a test job",
  "schedule": "* * * ? * *",
  "startDate": "2022-03-30T19:53:03.331Z",
  "endDate": "2024-03-30T19:55:03.331Z",
  "customData": {
    "callbackUrl": "https://webhook.site/05a3da57-d85d-49c4-aa1a-9200666c6f74",
    "uniqueId":"b6d5b86e678889ew3cs5ff6"
  }
}

1b. Create Job With Custom Payload

  • Enables a user to create a job with custom payload.
  • Authentication data can be passed to the authentication field as string
  • POST to {baseUrl}/api/jobs/job-with-data endpoint with the model structure below
  • The authentication field can be left empty if no authentication is required.
  • The requestPayload field takes a dynamic JSON object which will be serialized and sent to the callback url when the job is due.
JSON
{
  "name": "b6d5b86e678889ew3cs5ff6b6d5b86e678",
  "description": "This is a test job",
  "schedule": "* * * ? * *",
  "startDate": "2022-03-30T19:53:03.331Z",
  "endDate": "2024-03-30T19:55:03.331Z",
  "customData": {
     "callbackUrl": "your callback url",
     "requestPayload": {
      "id":24,
      "name":"Kwame Brown",
      "username":"kwameB123"
     },
     "authentication" : "Basic dXNlcm5hbWU6cGFzc3dvcmQ="
  }
}
  1. Delete job with job name
    • Enables the deletion of a job by providing the job name used to initially create the job.
      DELETE to {baseUrl}/api/jobs/{jobName}

Integration

Conslusion

  • Following the above steps, you will be able to use this service to assist in executing tasks when physically not available to initiate the process. Keep in mind of the cron expression which tells you how the job will run