There are some aspects of the Doshii API that are only valid during certain times of the day, or certain days in the year (e.g. location operating hours, menu pricing, item availability, etc). We have termed this logic, Effective Dating, and will use the below structure across the various API endpoints to define the dates and times that the entity comes into effect.
The structure is broken up into a list of policies, each of those policies define a period of time.
Policy
All root-level properties are optional. An optional root-level property without a value is omitted.
[{
status: <String* (open|closed)>,
dates: [<PolicyDate>],
time: {
from: <String* (HH:mm)>,
to: <String* (HH:mm)>
},
daysOfWeek: [<String (mon|tue|wed|thu|fri|sat|sun)>],
effective: {
from: <String (yyyy-mm-dd)>,
to: <String (yyyy-mm-dd)>
}
}]
PolicyDate Object
[{
day: <Number (1-31)>,
month: <Number (1-12)>,
year: <Number>
}]
Policy Properties
Field | Type | Description |
---|---|---|
datesoptional | Object[] |
Either an array with 1 or 2 PolicyDates. Two PolicyDates signify an inclusive range from PolicyDate1 to PolicyDate2 |
dayoptional | Number |
The day of the month (1 - 31). |
monthoptional | Number |
The month of the year (1 - 12). |
yearoptional | Number |
The 4 digit year (e.g. 2019). |
timeoptional | Object |
Either an array with 1 or 2 PolicyDates. Two PolicyDates signify an inclusive range from PolicyDate1 to PolicyDate2 |
fromoptional | String |
Time from. HH:mm format. |
tooptional | String |
Time to. HH:mm format. |
daysOfWeekoptional | String[] |
A set of mon | tue | wed | thu | fri | sat | sun. |
effectiveoptional | Object |
Indicates when the policy becomes effective, for example, from the 1st of January 2020, etc |
fromoptional | String |
Policy is effective from (inclusive). yyyy-mm-dd format. |
tooptional | String |
Policy is effective to (inclusive). yyyy-mm-dd format. |
Example
A restaurant could have the following trading hours:
Date | Status | Description |
---|---|---|
Monday | Closed |
- |
Tuesday | Open |
11:30am–2:30pm, 5:30–9pm |
Wednesday | Open |
11:30am–2:30pm, 5:30–9pm |
Thursday | Open |
11:30am–2:30pm, 5:30–9pm |
Friday | Open |
11:30am–2:30pm, 5:30–9:30pm |
Saturday | Open |
11:30am–2:30pm, 5:30–9:30pm |
Sunday | Open |
11:30am–2:30pm, 5:30–9pm |
1 Jan | Closed |
New Year's Day |
24 Dec - 26 Dec | Closed |
Closed from Christmas Eve to Boxing Day |
Its full payload would be:
[{
status: 'closed',
daysOfWeek: ['mon']
}, {
status: 'open',
time: {
from: '11:30',
to: '14:30'
},
daysOfWeek: ['tue', 'wed', 'thu', 'fri', 'sat', 'sun']
}, {
status: 'open',
time: {
from: '17:30',
to: '21:00'
},
daysOfWeek: ['tue', 'wed', 'thu', 'sun']
}, {
status: 'open',
time: {
from: '17:30',
to: '21:30'
},
daysOfWeek: ['fri', 'sat']
}, {
status: 'closed',
dates: [{
day: 1,
month: 1
}]
}, {
status: 'closed',
dates: [{
day: 24,
month: 12
}, {
day: 26,
month: 12
}]
}]
More Examples
Example 1: Opening times from Jan 1 next year
[{
status: 'open',
time: {
from: '11:00',
to: '19:00'
},
effective: {
from: '2019-01-01'
}
}]
Example 2: Closed every Monday
[{
status: 'closed',
daysOfWeek: ['mon']
}]
Example 3: Closed every Xmas Day
[{
status: 'closed',
dates: [{
day: 25,
month: 12
}]
}]
Example 4: Closed for lunch everyday
[{
status: 'closed',
time: {
from: '12:00',
to: '13:00'
}
}]
Example 5: Longer hours for week night trading
[[{
status: 'open',
time: {
from: '11:00',
to: '21:00'
},
daysOfWeek: ['mon', 'tue', 'wed', 'thu', 'fri']
}]
Example 6: Xmas
Open till midnight the day before xmas and closed for xmas.
[{
status: 'open',
dates: [{
day: 23,
month: 12
}],
time: {
from: '11:00',
to: '23:59'
}
}, {
status: 'closed',
dates: [{
day: 24,
month: 12
}]
}]
Comments
0 comments
Please sign in to leave a comment.