Configure the scheduled order service

A scheduled order service runs periodically to review the order repository and determine if any scheduled orders are due to be filled.

Out of the box, this service is not set to run, so you must provide a frequency for it before scheduled orders can work.

To set the initial frequency of the scheduled order service, you issue a POST request to the scheduledJobs endpoint, with a payload that defines the schedule, an example of which is provided below. To update the schedule, you issue a PUT request to the same endpoint.

POST /ccadmin/v1/merchant/scheduledJobs

{
"componentPath": "ScheduledOrderService",
"scheduleType": "periodic",
"schedule":
  {
   "period" : 1000000
  }
}

The scheduleType and schedule properties determine the frequency used when running the scheduled order service. The scheduleType property may be either periodic (time-based) or calendar (calendar-based).

If you specify periodic for the scheduleType property, you must also provide a period property in milliseconds.

If you specify calendar, you must provide additional properties that further define the frequency. These properties include:

  • occurrenceInDay: This field can be set to 1 or 2, representing once a day or twice a day, respectively. The default is 1, in other words, if occurenceInDay is not specified, the order will be run once on the specified days.
  • daysOfWeek: This field can be set to 1, 2, 3, 4, 5, 6, or 7, which correspond to (and can be represented in the UI as) Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday.
  • weeksInMonth: This field can be set to 1, 2, 3, 4, or 5, which correspond to (and can be represented in the UI as) the first, second, third, fourth, or last week of the month.
  • monthsInYear: This field can be set to 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, which correspond to (and can be represented in the UI as) January, February, March, April, May, June, July, August, September, October, November, and December.
  • daysInMonth : This field corresponds to the day of the month and it can be set to a number between 1 and 31 (depending on the number of days in the month).

The following combinations of these properties are allowed:

  • occurenceInDay, daysOfWeek, weeksInMonth, monthsInYear
  • monthsInYear, daysInMonth, occurenceInDay

Note: If both daysInMonth and daysOfWeek are sent in the payload, then daysInMonth takes priority.

To help you better understand how to combine these properties, some examples are provided below.

This schedule runs twice on Sunday, Monday, and Tuesday of the first, second and third weeks of February and April.

"schedule":{    "daysOfWeek":[1,2,3],
           "weeksInMonth":[1,2,3],    "monthsInYear":[1, 3],
           "occurrenceInDay":2 }

This schedule runs twice a day:

"schedule":{    "occurrenceInDay":2 }

This schedule runs once every Sunday:

"schedule":{    "daysOfWeek":[1] }

This schedule runs twice on Monday in the second and third weeks of every month:

"schedule":{    "daysOfWeek":[2],    "weeksInMonth":[2,3],
           "occurrenceInDay":2 }

This schedule runs once on the first day of every month:

"schedule":{    "daysInMonth ":[1] }

This schedule runs once on the fifth day of June:

"schedule":{    "daysInMonth ":[5],    "monthsInYear": [5]
        }

This schedule runs once on the first day of January, March, May, July, September, and November:

"schedule":{    "daysInMonth ":[1]
           "monthsInYear":[0, 2, 4, 6, 8, 10] }

This schedule runs on the 10th, 15th, 20th, and 21st days of February and December:

"schedule":{    "daysInMonth":[10,15,20,21],
           "monthsInYear":[1, 11] }