@findhotel/sapi 0.26.5 → 1.0.0-beta.0

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.
package/README.md CHANGED
@@ -242,8 +242,6 @@ const sapiClient = await sapi(profileKey, {
242
242
  currency: 'USD',
243
243
  countryCode: 'US',
244
244
  deviceType: 'mobile',
245
- includeLocalTaxes: true,
246
- includeTaxes: false,
247
245
  pageSize: 20,
248
246
  initWithAppConfig: {
249
247
  features: ['search', 'configs'],
@@ -259,6 +257,13 @@ const sapiClient = await sapi(profileKey, {
259
257
  onConfigReceived: (config) => {
260
258
  log('Config received', config)
261
259
  }
260
+ },
261
+ totalRateFormula: (rate) => {
262
+ let totalRate = rate.base
263
+ if (includeTaxes) totalRate += rate.taxes
264
+ if (includeHotelFees) totalRate += rate.hotelFees
265
+
266
+ return totalRate
262
267
  }
263
268
  })
264
269
  ```
@@ -266,20 +271,19 @@ const sapiClient = await sapi(profileKey, {
266
271
  ### Supported options
267
272
  <a id="client-options"></a>
268
273
 
269
- | name | required | type | default | description | example |
270
- | ---------------------- | -------- | ------------------------ | ------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------ |
271
- | `anonymousId` | yes | `string` | | Unique ID identifying users | `2d360284-577b-4a53-8b91-68f72b9227fa` |
272
- | `language` | no | `string` | `en` | 2-char language code | `en` |
273
- | `currency` | no | `string` | `USD` | 3-char uppercased ISO currency code | `USD` |
274
- | `countryCode` | no | `string` | `US` | 2-char uppercased ISO country code | `US` |
275
- | `deviceType` | yes | `string` | | `desktop` or `mobile` | `desktop` |
276
- | `includeLocalTaxes` | no | `boolean` | | Include or not local taxes based in the displayed price | `false` |
277
- | `includeTaxes` | no | `boolean` | | Include or not taxes based in the displayed price | `false` |
278
- | `pageSize` | no | `number` | `20` | Displayed page size | `20` |
279
- | `initWithAppConfig` | no | `AppConfig` | | External app config to override internal one | |
280
- | `algoliaClientOptions` | no | `AlgoliaSearchOptions` | | Algolia client options used for debugging and setting additional options like timeouts etc. | |
281
- | `variations` | no | `Record<string, string>` | | A/B test variations | `{'pp000004-tags2': 'b', 'pp000004-tags3': '1'}` |
282
- | `callbacks` | no | `Record<string, fnc>` | | Client callbasks | |
274
+ | name | required | type | default | description | example |
275
+ | ---------------------- | -------- | ------------------------ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
276
+ | `anonymousId` | yes | `string` | | Unique ID identifying users | `2d360284-577b-4a53-8b91-68f72b9227fa` |
277
+ | `language` | no | `string` | `en` | 2-char language code | `en` |
278
+ | `currency` | no | `string` | `USD` | 3-char uppercased ISO currency code | `USD` |
279
+ | `countryCode` | no | `string` | `US` | 2-char uppercased ISO country code | `US` |
280
+ | `deviceType` | yes | `string` | | `desktop` or `mobile` | `desktop` |
281
+ | `pageSize` | no | `number` | `20` | Displayed page size | `20` |
282
+ | `initWithAppConfig` | no | `AppConfig` | | External app config to override internal one | |
283
+ | `algoliaClientOptions` | no | `AlgoliaSearchOptions` | | Algolia client options used for debugging and setting additional options like timeouts etc. | |
284
+ | `variations` | no | `Record<string, string>` | | A/B test variations | `{'pp000004-tags2': 'b', 'pp000004-tags3': '1'}` |
285
+ | `callbacks` | no | `Record<string, fnc>` | | Client callbasks | |
286
+ | `totalRateFormula` | no | `function` | Total rate including taxes and fees | Formula to calculate total display rate based on tax display logic. Used for price filter and sort by price functionalities. | |
283
287
 
284
288
  ### Available client callbacks
285
289
  <a id="client-callbacks"></a>
@@ -333,7 +337,7 @@ const search = await sapiClient.search(searchParameters, callbacks)
333
337
  All parameters are optional.
334
338
 
335
339
  | name | type | description | example |
336
- |-----------------|--------------------------------|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
340
+ | --------------- | ------------------------------ | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------- |
337
341
  | `hotelId` | `string` | Hotel Id for hotel search. If present, takes precedence over `placeId`, `query` and `geolocation`. | `1371626` |
338
342
  | `placeId` | `string` | Place Id for place search. If present, takes precedence over `query` and `geolocation`. | `47319` |
339
343
  | `geolocation` | `{lat: number, lon: number}` | Geolocation query. If present, takes precedence over `query` | `{lat: 36.114303, lon: -115.178312}` |
@@ -387,7 +391,7 @@ time of callbacks executions. This means that each subsequent callback
387
391
  incrementally adds new properties and returns updated state. The data in
388
392
  the state can be repeated between different callbacks.
389
393
 
390
- 1. onStart()
394
+ 1. ### onStart()
391
395
 
392
396
  Runs at the beginning of the each new search.
393
397
 
@@ -399,7 +403,7 @@ the state can be repeated between different callbacks.
399
403
  hotels search has started, in Search SPA the event is
400
404
  [HotelsSearched](https://engdocs.fih.io/event-analytics/sources/#event-hotelssearched).
401
405
 
402
- 2. onAnchorReceived()
406
+ 2. ### onAnchorReceived()
403
407
 
404
408
  Runs when SAPI receives anchor and(?) anchor hotel (in case of hotel
405
409
  search)\
@@ -407,23 +411,23 @@ the state can be repeated between different callbacks.
407
411
  anchor hotel inside `response.hotelEntities` object (in
408
412
  case of hotel search).
409
413
 
410
- 3. onHotelsReceived()
414
+ 3. ### onHotelsReceived()
411
415
 
412
416
  Runs when SAPI receives static search results\
413
417
  Returns static data about hotels inside
414
418
  `response.hotelEntities` object as well as appropriate
415
419
  hotel sort order in `response.hotelIds` array (sorted
416
- according HSO).
420
+ according to HSO).
417
421
 
418
- 4. onOffersReceived()
422
+ 4. ### onOffersReceived()
419
423
 
420
424
  Runs when SAPI receives a bunch of offers\
421
425
  Returns hotel's offers (incomplete response) in
422
426
  `response.hotelOfferEntities` object as well as updated
423
427
  hotel sort order in `response.hotelIds` array (sorted
424
- according HSO and taking into account the real offers data)
428
+ according to HSO and taking into account the real offers data)
425
429
 
426
- 5. onComplete()
430
+ 5. ### onComplete()
427
431
 
428
432
  Runs when current search is complete and all offers are retrieved\
429
433
  Return complete SAPI seearch response.
@@ -493,51 +497,47 @@ so there is a simplified example:
493
497
  "hotelOfferEntities": {
494
498
  "1041597": {
495
499
  "anchorPriceRateBreakdown": {
496
- "baseRate": 244.6021305,
497
- "calculatedTotalRate": 288.13897963499994,
498
- "localTaxes": 23.122149135,
499
- "nightlyRate": 288.13897963499994,
500
+ "base": 244.6021305,
501
+ "hotelFees": 23.122149135,
500
502
  "taxes": 20.4147
501
503
  },
502
504
  "availableOffersCount": 23,
503
- "fetchedAllOffers": false,
504
- "hasMoreOffers": true,
505
505
  "id": "1041597",
506
506
  "offers": [
507
507
  {
508
- "additionalProviderParams": {
509
- "feedId": "1524856"
510
- },
511
- "availableRooms": 10,
512
- "bookURI": "https://r.findhotel.net?...",
513
- "calculatedTotalRate": 110.72,
514
- "canPayLater": true,
515
- "cug": null,
508
+ "id": "o5vFF4-wmvcc",
516
509
  "currency": "EUR",
517
- "hasAnchorPrice": true,
518
- "hasFreeCancellation": true,
519
- "id": "oO8jdRHaO8y0",
520
- "isAnchorPriceOffer": false,
521
- "isCheapest": false,
522
- "isTopOffer": true,
523
- "meals": ["breakfast"],
524
- "nightlyRate": 110.72,
510
+ "availableRooms": 6,
511
+ "url": "https://r.findhotel.net?...",
512
+ "rate": {
513
+ "base": 197.17,
514
+ "taxes": 17.75,
515
+ "hotelFees": 31.8
516
+ },
517
+ "accessTier": "",
525
518
  "providerCode": "BKS",
526
- "proxyProviderCode": "BKS",
527
- "rateBreakdown": {
528
- "baseRate": 90.28,
529
- "localTaxes": 12.32,
530
- "taxes": 8.12
519
+ "intermediaryProvider": "BKS",
520
+ "roomName": "Standard Twin Room",
521
+ "package": {
522
+ "amenities": [
523
+ "breakfast"
524
+ ],
525
+ "canPayLater": false
531
526
  },
532
- "roomID": "moc_08Ap8BcbIDg",
533
- "roomName": "Standard Double Room",
534
- "tags": ["top_offer"]
527
+ "cancellationPenalties": [],
528
+ "tags": [
529
+ "top_offer"
530
+ ],
531
+ "metadata": {
532
+ "feedID": ""
533
+ }
535
534
  }
536
535
  ],
537
- "topOfferData": {
538
- "anchorPrice": 288.13897963499994,
539
- "anchorPriceNightly": 288.13897963499994,
540
- "offerIndexes": [0, 1, 2, 3]
536
+ "discount": {
537
+ "discountProvider": "FHT",
538
+ "hasDiscountProvider": true,
539
+ "hasParityProvider": true,
540
+ "modifier": "b"
541
541
  }
542
542
  }
543
543
  },
@@ -651,6 +651,7 @@ const rooms = await sapiClient.rooms({
651
651
  | `clickedOfferTaxes` | `number` | Taxes value of the offer which user clicked on SRP | no | `10` |
652
652
  | `clickedOfferHotelFees` | `number` | Hotel fees value of the offer which the user clicked on SRP | no | `5` |
653
653
  | `preHeat` | `number` | Enables pre-heat mode | no | `1` |
654
+ | `trafficSource` | `string` | Visitor\'s traffic source. Opaque value that will be passed to tracking systems | no | `gha-vr` |
654
655
 
655
656
  ### Response
656
657
  <a id="rooms-response"></a>
@@ -869,17 +870,17 @@ const callbacks = {
869
870
  }
870
871
  ```
871
872
 
872
- 1. onStart()
873
+ 1. ### onStart()
873
874
 
874
875
  Runs at the beginning of the each new offers request.\
875
876
  Returns adjusted and validated offers request parameters.
876
877
 
877
- 2. onOffersReceived()
878
+ 2. ### onOffersReceived()
878
879
 
879
880
  Runs on every received batch of offers.\
880
881
  Returns hotel\'s offers (incomplete response).
881
882
 
882
- 3. onComplete()
883
+ 3. ### onComplete()
883
884
 
884
885
  Runs after offers request complete.\
885
886
  Returns hotel\'s offers (complete response).
@@ -901,51 +902,47 @@ const parameters = {
901
902
  ```js
902
903
  {
903
904
  "anchorPriceRateBreakdown": {
904
- "baseRate": 113.21,
905
- "localTaxes": 8.64,
906
- "taxes": 10.19,
907
- "calculatedTotalRate": 132.04,
908
- "nightlyRate": 132.04
905
+ "base": 244.6021305,
906
+ "hotelFees": 23.122149135,
907
+ "taxes": 20.4147
909
908
  },
910
- "availableOffersCount": 19,
911
- "fetchedAllOffers": false,
912
- "hasMoreOffers": true,
913
- "id": "1926746",
909
+ "availableOffersCount": 23,
910
+ "id": "1041597",
914
911
  "offers": [
915
912
  {
916
- "additionalProviderParams": {
917
- "feedId": "1524856"
918
- },
919
- "availableRooms": 10,
920
- "bookURI": "https://r.findhotel.net?...",
921
- "calculatedTotalRate": 110.72,
922
- "canPayLater": true,
923
- "cug": null,
913
+ "id": "o5vFF4-wmvcc",
924
914
  "currency": "EUR",
925
- "hasAnchorPrice": true,
926
- "hasFreeCancellation": true,
927
- "id": "oO8jdRHaO8y0",
928
- "isAnchorPriceOffer": false,
929
- "isCheapest": false,
930
- "isTopOffer": true,
931
- "meals": ["breakfast"],
932
- "nightlyRate": 110.72,
915
+ "availableRooms": 6,
916
+ "url": "https://r.findhotel.net?...",
917
+ "rate": {
918
+ "base": 197.17,
919
+ "taxes": 17.75,
920
+ "hotelFees": 31.8
921
+ },
922
+ "accessTier": "",
933
923
  "providerCode": "BKS",
934
- "proxyProviderCode": "BKS",
935
- "rateBreakdown": {
936
- "baseRate": 90.28,
937
- "localTaxes": 12.32,
938
- "taxes": 8.12
924
+ "intermediaryProvider": "BKS",
925
+ "roomName": "Standard Twin Room",
926
+ "package": {
927
+ "amenities": [
928
+ "breakfast"
929
+ ],
930
+ "canPayLater": false
939
931
  },
940
- "roomID": "moc_08Ap8BcbIDg",
941
- "roomName": "Standard Double Room",
942
- "tags": ["top_offer"]
932
+ "cancellationPenalties": [],
933
+ "tags": [
934
+ "top_offer"
935
+ ],
936
+ "metadata": {
937
+ "feedID": ""
938
+ }
943
939
  }
944
940
  ],
945
- "topOfferData": {
946
- "anchorPrice": 132.04,
947
- "anchorPriceNightly": 132.04,
948
- "offerIndexes": [0, 1, 2, 3]
941
+ "discount": {
942
+ "discountProvider": "FHT",
943
+ "hasDiscountProvider": true,
944
+ "hasParityProvider": true,
945
+ "modifier": "b"
949
946
  }
950
947
  }
951
948
  ```