@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,1597 @@
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 { Observable, of, BehaviorSubject, combineLatest } from 'rxjs';
6
+ import { CarHireSort } from '../interfaces/car-hire-sort.interface';
7
+ import { CarHireFilters } from '../interfaces/car-hire-filters.interface';
8
+ import { SelectFilter } from '../interfaces/select-filter.interface';
9
+ import { ValueDisplay } from '../interfaces/value-display';
10
+ import { EnterpriseSearchServiceInterface } from '../interfaces/Isearch.service';
11
+ import {
12
+ EnterpriseBasketServiceInterface,
13
+ InternalBasketInterface
14
+ } from '../interfaces/Ienterprise-basket.service';
15
+ import {
16
+ CarHireDetailRequestResponse,
17
+ CurrencyCode,
18
+ BasketItem,
19
+ CarHireInputIdentifiers,
20
+ CarHireVehicleAvailibility,
21
+ QuerySearchCarHireArgs,
22
+ SearchFlightsV2QueryVariables,
23
+ ServiceType,
24
+ CarHireTransmission,
25
+ CarHireClass,
26
+ CarHireType,
27
+ DistanceTypes,
28
+ SearchCarHireQueryVariables,
29
+ SaveRecentSearchMutationVariables
30
+ } from '../types/graphql.types';
31
+ import {
32
+ CarHireQuoteResult,
33
+ CarHireQuoteResultArray,
34
+ NgbDateStruct,
35
+ OBTAirportDetails,
36
+ Vendor,
37
+ LocationTypes,
38
+ LocationDetails,
39
+ CarHireDepot,
40
+ RecentSearch
41
+ } from '../types/types';
42
+ import {
43
+ BaseCarhireQuoteFetcher,
44
+ CarHireFetcherType
45
+ } from '../fetchers/carhire-quote-fetcher';
46
+ import {
47
+ CarhireEnterpriseSearchInterface,
48
+ CarHireTempParams
49
+ } from '../interfaces/Icarhire-enterprise-search';
50
+ import { ICheapestPrice } from '../interfaces/cheapest-price';
51
+ import {
52
+ BaseCarHireAvailabilityDetailFetcher,
53
+ CarHireAvailabilityDetailFetcherType
54
+ } from '../fetchers/carhire-availability-detail.fetcher';
55
+ import { take, map } from 'rxjs/operators';
56
+ import { ICarClasses } from '../interfaces/car-hire-classes.interface';
57
+ import { Traveller } from '../models/traveller.object';
58
+
59
+ export enum SortTypesCar {
60
+ price = 'price',
61
+ brand = 'brand',
62
+ size = 'size',
63
+ preferred = 'preferred',
64
+ expensive = 'expensive'
65
+ }
66
+
67
+ export class CarhireEnterpriseSearch<
68
+ CH_Q extends CarHireFetcherType,
69
+ CHAD_Q extends CarHireAvailabilityDetailFetcherType
70
+ >
71
+ extends BaseEnterpriseSearch<
72
+ CarHireTempParams,
73
+ CarHireQuoteResultArray,
74
+ CarHireQuoteResultArray
75
+ >
76
+ implements CarhireEnterpriseSearchInterface
77
+ {
78
+ static readonly STORAGE_SESSION_PARAMS = 'carhire_params';
79
+ static readonly STORAGE_SESSION_RESULTS = 'carhire_results';
80
+
81
+ // ! - Hardcoded Data
82
+ private _carTypeCodes: [string, string, CarHireType][] = [
83
+ ['B', '2-3 Door', CarHireType.TwoToThreeDoor],
84
+ ['C', '2/4 Door', CarHireType.TwoOrFourDoor],
85
+ ['D', '4-5 Door', CarHireType.FourToFiveDoor],
86
+ ['W', 'Wagon / Estate', CarHireType.WagonOrEstate],
87
+ ['V', 'Passenger Van', CarHireType.PassengerVan],
88
+ ['L', 'Limousine', CarHireType.Limousine],
89
+ ['S', 'Sport', CarHireType.Sport],
90
+ ['T', 'Convertible', CarHireType.Convertible],
91
+ ['F', 'SUV', CarHireType.Suv],
92
+ ['J', 'Open Air All Terrain', CarHireType.OpenAirAllTerrain],
93
+ ['X', 'Special', CarHireType.Special],
94
+ ['P', 'Pickup Regular Cab', CarHireType.PickUpRegularCab],
95
+ ['Q', 'Pickup Extended Cab', CarHireType.PickUpExtendedCab],
96
+ ['Z', 'Special Offer Car', CarHireType.SpecialOfferCar],
97
+ ['E', 'Coupe', CarHireType.Coupe],
98
+ ['M', 'Monospace (Europe)', CarHireType.MonospaceEuropeanUse],
99
+ ['R', 'Recreational Vehicle', CarHireType.Suv],
100
+ ['H', 'Motor Home', CarHireType.MotorHome],
101
+ ['Y', '2-Wheel Vehicle', CarHireType.TwoWheelVehicle],
102
+ ['N', 'Roadster', CarHireType.Roadster],
103
+ ['G', 'Crossover', CarHireType.Suv],
104
+ ['K', 'Commercial Van / Truck', CarHireType.PassengerVan]
105
+ ];
106
+
107
+ private _carAirConditionTypes: [string, string, boolean][] = [
108
+ ['Any', 'Any', null],
109
+ ['Y', 'Yes', true],
110
+ ['N', 'No', false]
111
+ ];
112
+
113
+ private _carTransmissionCodes: [string, string, CarHireTransmission][] = [
114
+ ['M', 'Manual', CarHireTransmission.Manual],
115
+ ['N', 'Manual 4-Wheel Drive', CarHireTransmission.Manual],
116
+ ['C', 'Manual All-Wheel Drive', CarHireTransmission.Manual],
117
+ ['A', 'Automatic', CarHireTransmission.Auto],
118
+ ['B', 'Automatic 4-Wheel Drive', CarHireTransmission.Auto],
119
+ ['D', 'Automatic All- Wheel Drive', CarHireTransmission.Auto]
120
+ ];
121
+
122
+ carhireCodes: any;
123
+ private _vendors: Vendor[] = [
124
+ { code: '-', name: 'Any' },
125
+ { code: 'AC', name: 'Ace Rent A Car' },
126
+ { code: 'AD', name: 'Advantage Rent A Car' },
127
+ { code: 'AL', name: 'Alamo' },
128
+ { code: 'ZI', name: 'Avis' },
129
+ { code: 'AT', name: 'Atesa' },
130
+ { code: 'ZD', name: 'Budget Rent A Car' },
131
+ { code: 'CI', name: 'Citer Rent A Car' },
132
+ { code: 'ZR', name: 'Dollar Rent A Car' },
133
+ { code: 'DF', name: 'Driving Force' },
134
+ { code: 'EY', name: 'Economy Rent A Car' },
135
+ { code: 'ET', name: 'Enterprise' },
136
+ { code: 'EP', name: 'Europcar' },
137
+ { code: 'IM', name: 'Europcar Southafrica' },
138
+ { code: 'EZ', name: 'Ez Rent A Car' },
139
+ { code: 'FF', name: 'Firefly' },
140
+ { code: 'FX', name: 'Fox Rent A Car' },
141
+ { code: 'GN', name: 'Guerin Car Rental' },
142
+ { code: 'ZE', name: 'Hertz' },
143
+ { code: 'LM', name: 'L & M Car Rental' },
144
+ { code: 'LL', name: 'Localiza' },
145
+ { code: 'MW', name: 'Midway Car Rental' },
146
+ { code: 'ZL', name: 'National Car Rental System' },
147
+ { code: 'NC', name: 'Nextcar' },
148
+ { code: 'NU', name: 'Nu Car Rentals' },
149
+ { code: 'ZA', name: 'Payless Car Rental' },
150
+ { code: 'PR', name: 'Priceless' },
151
+ { code: 'RW', name: 'Rent A Wreck' },
152
+ { code: 'SX', name: 'Sixt' },
153
+ { code: 'TE', name: 'Tempest' },
154
+ { code: 'XF', name: 'Test-S Cross Galileo' },
155
+ { code: 'XG', name: 'Test-S Cross Trng' },
156
+ { code: 'ZT', name: 'Thrifty Car Rental' },
157
+ { code: 'PM', name: 'Travelport Test Code' },
158
+ { code: 'SV', name: 'U-Save Auto Rental' },
159
+ { code: 'WF', name: 'Woodford' }
160
+ ];
161
+
162
+ private _car_classes: ICarClasses[] = [
163
+ { code: 'M', name: 'Mini', key: CarHireClass.Mini, value: '10' },
164
+ { code: 'N', name: 'Mini Elite', key: CarHireClass.MiniElite, value: '20' },
165
+ { code: 'E', name: 'Economy', key: CarHireClass.Economy, value: '30' },
166
+ {
167
+ code: 'H',
168
+ name: 'Economy Elite',
169
+ key: CarHireClass.EconomyElite,
170
+ value: '40'
171
+ },
172
+ { code: 'C', name: 'Compact', key: CarHireClass.Compact, value: '50' },
173
+ {
174
+ code: 'D',
175
+ name: 'Compact Elite',
176
+ key: CarHireClass.CompactElite,
177
+ value: '60'
178
+ },
179
+ {
180
+ code: 'I',
181
+ name: 'Intermediate',
182
+ key: CarHireClass.Intermediate,
183
+ value: '70'
184
+ },
185
+ {
186
+ code: 'J',
187
+ name: 'Intermediate Elite',
188
+ key: CarHireClass.IntermediateElite,
189
+ value: '80'
190
+ },
191
+ { code: 'S', name: 'Standard', key: CarHireClass.Standard, value: '90' },
192
+ {
193
+ code: 'R',
194
+ name: 'Standard Elite',
195
+ key: CarHireClass.StandardElite,
196
+ value: '100'
197
+ },
198
+ { code: 'F', name: 'Full Size', key: CarHireClass.Fullsize, value: '110' },
199
+ {
200
+ code: 'G',
201
+ name: 'Full Size Elite',
202
+ key: CarHireClass.FullsizeElite,
203
+ value: '120'
204
+ },
205
+ { code: 'P', name: 'Premium', key: CarHireClass.Premium, value: '130' },
206
+ {
207
+ code: 'U',
208
+ name: 'Premium Elite',
209
+ key: CarHireClass.PremiumElite,
210
+ value: '140'
211
+ },
212
+ { code: 'L', name: 'Luxury', key: CarHireClass.Luxury, value: '150' },
213
+ {
214
+ code: 'W',
215
+ name: 'Luxury Elite',
216
+ key: CarHireClass.LuxuryElite,
217
+ value: '160'
218
+ },
219
+ { code: 'O', name: 'Oversize', key: CarHireClass.Oversize, value: '170' },
220
+ { code: 'X', name: 'Special', key: CarHireClass.Special, value: '180' }
221
+ ];
222
+
223
+ private _location_types = [
224
+ LocationTypes.City,
225
+ LocationTypes.Airport,
226
+ LocationTypes.Postcode
227
+ ];
228
+
229
+ private carClassMap: { [key: string]: number } = {
230
+ mini: 0,
231
+ 'mini elite': 1,
232
+ economy: 2,
233
+ 'economy elite': 3,
234
+ compact: 4,
235
+ 'compact special': 5,
236
+ 'compact elite': 6,
237
+ intermediate: 7,
238
+ 'intermediate elite': 8,
239
+ standard: 9,
240
+ 'standard elite': 10,
241
+ 'full size': 11,
242
+ 'full size elite': 12,
243
+ premium: 13,
244
+ 'premium elite': 14,
245
+ luxury: 15,
246
+ 'luxury elite': 16,
247
+ oversize: 17,
248
+ special: 18
249
+ };
250
+ // ! - End of hardcoded data
251
+
252
+ public type: ServiceType = ServiceType.Car;
253
+
254
+ private _ngbPickupDate: NgbDateStruct;
255
+ private _pickupTime: string;
256
+ private _ngbDropoffDate: NgbDateStruct;
257
+ private _dropoffTime: string;
258
+ private _sorting_options: CarHireSort[] = [
259
+ {
260
+ value: 0,
261
+ display: 'Cheapest First'
262
+ },
263
+ {
264
+ value: 1,
265
+ display: 'Most Expensive First'
266
+ },
267
+ {
268
+ value: 2,
269
+ display: 'Preferred First'
270
+ }
271
+ ];
272
+ private _minDate: NgbDateStruct = {
273
+ day: moment().date(),
274
+ month: moment().month() + 1,
275
+ year: moment().year()
276
+ };
277
+
278
+ private _minInDate: NgbDateStruct = {
279
+ day: moment().date(),
280
+ month: moment().month() + 1,
281
+ year: moment().year()
282
+ };
283
+ travellers: Traveller[];
284
+
285
+ get adults(): number {
286
+ return this.tempParams.adults;
287
+ }
288
+
289
+ set adults(value: number) {
290
+ this.tempParams.adults = value;
291
+ this._isValid();
292
+ }
293
+
294
+ get children(): number {
295
+ return this.tempParams.children;
296
+ }
297
+
298
+ set children(value: number) {
299
+ this.tempParams.children = value;
300
+ this._isValid();
301
+ }
302
+
303
+ get estimatedMileage(): number {
304
+ return this.tempParams.estimatedMileage;
305
+ }
306
+
307
+ set estimatedMileage(milage: number) {
308
+ this.tempParams.estimatedMileage = milage;
309
+ this._isValid();
310
+ }
311
+
312
+ get pickupTime(): string {
313
+ return this._pickupTime;
314
+ }
315
+
316
+ set pickupTime(newtime: string) {
317
+ this._pickupTime = newtime;
318
+ this._updateNgbPickupDateTime();
319
+ }
320
+
321
+ get dropoffTime(): string {
322
+ return this._dropoffTime;
323
+ }
324
+
325
+ set dropoffTime(newtime: string) {
326
+ this._dropoffTime = newtime;
327
+ this._updateNgbDropoffDateTime();
328
+ }
329
+
330
+ get postcodePickupRaw(): LocationDetails {
331
+ return this.tempParams.postcodePickupRaw;
332
+ }
333
+
334
+ set postcodePickupRaw(newPickupCountry: LocationDetails) {
335
+ this.tempParams.postcodePickupRaw = newPickupCountry;
336
+ this._isValid();
337
+ }
338
+
339
+ get postcodeDropoffRaw(): LocationDetails {
340
+ return this.tempParams.postcodeDropoffRaw;
341
+ }
342
+
343
+ set postcodeDropoffRaw(newPickupCountry: LocationDetails) {
344
+ this.tempParams.postcodeDropoffRaw = newPickupCountry;
345
+ this._isValid();
346
+ }
347
+
348
+ get cityPickupDepot(): CarHireDepot {
349
+ return this.tempParams.cityPickupDepot;
350
+ }
351
+
352
+ set cityPickupDepot(newPickupCountry: CarHireDepot) {
353
+ this.tempParams.cityPickupDepot = newPickupCountry;
354
+ this._isValid();
355
+ }
356
+
357
+ get cityDropoffDepot(): CarHireDepot {
358
+ return this.tempParams.cityDropoffDepot;
359
+ }
360
+
361
+ set cityDropoffDepot(newPostCodeDropoff: CarHireDepot) {
362
+ this.tempParams.cityDropoffDepot = newPostCodeDropoff;
363
+ this._isValid();
364
+ }
365
+
366
+ get postcodePickup(): CarHireDepot {
367
+ return this.tempParams.postcodePickup;
368
+ }
369
+
370
+ set postcodePickup(newPickupCountry: CarHireDepot) {
371
+ this.tempParams.postcodePickup = newPickupCountry;
372
+ if (this.tempParams.postcodePickup) {
373
+ this.tempParams.locationType = LocationTypes.Postcode;
374
+ }
375
+ this._isValid();
376
+ }
377
+
378
+ get postcodeDropoff(): CarHireDepot {
379
+ return this.tempParams.postcodeDropoff;
380
+ }
381
+
382
+ set postcodeDropoff(newPostCodeDropoff: CarHireDepot) {
383
+ this.tempParams.postcodeDropoff = newPostCodeDropoff;
384
+ this._isValid();
385
+ }
386
+
387
+ get cityPickup(): LocationDetails {
388
+ return this.tempParams.cityPickup;
389
+ }
390
+
391
+ set cityPickup(newPickup: LocationDetails) {
392
+ this.tempParams.cityPickup = newPickup;
393
+ if (this.tempParams.cityPickup) {
394
+ this.tempParams.locationType = LocationTypes.City;
395
+ console.log(this.tempParams.locationType);
396
+ }
397
+
398
+ this._isValid();
399
+ }
400
+
401
+ get cityDropoff(): LocationDetails {
402
+ return this.tempParams.cityDropoff;
403
+ }
404
+
405
+ set cityDropoff(newDropoff: LocationDetails) {
406
+ this.tempParams.cityDropoff = newDropoff;
407
+ this._isValid();
408
+ }
409
+
410
+ get minDate(): NgbDateStruct {
411
+ return this._minDate;
412
+ }
413
+
414
+ get minInDate(): NgbDateStruct {
415
+ return this._minInDate;
416
+ }
417
+
418
+ private _timeArray: ValueDisplay[];
419
+ // - Getters And Setters For Various Variables
420
+ get pickup_country(): string {
421
+ return this.tempParams.pickup_country;
422
+ }
423
+
424
+ set pickup_country(newPickupCountry: string) {
425
+ this.tempParams.pickup_country = newPickupCountry;
426
+ this._isValid();
427
+ }
428
+
429
+ get dropoff_country(): string {
430
+ return this.tempParams.dropoff_country;
431
+ }
432
+
433
+ set dropoff_country(newDropoffCountry: string) {
434
+ this.tempParams.dropoff_country = newDropoffCountry;
435
+ this._isValid();
436
+ }
437
+
438
+ get pickup_location(): OBTAirportDetails {
439
+ return this.tempParams.pickup_location;
440
+ }
441
+
442
+ set pickup_location(pickupLocation: OBTAirportDetails) {
443
+ this.tempParams.pickup_location = pickupLocation;
444
+ if (this.tempParams.pickup_location) {
445
+ this.tempParams.locationType = LocationTypes.Airport;
446
+ }
447
+
448
+ if (this.return_to_pickup) {
449
+ this.dropoff_location = pickupLocation;
450
+ }
451
+
452
+ this._isValid();
453
+ }
454
+
455
+ get dropoff_location(): OBTAirportDetails {
456
+ return this.tempParams.dropoff_location;
457
+ }
458
+
459
+ set dropoff_location(dropOffLocation: OBTAirportDetails) {
460
+ this.tempParams.dropoff_location = dropOffLocation;
461
+ this._isValid();
462
+ }
463
+
464
+ set ngbPickupDate(value: NgbDateStruct) {
465
+ this._ngbPickupDate = value;
466
+ this._updateNgbPickupDateTime();
467
+ }
468
+
469
+ get ngbPickupDate(): NgbDateStruct {
470
+ return this._ngbPickupDate;
471
+ }
472
+
473
+ set ngbDropoffDate(value: NgbDateStruct) {
474
+ this._ngbDropoffDate = value;
475
+ this._updateNgbDropoffDateTime();
476
+ }
477
+
478
+ get ngbDropoffDate(): NgbDateStruct {
479
+ return this._ngbDropoffDate;
480
+ }
481
+
482
+ // Datetimes within the query itself
483
+ get pickup_datetime(): moment.Moment {
484
+ return this.tempParams.pickup_datetime;
485
+ }
486
+
487
+ set pickup_datetime(value: moment.Moment) {
488
+ this.tempParams.pickup_datetime = value;
489
+ try {
490
+ if (value && value.isValid()) {
491
+ this._ngbPickupDate = this.helpers.momentToNgDate(value);
492
+ this._pickupTime = moment(value).format('HH:mm')
493
+ ? moment(value).format('HH:mm')
494
+ : '07:30';
495
+ }
496
+ this._minInDate = {
497
+ day: value.date(),
498
+ month: value.month() + 1,
499
+ year: value.year()
500
+ };
501
+
502
+ if (value.isSameOrAfter(this.tempParams.dropoff_datetime)) {
503
+ this.dropoff_datetime = this.dropoff_datetime
504
+ .set('date', value.date())
505
+ .set('month', value.month())
506
+ .set('year', value.year());
507
+ }
508
+ } catch (error) {}
509
+
510
+ this._isValid();
511
+ }
512
+
513
+ get dropoff_datetime(): moment.Moment {
514
+ return this.tempParams.dropoff_datetime;
515
+ }
516
+
517
+ set dropoff_datetime(value: moment.Moment) {
518
+ this.tempParams.dropoff_datetime = value;
519
+ if (value && value.isValid()) {
520
+ this._ngbDropoffDate = this.helpers.momentToNgDate(value);
521
+ this._dropoffTime = moment(value).format('HH:mm')
522
+ ? moment(value).format('HH:mm')
523
+ : '08:30';
524
+ }
525
+ this._isValid();
526
+ }
527
+
528
+ // !date and time is handled differently for LU
529
+ private _pickup_date: NgbDateStruct = null;
530
+
531
+ get pickup_date(): NgbDateStruct {
532
+ return this._pickup_date;
533
+ }
534
+
535
+ set pickup_date(value: NgbDateStruct) {
536
+ this._pickup_date = value;
537
+ this._updatePickupDateTime();
538
+ }
539
+
540
+ private _pickup_time: string = null;
541
+ get pickup_time(): string {
542
+ return this._pickup_time;
543
+ }
544
+
545
+ set pickup_time(value: string) {
546
+ this._pickup_time = value;
547
+ this._updatePickupDateTime();
548
+ }
549
+
550
+ private _dropoff_date: NgbDateStruct = null;
551
+
552
+ get dropoff_date(): NgbDateStruct {
553
+ return this._dropoff_date;
554
+ }
555
+
556
+ set dropoff_date(value: NgbDateStruct) {
557
+ this._dropoff_date = value;
558
+ this._updateDropoffDateTime();
559
+ }
560
+
561
+ private _dropoff_time: string = null;
562
+ get dropoff_time(): string {
563
+ return this._dropoff_time;
564
+ }
565
+
566
+ set dropoff_time(value: string) {
567
+ this._dropoff_time = value;
568
+ this._updateDropoffDateTime();
569
+ }
570
+
571
+ get return_to_pickup(): boolean {
572
+ return this.tempParams.return_to_pickup;
573
+ }
574
+
575
+ set return_to_pickup(newVal: boolean) {
576
+ this.tempParams.return_to_pickup = newVal;
577
+ this._isValid();
578
+ }
579
+
580
+ get chosenVendor(): string {
581
+ return this.tempParams.chosenVendor;
582
+ }
583
+
584
+ set chosenVendor(newVendor: string) {
585
+ this.tempParams.chosenVendor = newVendor;
586
+ this._isValid();
587
+ }
588
+
589
+ get carClass(): CarHireClass {
590
+ return this.tempParams.carClass;
591
+ }
592
+
593
+ set carClass(carClass: CarHireClass) {
594
+ this.tempParams.carClass = carClass;
595
+ this._isValid();
596
+ }
597
+
598
+ get carType(): CarHireType {
599
+ return this.tempParams.carType;
600
+ }
601
+
602
+ set carType(type: CarHireType) {
603
+ this.tempParams.carType = type;
604
+ this._isValid();
605
+ }
606
+
607
+ get transmission(): CarHireTransmission {
608
+ return this.tempParams.transmission;
609
+ }
610
+
611
+ set transmission(trans: CarHireTransmission) {
612
+ this.tempParams.transmission = trans;
613
+ this._isValid();
614
+ }
615
+
616
+ get airCon(): boolean {
617
+ return this.tempParams.airCon;
618
+ }
619
+
620
+ set airCon(newCon: boolean) {
621
+ this.tempParams.airCon = newCon;
622
+ this._isValid();
623
+ }
624
+
625
+ get locationType(): LocationTypes {
626
+ return this.tempParams.locationType;
627
+ }
628
+ set locationType(value: LocationTypes) {
629
+ this.tempParams.locationType = value;
630
+ this._isValid();
631
+ }
632
+
633
+ public get timeArray() {
634
+ this._timeArray =
635
+ this._timeArray ||
636
+ Array(96)
637
+ .fill(0)
638
+ .map((_, index: number) => {
639
+ return {
640
+ value:
641
+ Math.floor(index / 4)
642
+ .toString()
643
+ .padStart(2, '0') +
644
+ ':' +
645
+ ((index % 4) * 15).toString().padStart(2, '0'),
646
+ display:
647
+ Math.floor(index / 4)
648
+ .toString()
649
+ .padStart(2, '0') +
650
+ ':' +
651
+ ((index % 4) * 15).toString().padStart(2, '0')
652
+ };
653
+ });
654
+ return this._timeArray;
655
+ }
656
+
657
+ // ! - The below values have getters only (I.E Cannot modify)
658
+
659
+ get carAirConditionTypes(): [string, string, boolean][] {
660
+ return this._carAirConditionTypes;
661
+ }
662
+
663
+ get carTransmissionCodes(): [string, string, CarHireTransmission][] {
664
+ return this._carTransmissionCodes;
665
+ }
666
+
667
+ get carTypeCodes(): [string, string, CarHireType][] {
668
+ return this._carTypeCodes;
669
+ }
670
+
671
+ get vendors(): Vendor[] {
672
+ return this._vendors;
673
+ }
674
+
675
+ get sortingOptions(): CarHireSort[] {
676
+ return this._sorting_options;
677
+ }
678
+
679
+ // ! - End of getters and setters
680
+
681
+ constructor(
682
+ private carhirefetcher: BaseCarhireQuoteFetcher<CH_Q>,
683
+ private carHireAvailabilityDetailFetcher: BaseCarHireAvailabilityDetailFetcher<CHAD_Q>,
684
+ private helpers: BaseHelperRoutines,
685
+ private basketService: EnterpriseBasketServiceInterface,
686
+ storageService: BaseStorageService,
687
+ private searchService: EnterpriseSearchServiceInterface
688
+ ) {
689
+ super(storageService);
690
+ const data: {
691
+ tempParams: CarHireTempParams;
692
+ } = storageService.getSessionItem(
693
+ CarhireEnterpriseSearch.STORAGE_SESSION_PARAMS
694
+ ) || {
695
+ tempParams: {} as CarHireTempParams
696
+ };
697
+
698
+ this.updateTempParams(searchService.makeCarHireQuery(data.tempParams));
699
+
700
+ if (searchService.shouldAddTravellerSubscription()) {
701
+ searchService.travellerInformation.subscribe(
702
+ (travellers: Traveller[]) => {
703
+ const splitTravellers = this.helpers.selectedTravellers(
704
+ travellers,
705
+ ServiceType.Car
706
+ );
707
+ this.adults = splitTravellers.adults.length;
708
+ this.children = splitTravellers.children.length;
709
+ this.travellers = travellers;
710
+ this._isValid();
711
+ }
712
+ );
713
+ }
714
+
715
+ const results =
716
+ storageService.getSessionItemAsList<CarHireQuoteResultArray>(
717
+ this.resultsSessionName
718
+ ) || [];
719
+
720
+ this.fullResults = helpers.clone(results || []);
721
+ this._cheapestResultPrice = this.updateLowestPrice(results);
722
+ this.results.next(results);
723
+ }
724
+
725
+ protected resultsSessionName =
726
+ CarhireEnterpriseSearch.STORAGE_SESSION_RESULTS;
727
+
728
+ protected resetQuery(): void {
729
+ this.updateTempParams(this.searchService.makeCarHireQuery());
730
+ this.estimatedMileage = null;
731
+ this._isValid();
732
+ }
733
+
734
+ private _isValid() {
735
+ if (!this.doChecks) {
736
+ return;
737
+ }
738
+ this.storageService.setSessionItem(
739
+ CarhireEnterpriseSearch.STORAGE_SESSION_PARAMS,
740
+ {
741
+ tempParams: this.tempParams
742
+ }
743
+ );
744
+
745
+ // go over and check that all of the various variables are correct
746
+
747
+ // first of all check that we have a valid location
748
+ this.validationMessages = [];
749
+
750
+ switch (this.locationType) {
751
+ case LocationTypes.Airport:
752
+ if (!this.pickup_location || !this.pickup_location.destination) {
753
+ this.validationMessages.push('Please supply a pickup location');
754
+ }
755
+
756
+ if (!this.dropoff_location || !this.dropoff_location.destination) {
757
+ this.validationMessages.push('Please supply a dropoff location');
758
+ }
759
+ break;
760
+ case LocationTypes.City:
761
+ if (!this.cityPickup) {
762
+ this.validationMessages.push('Please supply a pickup city');
763
+ }
764
+
765
+ if (!this.cityDropoff) {
766
+ this.validationMessages.push('Please supply a dropoff city');
767
+ }
768
+ break;
769
+ case LocationTypes.Postcode:
770
+ if (!this.postcodePickup) {
771
+ this.validationMessages.push('Please supply a pickup depot');
772
+ }
773
+
774
+ if (!this.postcodeDropoff) {
775
+ this.validationMessages.push('Please supply a dropoff depot');
776
+ }
777
+ break;
778
+ }
779
+
780
+ if (this.estimatedMileage && this.estimatedMileage <= 0) {
781
+ this.validationMessages.push(
782
+ 'Estimated Milage must be a positive number.'
783
+ );
784
+ }
785
+
786
+ try {
787
+ if (!this.pickup_datetime) {
788
+ this.validationMessages.push('Please supply a pickup time and date');
789
+ }
790
+
791
+ if (!this.dropoff_datetime) {
792
+ this.validationMessages.push('Please supply a drop off time and date');
793
+ }
794
+
795
+ if (
796
+ this.dropoff_datetime?.isSameOrBefore(this.pickup_datetime, 'minute')
797
+ ) {
798
+ this.validationMessages.push(
799
+ 'Dropoff date/time cannot be before or the same as pickup date/time'
800
+ );
801
+ }
802
+
803
+ if (this.pickup_datetime?.isBefore(moment())) {
804
+ this.validationMessages.push(
805
+ 'Pickup date/time must be after present date/time'
806
+ );
807
+ }
808
+
809
+ if (this.dropoff_datetime?.isBefore(moment())) {
810
+ this.validationMessages.push(
811
+ 'Dropoff date/time must be after present date/time'
812
+ );
813
+ }
814
+ } catch (error) {}
815
+
816
+ this.isValid.next(this.validationMessages.length === 0);
817
+ this.messages.next(this.validationMessages);
818
+ }
819
+
820
+ startSearch(): Promise<boolean> {
821
+ this.results.next([]);
822
+ if (this.isValid.value) {
823
+ const query = this.getSearchQuery();
824
+ this.searchService.saveRecentSearch(
825
+ this.getRecentSearchQuery(this.getSearchQuery())
826
+ );
827
+ return this._startSearch(
828
+ this.carhirefetcher.fetchList(
829
+ this.helpers.removeNulls<QuerySearchCarHireArgs>(query)
830
+ )
831
+ );
832
+ } else {
833
+ return Promise.resolve(false);
834
+ }
835
+ }
836
+
837
+ getRecentSearchQuery(
838
+ query: QuerySearchCarHireArgs
839
+ ): SaveRecentSearchMutationVariables {
840
+ const recentSearchQuery: any = query;
841
+ switch (this.locationType) {
842
+ case LocationTypes.City:
843
+ recentSearchQuery.city = {
844
+ pickupName: this.cityPickup.name,
845
+ pickupCountryCode: this.cityPickup.countryCode,
846
+ pickupCity: this.cityPickup.id.toString(),
847
+ pickupLatitude: this.cityPickup.latitude,
848
+ pickupLongitude: this.cityPickup.longitude,
849
+
850
+ dropOffName: this.cityDropoff.name,
851
+ dropoffCountryCode: this.cityDropoff.countryCode,
852
+ dropoffCity: this.cityDropoff.id.toString(),
853
+ dropOffLatitude: this.cityDropoff.latitude,
854
+ dropOffLongitude: this.cityDropoff.longitude,
855
+
856
+ pickupAddressLines: this.cityPickupDepot.addressLines[0],
857
+ pickupCityName: this.cityPickupDepot.cityName,
858
+ pickupExtendedLocationCode: this.cityPickupDepot.extendedLocationCode,
859
+ pickupLocationCode: this.cityPickupDepot.locationCode,
860
+ pickupVendor: this.cityPickupDepot.vendor,
861
+ pickupVendorCode: this.cityPickupDepot.vendorCode,
862
+
863
+ dropOffAddressLines: this.cityDropoffDepot.addressLines[0],
864
+ dropOffCityName: this.cityDropoffDepot.cityName,
865
+ dropOffExtendedLocationCode:
866
+ this.cityDropoffDepot.extendedLocationCode,
867
+ dropOffLocationCode: this.cityDropoffDepot.locationCode,
868
+ dropOffVendor: this.cityDropoffDepot.vendor,
869
+ dropOffVendorCode: this.cityDropoffDepot.vendorCode
870
+ };
871
+ break;
872
+ case LocationTypes.Postcode:
873
+ recentSearchQuery.depot = {
874
+ vendorCode: this.postcodePickup.vendorCode,
875
+ pickupLocationCode: this.postcodePickup.locationCode,
876
+ pickupExtendedLocationCode: this.postcodePickup.extendedLocationCode,
877
+ pickupAddressLines: this.postcodePickup.addressLines[0],
878
+ pickupCityName: this.postcodePickup.cityName,
879
+ pickupVendor: this.postcodePickup.vendor,
880
+
881
+ dropOffLocationCode: this.postcodeDropoff.locationCode,
882
+ dropOffExtendedLocationCode:
883
+ this.postcodeDropoff.extendedLocationCode,
884
+ dropoffAddressLines: this.postcodeDropoff.addressLines[0],
885
+ dropoffCityName: this.postcodeDropoff.cityName,
886
+ dropoffVendor: this.postcodeDropoff.vendor,
887
+
888
+ pickupPostCode: this.postcodePickupRaw.name,
889
+ pickupLatitude: this.postcodePickupRaw.latitude,
890
+ pickupLongitude: this.postcodePickupRaw.longitude,
891
+
892
+ dropoffPostCode: this.postcodeDropoffRaw.name,
893
+ dropoffLatitude: this.postcodeDropoffRaw.latitude,
894
+ dropoffLongitude: this.postcodeDropoffRaw.longitude
895
+ };
896
+ break;
897
+ }
898
+
899
+ return {
900
+ serviceType: ServiceType.Car,
901
+ searchArgs: recentSearchQuery,
902
+ travelDate: this.pickup_datetime.format(),
903
+ travellers: this.helpers.getTravellersId(this.travellers)
904
+ };
905
+ }
906
+
907
+ public startRecentSearch(recentSearch: RecentSearch): void {
908
+ this.chosenVendor = recentSearch.searchArgs.vendor;
909
+ this.carClass = recentSearch.searchArgs.class;
910
+ this.carType = recentSearch.searchArgs.type;
911
+ this.transmission = recentSearch.searchArgs.transmission;
912
+ this.airCon = recentSearch.searchArgs.aircon;
913
+ this.estimatedMileage = recentSearch.searchArgs.estimatedDailyDistance;
914
+ this.dropoff_datetime = moment(recentSearch.searchArgs.dropoffDateTime);
915
+ this.pickup_datetime = moment(recentSearch.searchArgs.pickupDateTime);
916
+
917
+ if (recentSearch.searchArgs.city) {
918
+ this.getParamsForCarbyCity(recentSearch);
919
+ } else if (recentSearch.searchArgs.airport) {
920
+ this.getParamsForCarbyAirport(recentSearch);
921
+ } else if (recentSearch.searchArgs.depot) {
922
+ this.getParamsForCarbyPostCode(recentSearch);
923
+ }
924
+ }
925
+
926
+ private getParamsForCarbyAirport(recentSearch: RecentSearch): void {
927
+ this.locationType = LocationTypes.Airport;
928
+ combineLatest([
929
+ this.searchService.getAirportByCode(
930
+ recentSearch.searchArgs.airport.pickupCode
931
+ ),
932
+ this.searchService.getAirportByCode(
933
+ recentSearch.searchArgs.airport.dropoffCode
934
+ )
935
+ ]).subscribe(([departLocation, arriveLocation]) => {
936
+ if (departLocation && arriveLocation) {
937
+ this.dropoff_location = {
938
+ destination: departLocation.iataMatch.name,
939
+ gateway: departLocation.iataMatch.iata,
940
+ terminals: this.searchService.processTerminals(
941
+ arriveLocation.iataMatch.terminals
942
+ ),
943
+ country: departLocation.iataMatch?.locationDetails?.country,
944
+ postcode: departLocation.iataMatch?.locationDetails?.postcode,
945
+ countryCode: departLocation.iataMatch?.locationDetails?.countryCode
946
+ };
947
+ this.pickup_location = {
948
+ destination: arriveLocation.iataMatch.name,
949
+ gateway: arriveLocation.iataMatch.iata,
950
+ terminals: this.searchService.processTerminals(
951
+ arriveLocation.iataMatch.terminals
952
+ ),
953
+ country: arriveLocation.iataMatch?.locationDetails?.country,
954
+ postcode: arriveLocation.iataMatch?.locationDetails?.postcode,
955
+ countryCode: arriveLocation.iataMatch?.locationDetails?.countryCode
956
+ };
957
+
958
+ this.dropoff_country = this.dropoff_location.countryCode;
959
+ this.pickup_country = this.pickup_location.countryCode;
960
+ this.searchService.startSearches();
961
+ }
962
+ });
963
+ }
964
+
965
+ private getParamsForCarbyCity(recentSearch: RecentSearch): void {
966
+ this.locationType = LocationTypes.City;
967
+
968
+ this.cityPickup = {
969
+ countryCode: recentSearch.searchArgs.city.pickupCountryCode,
970
+ id: recentSearch.searchArgs.city.pickupCity,
971
+ name: recentSearch.searchArgs.city.pickupName,
972
+ type: LocationTypes.City,
973
+ latitude: recentSearch.searchArgs.city.pickupLatitude,
974
+ longitude: recentSearch.searchArgs.city.pickupLongitude
975
+ };
976
+
977
+ this.cityDropoff = {
978
+ countryCode: recentSearch.searchArgs.city.dropoffCountryCode,
979
+ id: recentSearch.searchArgs.city.dropoffCity,
980
+ name: recentSearch.searchArgs.city.dropOffName,
981
+ type: LocationTypes.City,
982
+ latitude: recentSearch.searchArgs.city.dropOffLatitude,
983
+ longitude: recentSearch.searchArgs.city.dropOffLongitude
984
+ };
985
+
986
+ this.cityDropoffDepot = {
987
+ addressLines: [recentSearch.searchArgs.city.dropOffAddressLines],
988
+ cityName: recentSearch.searchArgs.city.dropOffCityName,
989
+ extendedLocationCode:
990
+ recentSearch.searchArgs.city.dropOffExtendedLocationCode,
991
+ locationCode: recentSearch.searchArgs.city.dropOffLocationCode,
992
+ vendor: recentSearch.searchArgs.city.dropOffVendor,
993
+ vendorCode: recentSearch.searchArgs.city.dropOffVendorCode
994
+ };
995
+
996
+ this.cityPickupDepot = {
997
+ addressLines: [recentSearch.searchArgs.city.pickupAddressLines],
998
+ cityName: recentSearch.searchArgs.city.pickupCityName,
999
+ extendedLocationCode:
1000
+ recentSearch.searchArgs.city.pickupExtendedLocationCode,
1001
+ locationCode: recentSearch.searchArgs.city.pickupLocationCode,
1002
+ vendor: recentSearch.searchArgs.city.pickupVendor,
1003
+ vendorCode: recentSearch.searchArgs.city.pickupVendorCode
1004
+ };
1005
+
1006
+ this.searchService.startSearches();
1007
+ }
1008
+
1009
+ private getParamsForCarbyPostCode(recentSearch: RecentSearch): void {
1010
+ this.locationType = LocationTypes.Postcode;
1011
+ this.postcodeDropoff = {
1012
+ addressLines: [recentSearch.searchArgs.depot.dropoffAddressLines],
1013
+ vendorCode: recentSearch.searchArgs.depot.vendorCode,
1014
+ locationCode: recentSearch.searchArgs.depot.dropOffLocationCode,
1015
+ extendedLocationCode:
1016
+ recentSearch.searchArgs.depot.dropOffExtendedLocationCode,
1017
+ cityName: recentSearch.searchArgs.depot.dropoffCityName,
1018
+ vendor: recentSearch.searchArgs.depot.dropoffVendor
1019
+ };
1020
+
1021
+ this.postcodeDropoffRaw = {
1022
+ name: recentSearch.searchArgs.depot.dropoffPostCode,
1023
+ type: LocationTypes.Postcode,
1024
+ latitude: recentSearch.searchArgs.depot.dropoffLatitude,
1025
+ longitude: recentSearch.searchArgs.depot.dropoffLongitude
1026
+ };
1027
+ this.postcodePickup = {
1028
+ addressLines: [recentSearch.searchArgs.depot.pickupAddressLines],
1029
+ vendorCode: recentSearch.searchArgs.depot.vendorCode,
1030
+ locationCode: recentSearch.searchArgs.depot.pickupLocationCode,
1031
+ extendedLocationCode:
1032
+ recentSearch.searchArgs.depot.pickupExtendedLocationCode,
1033
+ cityName: recentSearch.searchArgs.depot.pickupCityName,
1034
+ vendor: recentSearch.searchArgs.depot.pickupVendor
1035
+ };
1036
+
1037
+ this.postcodePickupRaw = {
1038
+ name: recentSearch.searchArgs.depot.pickupPostCode,
1039
+ type: LocationTypes.Postcode,
1040
+ latitude: recentSearch.searchArgs.depot.pickupLatitude,
1041
+ longitude: recentSearch.searchArgs.depot.pickupLongitude
1042
+ };
1043
+
1044
+ this.searchService.startSearches();
1045
+ }
1046
+
1047
+ getSearchQuery(): QuerySearchCarHireArgs {
1048
+ const query: QuerySearchCarHireArgs = {} as QuerySearchCarHireArgs;
1049
+ switch (this.locationType) {
1050
+ case LocationTypes.Airport:
1051
+ query.airport = {
1052
+ pickupCode: '',
1053
+ dropoffCode: ''
1054
+ };
1055
+
1056
+ query.airport.pickupCode = this.pickup_location.gateway;
1057
+ query.airport.dropoffCode = this.return_to_pickup
1058
+ ? this.pickup_location.gateway
1059
+ : this.dropoff_location.gateway;
1060
+ break;
1061
+ case LocationTypes.City:
1062
+ query.city = {
1063
+ pickupCountryCode: this.cityPickup.countryCode,
1064
+ pickupCity: this.cityPickup.id.toString(),
1065
+ dropoffCountryCode: this.cityDropoff.countryCode,
1066
+ dropoffCity: this.cityDropoff.id.toString()
1067
+ };
1068
+ break;
1069
+ case LocationTypes.Postcode:
1070
+ query.depot = {
1071
+ vendorCode: this.postcodePickup.vendorCode,
1072
+ pickupLocationCode: this.postcodePickup.locationCode,
1073
+ pickupExtendedLocationCode: this.postcodePickup.extendedLocationCode,
1074
+ dropOffLocationCode: this.postcodeDropoff.locationCode,
1075
+ dropOffExtendedLocationCode: this.postcodeDropoff.extendedLocationCode
1076
+ };
1077
+ break;
1078
+ }
1079
+ query.dropoffDateTime = this.dropoff_datetime;
1080
+ query.pickupDateTime = this.pickup_datetime;
1081
+
1082
+ // now for the optional fields - nullify these if they are '-' (Any)
1083
+ query.aircon = this.airCon || null;
1084
+ query.vendor = this.chosenVendor === '-' ? null : this.chosenVendor;
1085
+ query.transmission = this.transmission || null;
1086
+ query.class = this.carClass || null;
1087
+ query.type = this.carType || null;
1088
+ query.estimatedDailyDistance = this.estimatedMileage || null;
1089
+ query.estimatedDailyDistanceUnits = this.estimatedMileage
1090
+ ? DistanceTypes.M
1091
+ : null; // Setting as miles for now - may swap out for kilometers later
1092
+
1093
+ return this.helpers.removeNulls<QuerySearchCarHireArgs>(query);
1094
+ }
1095
+
1096
+ /**
1097
+ * @todo - turn this into a BE call to dynamically get the list of car classes
1098
+ * @returns all car classes as an array
1099
+ */
1100
+ getCarClasses(): Observable<ICarClasses[]> {
1101
+ return of(this._car_classes);
1102
+ }
1103
+
1104
+ getLocationTypes() {
1105
+ return of(this._location_types);
1106
+ }
1107
+
1108
+ /**
1109
+ * @description - filter down the car results based on user chosen filters
1110
+ */
1111
+ filterResults(appliedFilters: CarHireFilters, selectedSort: number): void {
1112
+ let fullResults: CarHireQuoteResultArray = this.helpers.clone(
1113
+ this.fullResults
1114
+ );
1115
+
1116
+ // now apply filters
1117
+ // price filters
1118
+ fullResults = fullResults.filter((result: CarHireQuoteResult) => {
1119
+ const price = this.getPrice(result);
1120
+
1121
+ return (
1122
+ price >= appliedFilters.minPrice && price <= appliedFilters.maxPrice
1123
+ );
1124
+ });
1125
+
1126
+ // apply transmission filters
1127
+ fullResults = this.filterByTransmissionType(
1128
+ appliedFilters.transmissions,
1129
+ fullResults
1130
+ );
1131
+
1132
+ // aircon
1133
+ fullResults = this.filterByAirconType(
1134
+ appliedFilters.airConditioning,
1135
+ fullResults
1136
+ );
1137
+
1138
+ // car types (class)
1139
+ fullResults = this.filterByCarType(appliedFilters.types, fullResults);
1140
+
1141
+ // company
1142
+ fullResults = this.filterByCompany(appliedFilters.companies, fullResults);
1143
+
1144
+ // lastly apply any required sorting
1145
+ fullResults = this.sortResults(selectedSort, fullResults);
1146
+
1147
+ this.results.next(fullResults);
1148
+ }
1149
+
1150
+ filterByCompany(
1151
+ companies: SelectFilter[],
1152
+ cars: CarHireQuoteResultArray
1153
+ ): CarHireQuoteResultArray {
1154
+ const selected = companies.filter((company) => company.selected);
1155
+
1156
+ if (selected.length) {
1157
+ cars = cars.filter((car: CarHireQuoteResult) => {
1158
+ const haveSelected = selected.find(
1159
+ (selc: any) =>
1160
+ selc.value.toString().toLowerCase() ===
1161
+ car.identifiers.vendor.toLowerCase()
1162
+ );
1163
+
1164
+ return haveSelected;
1165
+ });
1166
+ }
1167
+
1168
+ return cars;
1169
+ }
1170
+
1171
+ filterByCarType(
1172
+ types: SelectFilter[],
1173
+ cars: CarHireQuoteResultArray
1174
+ ): CarHireQuoteResultArray {
1175
+ // this is a filter type which allows more than one to be set
1176
+ // if none are set allow all through
1177
+
1178
+ const selected = types.filter((type) => type.selected);
1179
+
1180
+ if (selected.length) {
1181
+ cars = cars.filter((car: any) => {
1182
+ const haveSelected = selected.find(
1183
+ (selc) =>
1184
+ selc.value.toString().toLowerCase() ===
1185
+ car.displayRecord.vehicle.class.toLowerCase()
1186
+ );
1187
+
1188
+ return haveSelected;
1189
+ });
1190
+ }
1191
+
1192
+ return cars;
1193
+ }
1194
+
1195
+ filterByTransmissionType(
1196
+ tranmissions: SelectFilter[],
1197
+ cars: CarHireQuoteResultArray
1198
+ ): CarHireQuoteResultArray {
1199
+ const selectedTransmission = tranmissions.find((trans) => {
1200
+ return trans.selected;
1201
+ });
1202
+
1203
+ if (selectedTransmission && selectedTransmission.value !== 'Y') {
1204
+ // not 'Any'
1205
+ try {
1206
+ cars = cars.filter((car: CarHireQuoteResult) => {
1207
+ const trans = car.identifiers.vehType[2];
1208
+
1209
+ return (
1210
+ trans.toLowerCase() ===
1211
+ selectedTransmission.value.toString().toLowerCase()
1212
+ );
1213
+ });
1214
+ } catch (error) {
1215
+ console.error(`+++ Error filtering transmissions: ${error} +++`);
1216
+ }
1217
+ }
1218
+
1219
+ return cars;
1220
+ }
1221
+
1222
+ filterByAirconType(
1223
+ aircons: SelectFilter[],
1224
+ cars: CarHireQuoteResultArray
1225
+ ): CarHireQuoteResultArray {
1226
+ const selectedAircon = aircons.find((ac) => {
1227
+ return ac.selected;
1228
+ });
1229
+
1230
+ if (selectedAircon && selectedAircon.value !== 'A') {
1231
+ // not 'Any'
1232
+ try {
1233
+ cars = cars.filter((car: CarHireQuoteResult) => {
1234
+ const ac = car.identifiers.vehType[3];
1235
+
1236
+ return (
1237
+ ac.toLowerCase() === selectedAircon.value.toString().toLowerCase()
1238
+ );
1239
+ });
1240
+ } catch (error) {
1241
+ console.error(`+++ Error filtering aircons: ${error} +++`);
1242
+ }
1243
+ }
1244
+
1245
+ return cars;
1246
+ }
1247
+
1248
+ /**
1249
+ * @description - sort the results
1250
+ * @param selectedSort - the sort we have chosen
1251
+ * @param results - optionally pass in the results, if not provided - uses internal results (not full, would cause issues)
1252
+ */
1253
+ sortResults(
1254
+ selectedSort: number,
1255
+ results?: CarHireQuoteResultArray
1256
+ ): CarHireQuoteResultArray {
1257
+ let fullResults = this.helpers.clone(
1258
+ results ? results : this.results.value
1259
+ );
1260
+ switch (selectedSort) {
1261
+ case 0: // cheapest
1262
+ fullResults = fullResults.sort(
1263
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) =>
1264
+ this.getPrice(a) - this.getPrice(b)
1265
+ );
1266
+ break;
1267
+ case 1: // expensive
1268
+ fullResults = fullResults.sort(
1269
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) =>
1270
+ this.getPrice(b) - this.getPrice(a)
1271
+ );
1272
+ break;
1273
+ case 2: // preferred TODO
1274
+ break;
1275
+ case 3: // brand
1276
+ fullResults = this.sortByBrand(fullResults);
1277
+ break;
1278
+ case 4: // size
1279
+ fullResults = this.sortBySize(fullResults);
1280
+ break;
1281
+ }
1282
+ // fallback to whatever was before
1283
+ this.results.next(fullResults);
1284
+ return fullResults;
1285
+ }
1286
+
1287
+ /**
1288
+ * @description - sort the results expensive
1289
+ * @param results - full results from sort results function
1290
+ */
1291
+
1292
+ sortExpensive(results?: CarHireQuoteResultArray): CarHireQuoteResultArray {
1293
+ const fullResults = this.helpers.clone(
1294
+ results ? results : this.results.value
1295
+ );
1296
+ const sortedResults = fullResults.sort(
1297
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) =>
1298
+ this.getPrice(b) - this.getPrice(a)
1299
+ );
1300
+ this.results.next(sortedResults);
1301
+ return sortedResults;
1302
+ }
1303
+
1304
+ /**
1305
+ * @description - sort the results cheapest
1306
+ * @param results - full results from sort results function
1307
+ */
1308
+
1309
+ sortCheapest(results?: CarHireQuoteResultArray): CarHireQuoteResultArray {
1310
+ const fullResults = this.helpers.clone(
1311
+ results ? results : this.results.value
1312
+ );
1313
+ const sortedResults = fullResults.sort(
1314
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) =>
1315
+ this.getPrice(a) - this.getPrice(b)
1316
+ );
1317
+ this.results.next(sortedResults);
1318
+ return sortedResults;
1319
+ }
1320
+
1321
+ /**
1322
+ * @description - sort the results
1323
+ * @param results - full results from sort results function
1324
+ */
1325
+ sortBySize(results?: CarHireQuoteResultArray): CarHireQuoteResultArray {
1326
+ const fullResults = this.helpers.clone(
1327
+ results ? results : this.results.value
1328
+ );
1329
+ const sortedResults = fullResults.sort(
1330
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) => {
1331
+ let aVal: number;
1332
+ let bVal: number;
1333
+ aVal = this.carClassMap[a.displayRecord.vehicle.class.toLowerCase()];
1334
+ bVal = this.carClassMap[b.displayRecord.vehicle.class.toLowerCase()];
1335
+ if (aVal >= 0 && bVal >= 0) {
1336
+ return aVal - bVal;
1337
+ }
1338
+ return -1; // just place them at end - unrecognised product description
1339
+ }
1340
+ );
1341
+ this.results.next(sortedResults);
1342
+ return sortedResults;
1343
+ }
1344
+
1345
+ /**
1346
+ * @description - sort the results
1347
+ * @param results - full results from sort results function
1348
+ */
1349
+ sortByBrand(results?: CarHireQuoteResultArray): CarHireQuoteResultArray {
1350
+ const fullResults = this.helpers.clone(
1351
+ results ? results : this.results.value
1352
+ );
1353
+ const sortedResults = fullResults.sort(
1354
+ (a: CarHireQuoteResult, b: CarHireQuoteResult) => {
1355
+ let brandA = a.identifiers.vendor;
1356
+ let brandB = b.identifiers.vendor;
1357
+
1358
+ // switching as these strings don't match the brand name
1359
+ switch (brandA) {
1360
+ case 'ZE':
1361
+ brandA = 'HE';
1362
+ break;
1363
+ case 'ZI':
1364
+ brandA = 'AV';
1365
+ break;
1366
+ }
1367
+
1368
+ switch (brandB) {
1369
+ case 'ZE':
1370
+ brandB = 'HE';
1371
+ break;
1372
+ case 'ZI':
1373
+ brandB = 'AV';
1374
+ break;
1375
+ }
1376
+
1377
+ if (brandA < brandB) {
1378
+ return -1;
1379
+ } else if (brandA > brandB) {
1380
+ return 1;
1381
+ } else {
1382
+ return 0;
1383
+ }
1384
+ }
1385
+ );
1386
+
1387
+ this.results.next(sortedResults);
1388
+ return sortedResults;
1389
+ }
1390
+
1391
+ /**
1392
+ * @description - get the price of a individual car
1393
+ */
1394
+ getPrice(car: CarHireQuoteResult): number {
1395
+ try {
1396
+ return Number(car.displayRecord.charges[0].amount);
1397
+ } catch (error) {}
1398
+
1399
+ return 0;
1400
+ }
1401
+
1402
+ getMinPrice(cars: CarHireQuoteResultArray): number {
1403
+ return cars.reduce((min: number, car: CarHireQuoteResult) => {
1404
+ const price = this.getPrice(car);
1405
+ if (price < min) {
1406
+ min = price;
1407
+ }
1408
+ return min;
1409
+ }, Number.MAX_SAFE_INTEGER);
1410
+ }
1411
+
1412
+ getMaxPrice(cars: CarHireQuoteResultArray): number {
1413
+ return cars.reduce((max: number, car: CarHireQuoteResult) => {
1414
+ const price = this.getPrice(car);
1415
+ if (price > max) {
1416
+ max = price;
1417
+ }
1418
+ return max;
1419
+ }, Number.MIN_SAFE_INTEGER);
1420
+ }
1421
+
1422
+ updateFromPreviousSearches(
1423
+ previousItems: Record<ServiceType, BasketItem>
1424
+ ): void {
1425
+ const flightItem: SearchFlightsV2QueryVariables =
1426
+ previousItems[ServiceType.Flight]?.searchQuery;
1427
+ if (flightItem) {
1428
+ // TODO flights haven't been done yet.
1429
+ }
1430
+ }
1431
+
1432
+ // !date and time is handled differently for LU
1433
+ private _updatePickupDateTime() {
1434
+ if (this._pickup_date && this._pickup_time) {
1435
+ const time = this.helpers.ngDateToMoment(
1436
+ this._pickup_date,
1437
+ this._pickup_time
1438
+ );
1439
+ this.pickup_datetime = time.isValid() ? time : null;
1440
+ this._isValid();
1441
+ }
1442
+ }
1443
+
1444
+ private _updateDropoffDateTime() {
1445
+ if (this._dropoff_date && this._dropoff_time) {
1446
+ const time = this.helpers.ngDateToMoment(
1447
+ this._dropoff_date,
1448
+ this._dropoff_time
1449
+ );
1450
+ this.dropoff_datetime = time.isValid() ? time : null;
1451
+ this._isValid();
1452
+ }
1453
+ }
1454
+
1455
+ private _updateNgbPickupDateTime() {
1456
+ if (this._ngbPickupDate && this._pickupTime) {
1457
+ const time = this.helpers.ngDateToMoment(
1458
+ this._ngbPickupDate,
1459
+ this._pickupTime
1460
+ );
1461
+ this.pickup_datetime = time.isValid() ? time : null;
1462
+ this._isValid();
1463
+ }
1464
+ }
1465
+
1466
+ private _updateNgbDropoffDateTime() {
1467
+ if (this._ngbDropoffDate && this._dropoffTime) {
1468
+ const time = this.helpers.ngDateToMoment(
1469
+ this._ngbDropoffDate,
1470
+ this._dropoffTime
1471
+ );
1472
+ this.dropoff_datetime = time.isValid() ? time : null;
1473
+ this._isValid();
1474
+ }
1475
+ }
1476
+
1477
+ isOverNight(): boolean {
1478
+ const outwardDay = this.pickup_datetime.date();
1479
+ const returnDay = this.dropoff_datetime.date();
1480
+ if (returnDay - outwardDay >= 1) {
1481
+ return true;
1482
+ }
1483
+ return false;
1484
+ }
1485
+
1486
+ updateLowestPrice(results: CarHireQuoteResultArray): ICheapestPrice {
1487
+ if (!results.length) return null;
1488
+ const minPrice = this.getMinPrice(results);
1489
+ return {
1490
+ amount: minPrice,
1491
+ currencyCode: results[0].displayRecord.charges[0].currencyCode
1492
+ };
1493
+ }
1494
+
1495
+ /**
1496
+ * @description - get the availability details for a particular car hire result using locationDetails param
1497
+ * @param locationDetails - e.g. taken from response data in searchCarHire query
1498
+ * @param isLoading behaviourSubject for handling loading spinner state of request
1499
+ */
1500
+ getCarHireAvailabilityDetail(
1501
+ locationDetails: CarHireInputIdentifiers,
1502
+ isLoading: BehaviorSubject<boolean>
1503
+ ): Observable<CarHireDetailRequestResponse> {
1504
+ if (!isLoading.value) {
1505
+ isLoading.next(true);
1506
+ }
1507
+ return this.carHireAvailabilityDetailFetcher
1508
+ .fetchList({ locationDetails })
1509
+ .pipe(
1510
+ take(1),
1511
+ map((result: CarHireDetailRequestResponse) => {
1512
+ if (isLoading.value) {
1513
+ isLoading.next(false);
1514
+ }
1515
+ return result;
1516
+ })
1517
+ );
1518
+ }
1519
+
1520
+ /**
1521
+ * @description - add car hire to basket
1522
+ */
1523
+ async addCarHireToBasket(
1524
+ carHireVehicleAvailibility: CarHireVehicleAvailibility,
1525
+ carHireQuery: SearchCarHireQueryVariables
1526
+ ): Promise<boolean> {
1527
+ if (carHireVehicleAvailibility.unavailable) {
1528
+ return Promise.resolve(false);
1529
+ }
1530
+ const intBasket: InternalBasketInterface =
1531
+ await this.basketService.getDefaultBasket();
1532
+ const basket = intBasket?.subject.value;
1533
+ if (basket) {
1534
+ const {
1535
+ co2PerItem,
1536
+ co2PerPassenger,
1537
+ displayRecord,
1538
+ identifiers,
1539
+ sourceId
1540
+ } = carHireVehicleAvailibility;
1541
+ const price = parseFloat(displayRecord?.charges[0]?.amount ?? '0');
1542
+ return this.basketService.addToBasket(
1543
+ {
1544
+ adults: this.adults,
1545
+ basket: basket.id,
1546
+ service: sourceId.toString(),
1547
+ detail: {
1548
+ pickUpDatetime: new Date(displayRecord.pickup).toISOString(),
1549
+ dropOffDatetime: new Date(displayRecord.dropoff).toISOString(),
1550
+ pickUpLocation: {
1551
+ iata:
1552
+ this.locationType === LocationTypes.Airport
1553
+ ? identifiers.locationCode
1554
+ : '',
1555
+ name: displayRecord.pickupLocation.name,
1556
+ address: `${displayRecord.pickupLocation.topLine}, ${displayRecord.pickupLocation.city}`,
1557
+ postcode: displayRecord.pickupLocation.postCode
1558
+ },
1559
+ dropOffLocation: {
1560
+ iata:
1561
+ this.locationType === LocationTypes.Airport
1562
+ ? identifiers.dropOffLocation
1563
+ : '',
1564
+ name: displayRecord.returnLocation.name,
1565
+ address: `${displayRecord.returnLocation.topLine}, ${displayRecord.returnLocation.city}`,
1566
+ postcode: displayRecord.returnLocation.postCode
1567
+ },
1568
+ car: {
1569
+ type: displayRecord.vehicle.type,
1570
+ manualTransmission: displayRecord.vehicle.transmission.includes(
1571
+ CarHireTransmission.Manual
1572
+ )
1573
+ },
1574
+ vendorName: displayRecord.vendor.name,
1575
+ identifiers: {
1576
+ dropOffLocation: identifiers.dropOffLocation,
1577
+ locationCode: identifiers.locationCode,
1578
+ locationName: identifiers.locationName,
1579
+ vehType: identifiers.vehType,
1580
+ vendor: identifiers.vendor
1581
+ }
1582
+ },
1583
+ price,
1584
+ currency: 'GBP' as CurrencyCode,
1585
+ searchQuery: carHireQuery,
1586
+ co2PerItem,
1587
+ co2PerPassenger,
1588
+ outboundDate: new Date(displayRecord.pickup).toISOString()
1589
+ },
1590
+ intBasket,
1591
+ this.searchService,
1592
+ this.travellers
1593
+ );
1594
+ }
1595
+ return Promise.resolve(false);
1596
+ }
1597
+ }