@open-tender/cloud 0.4.28 → 0.4.29

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 (279) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +3 -3
  3. package/dist/cjs/app/hooks.d.ts +66 -66
  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 +194 -194
  8. package/dist/cjs/app/store.js +64 -64
  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 +171 -171
  12. package/dist/cjs/services/api.js +723 -721
  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 +100 -100
  20. package/dist/cjs/slices/allergens.js +83 -83
  21. package/dist/cjs/slices/announcements.d.ts +178 -178
  22. package/dist/cjs/slices/announcements.js +81 -81
  23. package/dist/cjs/slices/checkout.d.ts +58 -58
  24. package/dist/cjs/slices/checkout.js +311 -311
  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 +313 -313
  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 +136 -136
  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 +248 -248
  56. package/dist/cjs/slices/customer/loyalty.js +110 -110
  57. package/dist/cjs/slices/customer/order.d.ts +115 -115
  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 +235 -235
  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 +414 -414
  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 +89 -89
  85. package/dist/cjs/slices/index.d.ts +40 -40
  86. package/dist/cjs/slices/index.js +43 -43
  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 +363 -363
  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 +101 -101
  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 +100 -100
  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 +61 -61
  136. package/dist/cjs/slices/types.js +65 -65
  137. package/dist/cjs/slices/validTimes.d.ts +23 -23
  138. package/dist/cjs/slices/validTimes.js +57 -57
  139. package/dist/cjs/slices/verifyAccount.d.ts +23 -23
  140. package/dist/cjs/slices/verifyAccount.js +54 -54
  141. package/dist/esm/app/hooks.d.ts +66 -66
  142. package/dist/esm/app/hooks.js +4 -4
  143. package/dist/esm/app/index.d.ts +2 -2
  144. package/dist/esm/app/index.js +2 -2
  145. package/dist/esm/app/store.d.ts +194 -194
  146. package/dist/esm/app/store.js +61 -61
  147. package/dist/esm/index.d.ts +5 -5
  148. package/dist/esm/index.js +5 -5
  149. package/dist/esm/services/api.d.ts +171 -171
  150. package/dist/esm/services/api.js +721 -719
  151. package/dist/esm/services/errors.d.ts +50 -50
  152. package/dist/esm/services/errors.js +50 -50
  153. package/dist/esm/services/index.d.ts +3 -3
  154. package/dist/esm/services/index.js +3 -3
  155. package/dist/esm/slices/alerts.d.ts +5 -5
  156. package/dist/esm/slices/alerts.js +24 -24
  157. package/dist/esm/slices/allergens.d.ts +100 -100
  158. package/dist/esm/slices/allergens.js +77 -77
  159. package/dist/esm/slices/announcements.d.ts +178 -178
  160. package/dist/esm/slices/announcements.js +75 -75
  161. package/dist/esm/slices/checkout.d.ts +58 -58
  162. package/dist/esm/slices/checkout.js +303 -303
  163. package/dist/esm/slices/completedOrders.d.ts +31 -31
  164. package/dist/esm/slices/completedOrders.js +57 -57
  165. package/dist/esm/slices/config.d.ts +313 -313
  166. package/dist/esm/slices/config.js +168 -168
  167. package/dist/esm/slices/confirmation.d.ts +8 -8
  168. package/dist/esm/slices/confirmation.js +18 -18
  169. package/dist/esm/slices/customer/account.d.ts +128 -128
  170. package/dist/esm/slices/customer/account.js +344 -344
  171. package/dist/esm/slices/customer/addresses.d.ts +55 -55
  172. package/dist/esm/slices/customer/addresses.js +127 -127
  173. package/dist/esm/slices/customer/allergens.d.ts +37 -37
  174. package/dist/esm/slices/customer/allergens.js +89 -89
  175. package/dist/esm/slices/customer/communicationPreferences.d.ts +69 -69
  176. package/dist/esm/slices/customer/communicationPreferences.js +159 -159
  177. package/dist/esm/slices/customer/creditCards.d.ts +136 -136
  178. package/dist/esm/slices/customer/creditCards.js +165 -165
  179. package/dist/esm/slices/customer/favorites.d.ts +68 -68
  180. package/dist/esm/slices/customer/favorites.js +168 -168
  181. package/dist/esm/slices/customer/fcmToken.d.ts +49 -49
  182. package/dist/esm/slices/customer/fcmToken.js +106 -106
  183. package/dist/esm/slices/customer/giftCards.d.ts +98 -98
  184. package/dist/esm/slices/customer/giftCards.js +217 -217
  185. package/dist/esm/slices/customer/groupOrders.d.ts +118 -118
  186. package/dist/esm/slices/customer/groupOrders.js +256 -256
  187. package/dist/esm/slices/customer/history.d.ts +23 -23
  188. package/dist/esm/slices/customer/history.js +53 -53
  189. package/dist/esm/slices/customer/houseAccounts.d.ts +26 -26
  190. package/dist/esm/slices/customer/houseAccounts.js +62 -62
  191. package/dist/esm/slices/customer/index.d.ts +42 -42
  192. package/dist/esm/slices/customer/index.js +64 -64
  193. package/dist/esm/slices/customer/loyalty.d.ts +248 -248
  194. package/dist/esm/slices/customer/loyalty.js +102 -102
  195. package/dist/esm/slices/customer/order.d.ts +115 -115
  196. package/dist/esm/slices/customer/order.js +94 -94
  197. package/dist/esm/slices/customer/orders.d.ts +27 -27
  198. package/dist/esm/slices/customer/orders.js +63 -63
  199. package/dist/esm/slices/customer/pointsShop.d.ts +35 -35
  200. package/dist/esm/slices/customer/pointsShop.js +82 -82
  201. package/dist/esm/slices/customer/qrCode.d.ts +23 -23
  202. package/dist/esm/slices/customer/qrCode.js +53 -53
  203. package/dist/esm/slices/customer/rewards.d.ts +26 -26
  204. package/dist/esm/slices/customer/rewards.js +62 -62
  205. package/dist/esm/slices/customer/thanx.d.ts +23 -23
  206. package/dist/esm/slices/customer/thanx.js +52 -52
  207. package/dist/esm/slices/customer/tpls.d.ts +235 -235
  208. package/dist/esm/slices/customer/tpls.js +98 -98
  209. package/dist/esm/slices/customer/tplsPointsShop.d.ts +38 -38
  210. package/dist/esm/slices/customer/tplsPointsShop.js +84 -84
  211. package/dist/esm/slices/deals.d.ts +25 -25
  212. package/dist/esm/slices/deals.js +90 -90
  213. package/dist/esm/slices/donations.d.ts +27 -27
  214. package/dist/esm/slices/donations.js +53 -53
  215. package/dist/esm/slices/geolocation.d.ts +11 -11
  216. package/dist/esm/slices/geolocation.js +30 -30
  217. package/dist/esm/slices/giftCards.d.ts +27 -27
  218. package/dist/esm/slices/giftCards.js +54 -54
  219. package/dist/esm/slices/groupOrder.d.ts +414 -414
  220. package/dist/esm/slices/groupOrder.js +259 -259
  221. package/dist/esm/slices/guest.d.ts +51 -51
  222. package/dist/esm/slices/guest.js +84 -84
  223. package/dist/esm/slices/index.d.ts +40 -40
  224. package/dist/esm/slices/index.js +40 -40
  225. package/dist/esm/slices/loader.d.ts +9 -9
  226. package/dist/esm/slices/loader.js +21 -21
  227. package/dist/esm/slices/menu.d.ts +31 -31
  228. package/dist/esm/slices/menu.js +90 -90
  229. package/dist/esm/slices/menuDisplay.d.ts +32 -32
  230. package/dist/esm/slices/menuDisplay.js +55 -55
  231. package/dist/esm/slices/menuItems.d.ts +26 -26
  232. package/dist/esm/slices/menuItems.js +52 -52
  233. package/dist/esm/slices/misc.d.ts +17 -17
  234. package/dist/esm/slices/misc.js +41 -41
  235. package/dist/esm/slices/modal.d.ts +5 -5
  236. package/dist/esm/slices/modal.js +25 -25
  237. package/dist/esm/slices/nav.d.ts +7 -7
  238. package/dist/esm/slices/nav.js +19 -19
  239. package/dist/esm/slices/navSite.d.ts +7 -7
  240. package/dist/esm/slices/navSite.js +19 -19
  241. package/dist/esm/slices/notifications.d.ts +5 -5
  242. package/dist/esm/slices/notifications.js +22 -22
  243. package/dist/esm/slices/oneTimePasscode.d.ts +40 -40
  244. package/dist/esm/slices/oneTimePasscode.js +86 -86
  245. package/dist/esm/slices/order.d.ts +363 -363
  246. package/dist/esm/slices/order.js +508 -508
  247. package/dist/esm/slices/orderFulfillment.d.ts +37 -37
  248. package/dist/esm/slices/orderFulfillment.js +73 -73
  249. package/dist/esm/slices/orderRating.d.ts +52 -52
  250. package/dist/esm/slices/orderRating.js +101 -101
  251. package/dist/esm/slices/posts.d.ts +24 -24
  252. package/dist/esm/slices/posts.js +51 -51
  253. package/dist/esm/slices/pushNotifications.d.ts +9 -9
  254. package/dist/esm/slices/pushNotifications.js +23 -23
  255. package/dist/esm/slices/qr.d.ts +11 -11
  256. package/dist/esm/slices/qr.js +29 -29
  257. package/dist/esm/slices/quote.d.ts +101 -101
  258. package/dist/esm/slices/quote.js +61 -61
  259. package/dist/esm/slices/resetPassword.d.ts +41 -41
  260. package/dist/esm/slices/resetPassword.js +76 -76
  261. package/dist/esm/slices/revenueCenters.d.ts +35 -35
  262. package/dist/esm/slices/revenueCenters.js +89 -89
  263. package/dist/esm/slices/sidebar.d.ts +7 -7
  264. package/dist/esm/slices/sidebar.js +19 -19
  265. package/dist/esm/slices/sidebarModal.d.ts +7 -7
  266. package/dist/esm/slices/sidebarModal.js +19 -19
  267. package/dist/esm/slices/signUp.d.ts +25 -25
  268. package/dist/esm/slices/signUp.js +56 -56
  269. package/dist/esm/slices/tags.d.ts +100 -100
  270. package/dist/esm/slices/tags.js +84 -84
  271. package/dist/esm/slices/terms.d.ts +20 -20
  272. package/dist/esm/slices/terms.js +47 -47
  273. package/dist/esm/slices/types.d.ts +61 -61
  274. package/dist/esm/slices/types.js +62 -62
  275. package/dist/esm/slices/validTimes.d.ts +23 -23
  276. package/dist/esm/slices/validTimes.js +52 -52
  277. package/dist/esm/slices/verifyAccount.d.ts +23 -23
  278. package/dist/esm/slices/verifyAccount.js +50 -50
  279. package/package.json +58 -62
