@open-tender/cloud 0.5.7 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +3 -3
  3. package/dist/cjs/app/hooks.d.ts +67 -67
  4. package/dist/cjs/app/hooks.js +8 -8
  5. package/dist/cjs/app/index.d.ts +2 -2
  6. package/dist/cjs/app/index.js +5 -5
  7. package/dist/cjs/app/store.d.ts +197 -197
  8. package/dist/cjs/app/store.js +65 -65
  9. package/dist/cjs/index.d.ts +5 -5
  10. package/dist/cjs/index.js +11 -11
  11. package/dist/cjs/services/api.d.ts +173 -173
  12. package/dist/cjs/services/api.js +741 -741
  13. package/dist/cjs/services/errors.d.ts +50 -50
  14. package/dist/cjs/services/errors.js +53 -53
  15. package/dist/cjs/services/index.d.ts +3 -3
  16. package/dist/cjs/services/index.js +7 -7
  17. package/dist/cjs/slices/alerts.d.ts +5 -5
  18. package/dist/cjs/slices/alerts.js +29 -29
  19. package/dist/cjs/slices/allergens.d.ts +101 -101
  20. package/dist/cjs/slices/allergens.js +83 -83
  21. package/dist/cjs/slices/announcements.d.ts +180 -180
  22. package/dist/cjs/slices/announcements.js +81 -81
  23. package/dist/cjs/slices/checkout.d.ts +69 -69
  24. package/dist/cjs/slices/checkout.js +326 -326
  25. package/dist/cjs/slices/completedOrders.d.ts +31 -31
  26. package/dist/cjs/slices/completedOrders.js +61 -61
  27. package/dist/cjs/slices/config.d.ts +317 -317
  28. package/dist/cjs/slices/config.js +195 -195
  29. package/dist/cjs/slices/confirmation.d.ts +8 -8
  30. package/dist/cjs/slices/confirmation.js +23 -23
  31. package/dist/cjs/slices/customer/account.d.ts +128 -128
  32. package/dist/cjs/slices/customer/account.js +351 -351
  33. package/dist/cjs/slices/customer/addresses.d.ts +55 -55
  34. package/dist/cjs/slices/customer/addresses.js +132 -132
  35. package/dist/cjs/slices/customer/allergens.d.ts +37 -37
  36. package/dist/cjs/slices/customer/allergens.js +94 -94
  37. package/dist/cjs/slices/customer/communicationPreferences.d.ts +69 -69
  38. package/dist/cjs/slices/customer/communicationPreferences.js +164 -164
  39. package/dist/cjs/slices/customer/creditCards.d.ts +137 -137
  40. package/dist/cjs/slices/customer/creditCards.js +170 -170
  41. package/dist/cjs/slices/customer/favorites.d.ts +68 -68
  42. package/dist/cjs/slices/customer/favorites.js +173 -173
  43. package/dist/cjs/slices/customer/fcmToken.d.ts +49 -49
  44. package/dist/cjs/slices/customer/fcmToken.js +110 -110
  45. package/dist/cjs/slices/customer/giftCards.d.ts +98 -98
  46. package/dist/cjs/slices/customer/giftCards.js +222 -222
  47. package/dist/cjs/slices/customer/groupOrders.d.ts +118 -118
  48. package/dist/cjs/slices/customer/groupOrders.js +262 -262
  49. package/dist/cjs/slices/customer/history.d.ts +23 -23
  50. package/dist/cjs/slices/customer/history.js +57 -57
  51. package/dist/cjs/slices/customer/houseAccounts.d.ts +26 -26
  52. package/dist/cjs/slices/customer/houseAccounts.js +67 -67
  53. package/dist/cjs/slices/customer/index.d.ts +42 -42
  54. package/dist/cjs/slices/customer/index.js +68 -68
  55. package/dist/cjs/slices/customer/loyalty.d.ts +251 -251
  56. package/dist/cjs/slices/customer/loyalty.js +110 -110
  57. package/dist/cjs/slices/customer/order.d.ts +116 -116
  58. package/dist/cjs/slices/customer/order.js +98 -98
  59. package/dist/cjs/slices/customer/orders.d.ts +27 -27
  60. package/dist/cjs/slices/customer/orders.js +69 -69
  61. package/dist/cjs/slices/customer/pointsShop.d.ts +35 -35
  62. package/dist/cjs/slices/customer/pointsShop.js +86 -86
  63. package/dist/cjs/slices/customer/qrCode.d.ts +23 -23
  64. package/dist/cjs/slices/customer/qrCode.js +57 -57
  65. package/dist/cjs/slices/customer/rewards.d.ts +26 -26
  66. package/dist/cjs/slices/customer/rewards.js +67 -67
  67. package/dist/cjs/slices/customer/thanx.d.ts +23 -23
  68. package/dist/cjs/slices/customer/thanx.js +56 -56
  69. package/dist/cjs/slices/customer/tpls.d.ts +238 -238
  70. package/dist/cjs/slices/customer/tpls.js +102 -102
  71. package/dist/cjs/slices/customer/tplsPointsShop.d.ts +38 -38
  72. package/dist/cjs/slices/customer/tplsPointsShop.js +88 -88
  73. package/dist/cjs/slices/deals.d.ts +25 -25
  74. package/dist/cjs/slices/deals.js +96 -96
  75. package/dist/cjs/slices/donations.d.ts +27 -27
  76. package/dist/cjs/slices/donations.js +57 -57
  77. package/dist/cjs/slices/geolocation.d.ts +11 -11
  78. package/dist/cjs/slices/geolocation.js +36 -36
  79. package/dist/cjs/slices/giftCards.d.ts +27 -27
  80. package/dist/cjs/slices/giftCards.js +58 -58
  81. package/dist/cjs/slices/groupOrder.d.ts +418 -418
  82. package/dist/cjs/slices/groupOrder.js +266 -266
  83. package/dist/cjs/slices/guest.d.ts +51 -51
  84. package/dist/cjs/slices/guest.js +91 -91
  85. package/dist/cjs/slices/index.d.ts +41 -41
  86. package/dist/cjs/slices/index.js +44 -44
  87. package/dist/cjs/slices/loader.d.ts +9 -9
  88. package/dist/cjs/slices/loader.js +25 -25
  89. package/dist/cjs/slices/menu.d.ts +31 -31
  90. package/dist/cjs/slices/menu.js +97 -97
  91. package/dist/cjs/slices/menuDisplay.d.ts +32 -32
  92. package/dist/cjs/slices/menuDisplay.js +59 -59
  93. package/dist/cjs/slices/menuItems.d.ts +26 -26
  94. package/dist/cjs/slices/menuItems.js +57 -57
  95. package/dist/cjs/slices/misc.d.ts +17 -17
  96. package/dist/cjs/slices/misc.js +51 -51
  97. package/dist/cjs/slices/modal.d.ts +5 -5
  98. package/dist/cjs/slices/modal.js +30 -30
  99. package/dist/cjs/slices/nav.d.ts +7 -7
  100. package/dist/cjs/slices/nav.js +23 -23
  101. package/dist/cjs/slices/navSite.d.ts +7 -7
  102. package/dist/cjs/slices/navSite.js +23 -23
  103. package/dist/cjs/slices/notifications.d.ts +5 -5
  104. package/dist/cjs/slices/notifications.js +27 -27
  105. package/dist/cjs/slices/oneTimePasscode.d.ts +40 -40
  106. package/dist/cjs/slices/oneTimePasscode.js +91 -91
  107. package/dist/cjs/slices/order.d.ts +372 -372
  108. package/dist/cjs/slices/order.js +528 -528
  109. package/dist/cjs/slices/orderFulfillment.d.ts +37 -37
  110. package/dist/cjs/slices/orderFulfillment.js +77 -77
  111. package/dist/cjs/slices/orderRating.d.ts +52 -52
  112. package/dist/cjs/slices/orderRating.js +105 -105
  113. package/dist/cjs/slices/posts.d.ts +24 -24
  114. package/dist/cjs/slices/posts.js +55 -55
  115. package/dist/cjs/slices/pushNotifications.d.ts +9 -9
  116. package/dist/cjs/slices/pushNotifications.js +29 -29
  117. package/dist/cjs/slices/qr.d.ts +11 -11
  118. package/dist/cjs/slices/qr.js +34 -34
  119. package/dist/cjs/slices/quote.d.ts +102 -102
  120. package/dist/cjs/slices/quote.js +65 -65
  121. package/dist/cjs/slices/resetPassword.d.ts +41 -41
  122. package/dist/cjs/slices/resetPassword.js +80 -80
  123. package/dist/cjs/slices/revenueCenters.d.ts +35 -35
  124. package/dist/cjs/slices/revenueCenters.js +95 -95
  125. package/dist/cjs/slices/sidebar.d.ts +7 -7
  126. package/dist/cjs/slices/sidebar.js +23 -23
  127. package/dist/cjs/slices/sidebarModal.d.ts +7 -7
  128. package/dist/cjs/slices/sidebarModal.js +23 -23
  129. package/dist/cjs/slices/signUp.d.ts +25 -25
  130. package/dist/cjs/slices/signUp.js +60 -60
  131. package/dist/cjs/slices/tags.d.ts +101 -101
  132. package/dist/cjs/slices/tags.js +90 -90
  133. package/dist/cjs/slices/terms.d.ts +20 -20
  134. package/dist/cjs/slices/terms.js +51 -51
  135. package/dist/cjs/slices/types.d.ts +62 -62
  136. package/dist/cjs/slices/types.js +66 -66
  137. package/dist/cjs/slices/unsubscribe.d.ts +39 -39
  138. package/dist/cjs/slices/unsubscribe.js +78 -78
  139. package/dist/cjs/slices/validTimes.d.ts +23 -23
  140. package/dist/cjs/slices/validTimes.js +57 -57
  141. package/dist/cjs/slices/verifyAccount.d.ts +23 -23
  142. package/dist/cjs/slices/verifyAccount.js +54 -54
  143. package/dist/esm/app/hooks.d.ts +67 -67
  144. package/dist/esm/app/hooks.js +4 -4
  145. package/dist/esm/app/index.d.ts +2 -2
  146. package/dist/esm/app/index.js +2 -2
  147. package/dist/esm/app/store.d.ts +197 -197
  148. package/dist/esm/app/store.js +62 -62
  149. package/dist/esm/index.d.ts +5 -5
  150. package/dist/esm/index.js +5 -5
  151. package/dist/esm/services/api.d.ts +173 -173
  152. package/dist/esm/services/api.js +739 -739
  153. package/dist/esm/services/errors.d.ts +50 -50
  154. package/dist/esm/services/errors.js +50 -50
  155. package/dist/esm/services/index.d.ts +3 -3
  156. package/dist/esm/services/index.js +3 -3
  157. package/dist/esm/slices/alerts.d.ts +5 -5
  158. package/dist/esm/slices/alerts.js +24 -24
  159. package/dist/esm/slices/allergens.d.ts +101 -101
  160. package/dist/esm/slices/allergens.js +77 -77
  161. package/dist/esm/slices/announcements.d.ts +180 -180
  162. package/dist/esm/slices/announcements.js +75 -75
  163. package/dist/esm/slices/checkout.d.ts +69 -69
  164. package/dist/esm/slices/checkout.js +318 -318
  165. package/dist/esm/slices/completedOrders.d.ts +31 -31
  166. package/dist/esm/slices/completedOrders.js +57 -57
  167. package/dist/esm/slices/config.d.ts +317 -317
  168. package/dist/esm/slices/config.js +168 -168
  169. package/dist/esm/slices/confirmation.d.ts +8 -8
  170. package/dist/esm/slices/confirmation.js +18 -18
  171. package/dist/esm/slices/customer/account.d.ts +128 -128
  172. package/dist/esm/slices/customer/account.js +344 -344
  173. package/dist/esm/slices/customer/addresses.d.ts +55 -55
  174. package/dist/esm/slices/customer/addresses.js +127 -127
  175. package/dist/esm/slices/customer/allergens.d.ts +37 -37
  176. package/dist/esm/slices/customer/allergens.js +89 -89
  177. package/dist/esm/slices/customer/communicationPreferences.d.ts +69 -69
  178. package/dist/esm/slices/customer/communicationPreferences.js +159 -159
  179. package/dist/esm/slices/customer/creditCards.d.ts +137 -137
  180. package/dist/esm/slices/customer/creditCards.js +165 -165
  181. package/dist/esm/slices/customer/favorites.d.ts +68 -68
  182. package/dist/esm/slices/customer/favorites.js +168 -168
  183. package/dist/esm/slices/customer/fcmToken.d.ts +49 -49
  184. package/dist/esm/slices/customer/fcmToken.js +106 -106
  185. package/dist/esm/slices/customer/giftCards.d.ts +98 -98
  186. package/dist/esm/slices/customer/giftCards.js +217 -217
  187. package/dist/esm/slices/customer/groupOrders.d.ts +118 -118
  188. package/dist/esm/slices/customer/groupOrders.js +256 -256
  189. package/dist/esm/slices/customer/history.d.ts +23 -23
  190. package/dist/esm/slices/customer/history.js +53 -53
  191. package/dist/esm/slices/customer/houseAccounts.d.ts +26 -26
  192. package/dist/esm/slices/customer/houseAccounts.js +62 -62
  193. package/dist/esm/slices/customer/index.d.ts +42 -42
  194. package/dist/esm/slices/customer/index.js +64 -64
  195. package/dist/esm/slices/customer/loyalty.d.ts +251 -251
  196. package/dist/esm/slices/customer/loyalty.js +102 -102
  197. package/dist/esm/slices/customer/order.d.ts +116 -116
  198. package/dist/esm/slices/customer/order.js +94 -94
  199. package/dist/esm/slices/customer/orders.d.ts +27 -27
  200. package/dist/esm/slices/customer/orders.js +63 -63
  201. package/dist/esm/slices/customer/pointsShop.d.ts +35 -35
  202. package/dist/esm/slices/customer/pointsShop.js +82 -82
  203. package/dist/esm/slices/customer/qrCode.d.ts +23 -23
  204. package/dist/esm/slices/customer/qrCode.js +53 -53
  205. package/dist/esm/slices/customer/rewards.d.ts +26 -26
  206. package/dist/esm/slices/customer/rewards.js +62 -62
  207. package/dist/esm/slices/customer/thanx.d.ts +23 -23
  208. package/dist/esm/slices/customer/thanx.js +52 -52
  209. package/dist/esm/slices/customer/tpls.d.ts +238 -238
  210. package/dist/esm/slices/customer/tpls.js +98 -98
  211. package/dist/esm/slices/customer/tplsPointsShop.d.ts +38 -38
  212. package/dist/esm/slices/customer/tplsPointsShop.js +84 -84
  213. package/dist/esm/slices/deals.d.ts +25 -25
  214. package/dist/esm/slices/deals.js +90 -90
  215. package/dist/esm/slices/donations.d.ts +27 -27
  216. package/dist/esm/slices/donations.js +53 -53
  217. package/dist/esm/slices/geolocation.d.ts +11 -11
  218. package/dist/esm/slices/geolocation.js +30 -30
  219. package/dist/esm/slices/giftCards.d.ts +27 -27
  220. package/dist/esm/slices/giftCards.js +54 -54
  221. package/dist/esm/slices/groupOrder.d.ts +418 -418
  222. package/dist/esm/slices/groupOrder.js +259 -259
  223. package/dist/esm/slices/guest.d.ts +51 -51
  224. package/dist/esm/slices/guest.js +86 -86
  225. package/dist/esm/slices/index.d.ts +41 -41
  226. package/dist/esm/slices/index.js +41 -41
  227. package/dist/esm/slices/loader.d.ts +9 -9
  228. package/dist/esm/slices/loader.js +21 -21
  229. package/dist/esm/slices/menu.d.ts +31 -31
  230. package/dist/esm/slices/menu.js +90 -90
  231. package/dist/esm/slices/menuDisplay.d.ts +32 -32
  232. package/dist/esm/slices/menuDisplay.js +55 -55
  233. package/dist/esm/slices/menuItems.d.ts +26 -26
  234. package/dist/esm/slices/menuItems.js +52 -52
  235. package/dist/esm/slices/misc.d.ts +17 -17
  236. package/dist/esm/slices/misc.js +41 -41
  237. package/dist/esm/slices/modal.d.ts +5 -5
  238. package/dist/esm/slices/modal.js +25 -25
  239. package/dist/esm/slices/nav.d.ts +7 -7
  240. package/dist/esm/slices/nav.js +19 -19
  241. package/dist/esm/slices/navSite.d.ts +7 -7
  242. package/dist/esm/slices/navSite.js +19 -19
  243. package/dist/esm/slices/notifications.d.ts +5 -5
  244. package/dist/esm/slices/notifications.js +22 -22
  245. package/dist/esm/slices/oneTimePasscode.d.ts +40 -40
  246. package/dist/esm/slices/oneTimePasscode.js +86 -86
  247. package/dist/esm/slices/order.d.ts +372 -372
  248. package/dist/esm/slices/order.js +508 -508
  249. package/dist/esm/slices/orderFulfillment.d.ts +37 -37
  250. package/dist/esm/slices/orderFulfillment.js +73 -73
  251. package/dist/esm/slices/orderRating.d.ts +52 -52
  252. package/dist/esm/slices/orderRating.js +101 -101
  253. package/dist/esm/slices/posts.d.ts +24 -24
  254. package/dist/esm/slices/posts.js +51 -51
  255. package/dist/esm/slices/pushNotifications.d.ts +9 -9
  256. package/dist/esm/slices/pushNotifications.js +23 -23
  257. package/dist/esm/slices/qr.d.ts +11 -11
  258. package/dist/esm/slices/qr.js +29 -29
  259. package/dist/esm/slices/quote.d.ts +102 -102
  260. package/dist/esm/slices/quote.js +61 -61
  261. package/dist/esm/slices/resetPassword.d.ts +41 -41
  262. package/dist/esm/slices/resetPassword.js +76 -76
  263. package/dist/esm/slices/revenueCenters.d.ts +35 -35
  264. package/dist/esm/slices/revenueCenters.js +89 -89
  265. package/dist/esm/slices/sidebar.d.ts +7 -7
  266. package/dist/esm/slices/sidebar.js +19 -19
  267. package/dist/esm/slices/sidebarModal.d.ts +7 -7
  268. package/dist/esm/slices/sidebarModal.js +19 -19
  269. package/dist/esm/slices/signUp.d.ts +25 -25
  270. package/dist/esm/slices/signUp.js +56 -56
  271. package/dist/esm/slices/tags.d.ts +101 -101
  272. package/dist/esm/slices/tags.js +84 -84
  273. package/dist/esm/slices/terms.d.ts +20 -20
  274. package/dist/esm/slices/terms.js +47 -47
  275. package/dist/esm/slices/types.d.ts +62 -62
  276. package/dist/esm/slices/types.js +63 -63
  277. package/dist/esm/slices/unsubscribe.d.ts +39 -39
  278. package/dist/esm/slices/unsubscribe.js +74 -74
  279. package/dist/esm/slices/validTimes.d.ts +23 -23
  280. package/dist/esm/slices/validTimes.js +52 -52
  281. package/dist/esm/slices/verifyAccount.d.ts +23 -23
  282. package/dist/esm/slices/verifyAccount.js +50 -50
  283. package/package.json +61 -61
