@sabstravtech/obtservices 0.0.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.
Files changed (420) hide show
  1. package/.editorconfig +13 -0
  2. package/.gitmodules +0 -0
  3. package/.vscode/settings.json +4 -0
  4. package/README.md +27 -0
  5. package/angular.json +45 -0
  6. package/audit.config.json +6 -0
  7. package/codegen.yml +18 -0
  8. package/ng-package.json +7 -0
  9. package/package.json +84 -0
  10. package/projects/obtservices/README.md +24 -0
  11. package/projects/obtservices/angular/package.json +3 -0
  12. package/projects/obtservices/angular/src/classes.ts +3 -0
  13. package/projects/obtservices/angular/src/components/basket-panel.ts +139 -0
  14. package/projects/obtservices/angular/src/components/with-component.ts +40 -0
  15. package/projects/obtservices/angular/src/components.ts +2 -0
  16. package/projects/obtservices/angular/src/data.ts +5 -0
  17. package/projects/obtservices/angular/src/fetchers.ts +32 -0
  18. package/projects/obtservices/angular/src/lib/vendor/classes/environment.ts +5 -0
  19. package/projects/obtservices/angular/src/lib/vendor/classes/event-messenager.ts +11 -0
  20. package/projects/obtservices/angular/src/lib/vendor/classes/helpers.ts +87 -0
  21. package/projects/obtservices/angular/src/lib/vendor/data/airports.data.json +5508 -0
  22. package/projects/obtservices/angular/src/lib/vendor/data/animations.ts +38 -0
  23. package/projects/obtservices/angular/src/lib/vendor/data/booking-expected-responses.json +100 -0
  24. package/projects/obtservices/angular/src/lib/vendor/data/cities.data.json +31499 -0
  25. package/projects/obtservices/angular/src/lib/vendor/data/countries.json +1212 -0
  26. package/projects/obtservices/angular/src/lib/vendor/data/flight-booking.data.json +136 -0
  27. package/projects/obtservices/angular/src/lib/vendor/data/postcodes1.json +194 -0
  28. package/projects/obtservices/angular/src/lib/vendor/data/rail_addresses.json +2524 -0
  29. package/projects/obtservices/angular/src/lib/vendor/fetchers/basket-fetcher.ts +14 -0
  30. package/projects/obtservices/angular/src/lib/vendor/fetchers/cabhire-quote-fetcher.ts +15 -0
  31. package/projects/obtservices/angular/src/lib/vendor/fetchers/carhire-availability-detail.fetcher.ts +17 -0
  32. package/projects/obtservices/angular/src/lib/vendor/fetchers/carhire-quote-fetcher.ts +16 -0
  33. package/projects/obtservices/angular/src/lib/vendor/fetchers/conferma-office-names.fetcher.ts +16 -0
  34. package/projects/obtservices/angular/src/lib/vendor/fetchers/conferma-quicklist.fetcher.ts +16 -0
  35. package/projects/obtservices/angular/src/lib/vendor/fetchers/eurostar-quote.fetcher.ts +16 -0
  36. package/projects/obtservices/angular/src/lib/vendor/fetchers/flight-quote.fetcher.ts +16 -0
  37. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-rail-cards.fetcher.ts +16 -0
  38. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-rail-station.fetcher.ts +16 -0
  39. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-risk-alerts.fetcher.ts +18 -0
  40. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-user-company-offices.fetcher.ts +16 -0
  41. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-user-current-carbon-allowance.fetcher.ts +16 -0
  42. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-user-recent-searches.fetcher.ts +16 -0
  43. package/projects/obtservices/angular/src/lib/vendor/fetchers/get-users-baskets-fetcher.ts +16 -0
  44. package/projects/obtservices/angular/src/lib/vendor/fetchers/getMiAutoSugestions.fetcher.ts +16 -0
  45. package/projects/obtservices/angular/src/lib/vendor/fetchers/hotel-avaliability-fetcher.ts +17 -0
  46. package/projects/obtservices/angular/src/lib/vendor/fetchers/hotel-quote-fetcher.ts +16 -0
  47. package/projects/obtservices/angular/src/lib/vendor/fetchers/irl-quote-fetcher.ts +16 -0
  48. package/projects/obtservices/angular/src/lib/vendor/fetchers/lounge-quote.fetcher.ts +16 -0
  49. package/projects/obtservices/angular/src/lib/vendor/fetchers/parking-quote-fetcher.ts +16 -0
  50. package/projects/obtservices/angular/src/lib/vendor/fetchers/rail-quote-fetcher.ts +16 -0
  51. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-airlines-fetcher.ts +14 -0
  52. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-airports-fetcher.ts +14 -0
  53. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-cities.fetcher.ts +16 -0
  54. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-conferma-cities.fetcher.ts +14 -0
  55. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-depots.fetcher.ts +18 -0
  56. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-hotel-chains.fetcher.ts +16 -0
  57. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-postcodes.fetcher.ts +16 -0
  58. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-rail-stations.fetcher.ts +16 -0
  59. package/projects/obtservices/angular/src/lib/vendor/fetchers/search-users-can-book-for-fetcher.ts +16 -0
  60. package/projects/obtservices/angular/src/lib/vendor/fetchers/user-addresses.fetcher.ts +16 -0
  61. package/projects/obtservices/angular/src/lib/vendor/fetchers/user-fetcher.ts +14 -0
  62. package/projects/obtservices/angular/src/lib/vendor/fetchers/user-message.fetcher.ts +16 -0
  63. package/projects/obtservices/angular/src/lib/vendor/fetchers/user-products-fetcher.ts +16 -0
  64. package/projects/obtservices/angular/src/lib/vendor/fetchers/user-ui-configs-fetcher.ts +16 -0
  65. package/projects/obtservices/angular/src/lib/vendor/services/enterprise-basket.service.ts +133 -0
  66. package/projects/obtservices/angular/src/lib/vendor/services/hotel-avallibility.service.ts +19 -0
  67. package/projects/obtservices/angular/src/lib/vendor/services/http-call.service.ts +252 -0
  68. package/projects/obtservices/angular/src/lib/vendor/services/logon.service.ts +40 -0
  69. package/projects/obtservices/angular/src/lib/vendor/services/modal-opener.service.ts +9 -0
  70. package/projects/obtservices/angular/src/lib/vendor/services/my-bookings.service.ts +21 -0
  71. package/projects/obtservices/angular/src/lib/vendor/services/route-happy.service.ts +11 -0
  72. package/projects/obtservices/angular/src/lib/vendor/services/search.service.ts +213 -0
  73. package/projects/obtservices/angular/src/lib/vendor/services/storage.service.ts +82 -0
  74. package/projects/obtservices/angular/src/lib/vendor/services/user.service.ts +36 -0
  75. package/projects/obtservices/angular/src/lib/vendor/services/webtoken.service.ts +62 -0
  76. package/projects/obtservices/angular/src/lib/vendor/testers/postcode-validate.tester.ts +14 -0
  77. package/projects/obtservices/angular/src/lib/vendor/testers/validate-mi-free-value.tester.ts +14 -0
  78. package/projects/obtservices/angular/src/lib/vendor/types/graphql.angular.types.ts +11081 -0
  79. package/projects/obtservices/angular/src/lib/vendor/updaters/accept-new-price.updater.ts +14 -0
  80. package/projects/obtservices/angular/src/lib/vendor/updaters/add-item-to-basket.updater.ts +14 -0
  81. package/projects/obtservices/angular/src/lib/vendor/updaters/addUserToBasketItem.ts +14 -0
  82. package/projects/obtservices/angular/src/lib/vendor/updaters/book-basket-updater.ts +14 -0
  83. package/projects/obtservices/angular/src/lib/vendor/updaters/create-basket-updater.ts +14 -0
  84. package/projects/obtservices/angular/src/lib/vendor/updaters/move-basket-item-to-basket.ts +14 -0
  85. package/projects/obtservices/angular/src/lib/vendor/updaters/remove-basket-updater.ts +14 -0
  86. package/projects/obtservices/angular/src/lib/vendor/updaters/remove-item-from-basket.updater.ts +14 -0
  87. package/projects/obtservices/angular/src/lib/vendor/updaters/remove-recent-search.updater.ts +14 -0
  88. package/projects/obtservices/angular/src/lib/vendor/updaters/remove-user-address.updater.ts +14 -0
  89. package/projects/obtservices/angular/src/lib/vendor/updaters/revalidate-basket-updater.ts +14 -0
  90. package/projects/obtservices/angular/src/lib/vendor/updaters/save-recent-search.updater.ts +14 -0
  91. package/projects/obtservices/angular/src/lib/vendor/updaters/save-user-address.updater.ts +11 -0
  92. package/projects/obtservices/angular/src/lib/vendor/updaters/send-basket-for-approval.updater.ts +14 -0
  93. package/projects/obtservices/angular/src/lib/vendor/updaters/set-basket-item-lead-passenger.updater.ts +14 -0
  94. package/projects/obtservices/angular/src/lib/vendor/updaters/set-basket-item-mi-group.ts +14 -0
  95. package/projects/obtservices/angular/src/lib/vendor/updaters/set-basket-item-mi-value-updater.ts +15 -0
  96. package/projects/obtservices/angular/src/lib/vendor/updaters/set-payment-option.updater.ts +15 -0
  97. package/projects/obtservices/angular/src/lib/vendor/updaters/update-basket-notes-updater.ts +14 -0
  98. package/projects/obtservices/angular/src/lib/vendor/updaters/update-basket-title-updater.ts +14 -0
  99. package/projects/obtservices/angular/src/obtservices.module.ts +131 -0
  100. package/projects/obtservices/angular/src/public_api.ts +8 -0
  101. package/projects/obtservices/angular/src/services.ts +11 -0
  102. package/projects/obtservices/angular/src/testers.ts +2 -0
  103. package/projects/obtservices/angular/src/types.ts +1 -0
  104. package/projects/obtservices/angular/src/updaters.ts +13 -0
  105. package/projects/obtservices/base/package.json +3 -0
  106. package/projects/obtservices/base/src/classes.ts +27 -0
  107. package/projects/obtservices/base/src/custom.d.ts +3 -0
  108. package/projects/obtservices/base/src/fetchers.ts +36 -0
  109. package/projects/obtservices/base/src/interfaces.ts +29 -0
  110. package/projects/obtservices/base/src/lib/vendor/classes/base-enterprise.ts +126 -0
  111. package/projects/obtservices/base/src/lib/vendor/classes/base-network-call.ts +40 -0
  112. package/projects/obtservices/base/src/lib/vendor/classes/basket-info-mi-details.impl.ts +68 -0
  113. package/projects/obtservices/base/src/lib/vendor/classes/bookable-basket.ts +343 -0
  114. package/projects/obtservices/base/src/lib/vendor/classes/cabhire-enterprise-search.ts +907 -0
  115. package/projects/obtservices/base/src/lib/vendor/classes/carhire-enterprise-search.ts +1597 -0
  116. package/projects/obtservices/base/src/lib/vendor/classes/empty-enterprise-search.ts +75 -0
  117. package/projects/obtservices/base/src/lib/vendor/classes/enviroment.ts +25 -0
  118. package/projects/obtservices/base/src/lib/vendor/classes/eurostar-enterprise-search.ts +2126 -0
  119. package/projects/obtservices/base/src/lib/vendor/classes/eurostar-search-type.enum.ts +4 -0
  120. package/projects/obtservices/base/src/lib/vendor/classes/event-messenager.ts +23 -0
  121. package/projects/obtservices/base/src/lib/vendor/classes/flight-enterprise-search.ts +2399 -0
  122. package/projects/obtservices/base/src/lib/vendor/classes/flight-search-type.enum.ts +5 -0
  123. package/projects/obtservices/base/src/lib/vendor/classes/helpers.ts +1233 -0
  124. package/projects/obtservices/base/src/lib/vendor/classes/hotel-enterprise-search.ts +1370 -0
  125. package/projects/obtservices/base/src/lib/vendor/classes/irl-enterprise-search.ts +1380 -0
  126. package/projects/obtservices/base/src/lib/vendor/classes/limited-cache.class.ts +70 -0
  127. package/projects/obtservices/base/src/lib/vendor/classes/lounges-enterprise-search.ts +444 -0
  128. package/projects/obtservices/base/src/lib/vendor/classes/management-info-and-valid.ts +268 -0
  129. package/projects/obtservices/base/src/lib/vendor/classes/modal-types.enum.ts +28 -0
  130. package/projects/obtservices/base/src/lib/vendor/classes/parking-enterprise-search.ts +541 -0
  131. package/projects/obtservices/base/src/lib/vendor/classes/rail-direction.enum.ts +4 -0
  132. package/projects/obtservices/base/src/lib/vendor/classes/rail-enterprise-search.ts +1751 -0
  133. package/projects/obtservices/base/src/lib/vendor/classes/routehappy-request.ts +146 -0
  134. package/projects/obtservices/base/src/lib/vendor/classes/routehappy-response.ts +128 -0
  135. package/projects/obtservices/base/src/lib/vendor/classes/supplementary-booking-info-impl.ts +375 -0
  136. package/projects/obtservices/base/src/lib/vendor/classes/user-favourite.enum.ts +12 -0
  137. package/projects/obtservices/base/src/lib/vendor/classes/validator.checker.ts +7 -0
  138. package/projects/obtservices/base/src/lib/vendor/data/airports.data.json +5508 -0
  139. package/projects/obtservices/base/src/lib/vendor/data/booking-expected-responses.json +100 -0
  140. package/projects/obtservices/base/src/lib/vendor/data/cities.data.json +31499 -0
  141. package/projects/obtservices/base/src/lib/vendor/data/countries.json +1212 -0
  142. package/projects/obtservices/base/src/lib/vendor/data/euro-stations.json +30 -0
  143. package/projects/obtservices/base/src/lib/vendor/data/flight-booking.data.json +136 -0
  144. package/projects/obtservices/base/src/lib/vendor/data/postcodes1.json +194 -0
  145. package/projects/obtservices/base/src/lib/vendor/data/rail_addresses.json +2524 -0
  146. package/projects/obtservices/base/src/lib/vendor/fetchers/basket-fetcher.ts +29 -0
  147. package/projects/obtservices/base/src/lib/vendor/fetchers/cabhire-quote-fetcher.ts +34 -0
  148. package/projects/obtservices/base/src/lib/vendor/fetchers/carhire-availability-detail.fetcher.ts +35 -0
  149. package/projects/obtservices/base/src/lib/vendor/fetchers/carhire-quote-fetcher.ts +34 -0
  150. package/projects/obtservices/base/src/lib/vendor/fetchers/conferma-office-names.fetcher.ts +34 -0
  151. package/projects/obtservices/base/src/lib/vendor/fetchers/conferma-quicklist.fetcher.ts +35 -0
  152. package/projects/obtservices/base/src/lib/vendor/fetchers/eurostar-quote.fetcher.ts +35 -0
  153. package/projects/obtservices/base/src/lib/vendor/fetchers/flight-quote.fetcher.ts +35 -0
  154. package/projects/obtservices/base/src/lib/vendor/fetchers/get-rail-cards.fetcher.ts +35 -0
  155. package/projects/obtservices/base/src/lib/vendor/fetchers/get-rail-station.fetcher.ts +35 -0
  156. package/projects/obtservices/base/src/lib/vendor/fetchers/get-risk-alerts.fetcher.ts +35 -0
  157. package/projects/obtservices/base/src/lib/vendor/fetchers/get-user-company-offices.fetcher.ts +34 -0
  158. package/projects/obtservices/base/src/lib/vendor/fetchers/get-user-current-carbon-allowance.fetcher.ts +35 -0
  159. package/projects/obtservices/base/src/lib/vendor/fetchers/get-user-recent-searches.fetcher.ts +36 -0
  160. package/projects/obtservices/base/src/lib/vendor/fetchers/get-users-baskets-fetcher.ts +33 -0
  161. package/projects/obtservices/base/src/lib/vendor/fetchers/getMiAutoSugestions.fetcher.ts +35 -0
  162. package/projects/obtservices/base/src/lib/vendor/fetchers/hotel-avaliability-fetcher.ts +53 -0
  163. package/projects/obtservices/base/src/lib/vendor/fetchers/hotel-quote-fetcher.ts +35 -0
  164. package/projects/obtservices/base/src/lib/vendor/fetchers/irl-quote-fetcher.ts +34 -0
  165. package/projects/obtservices/base/src/lib/vendor/fetchers/list-fetchable-enterprise.ts +59 -0
  166. package/projects/obtservices/base/src/lib/vendor/fetchers/lounge-quote.fetcher.ts +34 -0
  167. package/projects/obtservices/base/src/lib/vendor/fetchers/object-fetchable-enterprise.ts +20 -0
  168. package/projects/obtservices/base/src/lib/vendor/fetchers/parking-quote-fetcher.ts +34 -0
  169. package/projects/obtservices/base/src/lib/vendor/fetchers/rail-quote-fetcher.ts +34 -0
  170. package/projects/obtservices/base/src/lib/vendor/fetchers/search-airlines.fetcher.ts +30 -0
  171. package/projects/obtservices/base/src/lib/vendor/fetchers/search-airports-fetcher.ts +29 -0
  172. package/projects/obtservices/base/src/lib/vendor/fetchers/search-cities.fetcher.ts +34 -0
  173. package/projects/obtservices/base/src/lib/vendor/fetchers/search-conferma-cities.fetcher.ts +32 -0
  174. package/projects/obtservices/base/src/lib/vendor/fetchers/search-depots.fetcher.ts +34 -0
  175. package/projects/obtservices/base/src/lib/vendor/fetchers/search-hotel-chains.fetcher.ts +34 -0
  176. package/projects/obtservices/base/src/lib/vendor/fetchers/search-postcodes.fetcher.ts +37 -0
  177. package/projects/obtservices/base/src/lib/vendor/fetchers/search-rail-stations.fetcher.ts +35 -0
  178. package/projects/obtservices/base/src/lib/vendor/fetchers/search-users-can-book-for-fetcher.ts +35 -0
  179. package/projects/obtservices/base/src/lib/vendor/fetchers/user-addresses.fetcher.ts +34 -0
  180. package/projects/obtservices/base/src/lib/vendor/fetchers/user-fetcher.ts +27 -0
  181. package/projects/obtservices/base/src/lib/vendor/fetchers/user-message.fetcher.ts +34 -0
  182. package/projects/obtservices/base/src/lib/vendor/fetchers/user-products-fetcher.ts +35 -0
  183. package/projects/obtservices/base/src/lib/vendor/fetchers/user-ui-configs-fetcher.ts +35 -0
  184. package/projects/obtservices/base/src/lib/vendor/interfaces/Icabhire-enterprise-search.ts +174 -0
  185. package/projects/obtservices/base/src/lib/vendor/interfaces/Icarhire-enterprise-search.ts +143 -0
  186. package/projects/obtservices/base/src/lib/vendor/interfaces/Ienterprise-basket.service.ts +127 -0
  187. package/projects/obtservices/base/src/lib/vendor/interfaces/Ieurostar-enterprise-search.ts +197 -0
  188. package/projects/obtservices/base/src/lib/vendor/interfaces/Iflight-enterprise-search.ts +196 -0
  189. package/projects/obtservices/base/src/lib/vendor/interfaces/Ihotel-enterprise-search.ts +219 -0
  190. package/projects/obtservices/base/src/lib/vendor/interfaces/Iirl-enterprise-search.ts +135 -0
  191. package/projects/obtservices/base/src/lib/vendor/interfaces/Ilounges-enterprise-search.ts +58 -0
  192. package/projects/obtservices/base/src/lib/vendor/interfaces/Imybookings.service.ts +27 -0
  193. package/projects/obtservices/base/src/lib/vendor/interfaces/Iparking-enterprise-search.ts +72 -0
  194. package/projects/obtservices/base/src/lib/vendor/interfaces/Irail-enterprise-search.ts +161 -0
  195. package/projects/obtservices/base/src/lib/vendor/interfaces/Isearch.service.ts +178 -0
  196. package/projects/obtservices/base/src/lib/vendor/interfaces/Isupplementary-booking-info-impl.ts +63 -0
  197. package/projects/obtservices/base/src/lib/vendor/interfaces/Iuser.service.ts +87 -0
  198. package/projects/obtservices/base/src/lib/vendor/interfaces/car-hire-classes.interface.ts +8 -0
  199. package/projects/obtservices/base/src/lib/vendor/interfaces/car-hire-filters.interface.ts +11 -0
  200. package/projects/obtservices/base/src/lib/vendor/interfaces/car-hire-sort.interface.ts +4 -0
  201. package/projects/obtservices/base/src/lib/vendor/interfaces/cheapest-price.ts +4 -0
  202. package/projects/obtservices/base/src/lib/vendor/interfaces/code-name.ts +4 -0
  203. package/projects/obtservices/base/src/lib/vendor/interfaces/flight-filters.interface.ts +41 -0
  204. package/projects/obtservices/base/src/lib/vendor/interfaces/flight-multi-destination.interface.ts +8 -0
  205. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-airport-express-stations.interface.ts +4 -0
  206. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-basket-item.interface.ts +79 -0
  207. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-journey-leg.interface.ts +6 -0
  208. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-recent-search-args.interface.ts +20 -0
  209. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-selected-ticket.interface.ts +11 -0
  210. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-ticket-group.interface.ts +29 -0
  211. package/projects/obtservices/base/src/lib/vendor/interfaces/rail-ticket-groups.interface.ts +5 -0
  212. package/projects/obtservices/base/src/lib/vendor/interfaces/search-objects.interface.ts +17 -0
  213. package/projects/obtservices/base/src/lib/vendor/interfaces/select-filter.interface.ts +5 -0
  214. package/projects/obtservices/base/src/lib/vendor/interfaces/user.data.ts +22 -0
  215. package/projects/obtservices/base/src/lib/vendor/interfaces/value-display.ts +4 -0
  216. package/projects/obtservices/base/src/lib/vendor/models/login.model.ts +97 -0
  217. package/projects/obtservices/base/src/lib/vendor/models/regexp.model.ts +13 -0
  218. package/projects/obtservices/base/src/lib/vendor/models/traveller.object.ts +61 -0
  219. package/projects/obtservices/base/src/lib/vendor/services/enterprise-basket.service.ts +1150 -0
  220. package/projects/obtservices/base/src/lib/vendor/services/hotel-avallibility.service.ts +251 -0
  221. package/projects/obtservices/base/src/lib/vendor/services/http-call.service.ts +57 -0
  222. package/projects/obtservices/base/src/lib/vendor/services/logon.service.ts +245 -0
  223. package/projects/obtservices/base/src/lib/vendor/services/modal-opener.service.ts +30 -0
  224. package/projects/obtservices/base/src/lib/vendor/services/my-bookings.service.ts +184 -0
  225. package/projects/obtservices/base/src/lib/vendor/services/routehappy.service.ts +275 -0
  226. package/projects/obtservices/base/src/lib/vendor/services/search.service.ts +2026 -0
  227. package/projects/obtservices/base/src/lib/vendor/services/storage.service.ts +15 -0
  228. package/projects/obtservices/base/src/lib/vendor/services/url.service.ts +12 -0
  229. package/projects/obtservices/base/src/lib/vendor/services/user.service.ts +354 -0
  230. package/projects/obtservices/base/src/lib/vendor/services/webtoken.service.ts +66 -0
  231. package/projects/obtservices/base/src/lib/vendor/testers/base.tester.ts +18 -0
  232. package/projects/obtservices/base/src/lib/vendor/testers/postcode-validate.tester.ts +24 -0
  233. package/projects/obtservices/base/src/lib/vendor/testers/validate-mi-free-value.tester.ts +23 -0
  234. package/projects/obtservices/base/src/lib/vendor/types/graphql.types.ts +6184 -0
  235. package/projects/obtservices/base/src/lib/vendor/types/types.ts +630 -0
  236. package/projects/obtservices/base/src/lib/vendor/updaters/accept-new-price.updater.ts +31 -0
  237. package/projects/obtservices/base/src/lib/vendor/updaters/add-item-to-basket.updater.ts +29 -0
  238. package/projects/obtservices/base/src/lib/vendor/updaters/addUserToBasketItem.ts +30 -0
  239. package/projects/obtservices/base/src/lib/vendor/updaters/book-basket-updater.ts +28 -0
  240. package/projects/obtservices/base/src/lib/vendor/updaters/create-basket-updater.ts +29 -0
  241. package/projects/obtservices/base/src/lib/vendor/updaters/move-basket-item-to-basket.ts +30 -0
  242. package/projects/obtservices/base/src/lib/vendor/updaters/object-updater-enterprise.ts +20 -0
  243. package/projects/obtservices/base/src/lib/vendor/updaters/remove-basket-updater.ts +29 -0
  244. package/projects/obtservices/base/src/lib/vendor/updaters/remove-item-from-basket.updater.ts +28 -0
  245. package/projects/obtservices/base/src/lib/vendor/updaters/remove-recent-search-updater.ts +29 -0
  246. package/projects/obtservices/base/src/lib/vendor/updaters/remove-user-address-updater.ts +29 -0
  247. package/projects/obtservices/base/src/lib/vendor/updaters/revalidate-basket-updater.ts +29 -0
  248. package/projects/obtservices/base/src/lib/vendor/updaters/save-recent-search-updater.ts +30 -0
  249. package/projects/obtservices/base/src/lib/vendor/updaters/save-user-address.updater.ts +30 -0
  250. package/projects/obtservices/base/src/lib/vendor/updaters/send-basket-for-approval.updater.ts +31 -0
  251. package/projects/obtservices/base/src/lib/vendor/updaters/set-basket-item-lead-passenger.updater.ts +30 -0
  252. package/projects/obtservices/base/src/lib/vendor/updaters/set-basket-item-mi-group.ts +32 -0
  253. package/projects/obtservices/base/src/lib/vendor/updaters/set-basket-item-mi-value-updater.ts +30 -0
  254. package/projects/obtservices/base/src/lib/vendor/updaters/set-basket-item-paymenr-option.updater.ts +28 -0
  255. package/projects/obtservices/base/src/lib/vendor/updaters/update-basket-notes-updater.ts +30 -0
  256. package/projects/obtservices/base/src/lib/vendor/updaters/update-basket-title-updater.ts +30 -0
  257. package/projects/obtservices/base/src/models.ts +3 -0
  258. package/projects/obtservices/base/src/public_api.ts +8 -0
  259. package/projects/obtservices/base/src/services.ts +12 -0
  260. package/projects/obtservices/base/src/testers.ts +2 -0
  261. package/projects/obtservices/base/src/types.ts +1 -0
  262. package/projects/obtservices/base/src/updaters.ts +20 -0
  263. package/projects/obtservices/graphQL/autogenerated/index.js +2 -0
  264. package/projects/obtservices/graphQL/autogenerated/mutations/acceptNewPrice.gql +1580 -0
  265. package/projects/obtservices/graphQL/autogenerated/mutations/addItemToBasket.gql +1580 -0
  266. package/projects/obtservices/graphQL/autogenerated/mutations/addUsersToBasketItem.gql +1580 -0
  267. package/projects/obtservices/graphQL/autogenerated/mutations/bookBasket.gql +1580 -0
  268. package/projects/obtservices/graphQL/autogenerated/mutations/cancelBooking.gql +6 -0
  269. package/projects/obtservices/graphQL/autogenerated/mutations/confermaCreateCard.gql +23 -0
  270. package/projects/obtservices/graphQL/autogenerated/mutations/confermaDeleteCard.gql +3 -0
  271. package/projects/obtservices/graphQL/autogenerated/mutations/createBasket.gql +1580 -0
  272. package/projects/obtservices/graphQL/autogenerated/mutations/deleteBasket.gql +3 -0
  273. package/projects/obtservices/graphQL/autogenerated/mutations/deleteFavouriteSearch.gql +3 -0
  274. package/projects/obtservices/graphQL/autogenerated/mutations/deleteRecentSearch.gql +3 -0
  275. package/projects/obtservices/graphQL/autogenerated/mutations/deleteUserAddress.gql +3 -0
  276. package/projects/obtservices/graphQL/autogenerated/mutations/index.js +36 -0
  277. package/projects/obtservices/graphQL/autogenerated/mutations/moveItemToADifferentBasket.gql +1580 -0
  278. package/projects/obtservices/graphQL/autogenerated/mutations/removeItemFromBasket.gql +1580 -0
  279. package/projects/obtservices/graphQL/autogenerated/mutations/removeItemsFromBasket.gql +1580 -0
  280. package/projects/obtservices/graphQL/autogenerated/mutations/removeUserFromBasketItem.gql +1580 -0
  281. package/projects/obtservices/graphQL/autogenerated/mutations/reopenBasket.gql +1580 -0
  282. package/projects/obtservices/graphQL/autogenerated/mutations/revalidateBasket.gql +1580 -0
  283. package/projects/obtservices/graphQL/autogenerated/mutations/revalidateBasketItem.gql +1580 -0
  284. package/projects/obtservices/graphQL/autogenerated/mutations/saveFavouriteSearch.gql +348 -0
  285. package/projects/obtservices/graphQL/autogenerated/mutations/saveRecentSearch.gql +348 -0
  286. package/projects/obtservices/graphQL/autogenerated/mutations/saveUserAddress.gql +14 -0
  287. package/projects/obtservices/graphQL/autogenerated/mutations/sendBasketForApproval.gql +1580 -0
  288. package/projects/obtservices/graphQL/autogenerated/mutations/setAddressAsUserPrimary.gql +14 -0
  289. package/projects/obtservices/graphQL/autogenerated/mutations/setBasketItemLeadPassenger.gql +1580 -0
  290. package/projects/obtservices/graphQL/autogenerated/mutations/setBasketItemMIGroup.gql +1580 -0
  291. package/projects/obtservices/graphQL/autogenerated/mutations/setBasketItemMIValue.gql +1580 -0
  292. package/projects/obtservices/graphQL/autogenerated/mutations/setBasketItemPaymentMethod.gql +1580 -0
  293. package/projects/obtservices/graphQL/autogenerated/mutations/setMIDefaultValue.gql +3 -0
  294. package/projects/obtservices/graphQL/autogenerated/mutations/setUserLanguage.gql +339 -0
  295. package/projects/obtservices/graphQL/autogenerated/mutations/updateBasketNotes.gql +1580 -0
  296. package/projects/obtservices/graphQL/autogenerated/mutations/updateBasketTitle.gql +1580 -0
  297. package/projects/obtservices/graphQL/autogenerated/queries/alive.gql +3 -0
  298. package/projects/obtservices/graphQL/autogenerated/queries/carHireAvailabilityDetailRequest.gql +42 -0
  299. package/projects/obtservices/graphQL/autogenerated/queries/confermaBlockClientHotels.gql +23 -0
  300. package/projects/obtservices/graphQL/autogenerated/queries/confermaBlockConsumerHotels.gql +23 -0
  301. package/projects/obtservices/graphQL/autogenerated/queries/confermaListCards.gql +11 -0
  302. package/projects/obtservices/graphQL/autogenerated/queries/confermaUnblockClientHotels.gql +23 -0
  303. package/projects/obtservices/graphQL/autogenerated/queries/confermaUnblockConsumerHotels.gql +23 -0
  304. package/projects/obtservices/graphQL/autogenerated/queries/getCOVIDMicrositeToken.gql +3 -0
  305. package/projects/obtservices/graphQL/autogenerated/queries/getCancellationInfo.gql +7 -0
  306. package/projects/obtservices/graphQL/autogenerated/queries/getCarHireDepots.gql +13 -0
  307. package/projects/obtservices/graphQL/autogenerated/queries/getConfermaOffice.gql +50 -0
  308. package/projects/obtservices/graphQL/autogenerated/queries/getConfermaOfficeNames.gql +26 -0
  309. package/projects/obtservices/graphQL/autogenerated/queries/getConfermaQuicklist.gql +131 -0
  310. package/projects/obtservices/graphQL/autogenerated/queries/getCountries.gql +8 -0
  311. package/projects/obtservices/graphQL/autogenerated/queries/getHotelAvailability.gql +78 -0
  312. package/projects/obtservices/graphQL/autogenerated/queries/getHotelChains.gql +3 -0
  313. package/projects/obtservices/graphQL/autogenerated/queries/getIRLSupplierStation.gql +28 -0
  314. package/projects/obtservices/graphQL/autogenerated/queries/getMultipleHotelsAvailability.gql +78 -0
  315. package/projects/obtservices/graphQL/autogenerated/queries/getPostcodeDetails.gql +25 -0
  316. package/projects/obtservices/graphQL/autogenerated/queries/getRailStation.gql +27 -0
  317. package/projects/obtservices/graphQL/autogenerated/queries/getRailcards.gql +6 -0
  318. package/projects/obtservices/graphQL/autogenerated/queries/getRiskAlerts.gql +17 -0
  319. package/projects/obtservices/graphQL/autogenerated/queries/getUser.gql +339 -0
  320. package/projects/obtservices/graphQL/autogenerated/queries/getUserAddresses.gql +14 -0
  321. package/projects/obtservices/graphQL/autogenerated/queries/getUserBasket.gql +1580 -0
  322. package/projects/obtservices/graphQL/autogenerated/queries/getUserBaskets.gql +1580 -0
  323. package/projects/obtservices/graphQL/autogenerated/queries/getUserCompanyOffices.gql +88 -0
  324. package/projects/obtservices/graphQL/autogenerated/queries/getUserCurrentCarbonAllowance.gql +524 -0
  325. package/projects/obtservices/graphQL/autogenerated/queries/getUserFavouriteSearches.gql +348 -0
  326. package/projects/obtservices/graphQL/autogenerated/queries/getUserMIAutoSuggestValues.gql +10 -0
  327. package/projects/obtservices/graphQL/autogenerated/queries/getUserMessages.gql +10 -0
  328. package/projects/obtservices/graphQL/autogenerated/queries/getUserPhoneNumbers.gql +13 -0
  329. package/projects/obtservices/graphQL/autogenerated/queries/getUserRecentSearches.gql +348 -0
  330. package/projects/obtservices/graphQL/autogenerated/queries/getUserServices.gql +16 -0
  331. package/projects/obtservices/graphQL/autogenerated/queries/getUserTravelRules.gql +111 -0
  332. package/projects/obtservices/graphQL/autogenerated/queries/getUserUIConfigs.gql +52 -0
  333. package/projects/obtservices/graphQL/autogenerated/queries/index.js +64 -0
  334. package/projects/obtservices/graphQL/autogenerated/queries/isPostcodeValid.gql +3 -0
  335. package/projects/obtservices/graphQL/autogenerated/queries/postcodeAutoSuggest.gql +3 -0
  336. package/projects/obtservices/graphQL/autogenerated/queries/searchAirlines.gql +32 -0
  337. package/projects/obtservices/graphQL/autogenerated/queries/searchAirports.gql +60 -0
  338. package/projects/obtservices/graphQL/autogenerated/queries/searchCabHire.gql +63 -0
  339. package/projects/obtservices/graphQL/autogenerated/queries/searchCarHire.gql +104 -0
  340. package/projects/obtservices/graphQL/autogenerated/queries/searchCities.gql +14 -0
  341. package/projects/obtservices/graphQL/autogenerated/queries/searchConfermaCities.gql +11 -0
  342. package/projects/obtservices/graphQL/autogenerated/queries/searchEurostar.gql +833 -0
  343. package/projects/obtservices/graphQL/autogenerated/queries/searchFastTrack.gql +46 -0
  344. package/projects/obtservices/graphQL/autogenerated/queries/searchFlights.gql +23 -0
  345. package/projects/obtservices/graphQL/autogenerated/queries/searchFlightsV2.gql +833 -0
  346. package/projects/obtservices/graphQL/autogenerated/queries/searchHotelChains.gql +3 -0
  347. package/projects/obtservices/graphQL/autogenerated/queries/searchHotels.gql +131 -0
  348. package/projects/obtservices/graphQL/autogenerated/queries/searchIRL.gql +514 -0
  349. package/projects/obtservices/graphQL/autogenerated/queries/searchIRLSupplierStations.gql +28 -0
  350. package/projects/obtservices/graphQL/autogenerated/queries/searchLounges.gql +89 -0
  351. package/projects/obtservices/graphQL/autogenerated/queries/searchParking.gql +70 -0
  352. package/projects/obtservices/graphQL/autogenerated/queries/searchPostcodes.gql +25 -0
  353. package/projects/obtservices/graphQL/autogenerated/queries/searchRail.gql +840 -0
  354. package/projects/obtservices/graphQL/autogenerated/queries/searchRailStations.gql +27 -0
  355. package/projects/obtservices/graphQL/autogenerated/queries/searchUserCanBookFor.gql +339 -0
  356. package/projects/obtservices/graphQL/autogenerated/queries/validateBasketItemMI.gql +3 -0
  357. package/projects/obtservices/graphQL/autogenerated/queries/validateUserMIFreeValue.gql +3 -0
  358. package/projects/obtservices/graphQL/documents/acceptNewPrice.graphql +5 -0
  359. package/projects/obtservices/graphQL/documents/addUserToBasketItem.graphql +9 -0
  360. package/projects/obtservices/graphQL/documents/basket.fragments.graphql +171 -0
  361. package/projects/obtservices/graphQL/documents/baskets.graphql +111 -0
  362. package/projects/obtservices/graphQL/documents/bookBasket.graphql +9 -0
  363. package/projects/obtservices/graphQL/documents/cabhire.graphql +66 -0
  364. package/projects/obtservices/graphQL/documents/carHireAvailabilityDetailRequest.graphql +44 -0
  365. package/projects/obtservices/graphQL/documents/carhire.graphql +117 -0
  366. package/projects/obtservices/graphQL/documents/deleteRecentSearch.graphql +3 -0
  367. package/projects/obtservices/graphQL/documents/deleteUserAddress.graphql +3 -0
  368. package/projects/obtservices/graphQL/documents/error.fragments.graphql +10 -0
  369. package/projects/obtservices/graphQL/documents/flights.graphql +830 -0
  370. package/projects/obtservices/graphQL/documents/getCarHireDepots.graphql +13 -0
  371. package/projects/obtservices/graphQL/documents/getConfermaOfficeNames.graphql +11 -0
  372. package/projects/obtservices/graphQL/documents/getConfermaQuicklist.graphql +108 -0
  373. package/projects/obtservices/graphQL/documents/getRailStation.graphql +31 -0
  374. package/projects/obtservices/graphQL/documents/getRailcards.graphql +6 -0
  375. package/projects/obtservices/graphQL/documents/getRiskAlerts.graphql +24 -0
  376. package/projects/obtservices/graphQL/documents/getUserAddresses.graphql +14 -0
  377. package/projects/obtservices/graphQL/documents/getUserCompanyOffices.graphql +18 -0
  378. package/projects/obtservices/graphQL/documents/getUserCurrentCarbonAllowance.graphql +29 -0
  379. package/projects/obtservices/graphQL/documents/getUserMIAutoSuggestValues.graphql +10 -0
  380. package/projects/obtservices/graphQL/documents/getUserPhoneNumbers.graphql +13 -0
  381. package/projects/obtservices/graphQL/documents/getUserRecentSearches.graphql +20 -0
  382. package/projects/obtservices/graphQL/documents/hotels.graphql +242 -0
  383. package/projects/obtservices/graphQL/documents/isPostcodeValid.graphql +3 -0
  384. package/projects/obtservices/graphQL/documents/lookups.graphql +54 -0
  385. package/projects/obtservices/graphQL/documents/lounges.graphql +88 -0
  386. package/projects/obtservices/graphQL/documents/moveItemToADifferentBasket.graphql +9 -0
  387. package/projects/obtservices/graphQL/documents/parking.graphql +79 -0
  388. package/projects/obtservices/graphQL/documents/rail.graphql +645 -0
  389. package/projects/obtservices/graphQL/documents/saveRecentSearch.graphql +5 -0
  390. package/projects/obtservices/graphQL/documents/saveUserAddress.graphql +14 -0
  391. package/projects/obtservices/graphQL/documents/searchAirlines.graphql +32 -0
  392. package/projects/obtservices/graphQL/documents/searchCities.graphql +14 -0
  393. package/projects/obtservices/graphQL/documents/searchConfermaCities.graphql +11 -0
  394. package/projects/obtservices/graphQL/documents/searchEurostar.graphql +810 -0
  395. package/projects/obtservices/graphQL/documents/searchHotelChains.graphql +3 -0
  396. package/projects/obtservices/graphQL/documents/searchIRL.graphql +521 -0
  397. package/projects/obtservices/graphQL/documents/searchPostcodes.graphql +7 -0
  398. package/projects/obtservices/graphQL/documents/searchRailStations.graphql +27 -0
  399. package/projects/obtservices/graphQL/documents/searchUserAddresses.graphql +14 -0
  400. package/projects/obtservices/graphQL/documents/set-basker-item-mi-group.graphql +9 -0
  401. package/projects/obtservices/graphQL/documents/setBasketItemLeadPassenger.graphql +5 -0
  402. package/projects/obtservices/graphQL/documents/setBasketItemMIValue.graphql +16 -0
  403. package/projects/obtservices/graphQL/documents/setBasketItemPaymentMethod.graphql +12 -0
  404. package/projects/obtservices/graphQL/documents/updateBasketNotes.graphql +10 -0
  405. package/projects/obtservices/graphQL/documents/updateBasketTitle.graphql +10 -0
  406. package/projects/obtservices/graphQL/documents/user.fragments.graphql +65 -0
  407. package/projects/obtservices/graphQL/documents/user.graphql +95 -0
  408. package/projects/obtservices/graphQL/documents/validateUserMIFreeValue.graphql +3 -0
  409. package/projects/obtservices/graphQL/schema/schema.graphql +2635 -0
  410. package/projects/obtservices/karma.conf.js +32 -0
  411. package/projects/obtservices/ng-package.json +7 -0
  412. package/projects/obtservices/package-lock.json +5 -0
  413. package/projects/obtservices/package.json +12 -0
  414. package/projects/obtservices/src/obtservices.ts +0 -0
  415. package/projects/obtservices/src/public_api.ts +1 -0
  416. package/projects/obtservices/tsconfig.lib.json +30 -0
  417. package/projects/obtservices/tsconfig.spec.json +17 -0
  418. package/projects/obtservices/tslint.json +17 -0
  419. package/tsconfig.json +36 -0
  420. package/tslint.json +62 -0