@@ -1,719 +1,721 @@
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) {
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
- return this.request(`/revenue-centers?${params}`);
310
- }
311
- getRevenueCenter(revenue_center_id, requestedAt) {
312
- const params = requestedAt ? `?requested_at=${requestedAt}` : '';
313
- return this.request(`/revenue-centers/${revenue_center_id}${params}`);
314
- }
315
- getLocations(revenue_center_type, is_outpost, lat, lng, requestedAt) {
316
- let params = '';
317
- if (revenue_center_type)
318
- params += `revenue_center_type=${revenue_center_type}`;
319
- if (is_outpost)
320
- params += '&is_outpost=true';
321
- if (lat && lng)
322
- params += `&lat=${lat}&lng=${lng}`;
323
- if (requestedAt)
324
- params += `&requested_at=${requestedAt}`;
325
- return this.request(`/locations?${params}`);
326
- }
327
- getLocation(revenue_center_id) {
328
- return this.request(`/locations/${revenue_center_id}`);
329
- }
330
- getLocationBySlug(slug) {
331
- return this.request(`/locations/${slug}`);
332
- }
333
- getValidTimes(revenueCenterType) {
334
- const params = `revenue_center_type=${revenueCenterType}`;
335
- return this.request(`/valid-times?${params}`);
336
- }
337
- getTags() {
338
- return this.request(`/tags?with_related=true`);
339
- }
340
- getAllergens() {
341
- return this.request(`/allergens?with_related=true`);
342
- }
343
- getMenu(revenueCenterId, serviceType, requestedAt) {
344
- const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}&requested_at=${requestedAt}`;
345
- return this.request(`/menus?${params}`);
346
- }
347
- getMenuItems(revenueCenterId, serviceType) {
348
- const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}`;
349
- return this.request(`/menu-items?${params}`);
350
- }
351
- getMenuDisplay(revenueCenterId, serviceType, weekday, minutes) {
352
- const params = `service_type=${serviceType}&weekday=${weekday}&minutes=${minutes}`;
353
- return this.request(`/menus/${revenueCenterId}/display?${params}`);
354
- }
355
- getMenuPages() {
356
- return this.request(`/menu-pages`);
357
- }
358
- getTerms() {
359
- return this.request(`/terms`);
360
- }
361
- getDeals(customerId) {
362
- const params = customerId ? `&customer_id=${customerId}` : '';
363
- return this.request(`/deals?with_related=true${params}`);
364
- }
365
- getAnnouncements(page) {
366
- return this.request(`/announcements?announcement_page=${page}&with_related=true`);
367
- }
368
- getAnnouncementPage(page) {
369
- return this.request(`/announcement-pages/${page}`);
370
- }
371
- getPages() {
372
- return this.request(`/pages`);
373
- }
374
- getPage(slug) {
375
- return this.request(`/pages/${slug}`);
376
- }
377
- getPosts(slug) {
378
- const params = slug ? `?post_category_slug=${slug}` : '';
379
- return this.request(`/posts${params}`);
380
- }
381
- getPost(slug) {
382
- return this.request(`/posts/${slug}`);
383
- }
384
- getDiscountQRCode(discountId, customerId) {
385
- const params = customerId ? `?customer_id=${customerId}` : '';
386
- return this.request(`/discounts/${discountId}/qrcode${params}`);
387
- }
388
- postTender(orderId, tender) {
389
- return this.request(`/orders/${orderId}/tenders`, 'POST', tender);
390
- }
391
- patchTender(orderId, index, data) {
392
- return this.request(`/orders/${orderId}/tenders/${index}`, 'PATCH', data);
393
- }
394
- postTenderVoid(orderId, index) {
395
- return this.request(`/orders/${orderId}/tenders/${index}/void`, 'POST', {});
396
- }
397
- postIdentifyCustomer(data) {
398
- return this.request(`/identify-customer`, 'POST', data);
399
- }
400
- postApplePayValidate(host, validationURL) {
401
- const data = { host, validationURL };
402
- return this.request(`/apple-pay/validate`, 'POST', data);
403
- }
404
- postApplePayPayment(token, amount, customerId) {
405
- let data = { token, amount };
406
- if (customerId) {
407
- data = Object.assign(Object.assign({}, data), { customer_id: customerId });
408
- }
409
- return this.request(`/apple-pay/payment`, 'POST', data);
410
- }
411
- postOrderValidate(order, token) {
412
- return this.request(`/orders/validate`, 'POST', order, null, token);
413
- }
414
- postOrder(order, token) {
415
- return this.request(`/orders`, 'POST', order, null, token);
416
- }
417
- deleteOrder(order) {
418
- return this.request(`/orders`, 'DELETE', order);
419
- }
420
- getOrders(args) {
421
- let params = [];
422
- if (!args) {
423
- params = [
424
- `prep_status=TODO,IN_PROGRESS,DONE`,
425
- `sort_by=fire_at`,
426
- `sort_direction=ASC`
427
- ];
428
- }
429
- else {
430
- const { business_date, channel_type, prep_status, receipt_type, parent_receipt_uuid, search, sort_by, sort_direction } = args;
431
- if (business_date)
432
- params.push(`business_date=${business_date}`);
433
- if (channel_type)
434
- params.push(`channel_type=${channel_type}`);
435
- if (prep_status)
436
- params.push(`prep_status=${prep_status}`);
437
- if (receipt_type)
438
- params.push(`receipt_type=${receipt_type}`);
439
- if (parent_receipt_uuid)
440
- params.push(`parent_receipt_uuid=${parent_receipt_uuid}`);
441
- if (search)
442
- params.push(`search=${search}`);
443
- if (sort_by)
444
- params.push(`sort_by=${sort_by}`);
445
- if (sort_direction)
446
- params.push(`sort_direction=${sort_direction}`);
447
- }
448
- params = params.length ? `?${params.join('&')}` : '';
449
- return this.request(`/orders${params}`);
450
- }
451
- postRefundValidate(orderId, refund) {
452
- return this.request(`/orders/${orderId}/refund/validate`, 'POST', refund);
453
- }
454
- postRefund(orderId, refund) {
455
- return this.request(`/orders/${orderId}/refund`, 'POST', refund);
456
- }
457
- getOrderFulfillment(orderId) {
458
- return this.request(`/orders/${orderId}/fulfillment`);
459
- }
460
- putOrderFulfillment(orderId, data) {
461
- return this.request(`/orders/${orderId}/fulfillment`, 'PUT', data);
462
- }
463
- getOrderRating(ratingUuid) {
464
- return this.request(`/ratings/${ratingUuid}`);
465
- }
466
- putOrderRating(ratingUuid, data) {
467
- return this.request(`/ratings/${ratingUuid}`, 'PUT', data);
468
- }
469
- postOrderRatingUnsubscribe(ratingUuid) {
470
- return this.request(`/ratings/${ratingUuid}/unsubscribe`, 'POST', {});
471
- }
472
- postPurchaseGiftCards(data) {
473
- return this.request(`/gift-cards-purchase`, 'POST', data);
474
- }
475
- postPurchaseDonation(data) {
476
- return this.request(`/donation-purchase`, 'POST', data);
477
- }
478
- postCart(data) {
479
- return this.request(`/carts`, 'POST', data);
480
- }
481
- getCart(cartId) {
482
- return this.request(`/carts/${cartId}`);
483
- }
484
- putCart(cartId, data) {
485
- return this.request(`/carts/${cartId}`, 'PUT', data);
486
- }
487
- deleteCart(cartId) {
488
- return this.request(`/carts/${cartId}`, 'DELETE');
489
- }
490
- postCartGuest(data) {
491
- return this.request(`/cart-guests`, 'POST', data);
492
- }
493
- getGuest(email) {
494
- return this.request(`/guest?email=${encodeURIComponent(email)}`);
495
- }
496
- getSubscriber(email) {
497
- return this.request(`/subscribers/${encodeURIComponent(email)}`);
498
- }
499
- postSubscriber(email) {
500
- return this.request(`/subscribers`, 'POST', { email });
501
- }
502
- postSignUp(data) {
503
- return this.request(`/customer`, 'POST', data);
504
- }
505
- postCustomerSignIn(data) {
506
- return this.request(`/customer/sign-in`, 'POST', data);
507
- }
508
- postThanxLogin(email, origin) {
509
- const data = origin ? { email, origin } : { email };
510
- return this.request('/thanx-login', 'POST', data);
511
- }
512
- postThanxAuth(code, path, origin) {
513
- const data = path ? { code, path } : { code };
514
- const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
515
- return this.request('/thanx-auth', 'POST', withOrigin);
516
- }
517
- postLogin(email, password) {
518
- const data = {
519
- grant_type: 'password',
520
- username: email,
521
- password: password
522
- };
523
- return this.authRequest('/token', data);
524
- }
525
- postLogout(token) {
526
- return this.authRequest('/revoke', { token });
527
- }
528
- postSendPasswordResetEmail(email, link_url) {
529
- const data = { email, link_url };
530
- return this.request(`/customer/password/send-email`, 'POST', data);
531
- }
532
- postResetPassword(new_password, token) {
533
- const data = { new_password, token };
534
- return this.request(`/customer/password/set-new-password`, 'POST', data);
535
- }
536
- getCustomer(token) {
537
- return this.request(`/customer?with_related=true`, 'GET', null, null, token);
538
- }
539
- putCustomer(token, data) {
540
- return this.request(`/customer`, 'PUT', data, null, token);
541
- }
542
- deleteCustomer(token) {
543
- return this.request(`/customer`, 'DELETE', null, null, token);
544
- }
545
- postCustomerPosToken(token, posToken) {
546
- const data = { pos_token: posToken };
547
- return this.request(`/customer/pos-token`, 'POST', data, null, token);
548
- }
549
- postSendVerificationEmail(token, linkUrl) {
550
- const data = { link_url: linkUrl };
551
- return this.request(`/customer/send-verification-email`, 'POST', data, null, token);
552
- }
553
- postVerifyAccount(verifyToken) {
554
- const data = { token: verifyToken };
555
- return this.request(`/verify-account`, 'POST', data);
556
- }
557
- getCustomerQRCode(token) {
558
- return this.request(`/customer/qrcode`, 'GET', null, null, token);
559
- }
560
- getCustomerRewards(token) {
561
- return this.request(`/customer/rewards?with_related=true`, 'GET', null, null, token);
562
- }
563
- getPointsShop(token) {
564
- return this.request(`/points-shop?with_related=true`, 'GET', null, null, token);
565
- }
566
- postPointsShopReward(token, rewardId) {
567
- return this.request(`/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
568
- }
569
- getTplsPointsShop(token) {
570
- return this.request(`/tpls/points-shop`, 'GET', null, null, token);
571
- }
572
- postTplsPointsShopReward(token, rewardId) {
573
- return this.request(`/tpls/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
574
- }
575
- getCustomerOrders(token, limit, timing) {
576
- let params = [];
577
- if (limit)
578
- params.push(`limit=${limit}`);
579
- if (timing)
580
- params.push(`requested_type=${timing}`);
581
- params = params.length ? `?${params.join('&')}` : '';
582
- return this.request(`/customer/orders${params}`, 'GET', null, null, token);
583
- }
584
- getCustomerOrder(token, orderId) {
585
- return this.request(`/customer/orders/${orderId}`, 'GET', null, null, token);
586
- }
587
- getQuote(token, orderUuid) {
588
- return this.request(`/orders/uuid/${orderUuid}`, 'GET', null, null, token);
589
- }
590
- postCustomerGroupOrder(token, data) {
591
- return this.request(`/customer/carts`, 'POST', data, null, token);
592
- }
593
- getCustomerGroupOrders(token) {
594
- return this.request(`/customer/carts?expand=true`, 'GET', null, null, token);
595
- }
596
- getCustomerGroupOrder(token, cartId) {
597
- return this.request(`/customer/carts/${cartId}?expand=customer&with_related=true`, 'GET', null, null, token);
598
- }
599
- putCustomerGroupOrder(token, cartId, data) {
600
- return this.request(`/customer/carts/${cartId}`, 'PUT', data, null, token);
601
- }
602
- putCustomerGroupOrderStatus(token, cartId, data) {
603
- return this.request(`/customer/carts/${cartId}/status`, 'PUT', data, null, token);
604
- }
605
- deleteCustomerGroupOrder(token, cartId) {
606
- return this.request(`/customer/carts/${cartId}`, 'DELETE', null, null, token);
607
- }
608
- getCustomerAllergens(token) {
609
- return this.request(`/customer/allergens`, 'GET', null, null, token);
610
- }
611
- // replace all existing allergens with a new list of allergens
612
- putCustomerAllergens(token, data) {
613
- return this.request(`/customer/allergens`, 'PUT', data, null, token);
614
- }
615
- // add new allergens incrementally without affecting existing allergens
616
- postCustomerAllergens(token, data) {
617
- return this.request(`/customer/allergens`, 'POST', data, null, token);
618
- }
619
- getCustomerAddresses(token, limit = 10) {
620
- const params = limit ? `?limit=${limit}` : '';
621
- return this.request(`/customer/addresses${params}`, 'GET', null, null, token);
622
- }
623
- putCustomerAddress(token, addressId, data) {
624
- return this.request(`/customer/addresses/${addressId}`, 'PUT', data, null, token);
625
- }
626
- deleteCustomerAddress(token, addressId) {
627
- return this.request(`/customer/addresses/${addressId}`, 'DELETE', null, null, token);
628
- }
629
- getCustomerCreditCards(token, includeLinked = false) {
630
- const params = includeLinked ? `?include_linked=true` : '';
631
- return this.request(`/customer/credit-cards${params}`, 'GET', null, null, token);
632
- }
633
- postCustomerCreditCard(token, data) {
634
- return this.request(`/customer/credit-cards`, 'POST', data, null, token);
635
- }
636
- putCustomerCreditCard(token, cardId, data) {
637
- return this.request(`/customer/credit-cards/${cardId}`, 'PUT', data, null, token);
638
- }
639
- deleteCustomerCreditCard(token, cardId) {
640
- return this.request(`/customer/credit-cards/${cardId}`, 'DELETE', null, null, token);
641
- }
642
- getCustomerGiftCards(token) {
643
- return this.request(`/customer/gift-cards`, 'GET', null, null, token);
644
- }
645
- postCustomerGiftCard(token, data) {
646
- return this.request(`/customer/gift-cards`, 'POST', data, null, token);
647
- }
648
- postCustomerGiftCardAssign(token, card_number) {
649
- return this.request(`/customer/gift-cards/assign`, 'POST', { card_number }, null, token);
650
- }
651
- postCustomerGiftCardAssignOther(token, giftCardId, email) {
652
- return this.request(`/customer/gift-cards/${giftCardId}/assign`, 'POST', { email }, null, token);
653
- }
654
- putCustomerGiftCard(token, giftCardId, data) {
655
- return this.request(`/customer/gift-cards/${giftCardId}`, 'PUT', data, null, token);
656
- }
657
- deleteCustomerGiftCard(token, giftCardId) {
658
- return this.request(`/customer/gift-cards/${giftCardId}`, 'DELETE', null, null, token);
659
- }
660
- getCustomerFavorites(token, limit) {
661
- const params = limit ? `?limit=${limit}` : '';
662
- return this.request(`/customer/favorites${params}`, 'GET', null, null, token);
663
- }
664
- postCustomerFavorite(token, data) {
665
- return this.request(`/customer/favorites`, 'POST', data, null, token);
666
- }
667
- deleteCustomerFavorite(token, favoriteId) {
668
- return this.request(`/customer/favorites/${favoriteId}`, 'DELETE', null, null, token);
669
- }
670
- getCustomerCommunicationPreferences(token) {
671
- return this.request(`/customer/notification-preferences`, 'GET', null, null, token);
672
- }
673
- postCustomerCommunicationPreference(token, data) {
674
- return this.request(`/customer/notification-preferences`, 'POST', data, null, token);
675
- }
676
- putCustomerCommunicationPreference(token, data) {
677
- return this.request(`/customer/notification-preferences`, 'PUT', data, null, token);
678
- }
679
- deleteCustomerCommunicationPreference(token, communicationPreferenceId) {
680
- return this.request(`/customer/notification-preferences/${communicationPreferenceId}`, 'DELETE', null, null, token);
681
- }
682
- postCustomerFcmToken(token, fcmToken) {
683
- return this.request(`/customer/fcm-tokens`, 'POST', { fcm_token: fcmToken }, null, token);
684
- }
685
- getCustomerFcmToken(token) {
686
- return this.request(`/customer/fcm-tokens`, 'GET', null, null, token);
687
- }
688
- deleteCustomerFcmToken(token) {
689
- return this.request(`/customer/fcm-tokens`, 'DELETE', null, null, token);
690
- }
691
- getCustomerLoyalty(token) {
692
- return this.request(`/customer/loyalty`, 'GET', null, null, token);
693
- }
694
- getCustomerLoyaltyV2(token) {
695
- return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
696
- }
697
- getCustomerThanx(token) {
698
- return this.request(`/customer/thanx`, 'GET', null, null, token);
699
- }
700
- getThanxCardSignature(token, acct) {
701
- return this.request(`/customer/thanx-card-signature?acct=${acct}`, 'GET', null, null, token);
702
- }
703
- postCustomerTplsVerify(token) {
704
- return this.request(`/customer/tpls/email-verify`, 'POST', null, null, token);
705
- }
706
- getCustomerTpls(token) {
707
- return this.request(`/customer/tpls`, 'GET', null, null, token);
708
- }
709
- getCustomerTplsHistory(token) {
710
- return this.request(`/customer/tpls/history`, 'GET', null, null, token);
711
- }
712
- getCustomerHouseAccounts(token) {
713
- return this.request(`/customer/house-accounts`, 'GET', null, null, token);
714
- }
715
- putCustomerOrderRating(token, orderId, data) {
716
- return this.request(`/customer/orders/${orderId}/rating`, 'PUT', data, null, token);
717
- }
718
- }
719
- 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) {
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
+ return this.request(`/revenue-centers?${params}`);
310
+ }
311
+ getRevenueCenter(revenue_center_id, requestedAt) {
312
+ const params = requestedAt ? `?requested_at=${requestedAt}` : '';
313
+ return this.request(`/revenue-centers/${revenue_center_id}${params}`);
314
+ }
315
+ getLocations(revenue_center_type, is_outpost, lat, lng, requestedAt, cart_total) {
316
+ let params = '';
317
+ if (revenue_center_type)
318
+ params += `revenue_center_type=${revenue_center_type}`;
319
+ if (is_outpost)
320
+ params += '&is_outpost=true';
321
+ if (lat && lng)
322
+ params += `&lat=${lat}&lng=${lng}`;
323
+ if (requestedAt)
324
+ params += `&requested_at=${requestedAt}`;
325
+ if (cart_total)
326
+ params += `&cart_total=${cart_total}`;
327
+ return this.request(`/locations?${params}`);
328
+ }
329
+ getLocation(revenue_center_id) {
330
+ return this.request(`/locations/${revenue_center_id}`);
331
+ }
332
+ getLocationBySlug(slug) {
333
+ return this.request(`/locations/${slug}`);
334
+ }
335
+ getValidTimes(revenueCenterType) {
336
+ const params = `revenue_center_type=${revenueCenterType}`;
337
+ return this.request(`/valid-times?${params}`);
338
+ }
339
+ getTags() {
340
+ return this.request(`/tags?with_related=true`);
341
+ }
342
+ getAllergens() {
343
+ return this.request(`/allergens?with_related=true`);
344
+ }
345
+ getMenu(revenueCenterId, serviceType, requestedAt) {
346
+ const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}&requested_at=${requestedAt}`;
347
+ return this.request(`/menus?${params}`);
348
+ }
349
+ getMenuItems(revenueCenterId, serviceType) {
350
+ const params = `revenue_center_id=${revenueCenterId}&service_type=${serviceType}`;
351
+ return this.request(`/menu-items?${params}`);
352
+ }
353
+ getMenuDisplay(revenueCenterId, serviceType, weekday, minutes) {
354
+ const params = `service_type=${serviceType}&weekday=${weekday}&minutes=${minutes}`;
355
+ return this.request(`/menus/${revenueCenterId}/display?${params}`);
356
+ }
357
+ getMenuPages() {
358
+ return this.request(`/menu-pages`);
359
+ }
360
+ getTerms() {
361
+ return this.request(`/terms`);
362
+ }
363
+ getDeals(customerId) {
364
+ const params = customerId ? `&customer_id=${customerId}` : '';
365
+ return this.request(`/deals?with_related=true${params}`);
366
+ }
367
+ getAnnouncements(page) {
368
+ return this.request(`/announcements?announcement_page=${page}&with_related=true`);
369
+ }
370
+ getAnnouncementPage(page) {
371
+ return this.request(`/announcement-pages/${page}`);
372
+ }
373
+ getPages() {
374
+ return this.request(`/pages`);
375
+ }
376
+ getPage(slug) {
377
+ return this.request(`/pages/${slug}`);
378
+ }
379
+ getPosts(slug) {
380
+ const params = slug ? `?post_category_slug=${slug}` : '';
381
+ return this.request(`/posts${params}`);
382
+ }
383
+ getPost(slug) {
384
+ return this.request(`/posts/${slug}`);
385
+ }
386
+ getDiscountQRCode(discountId, customerId) {
387
+ const params = customerId ? `?customer_id=${customerId}` : '';
388
+ return this.request(`/discounts/${discountId}/qrcode${params}`);
389
+ }
390
+ postTender(orderId, tender) {
391
+ return this.request(`/orders/${orderId}/tenders`, 'POST', tender);
392
+ }
393
+ patchTender(orderId, index, data) {
394
+ return this.request(`/orders/${orderId}/tenders/${index}`, 'PATCH', data);
395
+ }
396
+ postTenderVoid(orderId, index) {
397
+ return this.request(`/orders/${orderId}/tenders/${index}/void`, 'POST', {});
398
+ }
399
+ postIdentifyCustomer(data) {
400
+ return this.request(`/identify-customer`, 'POST', data);
401
+ }
402
+ postApplePayValidate(host, validationURL) {
403
+ const data = { host, validationURL };
404
+ return this.request(`/apple-pay/validate`, 'POST', data);
405
+ }
406
+ postApplePayPayment(token, amount, customerId) {
407
+ let data = { token, amount };
408
+ if (customerId) {
409
+ data = Object.assign(Object.assign({}, data), { customer_id: customerId });
410
+ }
411
+ return this.request(`/apple-pay/payment`, 'POST', data);
412
+ }
413
+ postOrderValidate(order, token) {
414
+ return this.request(`/orders/validate`, 'POST', order, null, token);
415
+ }
416
+ postOrder(order, token) {
417
+ return this.request(`/orders`, 'POST', order, null, token);
418
+ }
419
+ deleteOrder(order) {
420
+ return this.request(`/orders`, 'DELETE', order);
421
+ }
422
+ getOrders(args) {
423
+ let params = [];
424
+ if (!args) {
425
+ params = [
426
+ `prep_status=TODO,IN_PROGRESS,DONE`,
427
+ `sort_by=fire_at`,
428
+ `sort_direction=ASC`
429
+ ];
430
+ }
431
+ else {
432
+ const { business_date, channel_type, prep_status, receipt_type, parent_receipt_uuid, search, sort_by, sort_direction } = args;
433
+ if (business_date)
434
+ params.push(`business_date=${business_date}`);
435
+ if (channel_type)
436
+ params.push(`channel_type=${channel_type}`);
437
+ if (prep_status)
438
+ params.push(`prep_status=${prep_status}`);
439
+ if (receipt_type)
440
+ params.push(`receipt_type=${receipt_type}`);
441
+ if (parent_receipt_uuid)
442
+ params.push(`parent_receipt_uuid=${parent_receipt_uuid}`);
443
+ if (search)
444
+ params.push(`search=${search}`);
445
+ if (sort_by)
446
+ params.push(`sort_by=${sort_by}`);
447
+ if (sort_direction)
448
+ params.push(`sort_direction=${sort_direction}`);
449
+ }
450
+ params = params.length ? `?${params.join('&')}` : '';
451
+ return this.request(`/orders${params}`);
452
+ }
453
+ postRefundValidate(orderId, refund) {
454
+ return this.request(`/orders/${orderId}/refund/validate`, 'POST', refund);
455
+ }
456
+ postRefund(orderId, refund) {
457
+ return this.request(`/orders/${orderId}/refund`, 'POST', refund);
458
+ }
459
+ getOrderFulfillment(orderId) {
460
+ return this.request(`/orders/${orderId}/fulfillment`);
461
+ }
462
+ putOrderFulfillment(orderId, data) {
463
+ return this.request(`/orders/${orderId}/fulfillment`, 'PUT', data);
464
+ }
465
+ getOrderRating(ratingUuid) {
466
+ return this.request(`/ratings/${ratingUuid}`);
467
+ }
468
+ putOrderRating(ratingUuid, data) {
469
+ return this.request(`/ratings/${ratingUuid}`, 'PUT', data);
470
+ }
471
+ postOrderRatingUnsubscribe(ratingUuid) {
472
+ return this.request(`/ratings/${ratingUuid}/unsubscribe`, 'POST', {});
473
+ }
474
+ postPurchaseGiftCards(data) {
475
+ return this.request(`/gift-cards-purchase`, 'POST', data);
476
+ }
477
+ postPurchaseDonation(data) {
478
+ return this.request(`/donation-purchase`, 'POST', data);
479
+ }
480
+ postCart(data) {
481
+ return this.request(`/carts`, 'POST', data);
482
+ }
483
+ getCart(cartId) {
484
+ return this.request(`/carts/${cartId}`);
485
+ }
486
+ putCart(cartId, data) {
487
+ return this.request(`/carts/${cartId}`, 'PUT', data);
488
+ }
489
+ deleteCart(cartId) {
490
+ return this.request(`/carts/${cartId}`, 'DELETE');
491
+ }
492
+ postCartGuest(data) {
493
+ return this.request(`/cart-guests`, 'POST', data);
494
+ }
495
+ getGuest(email) {
496
+ return this.request(`/guest?email=${encodeURIComponent(email)}`);
497
+ }
498
+ getSubscriber(email) {
499
+ return this.request(`/subscribers/${encodeURIComponent(email)}`);
500
+ }
501
+ postSubscriber(email) {
502
+ return this.request(`/subscribers`, 'POST', { email });
503
+ }
504
+ postSignUp(data) {
505
+ return this.request(`/customer`, 'POST', data);
506
+ }
507
+ postCustomerSignIn(data) {
508
+ return this.request(`/customer/sign-in`, 'POST', data);
509
+ }
510
+ postThanxLogin(email, origin) {
511
+ const data = origin ? { email, origin } : { email };
512
+ return this.request('/thanx-login', 'POST', data);
513
+ }
514
+ postThanxAuth(code, path, origin) {
515
+ const data = path ? { code, path } : { code };
516
+ const withOrigin = origin ? Object.assign(Object.assign({}, data), { origin }) : data;
517
+ return this.request('/thanx-auth', 'POST', withOrigin);
518
+ }
519
+ postLogin(email, password) {
520
+ const data = {
521
+ grant_type: 'password',
522
+ username: email,
523
+ password: password
524
+ };
525
+ return this.authRequest('/token', data);
526
+ }
527
+ postLogout(token) {
528
+ return this.authRequest('/revoke', { token });
529
+ }
530
+ postSendPasswordResetEmail(email, link_url) {
531
+ const data = { email, link_url };
532
+ return this.request(`/customer/password/send-email`, 'POST', data);
533
+ }
534
+ postResetPassword(new_password, token) {
535
+ const data = { new_password, token };
536
+ return this.request(`/customer/password/set-new-password`, 'POST', data);
537
+ }
538
+ getCustomer(token) {
539
+ return this.request(`/customer?with_related=true`, 'GET', null, null, token);
540
+ }
541
+ putCustomer(token, data) {
542
+ return this.request(`/customer`, 'PUT', data, null, token);
543
+ }
544
+ deleteCustomer(token) {
545
+ return this.request(`/customer`, 'DELETE', null, null, token);
546
+ }
547
+ postCustomerPosToken(token, posToken) {
548
+ const data = { pos_token: posToken };
549
+ return this.request(`/customer/pos-token`, 'POST', data, null, token);
550
+ }
551
+ postSendVerificationEmail(token, linkUrl) {
552
+ const data = { link_url: linkUrl };
553
+ return this.request(`/customer/send-verification-email`, 'POST', data, null, token);
554
+ }
555
+ postVerifyAccount(verifyToken) {
556
+ const data = { token: verifyToken };
557
+ return this.request(`/verify-account`, 'POST', data);
558
+ }
559
+ getCustomerQRCode(token) {
560
+ return this.request(`/customer/qrcode`, 'GET', null, null, token);
561
+ }
562
+ getCustomerRewards(token) {
563
+ return this.request(`/customer/rewards?with_related=true`, 'GET', null, null, token);
564
+ }
565
+ getPointsShop(token) {
566
+ return this.request(`/points-shop?with_related=true`, 'GET', null, null, token);
567
+ }
568
+ postPointsShopReward(token, rewardId) {
569
+ return this.request(`/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
570
+ }
571
+ getTplsPointsShop(token) {
572
+ return this.request(`/tpls/points-shop`, 'GET', null, null, token);
573
+ }
574
+ postTplsPointsShopReward(token, rewardId) {
575
+ return this.request(`/tpls/points-shop/${rewardId}/exchange`, 'POST', null, null, token);
576
+ }
577
+ getCustomerOrders(token, limit, timing) {
578
+ let params = [];
579
+ if (limit)
580
+ params.push(`limit=${limit}`);
581
+ if (timing)
582
+ params.push(`requested_type=${timing}`);
583
+ params = params.length ? `?${params.join('&')}` : '';
584
+ return this.request(`/customer/orders${params}`, 'GET', null, null, token);
585
+ }
586
+ getCustomerOrder(token, orderId) {
587
+ return this.request(`/customer/orders/${orderId}`, 'GET', null, null, token);
588
+ }
589
+ getQuote(token, orderUuid) {
590
+ return this.request(`/orders/uuid/${orderUuid}`, 'GET', null, null, token);
591
+ }
592
+ postCustomerGroupOrder(token, data) {
593
+ return this.request(`/customer/carts`, 'POST', data, null, token);
594
+ }
595
+ getCustomerGroupOrders(token) {
596
+ return this.request(`/customer/carts?expand=true`, 'GET', null, null, token);
597
+ }
598
+ getCustomerGroupOrder(token, cartId) {
599
+ return this.request(`/customer/carts/${cartId}?expand=customer&with_related=true`, 'GET', null, null, token);
600
+ }
601
+ putCustomerGroupOrder(token, cartId, data) {
602
+ return this.request(`/customer/carts/${cartId}`, 'PUT', data, null, token);
603
+ }
604
+ putCustomerGroupOrderStatus(token, cartId, data) {
605
+ return this.request(`/customer/carts/${cartId}/status`, 'PUT', data, null, token);
606
+ }
607
+ deleteCustomerGroupOrder(token, cartId) {
608
+ return this.request(`/customer/carts/${cartId}`, 'DELETE', null, null, token);
609
+ }
610
+ getCustomerAllergens(token) {
611
+ return this.request(`/customer/allergens`, 'GET', null, null, token);
612
+ }
613
+ // replace all existing allergens with a new list of allergens
614
+ putCustomerAllergens(token, data) {
615
+ return this.request(`/customer/allergens`, 'PUT', data, null, token);
616
+ }
617
+ // add new allergens incrementally without affecting existing allergens
618
+ postCustomerAllergens(token, data) {
619
+ return this.request(`/customer/allergens`, 'POST', data, null, token);
620
+ }
621
+ getCustomerAddresses(token, limit = 10) {
622
+ const params = limit ? `?limit=${limit}` : '';
623
+ return this.request(`/customer/addresses${params}`, 'GET', null, null, token);
624
+ }
625
+ putCustomerAddress(token, addressId, data) {
626
+ return this.request(`/customer/addresses/${addressId}`, 'PUT', data, null, token);
627
+ }
628
+ deleteCustomerAddress(token, addressId) {
629
+ return this.request(`/customer/addresses/${addressId}`, 'DELETE', null, null, token);
630
+ }
631
+ getCustomerCreditCards(token, includeLinked = false) {
632
+ const params = includeLinked ? `?include_linked=true` : '';
633
+ return this.request(`/customer/credit-cards${params}`, 'GET', null, null, token);
634
+ }
635
+ postCustomerCreditCard(token, data) {
636
+ return this.request(`/customer/credit-cards`, 'POST', data, null, token);
637
+ }
638
+ putCustomerCreditCard(token, cardId, data) {
639
+ return this.request(`/customer/credit-cards/${cardId}`, 'PUT', data, null, token);
640
+ }
641
+ deleteCustomerCreditCard(token, cardId) {
642
+ return this.request(`/customer/credit-cards/${cardId}`, 'DELETE', null, null, token);
643
+ }
644
+ getCustomerGiftCards(token) {
645
+ return this.request(`/customer/gift-cards`, 'GET', null, null, token);
646
+ }
647
+ postCustomerGiftCard(token, data) {
648
+ return this.request(`/customer/gift-cards`, 'POST', data, null, token);
649
+ }
650
+ postCustomerGiftCardAssign(token, card_number) {
651
+ return this.request(`/customer/gift-cards/assign`, 'POST', { card_number }, null, token);
652
+ }
653
+ postCustomerGiftCardAssignOther(token, giftCardId, email) {
654
+ return this.request(`/customer/gift-cards/${giftCardId}/assign`, 'POST', { email }, null, token);
655
+ }
656
+ putCustomerGiftCard(token, giftCardId, data) {
657
+ return this.request(`/customer/gift-cards/${giftCardId}`, 'PUT', data, null, token);
658
+ }
659
+ deleteCustomerGiftCard(token, giftCardId) {
660
+ return this.request(`/customer/gift-cards/${giftCardId}`, 'DELETE', null, null, token);
661
+ }
662
+ getCustomerFavorites(token, limit) {
663
+ const params = limit ? `?limit=${limit}` : '';
664
+ return this.request(`/customer/favorites${params}`, 'GET', null, null, token);
665
+ }
666
+ postCustomerFavorite(token, data) {
667
+ return this.request(`/customer/favorites`, 'POST', data, null, token);
668
+ }
669
+ deleteCustomerFavorite(token, favoriteId) {
670
+ return this.request(`/customer/favorites/${favoriteId}`, 'DELETE', null, null, token);
671
+ }
672
+ getCustomerCommunicationPreferences(token) {
673
+ return this.request(`/customer/notification-preferences`, 'GET', null, null, token);
674
+ }
675
+ postCustomerCommunicationPreference(token, data) {
676
+ return this.request(`/customer/notification-preferences`, 'POST', data, null, token);
677
+ }
678
+ putCustomerCommunicationPreference(token, data) {
679
+ return this.request(`/customer/notification-preferences`, 'PUT', data, null, token);
680
+ }
681
+ deleteCustomerCommunicationPreference(token, communicationPreferenceId) {
682
+ return this.request(`/customer/notification-preferences/${communicationPreferenceId}`, 'DELETE', null, null, token);
683
+ }
684
+ postCustomerFcmToken(token, fcmToken) {
685
+ return this.request(`/customer/fcm-tokens`, 'POST', { fcm_token: fcmToken }, null, token);
686
+ }
687
+ getCustomerFcmToken(token) {
688
+ return this.request(`/customer/fcm-tokens`, 'GET', null, null, token);
689
+ }
690
+ deleteCustomerFcmToken(token) {
691
+ return this.request(`/customer/fcm-tokens`, 'DELETE', null, null, token);
692
+ }
693
+ getCustomerLoyalty(token) {
694
+ return this.request(`/customer/loyalty`, 'GET', null, null, token);
695
+ }
696
+ getCustomerLoyaltyV2(token) {
697
+ return this.request(`/v2/customer/loyalty`, 'GET', null, null, token);
698
+ }
699
+ getCustomerThanx(token) {
700
+ return this.request(`/customer/thanx`, 'GET', null, null, token);
701
+ }
702
+ getThanxCardSignature(token, acct) {
703
+ return this.request(`/customer/thanx-card-signature?acct=${acct}`, 'GET', null, null, token);
704
+ }
705
+ postCustomerTplsVerify(token) {
706
+ return this.request(`/customer/tpls/email-verify`, 'POST', null, null, token);
707
+ }
708
+ getCustomerTpls(token) {
709
+ return this.request(`/customer/tpls`, 'GET', null, null, token);
710
+ }
711
+ getCustomerTplsHistory(token) {
712
+ return this.request(`/customer/tpls/history`, 'GET', null, null, token);
713
+ }
714
+ getCustomerHouseAccounts(token) {
715
+ return this.request(`/customer/house-accounts`, 'GET', null, null, token);
716
+ }
717
+ putCustomerOrderRating(token, orderId, data) {
718
+ return this.request(`/customer/orders/${orderId}/rating`, 'PUT', data, null, token);
719
+ }
720
+ }
721
+ export default OpenTenderAPI;