@@ -1,739 +1,739 @@
1
- import { __awaiter } from "tslib";
2
- import { serialize } from '@open-tender/utils';
3
- class requestException extends Error {
4
- constructor(message, response, exception, extracted) {
5
- super(message, { cause: exception });
6
- this.message = `${message || 'An unknown exception was triggered.'}`;
7
- this.stack = new Error().stack;
8
- this.response = response;
9
- this.exception = exception;
10
- this.extracted = extracted;
11
- }
12
- }
13
- const fiveHundredError = (status = 500, statusText = 'Unknown 500 error') => ({
14
- status: status,
15
- code: 'errors.server.internal',
16
- title: 'Internal Server Error',
17
- detail: statusText
18
- });
19
- const unauthorizedError = {
20
- status: 401,
21
- code: 'errors.unauthorized',
22
- title: 'Unauthorized',
23
- detail: 'Provided token is not valid'
24
- };
25
- const handleResponse = (response) => {
26
- const { status, statusText } = response;
27
- if (status >= 500)
28
- throw fiveHundredError(status, statusText);
29
- if (status === 401)
30
- throw unauthorizedError;
31
- if (statusText === 'NO CONTENT' || status === 204) {
32
- return true;
33
- }
34
- if (status === 202) {
35
- try {
36
- return response.body;
37
- }
38
- catch (err) {
39
- throw new requestException('Response could not be parsed', response, err);
40
- }
41
- }
42
- const requestWasSuccessful = status >= 200 && status < 300;
43
- try {
44
- return response.json().then(parsed => {
45
- if (requestWasSuccessful)
46
- return parsed;
47
- throw parsed;
48
- });
49
- }
50
- catch (err) {
51
- throw new requestException('Response could not be parsed', response, err);
52
- }
53
- };
54
- class OpenTenderAPI {
55
- constructor(config) {
56
- this.request = (endpoint, method = 'GET', data = null, timeout = null, token = null) => __awaiter(this, void 0, void 0, function* () {
57
- let didTimeOut = false;
58
- return new Promise((resolve, reject) => {
59
- let timer;
60
- if (timeout) {
61
- timer = setTimeout(() => {
62
- didTimeOut = true;
63
- reject(new Error('Request timed out'));
64
- }, timeout);
65
- }
66
- const headers = {
67
- Accept: 'application/json',
68
- 'Content-Type': 'application/json'
69
- };
70
- if (this.clientId)
71
- headers['client-id'] = `${this.clientId}`;
72
- if (this.brandId)
73
- headers['brand-id'] = `${this.brandId}`;
74
- if (token)
75
- headers.Authorization = `Bearer ${token}`;
76
- const options = {
77
- method: method,
78
- headers: headers
79
- };
80
- if (data)
81
- options.body = JSON.stringify(data);
82
- fetch(`${this.baseUrl}${endpoint}`, options)
83
- .then(handleResponse)
84
- .then(json => {
85
- if (didTimeOut)
86
- return;
87
- resolve(json);
88
- })
89
- .catch(err => {
90
- if (didTimeOut)
91
- return;
92
- err.code ? reject(err) : reject(fiveHundredError());
93
- })
94
- .finally(() => {
95
- if (timeout)
96
- clearTimeout(timer);
97
- });
98
- });
99
- });
100
- this.authRequest = (endpoint, data) => __awaiter(this, void 0, void 0, function* () {
101
- return new Promise((resolve, reject) => {
102
- data.client_id = this.clientId;
103
- const options = {
104
- method: 'POST',
105
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
106
- body: serialize(data)
107
- };
108
- fetch(`${this.authUrl}/oauth2${endpoint}`, options)
109
- .then(res => res.json())
110
- .then(json => {
111
- if (json.error)
112
- throw new Error(json.error_description);
113
- resolve(json);
114
- })
115
- .catch(err => {
116
- reject(err);
117
- });
118
- });
119
- });
120
- this.brandId = config === null || config === void 0 ? void 0 : config.brandId;
121
- this.clientId = config === null || config === void 0 ? void 0 : config.clientId;
122
- this.baseUrl = config === null || config === void 0 ? void 0 : config.baseUrl;
123
- this.authUrl = config === null || config === void 0 ? void 0 : config.authUrl;
124
- }
125
- post(endpoint, data) {
126
- return this.request(`/${endpoint}`, 'POST', data);
127
- }
128
- getHttpResponse(code) {
129
- return this.request(`/${code}/cors`);
130
- }
131
- postSettings(entityType) {
132
- const params = entityType ? `&entity_type=${entityType}` : '';
133
- return this.request(`/settings/pull?force=true${params}`, 'POST', {});
134
- }
135
- getConfig() {
136
- return this.request(`/config`);
137
- }
138
- postChipDNATender(orderId, data) {
139
- return this.request(`/orders/${orderId}/tenders/chipdna`, 'POST', data);
140
- }
141
- postChipDNACancel() {
142
- return this.request(`/chipdna/cancel`, 'POST', {});
143
- }
144
- postChipDNATmsUpdate() {
145
- return this.request(`/chipdna/tms-update`, 'POST', {});
146
- }
147
- getBarcodeRead() {
148
- return this.request(`/devices/qrcode/read`);
149
- }
150
- postBarcodeCancel() {
151
- return this.request(`/devices/qrcode/cancel`, 'POST', {});
152
- }
153
- getCardRead() {
154
- return this.request(`/devices/card/read`);
155
- }
156
- postCardCancel() {
157
- return this.request(`/devices/card/cancel`, 'POST', {});
158
- }
159
- postCardAssign(employeeId, code) {
160
- const data = { employee_id: employeeId, code };
161
- return this.request(`/employee-cards/assign`, 'POST', data);
162
- }
163
- postCardUnassign(code) {
164
- return this.request(`/employee-cards/unassign`, 'POST', { code });
165
- }
166
- // identifier can be either a timeclock ID as an integer
167
- // or a swipe card code as a string
168
- getEmployee(identifier) {
169
- return this.request(`/employees/${identifier}`);
170
- }
171
- postTimePunch(data) {
172
- return this.request(`/time-punches`, 'POST', data);
173
- }
174
- getTimePunchesReport(businessDate, employeeId) {
175
- let params = [];
176
- if (businessDate)
177
- params.push(`business_date=${businessDate}`);
178
- if (employeeId)
179
- params.push(`employee_id=${employeeId}`);
180
- params = params.length ? `?${params.join('&')}` : '';
181
- return this.request(`/time-punches-report${params}`);
182
- }
183
- postPrintShiftSummary(employeeId) {
184
- return this.request(`/shift-summary/${employeeId}/print`, 'POST', {});
185
- }
186
- postCashEvent(data) {
187
- return this.request(`/cash-events`, 'POST', data);
188
- }
189
- getCashier() {
190
- return this.request(`/cashier`);
191
- }
192
- getCashSummary(employeeId) {
193
- return this.request(`/cash-summary/${employeeId}`);
194
- }
195
- postPrintCashSummary(employeeId) {
196
- return this.request(`/cash-summary/${employeeId}/print`, 'POST', {});
197
- }
198
- getAlerts() {
199
- return this.request(`/alerts`);
200
- }
201
- getAlert(alertId) {
202
- return this.request(`/alerts/${alertId}`);
203
- }
204
- putAlert(alertId, data) {
205
- return this.request(`/alerts/${alertId}`, 'PUT', data);
206
- }
207
- deleteAlert(alertId) {
208
- return this.request(`/alerts/${alertId}`, 'DELETE');
209
- }
210
- getOfflineTransactions() {
211
- return this.request(`/credit/offline-transactions`);
212
- }
213
- postOfflineTransactions() {
214
- return this.request(`/credit/offline-transactions/process`, 'POST', {});
215
- }
216
- getSurcharges(serviceType) {
217
- const params = serviceType ? `?service_type=${serviceType}` : '';
218
- return this.request(`/surcharges${params}`);
219
- }
220
- getDiscounts(serviceType, orderType) {
221
- let params = [];
222
- if (serviceType)
223
- params.push(`service_type=${serviceType}`);
224
- if (orderType)
225
- params.push(`order_type=${orderType}`);
226
- params = params.length ? `?${params.join('&')}` : '';
227
- return this.request(`/discounts${params}`);
228
- }
229
- getDiscount(name) {
230
- return this.request(`/discounts/${name}`);
231
- }
232
- getDiscountViaQRCode(code) {
233
- return this.request(`/qrcodes/${code}`);
234
- }
235
- getTaxes(serviceType, orderType) {
236
- let params = [];
237
- if (serviceType)
238
- params.push(`service_type=${serviceType}`);
239
- if (orderType)
240
- params.push(`order_type=${orderType}`);
241
- params = params.length ? `?${params.join('&')}` : '';
242
- return this.request(`/taxes${params}`);
243
- }
244
- getItemTypes() {
245
- return this.request(`/item-types`);
246
- }
247
- getSelectOptions() {
248
- return this.request(`/select-options`);
249
- }
250
- postOpenCashDrawer() {
251
- return this.request(`/devices/drawer/open`, 'POST', {});
252
- }
253
- postTicketPrint(orderUuid, ticketNo, data) {
254
- const endpoint = `/orders/${orderUuid}/tickets/${ticketNo}/print`;
255
- return this.request(endpoint, 'POST', data);
256
- }
257
- postTicketStatus(orderUuid, ticketNo, status) {
258
- const endpoint = `/orders/${orderUuid}/tickets/${ticketNo}/${status}`;
259
- return this.request(endpoint, 'POST', {});
260
- }
261
- postTicketsPrint(orderUuid, data) {
262
- const endpoint = `/orders/${orderUuid}/tickets/print`;
263
- return this.request(endpoint, 'POST', data);
264
- }
265
- postTicketsReset(orderUuid) {
266
- const endpoint = `/orders/${orderUuid}/tickets/reset`;
267
- return this.request(endpoint, 'POST', {});
268
- }
269
- getArrivals() {
270
- return this.request(`/arrivals`);
271
- }
272
- postAcknowledgeArrival(orderUuid) {
273
- return this.request(`/orders/${orderUuid}/ack-arrival`, 'POST', {});
274
- }
275
- patchOrder(orderUuid, data) {
276
- return this.request(`/orders/${orderUuid}`, 'PATCH', data);
277
- }
278
- postReceipt(orderUuid) {
279
- const endpoint = `/orders/${orderUuid}/print`;
280
- return this.request(endpoint, 'POST', {});
281
- }
282
- postGiftCardCredit(data, checkOnly) {
283
- const params = checkOnly ? '?check_only=true' : '';
284
- return this.request(`/gift-cards/credit${params}`, 'POST', data);
285
- }
286
- getGiftCardBalance(code, cardNumber) {
287
- const params = code ? `code=${code}` : `card_number=${cardNumber || ''}`;
288
- return this.request(`/gift-cards/balance?${params}`);
289
- }
290
- getInternalSettings() {
291
- return this.request(`/internal-settings`);
292
- }
293
- postInternalSettings(data) {
294
- return this.request(`/internal-settings`, 'POST', data);
295
- }
296
- getStore() {
297
- return this.request(`/store`);
298
- }
299
- getRevenueCenters(revenue_center_type, is_outpost, lat, lng, requestedAt, serviceType) {
300
- let params = '';
301
- if (revenue_center_type)
302
- params += `revenue_center_type=${revenue_center_type}`;
303
- if (is_outpost)
304
- params += '&is_outpost=true';
305
- if (lat && lng)
306
- params += `&lat=${lat}&lng=${lng}`;
307
- if (requestedAt)
308
- params += `&requested_at=${requestedAt}`;
309
- if (serviceType)
310
- params += `&service_type=${serviceType}`;
311
- return this.request(`/revenue-centers?${params}`);
312
- }
313
- getRevenueCenter(revenue_center_id, requestedAt) {
314
- const params = requestedAt ? `?requested_at=${requestedAt}` : '';
315
- return this.request(`/revenue-centers/${revenue_center_id}${params}`);
316
- }
317
- getLocations(revenue_center_type, is_outpost, lat, lng, requestedAt, cart_total, address, serviceType) {
318
- let params = '';
319
- if (revenue_center_type)
320
- params += `revenue_center_type=${revenue_center_type}`;
321
- if (is_outpost)
322
- params += '&is_outpost=true';
323
- if (lat && lng)
324
- params += `&lat=${lat}&lng=${lng}`;
325
- if (requestedAt)
326
- params += `&requested_at=${requestedAt}`;
327
- if (cart_total)
328
- params += `&cart_total=${cart_total}`;
329
- if (address)
330
- params += `&address=${address}`;
331
- if (serviceType)
332
- params += `&service_type=${serviceType}`;
333
- return this.request(`/locations?${params}`);
334
- }
335
- getLocation(revenue_center_id, cart_total) {
336
- let params = '';
337
- if (cart_total)
338
- params += `?cart_total=${cart_total}`;
339
- return this.request(`/locations/${revenue_center_id}${params}`);
340
- }
341
- getLocationBySlug(slug, cart_total) {
342
- let params = '';
343
- if (cart_total)
344
- params += `?cart_total=${cart_total}`;
345
- return this.request(`/locations/${slug}${params}`);
346
- }
347
- getValidTimes(revenueCenterType) {
348
- const params = `revenue_center_type=${revenueCenterType}`;
349
- return this.request(`/valid-times?${params}`);
350
- }
351
- getTags() {
352
- return this.request(`/tags?with_related=true`);
353
- }
354
- getAllergens() {
355
- return this.request(`/allergens?with_related=true`);
356
- }
357
- getMenu(revenueCenterId, serviceType, requestedAt) {
358
- const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}&requested_at=${requestedAt}`;
359
- return this.request(`/menus?${params}`);
360
- }
361
- getMenuItems(revenueCenterId, serviceType) {
362
- const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}`;
363
- return this.request(`/menu-items?${params}`);
364
- }
365
- getMenuDisplay(revenueCenterId, serviceType, weekday, minutes) {
366
- const params = `service_type=${serviceType}&weekday=${weekday}&minutes=${minutes}`;
367
- return this.request(`/menus/${revenueCenterId}/display?${params}`);
368
- }
369
- getMenuPages() {
370
- return this.request(`/menu-pages`);
371
- }
372
- getTerms() {
373
- return this.request(`/terms`);
374
- }
375
- getDeals(customerId) {
376
- const params = customerId ? `&customer_id=${customerId}` : '';
377
- return this.request(`/deals?with_related=true${params}`);
378
- }
379
- getAnnouncements(page) {
380
- return this.request(`/announcements?announcement_page=${page}&with_related=true`);
381
- }
382
- getAnnouncementPage(page) {
383
- return this.request(`/announcement-pages/${page}`);
384
- }
385
- getPages() {
386
- return this.request(`/pages`);
387
- }
388
- getPage(slug) {
389
- return this.request(`/pages/${slug}`);
390
- }
391
- getPosts(slug) {
392
- const params = slug ? `?post_category_slug=${slug}` : '';
393
- return this.request(`/posts${params}`);
394
- }
395
- getPost(slug) {
396
- return this.request(`/posts/${slug}`);
397
- }
398
- getDiscountQRCode(discountId, customerId) {
399
- const params = customerId ? `?customer_id=${customerId}` : '';
400
- return this.request(`/discounts/${discountId}/qrcode${params}`);
401
- }
402
- postTender(orderId, tender) {
403
- return this.request(`/orders/${orderId}/tenders`, 'POST', tender);
404
- }
405
- patchTender(orderId, index, data) {
406
- return this.request(`/orders/${orderId}/tenders/${index}`, 'PATCH', data);
407
- }
408
- postTenderVoid(orderId, index) {
409
- return this.request(`/orders/${orderId}/tenders/${index}/void`, 'POST', {});
410
- }
411
- postIdentifyCustomer(data) {
412
- return this.request(`/identify-customer`, 'POST', data);
413
- }
414
- postApplePayValidate(host, validationURL) {
415
- const data = { host, validationURL };
416
- return this.request(`/apple-pay/validate`, 'POST', data);
417
- }
418
- postApplePayPayment(token, amount, customerId) {
419
- let data = { token, amount };
420
- if (customerId) {
421
- data = Object.assign(Object.assign({}, data), { customer_id: customerId });
422
- }
423
- return this.request(`/apple-pay/payment`, 'POST', data);
424
- }
425
- postOrderValidate(order, token) {
426
- return this.request(`/orders/validate`, 'POST', order, null, token);
427
- }
428
- postOrder(order, token) {
429
- return this.request(`/orders`, 'POST', order, null, token);
430
- }
431
- deleteOrder(order) {
432
- return this.request(`/orders`, 'DELETE', order);
433
- }
434
- getOrders(args) {
435
- let params = [];
436
- if (!args) {
437
- params = [
438
- `prep_status=TODO,IN_PROGRESS,DONE`,
439
- `sort_by=fire_at`,
440
- `sort_direction=ASC`
441
- ];
442
- }
443
- else {
444
- const { business_date, channel_type, prep_status, receipt_type, parent_receipt_uuid, search, sort_by, sort_direction } = args;
445
- if (business_date)
446
- params.push(`business_date=${business_date}`);
447
- if (channel_type)
448
- params.push(`channel_type=${channel_type}`);
449
- if (prep_status)
450
- params.push(`prep_status=${prep_status}`);
451
- if (receipt_type)
452
- params.push(`receipt_type=${receipt_type}`);
453
- if (parent_receipt_uuid)
454
- params.push(`parent_receipt_uuid=${parent_receipt_uuid}`);
455
- if (search)
456
- params.push(`search=${search}`);
457
- if (sort_by)
458
- params.push(`sort_by=${sort_by}`);
459
- if (sort_direction)
460
- params.push(`sort_direction=${sort_direction}`);
461
- }
462
- params = params.length ? `?${params.join('&')}` : '';
463
- return this.request(`/orders${params}`);
464
- }
465
- postRefundValidate(orderId, refund) {
466
- return this.request(`/orders/${orderId}/refund/validate`, 'POST', refund);
467
- }
468
- postRefund(orderId, refund) {
469
- return this.request(`/orders/${orderId}/refund`, 'POST', refund);
470
- }
471
- getOrderFulfillment(orderId) {
472
- return this.request(`/orders/${orderId}/fulfillment`);
473
- }
474
- putOrderFulfillment(orderId, data) {
475
- return this.request(`/orders/${orderId}/fulfillment`, 'PUT', data);
476
- }
477
- getOrderRating(ratingUuid) {
478
- return this.request(`/ratings/${ratingUuid}`);
479
- }
480
- putOrderRating(ratingUuid, data) {
481
- return this.request(`/ratings/${ratingUuid}`, 'PUT', data);
482
- }
483
- postOrderRatingUnsubscribe(ratingUuid) {
484
- return this.request(`/ratings/${ratingUuid}/unsubscribe`, 'POST', {});
485
- }
486
- postPurchaseGiftCards(data) {
487
- return this.request(`/gift-cards-purchase`, 'POST', data);
488
- }
489
- postPurchaseDonation(data) {
490
- return this.request(`/donation-purchase`, 'POST', data);
491
- }
492
- postCart(data) {
493
- return this.request(`/carts`, 'POST', data);
494
- }
495
- getCart(cartId) {
496
- return this.request(`/carts/${cartId}`);
497
- }
498
- putCart(cartId, data) {
499
- return this.request(`/carts/${cartId}`, 'PUT', data);
500
- }
501
- deleteCart(cartId) {
502
- return this.request(`/carts/${cartId}`, 'DELETE');
503
- }
504
- postCartGuest(data) {
505
- return this.request(`/cart-guests`, 'POST', data);
506
- }
507
- getGuest(email) {
508
- return this.request(`/guest?email=${encodeURIComponent(email)}`);
509
- }
510
- getSubscriber(email) {
511
- return this.request(`/subscribers/${encodeURIComponent(email)}`);
512
- }
513
- postSubscriber(email) {
514
- return this.request(`/subscribers`, 'POST', { email });
515
- }
516
- postUnsubscribe(customer_id, campaign_id) {
517
- return this.request(`/unsubscribe/campaign/${customer_id}/${campaign_id}`, 'POST');
518
- }
519
- postUnsubscribeByKey(key) {
520
- return this.request(`/unsubscribe/campaign/${key}`, 'POST');
521
- }
522
- postSignUp(data) {
523
- return this.request(`/customer`, 'POST', data);
524
- }
525
- postCustomerSignIn(data) {
526
- return this.request(`/customer/sign-in`, 'POST', data);
527
- }
528
- postThanxLogin(email, origin) {
529
- const data = origin ? { email, origin } : { email };
530
- return this.request('/thanx-login', 'POST', data);
531
- }
532
- postThanxAuth(code, path, origin) {
533
- const data = path ? { code, path } : { code };
534
- const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
535
- return this.request('/thanx-auth', 'POST', withOrigin);
536
- }
537
- postLogin(email, password) {
538
- const data = {
539
- grant_type: 'password',
540
- username: email,
541
- password: password
542
- };
543
- return this.authRequest('/token', data);
544
- }
545
- postLogout(token) {
546
- return this.authRequest('/revoke', { token });
547
- }
548
- postSendPasswordResetEmail(email, link_url) {
549
- const data = { email, link_url };
550
- return this.request(`/customer/password/send-email`, 'POST', data);
551
- }
552
- postResetPassword(new_password, token) {
553
- const data = { new_password, token };
554
- return this.request(`/customer/password/set-new-password`, 'POST', data);
555
- }
556
- getCustomer(token) {
557
- return this.request(`/customer?with_related=true`, 'GET', null, null, token);
558
- }
559
- putCustomer(token, data) {
560
- return this.request(`/customer`, 'PUT', data, null, token);
561
- }
562
- deleteCustomer(token) {
563
- return this.request(`/customer`, 'DELETE', null, null, token);
564
- }
565
- postCustomerPosToken(token, posToken) {
566
- const data = { pos_token: posToken };
567
- return this.request(`/customer/pos-token`, 'POST', data, null, token);
568
- }
569
- postSendVerificationEmail(token, linkUrl) {
570
- const data = { link_url: linkUrl };
571
- return this.request(`/customer/send-verification-email`, 'POST', data, null, token);
572
- }
573
- postVerifyAccount(verifyToken) {
574
- const data = { token: verifyToken };
575
- return this.request(`/verify-account`, 'POST', data);
576
- }
577
- getCustomerQRCode(token) {
578
- return this.request(`/customer/qrcode`, 'GET', null, null, token);
579
- }
580
- getCustomerRewards(token) {
581
- return this.request(`/customer/rewards?with_related=true`, 'GET', null, null, token);
582
- }
583
- getPointsShop(token) {
584
- return this.request(`/points-shop?with_related=true`, 'GET', null, null, token);
585
- }
586
- postPointsShopReward(token, rewardId) {
587
- return this.request(`/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
588
- }
589
- getTplsPointsShop(token) {
590
- return this.request(`/tpls/points-shop`, 'GET', null, null, token);
591
- }
592
- postTplsPointsShopReward(token, rewardId) {
593
- return this.request(`/tpls/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
594
- }
595
- getCustomerOrders(token, limit, timing) {
596
- let params = [];
597
- if (limit)
598
- params.push(`limit=${limit}`);
599
- if (timing)
600
- params.push(`requested_type=${timing}`);
601
- params = params.length ? `?${params.join('&')}` : '';
602
- return this.request(`/customer/orders${params}`, 'GET', null, null, token);
603
- }
604
- getCustomerOrder(token, orderId) {
605
- return this.request(`/customer/orders/${orderId}`, 'GET', null, null, token);
606
- }
607
- getQuote(token, orderUuid) {
608
- return this.request(`/orders/uuid/${orderUuid}`, 'GET', null, null, token);
609
- }
610
- postCustomerGroupOrder(token, data) {
611
- return this.request(`/customer/carts`, 'POST', data, null, token);
612
- }
613
- getCustomerGroupOrders(token) {
614
- return this.request(`/customer/carts?expand=true`, 'GET', null, null, token);
615
- }
616
- getCustomerGroupOrder(token, cartId) {
617
- return this.request(`/customer/carts/${cartId}?expand=customer&with_related=true`, 'GET', null, null, token);
618
- }
619
- putCustomerGroupOrder(token, cartId, data) {
620
- return this.request(`/customer/carts/${cartId}`, 'PUT', data, null, token);
621
- }
622
- putCustomerGroupOrderStatus(token, cartId, data) {
623
- return this.request(`/customer/carts/${cartId}/status`, 'PUT', data, null, token);
624
- }
625
- deleteCustomerGroupOrder(token, cartId) {
626
- return this.request(`/customer/carts/${cartId}`, 'DELETE', null, null, token);
627
- }
628
- getCustomerAllergens(token) {
629
- return this.request(`/customer/allergens`, 'GET', null, null, token);
630
- }
631
- // replace all existing allergens with a new list of allergens
632
- putCustomerAllergens(token, data) {
633
- return this.request(`/customer/allergens`, 'PUT', data, null, token);
634
- }
635
- // add new allergens incrementally without affecting existing allergens
636
- postCustomerAllergens(token, data) {
637
- return this.request(`/customer/allergens`, 'POST', data, null, token);
638
- }
639
- getCustomerAddresses(token, limit = 10) {
640
- const params = limit ? `?limit=${limit}` : '';
641
- return this.request(`/customer/addresses${params}`, 'GET', null, null, token);
642
- }
643
- putCustomerAddress(token, addressId, data) {
644
- return this.request(`/customer/addresses/${addressId}`, 'PUT', data, null, token);
645
- }
646
- deleteCustomerAddress(token, addressId) {
647
- return this.request(`/customer/addresses/${addressId}`, 'DELETE', null, null, token);
648
- }
649
- getCustomerCreditCards(token, includeLinked = false) {
650
- const params = includeLinked ? `?include_linked=true` : '';
651
- return this.request(`/customer/credit-cards${params}`, 'GET', null, null, token);
652
- }
653
- postCustomerCreditCard(token, data) {
654
- return this.request(`/customer/credit-cards`, 'POST', data, null, token);
655
- }
656
- putCustomerCreditCard(token, cardId, data) {
657
- return this.request(`/customer/credit-cards/${cardId}`, 'PUT', data, null, token);
658
- }
659
- deleteCustomerCreditCard(token, cardId) {
660
- return this.request(`/customer/credit-cards/${cardId}`, 'DELETE', null, null, token);
661
- }
662
- getCustomerGiftCards(token) {
663
- return this.request(`/customer/gift-cards`, 'GET', null, null, token);
664
- }
665
- postCustomerGiftCard(token, data) {
666
- return this.request(`/customer/gift-cards`, 'POST', data, null, token);
667
- }
668
- postCustomerGiftCardAssign(token, card_number) {
669
- return this.request(`/customer/gift-cards/assign`, 'POST', { card_number }, null, token);
670
- }
671
- postCustomerGiftCardAssignOther(token, giftCardId, email) {
672
- return this.request(`/customer/gift-cards/${giftCardId}/assign`, 'POST', { email }, null, token);
673
- }
674
- putCustomerGiftCard(token, giftCardId, data) {
675
- return this.request(`/customer/gift-cards/${giftCardId}`, 'PUT', data, null, token);
676
- }
677
- deleteCustomerGiftCard(token, giftCardId) {
678
- return this.request(`/customer/gift-cards/${giftCardId}`, 'DELETE', null, null, token);
679
- }
680
- getCustomerFavorites(token, limit) {
681
- const params = limit ? `?limit=${limit}` : '';
682
- return this.request(`/customer/favorites${params}`, 'GET', null, null, token);
683
- }
684
- postCustomerFavorite(token, data) {
685
- return this.request(`/customer/favorites`, 'POST', data, null, token);
686
- }
687
- deleteCustomerFavorite(token, favoriteId) {
688
- return this.request(`/customer/favorites/${favoriteId}`, 'DELETE', null, null, token);
689
- }
690
- getCustomerCommunicationPreferences(token) {
691
- return this.request(`/customer/notification-preferences`, 'GET', null, null, token);
692
- }
693
- postCustomerCommunicationPreference(token, data) {
694
- return this.request(`/customer/notification-preferences`, 'POST', data, null, token);
695
- }
696
- putCustomerCommunicationPreference(token, data) {
697
- return this.request(`/customer/notification-preferences`, 'PUT', data, null, token);
698
- }
699
- deleteCustomerCommunicationPreference(token, communicationPreferenceId) {
700
- return this.request(`/customer/notification-preferences/${communicationPreferenceId}`, 'DELETE', null, null, token);
701
- }
702
- postCustomerFcmToken(token, fcmToken) {
703
- return this.request(`/customer/fcm-tokens`, 'POST', { fcm_token: fcmToken }, null, token);
704
- }
705
- getCustomerFcmToken(token) {
706
- return this.request(`/customer/fcm-tokens`, 'GET', null, null, token);
707
- }
708
- deleteCustomerFcmToken(token) {
709
- return this.request(`/customer/fcm-tokens`, 'DELETE', null, null, token);
710
- }
711
- getCustomerLoyalty(token) {
712
- return this.request(`/customer/loyalty`, 'GET', null, null, token);
713
- }
714
- getCustomerLoyaltyV2(token) {
715
- return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
716
- }
717
- getCustomerThanx(token) {
718
- return this.request(`/customer/thanx`, 'GET', null, null, token);
719
- }
720
- getThanxCardSignature(token, acct) {
721
- return this.request(`/customer/thanx-card-signature?acct=${acct}`, 'GET', null, null, token);
722
- }
723
- postCustomerTplsVerify(token) {
724
- return this.request(`/customer/tpls/email-verify`, 'POST', null, null, token);
725
- }
726
- getCustomerTpls(token) {
727
- return this.request(`/customer/tpls`, 'GET', null, null, token);
728
- }
729
- getCustomerTplsHistory(token) {
730
- return this.request(`/customer/tpls/history`, 'GET', null, null, token);
731
- }
732
- getCustomerHouseAccounts(token) {
733
- return this.request(`/customer/house-accounts`, 'GET', null, null, token);
734
- }
735
- putCustomerOrderRating(token, orderId, data) {
736
- return this.request(`/customer/orders/${orderId}/rating`, 'PUT', data, null, token);
737
- }
738
- }
739
- export default OpenTenderAPI;
1
+ import { __awaiter } from "tslib";
2
+ import { serialize } from '@open-tender/utils';
3
+ class requestException extends Error {
4
+ constructor(message, response, exception, extracted) {
5
+ super(message, { cause: exception });
6
+ this.message = `${message || 'An unknown exception was triggered.'}`;
7
+ this.stack = new Error().stack;
8
+ this.response = response;
9
+ this.exception = exception;
10
+ this.extracted = extracted;
11
+ }
12
+ }
13
+ const fiveHundredError = (status = 500, statusText = 'Unknown 500 error') => ({
14
+ status: status,
15
+ code: 'errors.server.internal',
16
+ title: 'Internal Server Error',
17
+ detail: statusText
18
+ });
19
+ const unauthorizedError = {
20
+ status: 401,
21
+ code: 'errors.unauthorized',
22
+ title: 'Unauthorized',
23
+ detail: 'Provided token is not valid'
24
+ };
25
+ const handleResponse = (response) => {
26
+ const { status, statusText } = response;
27
+ if (status >= 500)
28
+ throw fiveHundredError(status, statusText);
29
+ if (status === 401)
30
+ throw unauthorizedError;
31
+ if (statusText === 'NO CONTENT' || status === 204) {
32
+ return true;
33
+ }
34
+ if (status === 202) {
35
+ try {
36
+ return response.body;
37
+ }
38
+ catch (err) {
39
+ throw new requestException('Response could not be parsed', response, err);
40
+ }
41
+ }
42
+ const requestWasSuccessful = status >= 200 && status < 300;
43
+ try {
44
+ return response.json().then(parsed => {
45
+ if (requestWasSuccessful)
46
+ return parsed;
47
+ throw parsed;
48
+ });
49
+ }
50
+ catch (err) {
51
+ throw new requestException('Response could not be parsed', response, err);
52
+ }
53
+ };
54
+ class OpenTenderAPI {
55
+ constructor(config) {
56
+ this.request = (endpoint, method = 'GET', data = null, timeout = null, token = null) => __awaiter(this, void 0, void 0, function* () {
57
+ let didTimeOut = false;
58
+ return new Promise((resolve, reject) => {
59
+ let timer;
60
+ if (timeout) {
61
+ timer = setTimeout(() => {
62
+ didTimeOut = true;
63
+ reject(new Error('Request timed out'));
64
+ }, timeout);
65
+ }
66
+ const headers = {
67
+ Accept: 'application/json',
68
+ 'Content-Type': 'application/json'
69
+ };
70
+ if (this.clientId)
71
+ headers['client-id'] = `${this.clientId}`;
72
+ if (this.brandId)
73
+ headers['brand-id'] = `${this.brandId}`;
74
+ if (token)
75
+ headers.Authorization = `Bearer ${token}`;
76
+ const options = {
77
+ method: method,
78
+ headers: headers
79
+ };
80
+ if (data)
81
+ options.body = JSON.stringify(data);
82
+ fetch(`${this.baseUrl}${endpoint}`, options)
83
+ .then(handleResponse)
84
+ .then(json => {
85
+ if (didTimeOut)
86
+ return;
87
+ resolve(json);
88
+ })
89
+ .catch(err => {
90
+ if (didTimeOut)
91
+ return;
92
+ err.code ? reject(err) : reject(fiveHundredError());
93
+ })
94
+ .finally(() => {
95
+ if (timeout)
96
+ clearTimeout(timer);
97
+ });
98
+ });
99
+ });
100
+ this.authRequest = (endpoint, data) => __awaiter(this, void 0, void 0, function* () {
101
+ return new Promise((resolve, reject) => {
102
+ data.client_id = this.clientId;
103
+ const options = {
104
+ method: 'POST',
105
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
106
+ body: serialize(data)
107
+ };
108
+ fetch(`${this.authUrl}/oauth2${endpoint}`, options)
109
+ .then(res => res.json())
110
+ .then(json => {
111
+ if (json.error)
112
+ throw new Error(json.error_description);
113
+ resolve(json);
114
+ })
115
+ .catch(err => {
116
+ reject(err);
117
+ });
118
+ });
119
+ });
120
+ this.brandId = config === null || config === void 0 ? void 0 : config.brandId;
121
+ this.clientId = config === null || config === void 0 ? void 0 : config.clientId;
122
+ this.baseUrl = config === null || config === void 0 ? void 0 : config.baseUrl;
123
+ this.authUrl = config === null || config === void 0 ? void 0 : config.authUrl;
124
+ }
125
+ post(endpoint, data) {
126
+ return this.request(`/${endpoint}`, 'POST', data);
127
+ }
128
+ getHttpResponse(code) {
129
+ return this.request(`/${code}/cors`);
130
+ }
131
+ postSettings(entityType) {
132
+ const params = entityType ? `&entity_type=${entityType}` : '';
133
+ return this.request(`/settings/pull?force=true${params}`, 'POST', {});
134
+ }
135
+ getConfig() {
136
+ return this.request(`/config`);
137
+ }
138
+ postChipDNATender(orderId, data) {
139
+ return this.request(`/orders/${orderId}/tenders/chipdna`, 'POST', data);
140
+ }
141
+ postChipDNACancel() {
142
+ return this.request(`/chipdna/cancel`, 'POST', {});
143
+ }
144
+ postChipDNATmsUpdate() {
145
+ return this.request(`/chipdna/tms-update`, 'POST', {});
146
+ }
147
+ getBarcodeRead() {
148
+ return this.request(`/devices/qrcode/read`);
149
+ }
150
+ postBarcodeCancel() {
151
+ return this.request(`/devices/qrcode/cancel`, 'POST', {});
152
+ }
153
+ getCardRead() {
154
+ return this.request(`/devices/card/read`);
155
+ }
156
+ postCardCancel() {
157
+ return this.request(`/devices/card/cancel`, 'POST', {});
158
+ }
159
+ postCardAssign(employeeId, code) {
160
+ const data = { employee_id: employeeId, code };
161
+ return this.request(`/employee-cards/assign`, 'POST', data);
162
+ }
163
+ postCardUnassign(code) {
164
+ return this.request(`/employee-cards/unassign`, 'POST', { code });
165
+ }
166
+ // identifier can be either a timeclock ID as an integer
167
+ // or a swipe card code as a string
168
+ getEmployee(identifier) {
169
+ return this.request(`/employees/${identifier}`);
170
+ }
171
+ postTimePunch(data) {
172
+ return this.request(`/time-punches`, 'POST', data);
173
+ }
174
+ getTimePunchesReport(businessDate, employeeId) {
175
+ let params = [];
176
+ if (businessDate)
177
+ params.push(`business_date=${businessDate}`);
178
+ if (employeeId)
179
+ params.push(`employee_id=${employeeId}`);
180
+ params = params.length ? `?${params.join('&')}` : '';
181
+ return this.request(`/time-punches-report${params}`);
182
+ }
183
+ postPrintShiftSummary(employeeId) {
184
+ return this.request(`/shift-summary/${employeeId}/print`, 'POST', {});
185
+ }
186
+ postCashEvent(data) {
187
+ return this.request(`/cash-events`, 'POST', data);
188
+ }
189
+ getCashier() {
190
+ return this.request(`/cashier`);
191
+ }
192
+ getCashSummary(employeeId) {
193
+ return this.request(`/cash-summary/${employeeId}`);
194
+ }
195
+ postPrintCashSummary(employeeId) {
196
+ return this.request(`/cash-summary/${employeeId}/print`, 'POST', {});
197
+ }
198
+ getAlerts() {
199
+ return this.request(`/alerts`);
200
+ }
201
+ getAlert(alertId) {
202
+ return this.request(`/alerts/${alertId}`);
203
+ }
204
+ putAlert(alertId, data) {
205
+ return this.request(`/alerts/${alertId}`, 'PUT', data);
206
+ }
207
+ deleteAlert(alertId) {
208
+ return this.request(`/alerts/${alertId}`, 'DELETE');
209
+ }
210
+ getOfflineTransactions() {
211
+ return this.request(`/credit/offline-transactions`);
212
+ }
213
+ postOfflineTransactions() {
214
+ return this.request(`/credit/offline-transactions/process`, 'POST', {});
215
+ }
216
+ getSurcharges(serviceType) {
217
+ const params = serviceType ? `?service_type=${serviceType}` : '';
218
+ return this.request(`/surcharges${params}`);
219
+ }
220
+ getDiscounts(serviceType, orderType) {
221
+ let params = [];
222
+ if (serviceType)
223
+ params.push(`service_type=${serviceType}`);
224
+ if (orderType)
225
+ params.push(`order_type=${orderType}`);
226
+ params = params.length ? `?${params.join('&')}` : '';
227
+ return this.request(`/discounts${params}`);
228
+ }
229
+ getDiscount(name) {
230
+ return this.request(`/discounts/${name}`);
231
+ }
232
+ getDiscountViaQRCode(code) {
233
+ return this.request(`/qrcodes/${code}`);
234
+ }
235
+ getTaxes(serviceType, orderType) {
236
+ let params = [];
237
+ if (serviceType)
238
+ params.push(`service_type=${serviceType}`);
239
+ if (orderType)
240
+ params.push(`order_type=${orderType}`);
241
+ params = params.length ? `?${params.join('&')}` : '';
242
+ return this.request(`/taxes${params}`);
243
+ }
244
+ getItemTypes() {
245
+ return this.request(`/item-types`);
246
+ }
247
+ getSelectOptions() {
248
+ return this.request(`/select-options`);
249
+ }
250
+ postOpenCashDrawer() {
251
+ return this.request(`/devices/drawer/open`, 'POST', {});
252
+ }
253
+ postTicketPrint(orderUuid, ticketNo, data) {
254
+ const endpoint = `/orders/${orderUuid}/tickets/${ticketNo}/print`;
255
+ return this.request(endpoint, 'POST', data);
256
+ }
257
+ postTicketStatus(orderUuid, ticketNo, status) {
258
+ const endpoint = `/orders/${orderUuid}/tickets/${ticketNo}/${status}`;
259
+ return this.request(endpoint, 'POST', {});
260
+ }
261
+ postTicketsPrint(orderUuid, data) {
262
+ const endpoint = `/orders/${orderUuid}/tickets/print`;
263
+ return this.request(endpoint, 'POST', data);
264
+ }
265
+ postTicketsReset(orderUuid) {
266
+ const endpoint = `/orders/${orderUuid}/tickets/reset`;
267
+ return this.request(endpoint, 'POST', {});
268
+ }
269
+ getArrivals() {
270
+ return this.request(`/arrivals`);
271
+ }
272
+ postAcknowledgeArrival(orderUuid) {
273
+ return this.request(`/orders/${orderUuid}/ack-arrival`, 'POST', {});
274
+ }
275
+ patchOrder(orderUuid, data) {
276
+ return this.request(`/orders/${orderUuid}`, 'PATCH', data);
277
+ }
278
+ postReceipt(orderUuid) {
279
+ const endpoint = `/orders/${orderUuid}/print`;
280
+ return this.request(endpoint, 'POST', {});
281
+ }
282
+ postGiftCardCredit(data, checkOnly) {
283
+ const params = checkOnly ? '?check_only=true' : '';
284
+ return this.request(`/gift-cards/credit${params}`, 'POST', data);
285
+ }
286
+ getGiftCardBalance(code, cardNumber) {
287
+ const params = code ? `code=${code}` : `card_number=${cardNumber || ''}`;
288
+ return this.request(`/gift-cards/balance?${params}`);
289
+ }
290
+ getInternalSettings() {
291
+ return this.request(`/internal-settings`);
292
+ }
293
+ postInternalSettings(data) {
294
+ return this.request(`/internal-settings`, 'POST', data);
295
+ }
296
+ getStore() {
297
+ return this.request(`/store`);
298
+ }
299
+ getRevenueCenters(revenue_center_type, is_outpost, lat, lng, requestedAt, serviceType) {
300
+ let params = '';
301
+ if (revenue_center_type)
302
+ params += `revenue_center_type=${revenue_center_type}`;
303
+ if (is_outpost)
304
+ params += '&is_outpost=true';
305
+ if (lat && lng)
306
+ params += `&lat=${lat}&lng=${lng}`;
307
+ if (requestedAt)
308
+ params += `&requested_at=${requestedAt}`;
309
+ if (serviceType)
310
+ params += `&service_type=${serviceType}`;
311
+ return this.request(`/revenue-centers?${params}`);
312
+ }
313
+ getRevenueCenter(revenue_center_id, requestedAt) {
314
+ const params = requestedAt ? `?requested_at=${requestedAt}` : '';
315
+ return this.request(`/revenue-centers/${revenue_center_id}${params}`);
316
+ }
317
+ getLocations(revenue_center_type, is_outpost, lat, lng, requestedAt, cart_total, address, serviceType) {
318
+ let params = '';
319
+ if (revenue_center_type)
320
+ params += `revenue_center_type=${revenue_center_type}`;
321
+ if (is_outpost)
322
+ params += '&is_outpost=true';
323
+ if (lat && lng)
324
+ params += `&lat=${lat}&lng=${lng}`;
325
+ if (requestedAt)
326
+ params += `&requested_at=${requestedAt}`;
327
+ if (cart_total)
328
+ params += `&cart_total=${cart_total}`;
329
+ if (address)
330
+ params += `&address=${address}`;
331
+ if (serviceType)
332
+ params += `&service_type=${serviceType}`;
333
+ return this.request(`/locations?${params}`);
334
+ }
335
+ getLocation(revenue_center_id, cart_total) {
336
+ let params = '';
337
+ if (cart_total)
338
+ params += `?cart_total=${cart_total}`;
339
+ return this.request(`/locations/${revenue_center_id}${params}`);
340
+ }
341
+ getLocationBySlug(slug, cart_total) {
342
+ let params = '';
343
+ if (cart_total)
344
+ params += `?cart_total=${cart_total}`;
345
+ return this.request(`/locations/${slug}${params}`);
346
+ }
347
+ getValidTimes(revenueCenterType) {
348
+ const params = `revenue_center_type=${revenueCenterType}`;
349
+ return this.request(`/valid-times?${params}`);
350
+ }
351
+ getTags() {
352
+ return this.request(`/tags?with_related=true`);
353
+ }
354
+ getAllergens() {
355
+ return this.request(`/allergens?with_related=true`);
356
+ }
357
+ getMenu(revenueCenterId, serviceType, requestedAt) {
358
+ const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}&requested_at=${requestedAt}`;
359
+ return this.request(`/menus?${params}`);
360
+ }
361
+ getMenuItems(revenueCenterId, serviceType) {
362
+ const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}`;
363
+ return this.request(`/menu-items?${params}`);
364
+ }
365
+ getMenuDisplay(revenueCenterId, serviceType, weekday, minutes) {
366
+ const params = `service_type=${serviceType}&weekday=${weekday}&minutes=${minutes}`;
367
+ return this.request(`/menus/${revenueCenterId}/display?${params}`);
368
+ }
369
+ getMenuPages() {
370
+ return this.request(`/menu-pages`);
371
+ }
372
+ getTerms() {
373
+ return this.request(`/terms`);
374
+ }
375
+ getDeals(customerId) {
376
+ const params = customerId ? `&customer_id=${customerId}` : '';
377
+ return this.request(`/deals?with_related=true${params}`);
378
+ }
379
+ getAnnouncements(page) {
380
+ return this.request(`/announcements?announcement_page=${page}&with_related=true`);
381
+ }
382
+ getAnnouncementPage(page) {
383
+ return this.request(`/announcement-pages/${page}`);
384
+ }
385
+ getPages() {
386
+ return this.request(`/pages`);
387
+ }
388
+ getPage(slug) {
389
+ return this.request(`/pages/${slug}`);
390
+ }
391
+ getPosts(slug) {
392
+ const params = slug ? `?post_category_slug=${slug}` : '';
393
+ return this.request(`/posts${params}`);
394
+ }
395
+ getPost(slug) {
396
+ return this.request(`/posts/${slug}`);
397
+ }
398
+ getDiscountQRCode(discountId, customerId) {
399
+ const params = customerId ? `?customer_id=${customerId}` : '';
400
+ return this.request(`/discounts/${discountId}/qrcode${params}`);
401
+ }
402
+ postTender(orderId, tender) {
403
+ return this.request(`/orders/${orderId}/tenders`, 'POST', tender);
404
+ }
405
+ patchTender(orderId, index, data) {
406
+ return this.request(`/orders/${orderId}/tenders/${index}`, 'PATCH', data);
407
+ }
408
+ postTenderVoid(orderId, index) {
409
+ return this.request(`/orders/${orderId}/tenders/${index}/void`, 'POST', {});
410
+ }
411
+ postIdentifyCustomer(data) {
412
+ return this.request(`/identify-customer`, 'POST', data);
413
+ }
414
+ postApplePayValidate(host, validationURL) {
415
+ const data = { host, validationURL };
416
+ return this.request(`/apple-pay/validate`, 'POST', data);
417
+ }
418
+ postApplePayPayment(token, amount, customerId) {
419
+ let data = { token, amount };
420
+ if (customerId) {
421
+ data = Object.assign(Object.assign({}, data), { customer_id: customerId });
422
+ }
423
+ return this.request(`/apple-pay/payment`, 'POST', data);
424
+ }
425
+ postOrderValidate(order, token) {
426
+ return this.request(`/orders/validate`, 'POST', order, null, token);
427
+ }
428
+ postOrder(order, token) {
429
+ return this.request(`/orders`, 'POST', order, null, token);
430
+ }
431
+ deleteOrder(order) {
432
+ return this.request(`/orders`, 'DELETE', order);
433
+ }
434
+ getOrders(args) {
435
+ let params = [];
436
+ if (!args) {
437
+ params = [
438
+ `prep_status=TODO,IN_PROGRESS,DONE`,
439
+ `sort_by=fire_at`,
440
+ `sort_direction=ASC`
441
+ ];
442
+ }
443
+ else {
444
+ const { business_date, channel_type, prep_status, receipt_type, parent_receipt_uuid, search, sort_by, sort_direction } = args;
445
+ if (business_date)
446
+ params.push(`business_date=${business_date}`);
447
+ if (channel_type)
448
+ params.push(`channel_type=${channel_type}`);
449
+ if (prep_status)
450
+ params.push(`prep_status=${prep_status}`);
451
+ if (receipt_type)
452
+ params.push(`receipt_type=${receipt_type}`);
453
+ if (parent_receipt_uuid)
454
+ params.push(`parent_receipt_uuid=${parent_receipt_uuid}`);
455
+ if (search)
456
+ params.push(`search=${search}`);
457
+ if (sort_by)
458
+ params.push(`sort_by=${sort_by}`);
459
+ if (sort_direction)
460
+ params.push(`sort_direction=${sort_direction}`);
461
+ }
462
+ params = params.length ? `?${params.join('&')}` : '';
463
+ return this.request(`/orders${params}`);
464
+ }
465
+ postRefundValidate(orderId, refund) {
466
+ return this.request(`/orders/${orderId}/refund/validate`, 'POST', refund);
467
+ }
468
+ postRefund(orderId, refund) {
469
+ return this.request(`/orders/${orderId}/refund`, 'POST', refund);
470
+ }
471
+ getOrderFulfillment(orderId) {
472
+ return this.request(`/orders/${orderId}/fulfillment`);
473
+ }
474
+ putOrderFulfillment(orderId, data) {
475
+ return this.request(`/orders/${orderId}/fulfillment`, 'PUT', data);
476
+ }
477
+ getOrderRating(ratingUuid) {
478
+ return this.request(`/ratings/${ratingUuid}`);
479
+ }
480
+ putOrderRating(ratingUuid, data) {
481
+ return this.request(`/ratings/${ratingUuid}`, 'PUT', data);
482
+ }
483
+ postOrderRatingUnsubscribe(ratingUuid) {
484
+ return this.request(`/ratings/${ratingUuid}/unsubscribe`, 'POST', {});
485
+ }
486
+ postPurchaseGiftCards(data) {
487
+ return this.request(`/gift-cards-purchase`, 'POST', data);
488
+ }
489
+ postPurchaseDonation(data) {
490
+ return this.request(`/donation-purchase`, 'POST', data);
491
+ }
492
+ postCart(data) {
493
+ return this.request(`/carts`, 'POST', data);
494
+ }
495
+ getCart(cartId) {
496
+ return this.request(`/carts/${cartId}`);
497
+ }
498
+ putCart(cartId, data) {
499
+ return this.request(`/carts/${cartId}`, 'PUT', data);
500
+ }
501
+ deleteCart(cartId) {
502
+ return this.request(`/carts/${cartId}`, 'DELETE');
503
+ }
504
+ postCartGuest(data) {
505
+ return this.request(`/cart-guests`, 'POST', data);
506
+ }
507
+ getGuest(email) {
508
+ return this.request(`/guest?email=${encodeURIComponent(email)}`);
509
+ }
510
+ getSubscriber(email) {
511
+ return this.request(`/subscribers/${encodeURIComponent(email)}`);
512
+ }
513
+ postSubscriber(email) {
514
+ return this.request(`/subscribers`, 'POST', { email });
515
+ }
516
+ postUnsubscribe(customer_id, campaign_id) {
517
+ return this.request(`/unsubscribe/campaign/${customer_id}/${campaign_id}`, 'POST');
518
+ }
519
+ postUnsubscribeByKey(key) {
520
+ return this.request(`/unsubscribe/campaign/${key}`, 'POST');
521
+ }
522
+ postSignUp(data) {
523
+ return this.request(`/customer`, 'POST', data);
524
+ }
525
+ postCustomerSignIn(data) {
526
+ return this.request(`/customer/sign-in`, 'POST', data);
527
+ }
528
+ postThanxLogin(email, origin) {
529
+ const data = origin ? { email, origin } : { email };
530
+ return this.request('/thanx-login', 'POST', data);
531
+ }
532
+ postThanxAuth(code, path, origin) {
533
+ const data = path ? { code, path } : { code };
534
+ const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
535
+ return this.request('/thanx-auth', 'POST', withOrigin);
536
+ }
537
+ postLogin(email, password) {
538
+ const data = {
539
+ grant_type: 'password',
540
+ username: email,
541
+ password: password
542
+ };
543
+ return this.authRequest('/token', data);
544
+ }
545
+ postLogout(token) {
546
+ return this.authRequest('/revoke', { token });
547
+ }
548
+ postSendPasswordResetEmail(email, link_url) {
549
+ const data = { email, link_url };
550
+ return this.request(`/customer/password/send-email`, 'POST', data);
551
+ }
552
+ postResetPassword(new_password, token) {
553
+ const data = { new_password, token };
554
+ return this.request(`/customer/password/set-new-password`, 'POST', data);
555
+ }
556
+ getCustomer(token) {
557
+ return this.request(`/customer?with_related=true`, 'GET', null, null, token);
558
+ }
559
+ putCustomer(token, data) {
560
+ return this.request(`/customer`, 'PUT', data, null, token);
561
+ }
562
+ deleteCustomer(token) {
563
+ return this.request(`/customer`, 'DELETE', null, null, token);
564
+ }
565
+ postCustomerPosToken(token, posToken) {
566
+ const data = { pos_token: posToken };
567
+ return this.request(`/customer/pos-token`, 'POST', data, null, token);
568
+ }
569
+ postSendVerificationEmail(token, linkUrl) {
570
+ const data = { link_url: linkUrl };
571
+ return this.request(`/customer/send-verification-email`, 'POST', data, null, token);
572
+ }
573
+ postVerifyAccount(verifyToken) {
574
+ const data = { token: verifyToken };
575
+ return this.request(`/verify-account`, 'POST', data);
576
+ }
577
+ getCustomerQRCode(token) {
578
+ return this.request(`/customer/qrcode`, 'GET', null, null, token);
579
+ }
580
+ getCustomerRewards(token) {
581
+ return this.request(`/customer/rewards?with_related=true`, 'GET', null, null, token);
582
+ }
583
+ getPointsShop(token) {
584
+ return this.request(`/points-shop?with_related=true`, 'GET', null, null, token);
585
+ }
586
+ postPointsShopReward(token, rewardId) {
587
+ return this.request(`/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
588
+ }
589
+ getTplsPointsShop(token) {
590
+ return this.request(`/tpls/points-shop`, 'GET', null, null, token);
591
+ }
592
+ postTplsPointsShopReward(token, rewardId) {
593
+ return this.request(`/tpls/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
594
+ }
595
+ getCustomerOrders(token, limit, timing) {
596
+ let params = [];
597
+ if (limit)
598
+ params.push(`limit=${limit}`);
599
+ if (timing)
600
+ params.push(`requested_type=${timing}`);
601
+ params = params.length ? `?${params.join('&')}` : '';
602
+ return this.request(`/customer/orders${params}`, 'GET', null, null, token);
603
+ }
604
+ getCustomerOrder(token, orderId) {
605
+ return this.request(`/customer/orders/${orderId}`, 'GET', null, null, token);
606
+ }
607
+ getQuote(token, orderUuid) {
608
+ return this.request(`/orders/uuid/${orderUuid}`, 'GET', null, null, token);
609
+ }
610
+ postCustomerGroupOrder(token, data) {
611
+ return this.request(`/customer/carts`, 'POST', data, null, token);
612
+ }
613
+ getCustomerGroupOrders(token) {
614
+ return this.request(`/customer/carts?expand=true`, 'GET', null, null, token);
615
+ }
616
+ getCustomerGroupOrder(token, cartId) {
617
+ return this.request(`/customer/carts/${cartId}?expand=customer&with_related=true`, 'GET', null, null, token);
618
+ }
619
+ putCustomerGroupOrder(token, cartId, data) {
620
+ return this.request(`/customer/carts/${cartId}`, 'PUT', data, null, token);
621
+ }
622
+ putCustomerGroupOrderStatus(token, cartId, data) {
623
+ return this.request(`/customer/carts/${cartId}/status`, 'PUT', data, null, token);
624
+ }
625
+ deleteCustomerGroupOrder(token, cartId) {
626
+ return this.request(`/customer/carts/${cartId}`, 'DELETE', null, null, token);
627
+ }
628
+ getCustomerAllergens(token) {
629
+ return this.request(`/customer/allergens`, 'GET', null, null, token);
630
+ }
631
+ // replace all existing allergens with a new list of allergens
632
+ putCustomerAllergens(token, data) {
633
+ return this.request(`/customer/allergens`, 'PUT', data, null, token);
634
+ }
635
+ // add new allergens incrementally without affecting existing allergens
636
+ postCustomerAllergens(token, data) {
637
+ return this.request(`/customer/allergens`, 'POST', data, null, token);
638
+ }
639
+ getCustomerAddresses(token, limit = 10) {
640
+ const params = limit ? `?limit=${limit}` : '';
641
+ return this.request(`/customer/addresses${params}`, 'GET', null, null, token);
642
+ }
643
+ putCustomerAddress(token, addressId, data) {
644
+ return this.request(`/customer/addresses/${addressId}`, 'PUT', data, null, token);
645
+ }
646
+ deleteCustomerAddress(token, addressId) {
647
+ return this.request(`/customer/addresses/${addressId}`, 'DELETE', null, null, token);
648
+ }
649
+ getCustomerCreditCards(token, includeLinked = false) {
650
+ const params = includeLinked ? `?include_linked=true` : '';
651
+ return this.request(`/customer/credit-cards${params}`, 'GET', null, null, token);
652
+ }
653
+ postCustomerCreditCard(token, data) {
654
+ return this.request(`/customer/credit-cards`, 'POST', data, null, token);
655
+ }
656
+ putCustomerCreditCard(token, cardId, data) {
657
+ return this.request(`/customer/credit-cards/${cardId}`, 'PUT', data, null, token);
658
+ }
659
+ deleteCustomerCreditCard(token, cardId) {
660
+ return this.request(`/customer/credit-cards/${cardId}`, 'DELETE', null, null, token);
661
+ }
662
+ getCustomerGiftCards(token) {
663
+ return this.request(`/customer/gift-cards`, 'GET', null, null, token);
664
+ }
665
+ postCustomerGiftCard(token, data) {
666
+ return this.request(`/customer/gift-cards`, 'POST', data, null, token);
667
+ }
668
+ postCustomerGiftCardAssign(token, card_number) {
669
+ return this.request(`/customer/gift-cards/assign`, 'POST', { card_number }, null, token);
670
+ }
671
+ postCustomerGiftCardAssignOther(token, giftCardId, email) {
672
+ return this.request(`/customer/gift-cards/${giftCardId}/assign`, 'POST', { email }, null, token);
673
+ }
674
+ putCustomerGiftCard(token, giftCardId, data) {
675
+ return this.request(`/customer/gift-cards/${giftCardId}`, 'PUT', data, null, token);
676
+ }
677
+ deleteCustomerGiftCard(token, giftCardId) {
678
+ return this.request(`/customer/gift-cards/${giftCardId}`, 'DELETE', null, null, token);
679
+ }
680
+ getCustomerFavorites(token, limit) {
681
+ const params = limit ? `?limit=${limit}` : '';
682
+ return this.request(`/customer/favorites${params}`, 'GET', null, null, token);
683
+ }
684
+ postCustomerFavorite(token, data) {
685
+ return this.request(`/customer/favorites`, 'POST', data, null, token);
686
+ }
687
+ deleteCustomerFavorite(token, favoriteId) {
688
+ return this.request(`/customer/favorites/${favoriteId}`, 'DELETE', null, null, token);
689
+ }
690
+ getCustomerCommunicationPreferences(token) {
691
+ return this.request(`/customer/notification-preferences`, 'GET', null, null, token);
692
+ }
693
+ postCustomerCommunicationPreference(token, data) {
694
+ return this.request(`/customer/notification-preferences`, 'POST', data, null, token);
695
+ }
696
+ putCustomerCommunicationPreference(token, data) {
697
+ return this.request(`/customer/notification-preferences`, 'PUT', data, null, token);
698
+ }
699
+ deleteCustomerCommunicationPreference(token, communicationPreferenceId) {
700
+ return this.request(`/customer/notification-preferences/${communicationPreferenceId}`, 'DELETE', null, null, token);
701
+ }
702
+ postCustomerFcmToken(token, fcmToken) {
703
+ return this.request(`/customer/fcm-tokens`, 'POST', { fcm_token: fcmToken }, null, token);
704
+ }
705
+ getCustomerFcmToken(token) {
706
+ return this.request(`/customer/fcm-tokens`, 'GET', null, null, token);
707
+ }
708
+ deleteCustomerFcmToken(token) {
709
+ return this.request(`/customer/fcm-tokens`, 'DELETE', null, null, token);
710
+ }
711
+ getCustomerLoyalty(token) {
712
+ return this.request(`/customer/loyalty`, 'GET', null, null, token);
713
+ }
714
+ getCustomerLoyaltyV2(token) {
715
+ return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
716
+ }
717
+ getCustomerThanx(token) {
718
+ return this.request(`/customer/thanx`, 'GET', null, null, token);
719
+ }
720
+ getThanxCardSignature(token, acct) {
721
+ return this.request(`/customer/thanx-card-signature?acct=${acct}`, 'GET', null, null, token);
722
+ }
723
+ postCustomerTplsVerify(token) {
724
+ return this.request(`/customer/tpls/email-verify`, 'POST', null, null, token);
725
+ }
726
+ getCustomerTpls(token) {
727
+ return this.request(`/customer/tpls`, 'GET', null, null, token);
728
+ }
729
+ getCustomerTplsHistory(token) {
730
+ return this.request(`/customer/tpls/history`, 'GET', null, null, token);
731
+ }
732
+ getCustomerHouseAccounts(token) {
733
+ return this.request(`/customer/house-accounts`, 'GET', null, null, token);
734
+ }
735
+ putCustomerOrderRating(token, orderId, data) {
736
+ return this.request(`/customer/orders/${orderId}/rating`, 'PUT', data, null, token);
737
+ }
738
+ }
739
+ export default OpenTenderAPI;