@@ -0,0 +1,1370 @@
1
+ import moment from 'moment';
2
+ import { BaseEnterpriseSearch } from './base-enterprise';
3
+ import { BaseStorageService } from '../services/storage.service';
4
+ import { BaseHelperRoutines } from './helpers';
5
+ import { BehaviorSubject, from, of, Observable, Subject } from 'rxjs';
6
+ import { map, take } from 'rxjs/operators';
7
+ import { BaseEnvironment } from './enviroment';
8
+ import { BaseHotelAvalibilityService } from '../services/hotel-avallibility.service';
9
+ import { URLS } from './../services/url.service';
10
+ import {
11
+ Country,
12
+ HotelQuoteResult,
13
+ HotelQuoteResultArray,
14
+ LocationTypes,
15
+ NgbDateStruct,
16
+ LocationDetails,
17
+ HotelAvalibilityQuoteResult,
18
+ includedExpression,
19
+ excludedExpression,
20
+ SearchHandler,
21
+ RecentSearch,
22
+ AirportSearchResults
23
+ } from '../types/types';
24
+ import {
25
+ BasketItem,
26
+ ConfermaOfficeNames,
27
+ CurrencyCode,
28
+ DistanceTypes,
29
+ HotelLocation,
30
+ HotelRoom,
31
+ HotelTag,
32
+ RailStation,
33
+ SaveRecentSearchMutationVariables,
34
+ SearchFlightsV2QueryVariables,
35
+ SearchHotelsQueryVariables,
36
+ ServiceType
37
+ } from '../types/graphql.types';
38
+ import {
39
+ BaseHotelQuoteFetcher,
40
+ HotelQuoteFetcherType
41
+ } from '../fetchers/hotel-quote-fetcher';
42
+ import {
43
+ FullUserDetails,
44
+ UserServiceInterface
45
+ } from '../interfaces/Iuser.service';
46
+ import { EnterpriseSearchServiceInterface } from '../interfaces/Isearch.service';
47
+ import { AbstractHttpCallService } from '../services/http-call.service';
48
+
49
+ import { HotelAvalinilityFetcherType } from '../fetchers/hotel-avaliability-fetcher';
50
+ import {
51
+ EnterpriseBasketServiceInterface,
52
+ InternalBasketInterface
53
+ } from '../interfaces/Ienterprise-basket.service';
54
+ import {
55
+ AvailabilityObject,
56
+ DisplayFilterSettings,
57
+ HotelDetails,
58
+ HotelDetailsArray,
59
+ HotelEnterpriseSearchInterface,
60
+ HotelFilters,
61
+ HotelTempParams,
62
+ HotelView,
63
+ ResultDetails
64
+ } from '../interfaces/Ihotel-enterprise-search';
65
+ import { ICheapestPrice } from '../interfaces/cheapest-price';
66
+ import { Traveller } from '../models/traveller.object';
67
+ import { BaseSearchConfermaQuicklistFetcher, ConfermaQuicklistFetcherType } from '../fetchers/conferma-quicklist.fetcher';
68
+ import { BaseGetRailStationFetcher, GetRailStationFetcherType } from '../fetchers/get-rail-station.fetcher';
69
+
70
+ export enum SortTypesHotel {
71
+ distance = 'distance',
72
+ name = 'name',
73
+ price = 'price'
74
+ }
75
+
76
+ const CLIENT_PREFERRED_VALUE = 1;
77
+ const AGENT_PREFERRED_VALUE = 2;
78
+
79
+ export class HotelEnterpriseSearch<
80
+ HQ_Q extends HotelQuoteFetcherType,
81
+ HA_Q extends HotelAvalinilityFetcherType,
82
+ QL_Q extends ConfermaQuicklistFetcherType,
83
+ GRS_Q extends GetRailStationFetcherType
84
+ >
85
+ extends BaseEnterpriseSearch<
86
+ HotelTempParams,
87
+ HotelQuoteResultArray,
88
+ HotelDetailsArray
89
+ >
90
+ implements HotelEnterpriseSearchInterface {
91
+ static readonly MAX_HOTEL_ROOMS = 4;
92
+ static readonly STORAGE_SESSION_PARAMS = 'search_hotel';
93
+ static readonly STORAGE_SESSION_RESULTS = 'results_hotel';
94
+
95
+ public type: ServiceType = ServiceType.Hotel;
96
+ private travellers: Traveller[];
97
+ public location_types: BehaviorSubject<LocationTypes[]> = new BehaviorSubject<
98
+ LocationTypes[]
99
+ >([]);
100
+ public offices: BehaviorSubject<LocationTypes[]> = new BehaviorSubject<
101
+ LocationTypes[]
102
+ >([]);
103
+ public lastActivePage: BehaviorSubject<number> = new BehaviorSubject(null);
104
+
105
+ readonly galleries: { [key: string]: string[] } = {};
106
+ private occupied: number = 0;
107
+ private results_details: ResultDetails = {
108
+ chains: new Set<string>(),
109
+ amenities: [],
110
+ maxDistance: 0
111
+ };
112
+ private _checkin_date_ngb: NgbDateStruct;
113
+ private _checkout_date_ngb: NgbDateStruct;
114
+
115
+ get chains(): string[] {
116
+ return [...this.results_details.chains];
117
+ }
118
+
119
+ get amenities(): string[] {
120
+ return [...this.results_details.amenities];
121
+ }
122
+
123
+ get maxDistance(): number {
124
+ this.filters.distanceRange.max = Math.ceil(
125
+ Math.max.apply(
126
+ Math,
127
+ this.results.value.map((o) => o.location.distance)
128
+ )
129
+ );
130
+ this.results_details.maxDistance = this.filters.distanceRange.max;
131
+ return this.results_details.maxDistance;
132
+ }
133
+
134
+ get maxPrice(): number {
135
+ return Math.ceil(this.filters.priceRange.max);
136
+ }
137
+
138
+ get currency(): string {
139
+ return this.tempParams.currency;
140
+ }
141
+
142
+ set currency(value: string) {
143
+ this.tempParams.currency = value;
144
+ }
145
+ // Event Emitters
146
+ public filterChange: Subject<any> = new Subject();
147
+ public selectItemMapView: Subject<any> = new Subject();
148
+
149
+ public display: DisplayFilterSettings = {
150
+ minprice: Number.NEGATIVE_INFINITY,
151
+ maxprice: Number.POSITIVE_INFINITY,
152
+ filters: {
153
+ breakfastType: []
154
+ }
155
+ };
156
+
157
+ // public variables
158
+ public min_date = {
159
+ year: moment().year(),
160
+ month: moment().month() + 1, // ngbDate months are not 0 indexed
161
+ day: moment().date()
162
+ };
163
+
164
+ public min_return_date = {
165
+ year: moment().year(),
166
+ month: moment().month() + 1, // ngbDate months are not 0 indexed
167
+ day: moment().date() + 1 // min 1 night stay
168
+ };
169
+
170
+ // private variables
171
+ // don't need to worry about times here - maybe normalise these in the request body?
172
+
173
+ private localFilters = new HotelFilters();
174
+
175
+ public currentView: HotelView = HotelView.LIST;
176
+
177
+ // For NgForing over in the templates
178
+ private _max_no_of_rooms = 4;
179
+ private _max_rooms_array = new Array(this._max_no_of_rooms).fill(0);
180
+ private _max_no_of_occupants = 2;
181
+ private _max_occupant_array = new Array(this._max_no_of_occupants).fill(0);
182
+ private _distance_list = [1, 2, 5, 10, 20, 25]; // copied from old frontend for now
183
+ private _default_currency: any = null;
184
+
185
+ // getters and setters
186
+
187
+ get checkin_date_ngb(): NgbDateStruct {
188
+ return this._checkin_date_ngb;
189
+ }
190
+
191
+ set checkin_date_ngb(value: NgbDateStruct) {
192
+ this._checkin_date_ngb = value;
193
+
194
+ this.tempParams.checkin_date = this.helpers.ngDateToMoment(value);
195
+ this.checkin_date = this.helpers.ngDateToMoment(value);
196
+ }
197
+
198
+ get checkout_date_ngb(): NgbDateStruct {
199
+ return this._checkout_date_ngb;
200
+ }
201
+
202
+ set checkout_date_ngb(value: NgbDateStruct) {
203
+ this._checkout_date_ngb = value;
204
+ this.tempParams.checkout_date = this.helpers.ngDateToMoment(value);
205
+ this._isValid();
206
+ }
207
+
208
+ get checkin_date(): moment.Moment {
209
+ return this.tempParams.checkin_date;
210
+ }
211
+
212
+ set checkin_date(newDate: moment.Moment) {
213
+ if (newDate && newDate.isValid()) {
214
+ this.tempParams.checkin_date = moment(newDate);
215
+ this._checkin_date_ngb = this.helpers.momentToNgDate(newDate);
216
+ if (newDate.isSameOrBefore(this.tempParams.checkout_date)) {
217
+ this.checkout_date = moment(newDate).add(1, 'day');
218
+ }
219
+ this._isValid();
220
+ }
221
+ }
222
+
223
+ get checkout_date(): moment.Moment {
224
+ return this.tempParams.checkout_date;
225
+ }
226
+
227
+ set checkout_date(newDate: moment.Moment) {
228
+ // if (newDate.isSameOrBefore(this.checkin_date)) { // not allowed
229
+ // return;
230
+ // }
231
+ if (newDate && newDate.isValid()) {
232
+ this.tempParams.checkout_date = newDate;
233
+ this.checkout_date_ngb = this.helpers.momentToNgDate(newDate);
234
+ this._isValid();
235
+ }
236
+ }
237
+
238
+ get no_of_rooms(): number {
239
+ return this.tempParams.no_of_rooms;
240
+ }
241
+
242
+ set no_of_rooms(newRooms: number) {
243
+ if (newRooms > 4 || newRooms < 1) {
244
+ return;
245
+ }
246
+
247
+ this.tempParams.no_of_rooms = newRooms;
248
+ this._isValid();
249
+ }
250
+
251
+ get no_of_occupants(): number {
252
+ return this.tempParams.no_of_occupants;
253
+ }
254
+
255
+ set no_of_occupants(newOcc: number) {
256
+ if (newOcc < 1 || newOcc > 3) {
257
+ return;
258
+ }
259
+
260
+ this.tempParams.no_of_occupants = newOcc;
261
+ this._isValid();
262
+ }
263
+
264
+ get default_currency(): string {
265
+ return this.tempParams.currency;
266
+ }
267
+
268
+ set default_currency(currency: string) {
269
+ this.tempParams.currency = currency;
270
+ }
271
+
272
+ // may have to modify these
273
+ get location(): any {
274
+ return this.tempParams.location;
275
+ }
276
+
277
+ set location(newLoc: any) {
278
+ this.tempParams.location = newLoc;
279
+
280
+ this._isValid();
281
+ }
282
+
283
+ get formatted_location(): string {
284
+ return this.tempParams.location
285
+ ? this.tempParams.location.destination
286
+ : 'No Location Set'; // TODO - expand this for different types
287
+ }
288
+
289
+ get distance(): number {
290
+ return this.tempParams.distance;
291
+ }
292
+
293
+ set distance(newDist: number) {
294
+ this.tempParams.distance = newDist;
295
+ this._isValid();
296
+ }
297
+
298
+ get prefered_hotels_only(): boolean {
299
+ return this.tempParams.prefered_hotels_only;
300
+ }
301
+
302
+ set prefered_hotels_only(newPref: boolean) {
303
+ this.tempParams.prefered_hotels_only = newPref;
304
+ this._isValid();
305
+ }
306
+
307
+ get country(): Country {
308
+ return this.tempParams.country;
309
+ }
310
+
311
+ set country(newCont: Country) {
312
+ this.tempParams.country = newCont;
313
+ this._isValid();
314
+ }
315
+
316
+ get postcode(): LocationDetails {
317
+ return this.tempParams.postcode;
318
+ }
319
+
320
+ set postcode(postcode: LocationDetails) {
321
+ this.tempParams.postcode = postcode;
322
+ this._isValid();
323
+ }
324
+
325
+ get trainsStation(): LocationDetails {
326
+ return this.tempParams.trainsStation;
327
+ }
328
+
329
+ set trainsStation(station: LocationDetails) {
330
+ this.tempParams.trainsStation = station;
331
+ this._isValid();
332
+ }
333
+
334
+ get office(): ConfermaOfficeNames {
335
+ return this.tempParams.office;
336
+ }
337
+
338
+ set office(office: ConfermaOfficeNames) {
339
+ this.tempParams.office = office;
340
+ this._isValid();
341
+ }
342
+
343
+ // Additional Variables
344
+ get hotel_name(): string {
345
+ return this.tempParams.hotel_name;
346
+ }
347
+
348
+ set hotel_name(newName: string) {
349
+ this.tempParams.hotel_name = newName;
350
+ this._isValid();
351
+ }
352
+
353
+ get hotel_chain(): any {
354
+ return this.tempParams.hotel_chain;
355
+ }
356
+
357
+ set hotel_chain(newChain: any) {
358
+ this.tempParams.hotel_chain = newChain;
359
+ this._isValid();
360
+ }
361
+
362
+ // Getters Only
363
+
364
+ get max_rooms_array(): number[] {
365
+ return this._max_rooms_array;
366
+ }
367
+
368
+ get max_occupant_array(): number[] {
369
+ return this._max_occupant_array;
370
+ }
371
+
372
+ get distance_list(): number[] {
373
+ return this._distance_list;
374
+ }
375
+
376
+ get location_type_select(): LocationTypes {
377
+ return this.tempParams.location_type_select;
378
+ }
379
+
380
+ set location_type_select(value: LocationTypes) {
381
+ this.tempParams.location_type_select = value;
382
+ this._isValid();
383
+ }
384
+
385
+ get filters(): HotelFilters {
386
+ return this.localFilters;
387
+ }
388
+
389
+ constructor(
390
+ private hotelFetcher: BaseHotelQuoteFetcher<HQ_Q>,
391
+ private helpers: BaseHelperRoutines,
392
+ private userService: UserServiceInterface,
393
+ private environment: BaseEnvironment,
394
+ private avaliabilityService: BaseHotelAvalibilityService<HA_Q>,
395
+ private basketService: EnterpriseBasketServiceInterface,
396
+ storageService: BaseStorageService,
397
+ private searchService: EnterpriseSearchServiceInterface,
398
+ private httpCallService: AbstractHttpCallService,
399
+ private quickListFetcher: BaseSearchConfermaQuicklistFetcher<QL_Q>,
400
+ private getRailStationFetcher: BaseGetRailStationFetcher<GRS_Q>
401
+ ) {
402
+ super(storageService, (resultsToMap: HotelQuoteResultArray) => {
403
+ this.results_details.maxDistance = 0;
404
+ this.results_details.chains = new Set<string>();
405
+ return resultsToMap.map(
406
+ (hotelResult: HotelQuoteResult, index: number): HotelDetails => {
407
+ this.results_details.maxDistance = Math.max(
408
+ this.results_details.maxDistance,
409
+ hotelResult.location.distance
410
+ );
411
+ this.filters.distanceRange.max = this.results_details.maxDistance;
412
+ this.results_details.chains.add(hotelResult.group);
413
+ if (index < this.environment.numberHotelToPreload) {
414
+ this.avaliabilityService.getAvailabilityForId(
415
+ this.makeHotelAvalilityObject(hotelResult)
416
+ );
417
+ }
418
+ // this.getHotelAvailability(hotelResult);
419
+ return {
420
+ sortedTags: this.sortTags(hotelResult.tags),
421
+ Details: {
422
+ distance_airport: 0,
423
+ distance_metro: 0,
424
+ distance_rail: 0,
425
+ airport_details: { name: 'Not returned' },
426
+ metro_details: { name: 'Not returned' },
427
+ rail_details: { name: 'Not returned' }
428
+ },
429
+ // avilability: this.hotel_availability,
430
+ ...hotelResult
431
+ };
432
+ }
433
+ );
434
+ });
435
+ this.results_details.chains = new Set<string>();
436
+ const data: {
437
+ tempParams: HotelTempParams;
438
+ } = storageService.getSessionItem(
439
+ HotelEnterpriseSearch.STORAGE_SESSION_PARAMS
440
+ ) || {
441
+ tempParams: {} as HotelTempParams
442
+ };
443
+
444
+ this.default_currency = this.tempParams.currency
445
+ ? this.tempParams.currency
446
+ : this._default_currency;
447
+ this.updateTempParams(searchService.makeHotelQuery(data.tempParams));
448
+
449
+ if (searchService.shouldAddTravellerSubscription()) {
450
+ searchService.travellerInformation.subscribe(
451
+ (travellers: Traveller[]) => {
452
+ this.travellers = travellers;
453
+ const splitTravellers = this.helpers.selectedTravellers(
454
+ travellers,
455
+ ServiceType.Hotel
456
+ );
457
+ this.tempParams.no_of_occupants = splitTravellers.adults.length;
458
+ this.travellers = travellers;
459
+ this._isValid();
460
+ }
461
+ );
462
+ }
463
+
464
+ const results =
465
+ storageService.getSessionItemAsList<HotelDetailsArray>(
466
+ this.resultsSessionName
467
+ ) || [];
468
+ results
469
+ .slice(0, this.environment.numberHotelToPreload)
470
+ .forEach((hotel: HotelDetails) => {
471
+ this.avaliabilityService.getAvailabilityForId(
472
+ this.makeHotelAvalilityObject(hotel)
473
+ );
474
+ });
475
+
476
+ results.forEach((hotelResult: HotelDetails) => {
477
+ this.results_details.chains.add(hotelResult.group);
478
+ });
479
+ this.fullResults = results;
480
+ this.results.next(results);
481
+ this._isValid();
482
+
483
+ this.userService.changeUser.subscribe((user: Partial<FullUserDetails>) => {
484
+ this.location_types.next([
485
+ LocationTypes.Airport,
486
+ LocationTypes.City,
487
+ LocationTypes.Office,
488
+ LocationTypes.Shortlist,
489
+ LocationTypes.TrainStation
490
+ ]);
491
+ if (searchService.shouldFetchAllOffices()) {
492
+ this.offices.next([]); // TODO fetch offices
493
+ }
494
+ });
495
+
496
+ this.localFilters = new HotelFilters();
497
+
498
+ this.avaliabilityService.fetching.subscribe((isFetching: boolean) => {
499
+ if (!isFetching) {
500
+ // We've just finished fetching avalibility so update filters.
501
+
502
+ const maxNumber = this.avaliabilityService.maxPriceForCurrency('GBP');
503
+ if (maxNumber > 0) {
504
+ this.filters.priceRange.max = maxNumber;
505
+ this.localFilters.priceRange.max = maxNumber;
506
+ }
507
+ this._cheapestResultPrice = this.updateLowestPrice(results);
508
+ }
509
+ });
510
+ }
511
+
512
+ protected resultsSessionName = HotelEnterpriseSearch.STORAGE_SESSION_RESULTS;
513
+
514
+ private query: SearchHotelsQueryVariables = {} as SearchHotelsQueryVariables;
515
+
516
+ makeLocations(location: HotelLocation[]): { [key: string]: HotelLocation[] } {
517
+ return this.helpers.arrayToObjectArray<HotelLocation>(
518
+ location,
519
+ 'distanceType'
520
+ );
521
+ }
522
+
523
+ sortTags(tags: HotelTag[]): any[] {
524
+ if (tags) {
525
+ return [...tags]
526
+ .sort((a: HotelTag, b: HotelTag) => {
527
+ if (a.name < b.name) {
528
+ return -1;
529
+ } else if (a.name > b.name) {
530
+ return 1;
531
+ } else {
532
+ return 0;
533
+ }
534
+ })
535
+ .map((tag: HotelTag) => {
536
+ return {
537
+ ...tag,
538
+ icon: this.environment.tagMap[tag.name] || tag.icon
539
+ };
540
+ });
541
+ }
542
+ return [];
543
+ }
544
+
545
+ protected resetQuery(): void {
546
+ this.updateTempParams(this.searchService.makeHotelQuery());
547
+ this.localFilters = new HotelFilters();
548
+ this.results_details = {
549
+ chains: new Set<string>(),
550
+ amenities: [],
551
+ maxDistance: 0
552
+ };
553
+ this._isValid();
554
+ }
555
+
556
+ private _isValid() {
557
+ if (!this.doChecks) {
558
+ return;
559
+ }
560
+
561
+ this.storageService.setSessionItem(
562
+ HotelEnterpriseSearch.STORAGE_SESSION_PARAMS,
563
+ {
564
+ tempParams: this.tempParams
565
+ }
566
+ );
567
+
568
+ this.min_return_date = this.helpers.momentToNgDate(
569
+ this.tempParams.checkin_date
570
+ );
571
+ if (
572
+ this.tempParams.checkin_date.isSameOrAfter(this.tempParams.checkout_date)
573
+ ) {
574
+ this.checkout_date = moment(this.tempParams.checkin_date).add(1, 'day'); // ensure that checkout date is min 1 day after checkin date
575
+ }
576
+ this.validationMessages = [];
577
+
578
+ switch (this.tempParams.location_type_select) {
579
+ case LocationTypes.City:
580
+ if (!this.country) {
581
+ this.validationMessages.push('Please select country');
582
+ }
583
+ if (!this.location && !this.postcode) {
584
+ this.validationMessages.push(
585
+ 'Please select a hotel location or enter a postcode.'
586
+ );
587
+ }
588
+ break;
589
+
590
+ case LocationTypes.Office:
591
+ if (!this.tempParams.location?.office) {
592
+ this.validationMessages.push('Please select an office.');
593
+ }
594
+ break;
595
+
596
+ case LocationTypes.Airport:
597
+ if (this.tempParams?.location) {
598
+ if (!this.tempParams.location.airport?.gateway) {
599
+ this.validationMessages.push('Please select a airport.');
600
+ }
601
+ break;
602
+ } else {
603
+ this.validationMessages.push('Please select a airport.');
604
+ }
605
+
606
+ break;
607
+
608
+ case LocationTypes.TrainStation:
609
+ if (this.tempParams?.location) {
610
+ if (!this.tempParams.location.railstation?.stationCode) {
611
+ this.validationMessages.push('Please select a train station.');
612
+ }
613
+ break;
614
+ } else {
615
+ this.validationMessages.push('Please select a train station.');
616
+ }
617
+
618
+ break;
619
+
620
+ case LocationTypes.Shortlist:
621
+ if (!this.country) {
622
+ this.validationMessages.push('Please select country');
623
+ }
624
+ break;
625
+ }
626
+
627
+ if (
628
+ this.checkout_date &&
629
+ this.checkout_date.isSameOrBefore(this.checkin_date)
630
+ ) {
631
+ this.validationMessages.push('Checkout date must be after checkin date');
632
+ }
633
+
634
+ if (this.checkout_date && this.checkout_date.isBefore(moment())) {
635
+ this.validationMessages.push('Checkout date must not be in the past');
636
+ }
637
+
638
+ if (this.checkin_date && this.checkin_date.isBefore(moment())) {
639
+ this.validationMessages.push('Checkin date must not be in the past');
640
+ }
641
+
642
+ if (
643
+ this.checkout_date &&
644
+ this.checkin_date &&
645
+ this.checkin_date.isAfter(this.checkout_date)
646
+ ) {
647
+ this.validationMessages.push(
648
+ 'Checkout data must be after the checkin date'
649
+ );
650
+ }
651
+
652
+ // Calculating Occupancy
653
+ const occupancy = this.no_of_occupants / this.no_of_rooms;
654
+
655
+ if (!(occupancy === 1 || occupancy === 2)) {
656
+ this.validationMessages.push(
657
+ 'Occupants per room must be 1 or 2, if you have an odd number of travellers (greater than one), the no of rooms must be equal'
658
+ );
659
+ }
660
+
661
+ console.log(this.validationMessages);
662
+ this.isValid.next(this.validationMessages.length === 0);
663
+ this.messages.next(this.validationMessages);
664
+ }
665
+
666
+ startSearch(): Promise<boolean> {
667
+ this.results.next([]);
668
+ this.avaliabilityService.reset();
669
+ if (this.isValid.value) {
670
+ // build the query
671
+ this.buildQuery();
672
+ const query = this.getSearchQuery();
673
+ this.searchService.saveRecentSearch(this.getRecentSearchQuery(this.getSearchQuery()));
674
+ return this._startSearch(
675
+ this.tempParams.location_type_select === LocationTypes.Shortlist ?
676
+ this.quickListFetcher.fetchList({countryCode: this.country.cCode}) :
677
+ this.hotelFetcher.fetchList(
678
+ query
679
+ )
680
+ );
681
+ } else {
682
+ return Promise.resolve(false);
683
+ }
684
+ }
685
+
686
+ getRecentSearchQuery(query: SearchHotelsQueryVariables): SaveRecentSearchMutationVariables {
687
+ if (this.location?.name) {
688
+ query.cityName = this.location.name;
689
+ }
690
+ return {
691
+ serviceType: ServiceType.Hotel,
692
+ searchArgs: query,
693
+ travelDate: this.checkin_date.format(),
694
+ travellers: this.helpers.getTravellersId(this.travellers)
695
+ };
696
+ }
697
+
698
+ public startRecentSearch(recentSearch: RecentSearch): void {
699
+ this.currency = recentSearch.searchArgs.currency;
700
+ this.distance = recentSearch.searchArgs.distance;
701
+ this.no_of_rooms = recentSearch.searchArgs.rooms;
702
+ this.checkin_date = moment(recentSearch.searchArgs.startDate);
703
+ this.checkout_date = moment(recentSearch.searchArgs.endDate);
704
+ this.hotel_name = recentSearch.searchArgs.hotelName;
705
+
706
+ if (recentSearch.searchArgs.groupName) {
707
+ this.hotel_chain = {
708
+ name: recentSearch.searchArgs.groupName
709
+ }
710
+ }
711
+
712
+ // get location_type_select
713
+ if (recentSearch.searchArgs.iata) {
714
+ this.location_type_select = LocationTypes.Airport;
715
+ this.searchService.getAirportByCode(recentSearch.searchArgs.iata).subscribe((iata: AirportSearchResults) => {
716
+ let airport = {
717
+ airport: {
718
+ gateway: iata.iataMatch.iata
719
+ }
720
+ }
721
+ this.location = { ...airport, ...iata.iataMatch };
722
+ this.searchService.startSearches();
723
+ })
724
+ } else if ((recentSearch.searchArgs.latitude && recentSearch.searchArgs.longitude) || recentSearch.searchArgs.postOrZipCode) {
725
+ this.location_type_select = LocationTypes.City;
726
+ this.country = {
727
+ cCode: recentSearch.searchArgs.countryCode,
728
+ cName: ''
729
+ }
730
+ // should be one search metod for the city search: location or postcode
731
+ if (recentSearch.searchArgs.latitude && recentSearch.searchArgs.longitude) {
732
+ this.location = {
733
+ name: recentSearch.searchArgs.cityName,
734
+ latitude: recentSearch.searchArgs.latitude,
735
+ longitude: recentSearch.searchArgs.longitude
736
+ }
737
+ } else if (recentSearch.searchArgs.postOrZipCode) {
738
+ this.postcode = {
739
+ name: recentSearch.searchArgs.postOrZipCode,
740
+ type: LocationTypes.Postcode
741
+ }
742
+ }
743
+ this.searchService.startSearches();
744
+ } else if (recentSearch.searchArgs.officeId) {
745
+ this.location_type_select = LocationTypes.Office;
746
+ this.searchService.getOfficeNames(this.isLoading).pipe(take(1)).subscribe((offices: ConfermaOfficeNames[]) => {
747
+ if (offices) {
748
+ let office: ConfermaOfficeNames = offices.find((office: ConfermaOfficeNames) => office.id === recentSearch.searchArgs.officeId);
749
+ this.office = {
750
+ id: recentSearch.searchArgs.officeId,
751
+ name: office.name
752
+ }
753
+ this.searchService.startSearches();
754
+ }
755
+ });
756
+ } else if (recentSearch.searchArgs.trainStationCode) {
757
+ this.location_type_select = LocationTypes.TrainStation;
758
+ this.getRailStationByCode(recentSearch.searchArgs.trainStationCode).subscribe((trainsStation: RailStation) => {
759
+ this.trainsStation = trainsStation as LocationDetails
760
+ this.searchService.startSearches();
761
+ });
762
+ } else {
763
+ this.location_type_select = LocationTypes.Shortlist;
764
+ this.country = {
765
+ cCode: recentSearch.searchArgs.countryCode,
766
+ cName: ''
767
+ }
768
+ this.searchService.startSearches();
769
+ }
770
+ }
771
+
772
+ private getRailStationByCode(code: string): Observable<RailStation> {
773
+ if (code) {
774
+ return this.getRailStationFetcher.fetchList({ id: null, code: code }).pipe(
775
+ take(1)
776
+ );
777
+ } else {
778
+ return of();
779
+ }
780
+ }
781
+
782
+ getSearchQuery(): SearchHotelsQueryVariables {
783
+ this.buildQuery();
784
+ return this.helpers.removeNulls<SearchHotelsQueryVariables>(this.query);
785
+ }
786
+
787
+ buildQuery(): void {
788
+ const query: SearchHotelsQueryVariables = {
789
+ startDate: this.tempParams.checkin_date.format('YYYY-MM-DD'),
790
+ endDate: this.tempParams.checkout_date.format('YYYY-MM-DD'),
791
+ rooms: this.tempParams.no_of_rooms,
792
+ adults: this.tempParams.no_of_occupants,
793
+ currency: this.tempParams.currency ? this.tempParams.currency : null,
794
+ distance: this.tempParams.distance,
795
+ distanceType: DistanceTypes.M,
796
+ maxResults: 100
797
+ };
798
+
799
+ this.getRoomNumber();
800
+ console.log(this.location)
801
+ switch (this.tempParams.location_type_select) {
802
+ case LocationTypes.Airport:
803
+ query.iata = this.tempParams.location.airport.gateway;
804
+ break;
805
+
806
+ case LocationTypes.City:
807
+ query.countryCode = this.country.cCode;
808
+ // should be one search metod for the city search: location or postcode
809
+ if (this.location) {
810
+ query.latitude = this.location.latitude;
811
+ query.longitude = this.location.longitude;
812
+ } else if (this.postcode) {
813
+ query.postOrZipCode = this.postcode.name;
814
+ }
815
+ break;
816
+
817
+ case LocationTypes.TrainStation:
818
+ query.trainStationCode = this.location.railstation.stationCode;
819
+ break;
820
+
821
+ case LocationTypes.Office: // Needs to fix in next PR
822
+ query.officeId = +this.location.office?.id;
823
+ break;
824
+
825
+ case LocationTypes.Shortlist:
826
+ query.countryCode = this.country.cCode;
827
+ break;
828
+
829
+ }
830
+
831
+ // Add hotel name in the query
832
+ if (this.hotel_name) {
833
+ query.hotelName = this.tempParams.hotel_name;
834
+ }
835
+
836
+ // add chain or group name int he query
837
+ if (this.hotel_chain) {
838
+ query.groupName = this.tempParams.hotel_chain?.name;
839
+ }
840
+
841
+ this.query = query;
842
+ }
843
+
844
+ makeHotelAvalilityObject(hotel: HotelQuoteResult): AvailabilityObject {
845
+ return {
846
+ hotel: hotel.id,
847
+ startDate: this.helpers.formatIsoDate(this.checkin_date),
848
+ endDate: this.helpers.formatIsoDate(this.checkout_date),
849
+ rooms: this.no_of_rooms,
850
+ occupants: this.no_of_occupants,
851
+ currency: 'GBP'
852
+ };
853
+ }
854
+
855
+ public filterResults = () => {
856
+ this.results.next(
857
+ this.fullResults.filter((hotel: HotelDetails) => {
858
+ return (
859
+ this.inPriceRange(hotel) &&
860
+ this.inDistanceRange(hotel) &&
861
+ this.containsHotelname(hotel) &&
862
+ this.hasChain(hotel) &&
863
+ this.breakfastTypeFilter(hotel)
864
+ );
865
+ })
866
+ );
867
+ };
868
+
869
+ // Lightening Filters
870
+ public filterLighteningResults = () => {
871
+ this.results.next(
872
+ this.fullResults.filter((hotel: HotelDetails) => {
873
+ return (
874
+ this.inLighteningPriceRange(hotel) &&
875
+ this.containsHotelname(hotel) &&
876
+ this.hasChain(hotel) &&
877
+ this.hasPreferred(hotel) &&
878
+ this.breakfastTypeFilter(hotel) &&
879
+ this.getExtraFilter(hotel) &&
880
+ this.getAmenitiesFilter(hotel)
881
+ );
882
+ })
883
+ );
884
+ };
885
+
886
+ private inPriceRange(hotel: HotelDetails): boolean {
887
+ const availability = this.avaliabilityService.getAvailabilityValue(hotel);
888
+ if (availability) {
889
+ return (
890
+ this.helpers.inRange(availability.maxprice, this.filters.priceRange) &&
891
+ this.helpers.inRange(availability.minprice, this.filters.priceRange)
892
+ );
893
+ }
894
+
895
+ return false;
896
+ }
897
+
898
+ private inDistanceRange(hotel: HotelDetails): boolean {
899
+ return (
900
+ this.filters.distanceRange.max === 0 ||
901
+ this.helpers.inRange(hotel.location.distance, this.filters.distanceRange)
902
+ );
903
+ }
904
+
905
+ private containsHotelname(hotel: HotelDetails): boolean {
906
+ const tocheck = this.filters.hotelName.toLowerCase();
907
+
908
+ return tocheck && tocheck.length > 0
909
+ ? hotel.name.toLowerCase().includes(tocheck)
910
+ : true;
911
+ }
912
+
913
+ private inLighteningPriceRange(hotel: HotelDetails): boolean {
914
+ const availability = this.avaliabilityService.getAvailabilityValue(hotel);
915
+ if (availability && Object.keys(availability).length !== 0) {
916
+ let maxRange: boolean = false;
917
+ let findMax: number = 0;
918
+ let minRange = this.helpers.inRange(
919
+ availability.prpn,
920
+ this.filters.priceRange
921
+ );
922
+ if (availability?.maxprice) {
923
+ findMax = availability.maxprice;
924
+ } else {
925
+ findMax = availability?.rooms.reduce(
926
+ (op, item) => (op = op > item.total ? op : item.total),
927
+ 0
928
+ );
929
+ }
930
+ maxRange = this.helpers.inRange(findMax, this.filters.priceRange);
931
+ let result: boolean = minRange && maxRange;
932
+ return result;
933
+ }
934
+ return true;
935
+ }
936
+
937
+ private hasChain(hotel: HotelDetails): boolean {
938
+ const tocheck = (this.filters.chain || []).map((chain: string): string => {
939
+ return chain.toLowerCase();
940
+ });
941
+ return tocheck && tocheck.length
942
+ ? !!tocheck.find((chain: string) => {
943
+ return hotel.group.toLowerCase().includes(chain);
944
+ })
945
+ : true;
946
+ }
947
+
948
+ private breakfastTypeFilter(hotel: HotelDetails): boolean {
949
+ if(!this.filters.breakfastType.length) return true;
950
+ const hotelObject = this.avaliabilityService.getAvailabilityForId(this.makeHotelAvalilityObject(hotel));
951
+ if(!hotelObject && !hotelObject.value) return false;
952
+ const hotelObjectValue: HotelAvalibilityQuoteResult = hotelObject.value;
953
+ const isBreakfastIncluded = this.filters.breakfastType.includes(SearchHandler.BREAKFAST_INCLUDED);
954
+ const isBreakfastExcluded = this.filters.breakfastType.includes(SearchHandler.BREAKFAST_NOT_INCLUDED);
955
+
956
+ const breakfastMatches = hotelObjectValue.rooms.filter((rooms: any) => {
957
+ if(isBreakfastIncluded && isBreakfastExcluded){
958
+ return rooms;
959
+ } else if(isBreakfastIncluded) {
960
+ return rooms.rateDescription.match(includedExpression) && !rooms.rateDescription.match(excludedExpression);
961
+ } else if(isBreakfastExcluded){
962
+ return !rooms.rateDescription.match(includedExpression) || rooms.rateDescription.match(excludedExpression);
963
+ }
964
+ }
965
+ );
966
+ return !!breakfastMatches.length;
967
+ }
968
+
969
+ byMostExpensive() {
970
+ this.sortByPrice(false);
971
+ }
972
+
973
+ /**
974
+ * @param {boolean} min
975
+ * @param {boolean} debug set this to true to output console logs
976
+ * @description sorts results by price according to the 'min' paramater. min = true (lowest price first), min = false (highest price first)
977
+ * In summary, this method creates a sorted array of hotels with prices and an array of hotels WITHOUT prices,
978
+ * then finally joins these 2 temporary arrays together before triggering the next observable.
979
+ */
980
+
981
+ sortByPrice(min = true, debug = false): void {
982
+ // store all results
983
+ const hotels: HotelDetailsArray = this.fullResults;
984
+
985
+ // get hotels with and without prices
986
+ const hotelsWithPrices: HotelDetailsArray = [];
987
+ const hotelsWithoutPrices: HotelDetailsArray = [];
988
+ hotels.map((hotelResult) => {
989
+ this.avaliabilityService.getAvailabilityValue(hotelResult)?.prpn
990
+ ? hotelsWithPrices.push(hotelResult)
991
+ : hotelsWithoutPrices.push(hotelResult);
992
+ });
993
+
994
+ // sort hotels with prices according to the 'min' parameter for the order
995
+ hotelsWithPrices.sort((first: HotelDetails, second: HotelDetails) => {
996
+ const firstPrice =
997
+ this.avaliabilityService.getAvailabilityValue(first)?.prpn;
998
+ const secondPrice =
999
+ this.avaliabilityService.getAvailabilityValue(second)?.prpn;
1000
+ return min
1001
+ ? firstPrice > secondPrice
1002
+ ? 1
1003
+ : secondPrice > firstPrice
1004
+ ? -1
1005
+ : 0
1006
+ : firstPrice < secondPrice
1007
+ ? 1
1008
+ : secondPrice < firstPrice
1009
+ ? -1
1010
+ : 0;
1011
+ });
1012
+
1013
+ // join hotels with prices to hotels WITHOUT prices
1014
+ const sortedHotels = [...hotelsWithPrices, ...hotelsWithoutPrices];
1015
+
1016
+ // trigger next observable
1017
+ this.results.next(sortedHotels);
1018
+
1019
+ // display console logs if debug is true (could prove useful in future)
1020
+ if (debug) {
1021
+ console.log('++ sortByPrice() called ++');
1022
+ console.log('++ hotel ++', hotels);
1023
+ console.log('++ hotelsWithPrices ++', hotelsWithPrices);
1024
+ console.log('++ hotelsWithoutPrices ++', hotelsWithoutPrices);
1025
+ console.log('++ sortedHotels ++', sortedHotels);
1026
+ }
1027
+ }
1028
+
1029
+ sortByName(): void {
1030
+ this.results.next(
1031
+ this.results.value.sort(
1032
+ (fst: HotelDetails, snd: HotelDetails): number => {
1033
+ return fst.name.toLowerCase().localeCompare(snd.name.toLowerCase());
1034
+ }
1035
+ )
1036
+ );
1037
+ }
1038
+
1039
+ sortByDistance(): void {
1040
+ let results = this.results.value || [];
1041
+ results = results.sort((a, b) => {
1042
+ return Number(a.location.distance) - Number(b.location.distance);
1043
+ });
1044
+ this.results.next(results);
1045
+ }
1046
+
1047
+ byPreferred(): void {
1048
+ let results = this.results.value || [];
1049
+ results = results.sort((a: HotelDetails, b: HotelDetails) => {
1050
+ return this.preferredToInt(b) - this.preferredToInt(a);
1051
+ });
1052
+ this.results.next(results);
1053
+ }
1054
+
1055
+ private preferredToInt(hotel: HotelDetails): number {
1056
+ return (
1057
+ (hotel.preferred.client ? CLIENT_PREFERRED_VALUE : 0) +
1058
+ (hotel.preferred.consumer ? AGENT_PREFERRED_VALUE : 0)
1059
+ );
1060
+ }
1061
+
1062
+ private intToPreferred(preferred: 0 | 1 | 2 | 3) {
1063
+ return {
1064
+ // tslint:disable-next-line: no-bitwise
1065
+ client: (preferred & CLIENT_PREFERRED_VALUE) === CLIENT_PREFERRED_VALUE,
1066
+ // tslint:disable-next-line: no-bitwise
1067
+ consumer: (preferred & AGENT_PREFERRED_VALUE) === AGENT_PREFERRED_VALUE
1068
+ };
1069
+ }
1070
+
1071
+ addFilter(filter: string, type: keyof HotelFilters): void {
1072
+ const filt: any = this.localFilters;
1073
+ filt[type].push(filter);
1074
+ }
1075
+
1076
+ removeFilter(filter: string, type: keyof HotelFilters): void {
1077
+ const filt = this.localFilters;
1078
+ if (Array.isArray(filt[type])) {
1079
+ (filt[type] as string[]) = (filt[type] as string[]).filter(
1080
+ (chain: string) => {
1081
+ return filter !== chain;
1082
+ }
1083
+ );
1084
+ }
1085
+ }
1086
+
1087
+ resetFilters(): void {
1088
+ this.localFilters.chain = [];
1089
+ this.localFilters.amenitytype = [];
1090
+ this.localFilters.preferred = [];
1091
+ this.localFilters.extra = [];
1092
+ this.localFilters.hotelName = '';
1093
+ this.localFilters.breakfastType = [];
1094
+ }
1095
+
1096
+ updateFromPreviousSearches(
1097
+ previousItems: Record<ServiceType, BasketItem>
1098
+ ): void {
1099
+ const flightItem: SearchFlightsV2QueryVariables =
1100
+ previousItems[ServiceType.Flight]?.searchQuery;
1101
+ if (flightItem) {
1102
+ // TODO flights haven't been done yet.
1103
+ }
1104
+ }
1105
+
1106
+ private hasPreferred(hotel: HotelDetails): boolean {
1107
+ const preferredFilters = this.filters.preferred;
1108
+
1109
+ // Empty preferred filters OR "Any"
1110
+ if (
1111
+ !preferredFilters.length ||
1112
+ preferredFilters.includes(SearchHandler.ANY)
1113
+ ) {
1114
+ return true;
1115
+ }
1116
+
1117
+ // Agency (consumer) && Client
1118
+ if (
1119
+ preferredFilters.includes(SearchHandler.AGENCY) &&
1120
+ preferredFilters.includes(SearchHandler.CLIENT)
1121
+ ) {
1122
+ return (
1123
+ hotel.preferred.consumer === true && hotel.preferred.client === true
1124
+ );
1125
+ }
1126
+
1127
+ // Agency
1128
+ if (preferredFilters.includes(SearchHandler.AGENCY)) {
1129
+ return hotel.preferred.consumer === true;
1130
+ }
1131
+
1132
+ // Client
1133
+ if (preferredFilters.includes(SearchHandler.CLIENT)) {
1134
+ return hotel.preferred.client === true;
1135
+ }
1136
+ }
1137
+
1138
+ public getmaxPriceForCurrency(currency: string): any {
1139
+ return this.avaliabilityService.maxPriceForCurrency(currency);
1140
+ }
1141
+
1142
+ // Lightening Extra Filters
1143
+ private getExtraFilter(hotel: HotelDetails): boolean {
1144
+ const checkAvailability = this.filters.extra.includes(
1145
+ SearchHandler.AVAILABILITY
1146
+ );
1147
+ if (checkAvailability) {
1148
+ return hotel.unavailable === true;
1149
+ }
1150
+
1151
+ const checkFemaleFriendly = this.filters.extra.includes(
1152
+ SearchHandler.FEMALE_FRIENDLY
1153
+ );
1154
+ if (checkFemaleFriendly) {
1155
+ return (
1156
+ hotel.tags.filter((tag) => {
1157
+ if (tag.name) {
1158
+ let name: string = this.convertToOneString(tag.name).toLowerCase();
1159
+ return name.includes(
1160
+ this.convertToOneString(
1161
+ SearchHandler.FEMALE_FRIENDLY
1162
+ ).toLowerCase()
1163
+ );
1164
+ } else {
1165
+ return true;
1166
+ }
1167
+ }).length > 0
1168
+ );
1169
+ }
1170
+ return true;
1171
+ }
1172
+
1173
+ // Lightening Amernities Filters
1174
+ private getAmenitiesFilter(hotel: HotelDetails): boolean {
1175
+ let isTrue: boolean = true;
1176
+ this.filters.amenitytype.forEach((search) => {
1177
+ let filteredResults: any = hotel.tags.filter((tag) => {
1178
+ if (tag.name) {
1179
+ let name: string = this.convertToOneString(tag.name).toLowerCase();
1180
+ if (name.includes(this.convertToOneString(search).toLowerCase())) {
1181
+ return true;
1182
+ }
1183
+ return false;
1184
+ }
1185
+ });
1186
+ isTrue = filteredResults && filteredResults.length > 0 ? true : false;
1187
+ // console.log(`Hotel ${hotel.name} with filter applied`, hotel?.tags, isTrue);
1188
+ return isTrue;
1189
+ });
1190
+ return isTrue;
1191
+ }
1192
+
1193
+ private convertToOneString(item: string) {
1194
+ return item.replace(/[^a-zA-Z]/g, '');
1195
+ }
1196
+
1197
+ getImages(HolidayCode: string): Observable<string[]> {
1198
+ const url =
1199
+ this.environment.hostBaseUrl +
1200
+ URLS.CONFIRMA_PHOTO_URL +
1201
+ HolidayCode.split(',')[0];
1202
+ const imgProvider = 'https://www.vfmii.com/'; // img provider thats holds images, used to match which images on page belongs to gallery.
1203
+ if (this.galleries[HolidayCode]) {
1204
+ return of(this.galleries[HolidayCode]);
1205
+ }
1206
+
1207
+ return this.httpCallService.get(url as URLS, { responseType: 'text' }).pipe(
1208
+ map((imagesHTML) => {
1209
+ if (!imagesHTML) {
1210
+ throw Error(`Gallery for ${HolidayCode} can not be loaded.`);
1211
+ }
1212
+ const temp = document.createElement('div');
1213
+ temp.innerHTML = imagesHTML;
1214
+ const images = Array.from(temp.getElementsByTagName('img')).reduce(
1215
+ (acc, img) => {
1216
+ if (img.src.includes(imgProvider)) {
1217
+ acc.push(img.src);
1218
+ }
1219
+ return acc;
1220
+ },
1221
+ []
1222
+ );
1223
+ if (!images.length) {
1224
+ throw Error(
1225
+ `There is no media content provided for this hotel ${HolidayCode}`
1226
+ );
1227
+ }
1228
+ return (this.galleries[HolidayCode] = images);
1229
+ })
1230
+ );
1231
+ }
1232
+
1233
+ addPaginationPage(currentPage: number): any {
1234
+ const key = 'PaginationPageCount';
1235
+ this.storageService.setSessionItem(key, currentPage);
1236
+ return this.storageService.getSessionItem(key);
1237
+ }
1238
+
1239
+ toggleView(): void {
1240
+ if (this.currentView === HotelView.LIST) {
1241
+ this.currentView = HotelView.MAP;
1242
+ } else {
1243
+ this.currentView = HotelView.LIST;
1244
+ }
1245
+ }
1246
+
1247
+ calcDayDiff(): number {
1248
+ const checkout = moment(this.checkout_date);
1249
+ const checkin = moment(this.checkin_date);
1250
+ return checkout.startOf().diff(checkin.startOf(), 'days');
1251
+ }
1252
+ updateLowestPrice(results: HotelDetails[]): ICheapestPrice {
1253
+ const currenciesKey = Object.keys(this.avaliabilityService.currencies);
1254
+ if ((!results.length && !currenciesKey.length) || !currenciesKey.length)
1255
+ return null;
1256
+
1257
+ const currencie = currenciesKey[0];
1258
+
1259
+ return {
1260
+ amount: this.avaliabilityService.currencies[currencie].minprice,
1261
+ currencyCode: currencie
1262
+ };
1263
+ }
1264
+
1265
+ getRoomNumber() {
1266
+ let roomsOccupancy: any[] = [];
1267
+ for (let i = 0; i < Number(this.tempParams.no_of_rooms); i++) {
1268
+ const newRoomOccupancy = {
1269
+ Adults: this.calcRoomOccupancy(this.tempParams.no_of_rooms, this.tempParams.no_of_occupants),
1270
+ Children: 0,
1271
+ Infants: 0
1272
+ };
1273
+ roomsOccupancy.push(newRoomOccupancy);
1274
+ }
1275
+
1276
+ let rooms: number[] = [];
1277
+ for (let index = 0; index < roomsOccupancy.length; index++) {
1278
+ for (let j = 0; j < roomsOccupancy[index].Adults; j++) {
1279
+ rooms.push(index+1);
1280
+ }
1281
+ }
1282
+
1283
+ // --- should we add new property roomNumber for traveller? --
1284
+ // for (let index = 0; index < this.travellers.length; index++) {
1285
+ // this.travellers[index].roomNumber = rooms[index];
1286
+ // };
1287
+ }
1288
+
1289
+
1290
+ /**
1291
+ * @desc - return the occupancy for a room - need to calculate based on no of rooms, no of travellers and currently occupied rooms;
1292
+ **/
1293
+
1294
+ calcRoomOccupancy(no_of_rooms: number, travellers: number): number{
1295
+ console.log('No of Travellers: ' + travellers + '| No of rooms: ' + no_of_rooms + ' | Assigned: ' + this.occupied);
1296
+ let roomOccupancy: number = Math.ceil(travellers/no_of_rooms);
1297
+
1298
+ if (travellers - this.occupied < roomOccupancy) {
1299
+ console.log('We have run out of occupiers!');
1300
+ roomOccupancy = travellers - this.occupied;
1301
+ }
1302
+
1303
+ if (roomOccupancy <= 0) {
1304
+ roomOccupancy = 1;
1305
+ }
1306
+
1307
+ this.occupied += roomOccupancy;
1308
+ return roomOccupancy;
1309
+ }
1310
+
1311
+ async addHotelRoomToBasket(
1312
+ hotel: HotelQuoteResult,
1313
+ hotelRoom: HotelRoom,
1314
+ hotelQuery: SearchHotelsQueryVariables,
1315
+ travellers?: Traveller[]
1316
+ ): Promise<boolean> {
1317
+ if (hotel.unavailable) {
1318
+ return Promise.resolve(false);
1319
+ }
1320
+ // modify the 'startDate' and 'endDate' properties to have ISO format
1321
+ hotelQuery.startDate = new Date(hotelQuery.startDate).toISOString();
1322
+ hotelQuery.endDate = new Date(hotelQuery.endDate).toISOString();
1323
+
1324
+ // create copy of hotelQuery and delete 'adults' property as searchQuerySchema for hotel (conferma) does not seem to support it being added
1325
+ const searchQuery = { ...hotelQuery };
1326
+ delete searchQuery.adults;
1327
+
1328
+ const intBasket: InternalBasketInterface =
1329
+ await this.basketService.getDefaultBasket();
1330
+ const basket = intBasket?.subject.value;
1331
+ if (basket) {
1332
+ const { address: hotelAaddress } = hotel;
1333
+ const { rateDescription, roomDescription, roomId, roomType } = hotelRoom;
1334
+ return this.basketService.addToBasket(
1335
+ {
1336
+ adults: hotelQuery.adults,
1337
+ basket: basket.id,
1338
+ service: hotel.sourceId.toString(),
1339
+ detail: {
1340
+ checkIn: hotelQuery.startDate,
1341
+ checkOut: hotelQuery.endDate,
1342
+ hotelAddress: {
1343
+ streetName: hotelAaddress.addressLine1,
1344
+ town: hotelAaddress.addressLine2,
1345
+ county: hotelAaddress.addressLine3,
1346
+ postcode: hotelAaddress.postOrZipCode,
1347
+ countryCode: hotelAaddress.countryCode
1348
+ },
1349
+ hotelDescription: hotel.group,
1350
+ hotelName: hotel.name,
1351
+ numberOfRooms: hotelQuery.rooms,
1352
+ rateDescription,
1353
+ roomDescription,
1354
+ roomId,
1355
+ roomType
1356
+ },
1357
+ price: hotelRoom.total,
1358
+ currency: hotelRoom.currencyCode as CurrencyCode,
1359
+ searchQuery,
1360
+ outboundDate: hotelQuery.startDate
1361
+ },
1362
+ intBasket,
1363
+ this.searchService,
1364
+ this.travellers
1365
+ );
1366
+ }
1367
+
1368
+ return Promise.resolve(false);
1369
+ }
1370
+ }