@onylab/common-api 2.0.10 → 2.1.1

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.
@@ -1,10 +1,3 @@
1
- declare module "api/mockup/ApiMockup" {
2
- export class ApiMockup {
3
- static isDone(): boolean;
4
- static pending(): string;
5
- static reset(): void;
6
- }
7
- }
8
1
  declare module "api/hubrise/model/order/HubriseOrderStatus" {
9
2
  export enum HubriseOrderStatus {
10
3
  new = "new",
@@ -22,6 +15,7 @@ declare module "api/hubrise/model/order/HubriseOrderStatus" {
22
15
  }
23
16
  declare module "api/hubrise/model/customer/HubriseCustomerContract" {
24
17
  export interface HubriseCustomerContract {
18
+ id?: string;
25
19
  first_name?: string;
26
20
  last_name?: string;
27
21
  gender?: string;
@@ -45,9 +39,11 @@ declare module "api/hubrise/model/customer/HubriseCustomerContract" {
45
39
  }
46
40
  declare module "api/hubrise/model/order/HubriseOrderOptionContract" {
47
41
  export interface HubriseOrderOptionContract {
42
+ id?: string;
43
+ ref?: string;
48
44
  option_list_name: string;
49
45
  name: string;
50
- ref?: string;
46
+ quantity: number;
51
47
  price?: string;
52
48
  removed?: boolean;
53
49
  }
@@ -55,12 +51,13 @@ declare module "api/hubrise/model/order/HubriseOrderOptionContract" {
55
51
  declare module "api/hubrise/model/order/HubriseOrderItemContract" {
56
52
  import { HubriseOrderOptionContract } from "api/hubrise/model/order/HubriseOrderOptionContract";
57
53
  export interface HubriseOrderItemContract {
54
+ id?: string;
58
55
  private_ref?: string;
59
- product_name: string;
60
- sku_name?: string;
61
56
  sku_ref?: string;
57
+ sku_name?: string;
58
+ product_name: string;
59
+ quantity: number;
62
60
  price?: string;
63
- quantity?: string;
64
61
  subtotal?: string;
65
62
  tax_rate?: string;
66
63
  customer_notes?: string;
@@ -116,6 +113,13 @@ declare module "api/hubrise/model/order/HubriseOrderDealContract" {
116
113
  ref?: string;
117
114
  }
118
115
  }
116
+ declare module "api/hubrise/model/order/HubriseServiceType" {
117
+ export enum HubriseServiceType {
118
+ DELIVERY = "delivery",
119
+ COLLECTION = "collection",// = pickup
120
+ EAT_IN = "eat_in"
121
+ }
122
+ }
119
123
  declare module "api/hubrise/model/order/HubriseOrderContract" {
120
124
  import { HubriseOrderStatus } from "api/hubrise/model/order/HubriseOrderStatus";
121
125
  import { HubriseCustomerContract } from "api/hubrise/model/customer/HubriseCustomerContract";
@@ -125,12 +129,13 @@ declare module "api/hubrise/model/order/HubriseOrderContract" {
125
129
  import { HubriseOrderPaymentContract } from "api/hubrise/model/order/HubriseOrderPaymentContract";
126
130
  import { HubriseOrderDiscountContract } from "api/hubrise/model/order/HubriseOrderDiscountContract";
127
131
  import { HubriseOrderDealContract } from "api/hubrise/model/order/HubriseOrderDealContract";
132
+ import { HubriseServiceType } from "api/hubrise/model/order/HubriseServiceType";
128
133
  export interface HubriseOrderContract {
129
134
  id?: string;
130
135
  location_id?: string;
131
136
  private_ref?: string;
132
137
  status: HubriseOrderStatus;
133
- service_type?: 'delivery' | 'collection' | 'eat_in';
138
+ service_type?: HubriseServiceType;
134
139
  service_type_ref?: string;
135
140
  channel?: string;
136
141
  expected_time?: string;
@@ -155,26 +160,9 @@ declare module "api/hubrise/model/order/HubriseOrderContract" {
155
160
  created_by?: string;
156
161
  }
157
162
  }
158
- declare module "api/hubrise/mockup/HubriseApiMockup" {
159
- import { ApiMockup } from "api/mockup/ApiMockup";
160
- export class HubriseApiMockup extends ApiMockup {
161
- static readonly BASE_URL: string;
162
- static getUser(times?: number): void;
163
- static getLocations(times?: number): void;
164
- static createCustomer(times?: number): void;
165
- static getCustomer(times?: number): void;
166
- static getCustomers(times?: number): void;
167
- static getCustomerLists(times?: number): void;
168
- static createOrder(times?: number): void;
169
- static getOrder(times?: number, generateRandomId?: boolean): void;
170
- static setOrderStatus(times?: number): void;
171
- static getCatalog(times?: number): void;
172
- static getCatalogs(times?: number): void;
173
- static createWebhook(times?: number): void;
174
- }
175
- }
176
163
  declare module "api/hubrise/model/menu/HubriseMenuCategoryContract" {
177
164
  export interface HubriseMenuCategoryContract {
165
+ id: string;
178
166
  ref: string;
179
167
  parent_ref?: string;
180
168
  name: string;
@@ -197,13 +185,14 @@ declare module "api/hubrise/model/menu/HubriseMenuRestrictionsContract" {
197
185
  }
198
186
  }
199
187
  declare module "api/hubrise/model/menu/HubriseMenuPriceOverrideContract" {
188
+ import { HubriseServiceType } from "api/hubrise/model/order/HubriseServiceType";
200
189
  export interface HubriseMenuPriceOverrideContract {
201
190
  dow?: string;
202
191
  start_time?: string;
203
192
  end_time?: string;
204
193
  start_date?: string;
205
194
  end_date?: string;
206
- service_types?: ('delivery' | 'collection' | 'eat_in')[];
195
+ service_types?: HubriseServiceType[];
207
196
  price: string;
208
197
  }
209
198
  }
@@ -211,30 +200,38 @@ declare module "api/hubrise/model/menu/HubriseMenuSkuContract" {
211
200
  import { HubriseMenuRestrictionsContract } from "api/hubrise/model/menu/HubriseMenuRestrictionsContract";
212
201
  import { HubriseMenuPriceOverrideContract } from "api/hubrise/model/menu/HubriseMenuPriceOverrideContract";
213
202
  export interface HubriseMenuSkuContract {
203
+ id: string;
214
204
  ref?: string;
215
205
  name?: string;
216
206
  restrictions?: HubriseMenuRestrictionsContract;
217
207
  price: string;
218
208
  price_overrides: HubriseMenuPriceOverrideContract[];
219
- option_list_refs?: string[];
209
+ option_list_ids?: string[];
220
210
  tags?: string[];
221
211
  }
222
212
  }
223
213
  declare module "api/hubrise/model/menu/HubriseMenuProductContract" {
224
214
  import { HubriseMenuSkuContract } from "api/hubrise/model/menu/HubriseMenuSkuContract";
225
215
  export interface HubriseMenuProductContract {
216
+ id: string;
226
217
  ref?: string;
227
- category_ref: string;
218
+ category_id: string;
228
219
  name: string;
229
220
  description?: string;
230
221
  tags?: string[];
231
222
  image_ids: string[];
232
223
  skus: HubriseMenuSkuContract[];
224
+ tax_rate: {
225
+ delivery?: string;
226
+ collection?: string;
227
+ eat_in?: string;
228
+ };
233
229
  }
234
230
  }
235
231
  declare module "api/hubrise/model/menu/HubriseMenuProductOptionContract" {
236
232
  import { HubriseMenuPriceOverrideContract } from "api/hubrise/model/menu/HubriseMenuPriceOverrideContract";
237
233
  export interface HubriseMenuProductOptionContract {
234
+ id: string;
238
235
  ref?: string;
239
236
  name: string;
240
237
  price: string;
@@ -246,6 +243,7 @@ declare module "api/hubrise/model/menu/HubriseMenuProductOptionContract" {
246
243
  declare module "api/hubrise/model/menu/HubriseMenuProductOptionListContract" {
247
244
  import { HubriseMenuProductOptionContract } from "api/hubrise/model/menu/HubriseMenuProductOptionContract";
248
245
  export interface HubriseMenuProductOptionListContract {
246
+ id: string;
249
247
  ref: string;
250
248
  name: string;
251
249
  min_selections?: number;
@@ -309,7 +307,7 @@ declare module "api/hubrise/model/menu/HubriseMenuCatalogContract" {
309
307
  import { HubriseMenuDiscountContract } from "api/hubrise/model/menu/HubriseMenuDiscountContract";
310
308
  import { HubriseMenuChargeContract } from "api/hubrise/model/menu/HubriseMenuChargeContract";
311
309
  export interface HubriseMenuCatalogContract {
312
- id?: string;
310
+ id: string;
313
311
  location_id?: string;
314
312
  name: string;
315
313
  created_at?: string;
@@ -1212,10 +1210,143 @@ declare module "api/hubrise/model/menu/HubriseMenuImageContract" {
1212
1210
  seconds_before_removal: number;
1213
1211
  }
1214
1212
  }
1215
- declare module "api/index" {
1216
- export * from "api/hubrise/mockup/HubriseApiMockup";
1217
- export * from "api/hubrise/service/HubriseApiContract";
1218
- export * from "api/hubrise/service/HubriseApi";
1213
+ declare module "api/hubrise/model/order/HubriseOrderEditableOptionContract" {
1214
+ export interface HubriseOrderEditableOptionContract {
1215
+ id: string;
1216
+ ref?: string;
1217
+ option_list_name: string;
1218
+ name: string;
1219
+ quantity: number;
1220
+ price: string;
1221
+ }
1222
+ }
1223
+ declare module "api/hubrise/model/order/HubriseOrderEditableItemContract" {
1224
+ import { HubriseOrderEditableOptionContract } from "api/hubrise/model/order/HubriseOrderEditableOptionContract";
1225
+ export interface HubriseOrderEditableItemContract {
1226
+ id: string;
1227
+ sku_ref?: string;
1228
+ sku_name?: string;
1229
+ category_name?: string;
1230
+ product_name: string;
1231
+ quantity: number;
1232
+ price: string;
1233
+ tax_rate?: {
1234
+ delivery?: string;
1235
+ collection?: string;
1236
+ eat_in?: string;
1237
+ };
1238
+ customer_notes?: string;
1239
+ options?: HubriseOrderEditableOptionContract[];
1240
+ }
1241
+ }
1242
+ declare module "api/hubrise/service/HubriseCatalogConverterContract" {
1243
+ import { HubriseMenuCatalogContract } from "api/hubrise/model/menu/HubriseMenuCatalogContract";
1244
+ import { HubriseOrderEditableItemContract } from "api/hubrise/model/order/HubriseOrderEditableItemContract";
1245
+ import { HubriseOrderEditableOptionContract } from "api/hubrise/model/order/HubriseOrderEditableOptionContract";
1246
+ export interface HubriseCatalogConverterContract {
1247
+ editableItems(catalog: HubriseMenuCatalogContract): {
1248
+ withRef: HubriseOrderEditableItemContract[];
1249
+ withName: HubriseOrderEditableItemContract[];
1250
+ };
1251
+ editableItemOptions(catalog: HubriseMenuCatalogContract): {
1252
+ withRef: Record<string, HubriseOrderEditableOptionContract[]>;
1253
+ withName: Record<string, HubriseOrderEditableOptionContract[]>;
1254
+ };
1255
+ }
1256
+ }
1257
+ declare module "util/MathUtil" {
1258
+ export class MathUtil {
1259
+ static sum(values: number[]): number;
1260
+ static avg(values: number[]): number;
1261
+ static applyVariation(value: number, variation: number): number;
1262
+ static median(values: number[]): number;
1263
+ static percentage(part: number, total: number): number;
1264
+ static round(value: number, decimals: number): number;
1265
+ static variation(originalValue: number, newValue: number): number;
1266
+ }
1267
+ }
1268
+ declare module "api/hubrise/util/HubrisePriceUtil" {
1269
+ import { HubriseCurrencyCode } from "api/hubrise/model/common/HubriseCurrencyCode";
1270
+ export class HubrisePriceUtil {
1271
+ static sum(prices: string[], defaultCurrency?: HubriseCurrencyCode): string;
1272
+ static multiply(price: string, multiplier: number): string;
1273
+ static priceToAmount(price: string): {
1274
+ amount: number;
1275
+ currency: HubriseCurrencyCode;
1276
+ };
1277
+ static amountToPrice(amount: number, currency: HubriseCurrencyCode): string;
1278
+ }
1279
+ }
1280
+ declare module "api/hubrise/service/HubriseCatalogConverter" {
1281
+ import { HubriseCatalogConverterContract } from "api/hubrise/service/HubriseCatalogConverterContract";
1282
+ import { HubriseMenuCatalogContract } from "api/hubrise/model/menu/HubriseMenuCatalogContract";
1283
+ import { HubriseOrderEditableItemContract } from "api/hubrise/model/order/HubriseOrderEditableItemContract";
1284
+ import { HubriseOrderEditableOptionContract } from "api/hubrise/model/order/HubriseOrderEditableOptionContract";
1285
+ export class HubriseCatalogConverter implements HubriseCatalogConverterContract {
1286
+ editableItems(catalog: HubriseMenuCatalogContract): {
1287
+ withRef: HubriseOrderEditableItemContract[];
1288
+ withName: HubriseOrderEditableItemContract[];
1289
+ };
1290
+ editableItemOptions(catalog: HubriseMenuCatalogContract): {
1291
+ withRef: Record<string, HubriseOrderEditableOptionContract[]>;
1292
+ withName: Record<string, HubriseOrderEditableOptionContract[]>;
1293
+ };
1294
+ }
1295
+ }
1296
+ declare module "api/hubrise/service/HubriseOrderConverterContract" {
1297
+ import { HubriseOrderEditableItemContract } from "api/hubrise/model/order/HubriseOrderEditableItemContract";
1298
+ import { HubriseOrderItemContract } from "api/hubrise/model/order/HubriseOrderItemContract";
1299
+ import { HubriseServiceType } from "api/hubrise/model/order/HubriseServiceType";
1300
+ export interface HubriseOrderConverterContract {
1301
+ items(editableItems: HubriseOrderEditableItemContract[], serviceType: HubriseServiceType): HubriseOrderItemContract[];
1302
+ }
1303
+ }
1304
+ declare module "util/ObjectUtil" {
1305
+ export class ObjectUtil {
1306
+ static compact(obj: any, options?: {
1307
+ removeEmptyString?: boolean;
1308
+ }): any;
1309
+ static update(source: Record<string, unknown>, target: Record<string, unknown>): void;
1310
+ }
1311
+ }
1312
+ declare module "api/hubrise/service/HubriseOrderConverter" {
1313
+ import { HubriseOrderConverterContract } from "api/hubrise/service/HubriseOrderConverterContract";
1314
+ import { HubriseOrderItemContract } from "api/hubrise/model/order/HubriseOrderItemContract";
1315
+ import { HubriseOrderEditableItemContract } from "api/hubrise/model/order/HubriseOrderEditableItemContract";
1316
+ import { HubriseServiceType } from "api/hubrise/model/order/HubriseServiceType";
1317
+ export class HubriseOrderConverter implements HubriseOrderConverterContract {
1318
+ items(editableItems: HubriseOrderEditableItemContract[], serviceType: HubriseServiceType): HubriseOrderItemContract[];
1319
+ }
1320
+ }
1321
+ declare module "api/hubrise/service/TotalHubriseCalculatorContract" {
1322
+ import { HubriseCurrencyCode } from "api/hubrise/model/common/HubriseCurrencyCode";
1323
+ import { HubriseOrderContract } from "api/hubrise/model/order/HubriseOrderContract";
1324
+ export interface TotalHubriseCalculatorContract {
1325
+ calculateTotals(order: HubriseOrderContract, defaultCurrency: HubriseCurrencyCode): {
1326
+ subtotal: string;
1327
+ minimumOrderFee: string;
1328
+ deliveryFee: string;
1329
+ totalDiscount: string;
1330
+ total: string;
1331
+ };
1332
+ }
1333
+ }
1334
+ declare module "api/hubrise/service/TotalHubriseCalculator" {
1335
+ import { TotalHubriseCalculatorContract } from "api/hubrise/service/TotalHubriseCalculatorContract";
1336
+ import { HubriseCurrencyCode } from "api/hubrise/model/common/HubriseCurrencyCode";
1337
+ import { HubriseOrderContract } from "api/hubrise/model/order/HubriseOrderContract";
1338
+ export class TotalHubriseCalculator implements TotalHubriseCalculatorContract {
1339
+ calculateTotals(order: HubriseOrderContract, defaultCurrency: HubriseCurrencyCode): {
1340
+ subtotal: string;
1341
+ minimumOrderFee: string;
1342
+ deliveryFee: string;
1343
+ totalDiscount: string;
1344
+ total: string;
1345
+ };
1346
+ private findCurrency;
1347
+ }
1348
+ }
1349
+ declare module "api/web" {
1219
1350
  export * from "api/hubrise/model/account/HubriseAccountContract";
1220
1351
  export * from "api/hubrise/model/account/HubriseAuthContract";
1221
1352
  export * from "api/hubrise/model/account/HubriseAuthResource";
@@ -1254,7 +1385,22 @@ declare module "api/index" {
1254
1385
  export * from "api/hubrise/model/order/HubriseOrderOptionContract";
1255
1386
  export * from "api/hubrise/model/order/HubriseOrderPaymentContract";
1256
1387
  export * from "api/hubrise/model/order/HubriseOrderStatus";
1388
+ export * from "api/hubrise/model/order/HubriseServiceType";
1257
1389
  export * from "api/hubrise/model/user/HubriseUserContract";
1390
+ export * from "api/hubrise/model/order/HubriseOrderEditableItemContract";
1391
+ export * from "api/hubrise/model/order/HubriseOrderEditableOptionContract";
1392
+ export * from "api/hubrise/service/HubriseCatalogConverter";
1393
+ export * from "api/hubrise/service/HubriseCatalogConverterContract";
1394
+ export * from "api/hubrise/service/HubriseOrderConverter";
1395
+ export * from "api/hubrise/service/HubriseOrderConverterContract";
1396
+ export * from "api/hubrise/service/TotalHubriseCalculator";
1397
+ export * from "api/hubrise/service/TotalHubriseCalculatorContract";
1398
+ export * from "api/hubrise/util/HubrisePriceUtil";
1399
+ }
1400
+ declare module "api/index" {
1401
+ export * from "api/hubrise/service/HubriseApiContract";
1402
+ export * from "api/hubrise/service/HubriseApi";
1403
+ export * from "api/web";
1258
1404
  }
1259
1405
  declare module "constant/Path" {
1260
1406
  export class Path {
@@ -1434,6 +1580,35 @@ declare module "http/index" {
1434
1580
  export * from "http/ServerContract";
1435
1581
  export * from "http/HandlerController";
1436
1582
  }
1583
+ declare module "mockup/ApiMockup" {
1584
+ export class ApiMockup {
1585
+ static isDone(): boolean;
1586
+ static pending(): string;
1587
+ static reset(): void;
1588
+ }
1589
+ }
1590
+ declare module "mockup/HubriseApiMockup" {
1591
+ import { ApiMockup } from "mockup/ApiMockup";
1592
+ export class HubriseApiMockup extends ApiMockup {
1593
+ static readonly BASE_URL: string;
1594
+ static getUser(times?: number): void;
1595
+ static getLocations(times?: number): void;
1596
+ static createCustomer(times?: number): void;
1597
+ static getCustomer(times?: number): void;
1598
+ static getCustomers(times?: number): void;
1599
+ static getCustomerLists(times?: number): void;
1600
+ static createOrder(times?: number): void;
1601
+ static getOrder(times?: number, generateRandomId?: boolean): void;
1602
+ static setOrderStatus(times?: number): void;
1603
+ static getCatalog(times?: number): void;
1604
+ static getCatalogs(times?: number): void;
1605
+ static createWebhook(times?: number): void;
1606
+ }
1607
+ }
1608
+ declare module "mockup/index" {
1609
+ export * from "mockup/ApiMockup";
1610
+ export * from "mockup/HubriseApiMockup";
1611
+ }
1437
1612
  declare module "service/sender/SmsSenderServiceContract" {
1438
1613
  export interface SmsSenderServiceContract {
1439
1614
  send(senderName: string, message: string, phones: string[], isCommercial?: boolean, sendAt?: string): Promise<void>;
@@ -1927,24 +2102,6 @@ declare module "util/ExtractorUtil" {
1927
2102
  static phone(raw: string, locale: 'fr'): string;
1928
2103
  }
1929
2104
  }
1930
- declare module "util/MathUtil" {
1931
- export class MathUtil {
1932
- static sum(values: number[]): number;
1933
- static avg(values: number[]): number;
1934
- static applyVariation(value: number, variation: number): number;
1935
- static median(values: number[]): number;
1936
- static percentage(part: number, total: number): number;
1937
- static round(value: number, decimals: number): number;
1938
- static variation(originalValue: number, newValue: number): number;
1939
- }
1940
- }
1941
- declare module "util/ObjectUtil" {
1942
- export class ObjectUtil {
1943
- static compact(obj: any, options?: {
1944
- removeEmptyString?: boolean;
1945
- }): any;
1946
- }
1947
- }
1948
2105
  declare module "util/PriceUtil" {
1949
2106
  export class PriceUtil {
1950
2107
  private static readonly currencies;
@@ -1975,11 +2132,18 @@ declare module "@onylab/common-api" {
1975
2132
  import * as Constant from "constant/index";
1976
2133
  import * as Exception from "exception/index";
1977
2134
  import * as Http from "http/index";
2135
+ import * as Mockup from "mockup/index";
1978
2136
  import * as Service from "service/index";
1979
2137
  import * as Template from "templating/index";
1980
2138
  import * as Tool from "tool/index";
1981
2139
  import * as Util from "util/index";
1982
- export { Api, Constant, Exception, Http, Service, Template, Tool, Util };
2140
+ export { Api, Constant, Exception, Http, Mockup, Service, Template, Tool, Util };
2141
+ }
2142
+ declare module "web" {
2143
+ import * as Api from "api/web";
2144
+ import * as Exception from "exception/index";
2145
+ import * as Util from "util/index";
2146
+ export { Api, Exception, Util };
1983
2147
  }
1984
2148
  declare module "exception/ForbiddenException" {
1985
2149
  import { MainException } from "exception/MainException";