@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,2126 @@
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 { Traveller } from '../models/traveller.object';
6
+ import { BehaviorSubject } from 'rxjs';
7
+ import { ValueDisplay } from '../interfaces/value-display';
8
+ import { FlightFilters } from '../interfaces/flight-filters.interface';
9
+ import { SelectFilter } from '../interfaces/select-filter.interface';
10
+ import {
11
+ AddItemToBasketMutationVariables,
12
+ BasketItem,
13
+ CurrencyCode,
14
+ DestinationEntry,
15
+ FareType,
16
+ FlightCabinClass,
17
+ FlightFareTotal,
18
+ FlightItinerary,
19
+ FlightJourney,
20
+ FlightPassengerObject,
21
+ FlightPassengerType,
22
+ SearchFlightsV2QueryVariables,
23
+ ServiceType
24
+ } from '../types/graphql.types';
25
+ import {
26
+ EurostarQuoteResult,
27
+ NgbDateStruct,
28
+ OBTAirportDetails,
29
+ OBTAirlinesDetails,
30
+ FlightDirectionEnum,
31
+ GroupedFlights,
32
+ FlightItineraryWithSelected,
33
+ RecentSearch,
34
+ EurostarGroupedQuoteResult,
35
+ EurostarResults,
36
+ EurostarItem,
37
+ EurostarFare,
38
+ EurostarClassEnum,
39
+ EurostarQuoteResultArray
40
+ } from '../types/types';
41
+ import {
42
+ FullUserDetails,
43
+ UserServiceInterface
44
+ } from '../interfaces/Iuser.service';
45
+ import { EnterpriseSearchServiceInterface } from '../interfaces/Isearch.service';
46
+ import { ICheapestPrice } from '../interfaces/cheapest-price';
47
+ import { EurostarSearchType } from './eurostar-search-type.enum';
48
+ import { IMultiDestination } from '../interfaces/flight-multi-destination.interface';
49
+ import {
50
+ EnterpriseBasketServiceInterface,
51
+ InternalBasketInterface
52
+ } from '../interfaces/Ienterprise-basket.service';
53
+ import {
54
+ BaseEurostarQuoteFetcher,
55
+ EurostarQuoteFetcherType
56
+ } from '../fetchers/eurostar-quote.fetcher';
57
+ import {
58
+ EurostarEnterpriseSearchInterface,
59
+ EurostarTempParams
60
+ } from '../interfaces/Ieurostar-enterprise-search';
61
+ import {
62
+ FlightGroups,
63
+ FlightOperator,
64
+ TimeWindow
65
+ } from './flight-enterprise-search';
66
+ export interface AllowedClassEurostar {
67
+ name: string;
68
+ type: EurostarClassEnum | null;
69
+ }
70
+
71
+ export type AllowedClassesEurostar = AllowedClassEurostar[];
72
+
73
+ export type EurostarStation = {
74
+ gateway: string;
75
+ destination: string;
76
+ };
77
+
78
+ export enum SortTypesEurostar {
79
+ CheapestFirst = 'C',
80
+ EarliestFirst = 'E'
81
+ }
82
+
83
+ export enum SortMethod {
84
+ sortByPrice = 'sortByPrice',
85
+ sortByDate = 'sortByDate'
86
+ }
87
+
88
+ export interface SortTypeEurostar {
89
+ /** Title displayed on dropdown */
90
+ title: string;
91
+ /** Method name used by component to sort results */
92
+ method: SortMethod;
93
+ /** Icon displayed on drop down */
94
+ icon: string;
95
+ /** Sorting direction true for asc, false for dsc */
96
+ dir: boolean;
97
+ // this is what we will use to sort
98
+ code: SortTypesEurostar;
99
+ }
100
+
101
+ export type EurostarGroups = 'Standard' | 'StandardPremier' | 'BusinessPremier';
102
+
103
+ interface EurostarSessionType {
104
+ results: EurostarQuoteResultArray;
105
+ groupData: { [key: number]: number[] };
106
+ grouped: GroupedFlights;
107
+ query: SearchFlightsV2QueryVariables;
108
+ }
109
+
110
+ export class EurostarEnterpriseSearch<SE_Q extends EurostarQuoteFetcherType>
111
+ extends BaseEnterpriseSearch<
112
+ EurostarTempParams,
113
+ EurostarQuoteResult,
114
+ EurostarQuoteResultArray
115
+ >
116
+ implements EurostarEnterpriseSearchInterface {
117
+ static readonly STORAGE_SESSION_PARAMS = 'search_eurostar';
118
+ static readonly STORAGE_SESSION_RESULTS = 'results_eurostar';
119
+
120
+ public type: ServiceType = ServiceType.Eurostar;
121
+
122
+ avaliableClasses: BehaviorSubject<AllowedClassesEurostar> =
123
+ new BehaviorSubject<AllowedClassesEurostar>([]);
124
+ timeCriteriaOptions: BehaviorSubject<TimeWindow[]> = new BehaviorSubject<
125
+ TimeWindow[]
126
+ >([]);
127
+ flightOperators: BehaviorSubject<FlightOperator[]> = new BehaviorSubject<
128
+ FlightOperator[]
129
+ >([]);
130
+
131
+ private _negotiated: boolean = false;
132
+ private _nearby_airports: boolean = false;
133
+
134
+ private _timeArray: ValueDisplay[];
135
+ private _sortArray: SortTypeEurostar[] = [
136
+ {
137
+ title: 'Price',
138
+ method: SortMethod.sortByPrice,
139
+ icon: 'ico-dollar',
140
+ dir: true,
141
+ code: SortTypesEurostar.CheapestFirst
142
+ },
143
+ {
144
+ title: 'Time',
145
+ method: SortMethod.sortByDate,
146
+ icon: 'ico-calendar',
147
+ dir: true,
148
+ code: SortTypesEurostar.EarliestFirst
149
+ }
150
+ ];
151
+
152
+ private _fareTypeArray: ValueDisplay[] = [
153
+ { value: FareType.Flexible, display: 'Flexible' },
154
+ { value: FareType.Leisure, display: 'Leisure' },
155
+ { value: FareType.Lowest, display: 'Lowest' },
156
+ { value: FareType.Negotiated, display: 'Negotiated' },
157
+ { value: FareType.NonNegotiated, display: 'Non-Negotiated' },
158
+ { value: FareType.RequestFareRules, display: 'Request Fare Rules' },
159
+ { value: FareType.SelectAndPro, display: 'Select & Pro' }
160
+ ];
161
+
162
+ public minimumOutBoundDate = {
163
+ year: moment().year(),
164
+ month: moment().month() + 1,
165
+ day: moment().date()
166
+ };
167
+
168
+ public minimumInBoundDate = {
169
+ year: moment().year(),
170
+ month: moment().month() + 1,
171
+ day: moment().date()
172
+ };
173
+
174
+ public searchTypes: ValueDisplay[] = [
175
+ {value: EurostarSearchType.return, display: 'Return'},
176
+ {value: EurostarSearchType.oneWay, display: 'One-way'},
177
+ ]
178
+
179
+ private _outDate: NgbDateStruct;
180
+ private _outTime: string;
181
+ private _inDate: NgbDateStruct;
182
+ private _inTime: string;
183
+ private _destinationAirport: any;
184
+ private _originAirport: any;
185
+ private _passengers: any;
186
+ private groupedObject: FlightItineraryWithSelected[];
187
+ protected flightsToGroup: { [key: number]: number[] } = {};
188
+ protected resultQuery: SearchFlightsV2QueryVariables;
189
+ protected grouped: GroupedFlights = null;
190
+ travellers: Traveller[] = null;
191
+ protected resultsSessionName =
192
+ EurostarEnterpriseSearch.STORAGE_SESSION_RESULTS;
193
+ selectedGroupFlight: FlightItineraryWithSelected;
194
+ private _displayAddHotel: boolean = false;
195
+
196
+ public get displayAddHotel(): boolean {
197
+ return this._displayAddHotel;
198
+ }
199
+
200
+ public set displayAddHotel(newVal: boolean) {
201
+ this._displayAddHotel = newVal;
202
+ }
203
+ selectedGroupEurostar: EurostarItem;
204
+ selectedEurostarFare: EurostarFare;
205
+
206
+ public get timeArray() {
207
+ this._timeArray =
208
+ this._timeArray ||
209
+ Array(96)
210
+ .fill(0)
211
+ .map((_, index: number) => {
212
+ return {
213
+ value:
214
+ Math.floor(index / 4)
215
+ .toString()
216
+ .padStart(2, '0') +
217
+ ':' +
218
+ ((index % 4) * 15).toString().padStart(2, '0'),
219
+ display:
220
+ Math.floor(index / 4)
221
+ .toString()
222
+ .padStart(2, '0') +
223
+ ':' +
224
+ ((index % 4) * 15).toString().padStart(2, '0')
225
+ };
226
+ });
227
+ return this._timeArray;
228
+ }
229
+
230
+ public get preferredCarriers(): OBTAirlinesDetails[] {
231
+ return this.tempParams.preferredCarriers;
232
+ }
233
+
234
+ public set preferredCarriers(value: OBTAirlinesDetails[]) {
235
+ this.tempParams.preferredCarriers = value;
236
+ this._isValid();
237
+ }
238
+
239
+ public get operator1(): OBTAirlinesDetails {
240
+ return this.tempParams.preferredCarriers[0];
241
+ }
242
+
243
+ public set operator1(value: OBTAirlinesDetails) {
244
+ this.tempParams.preferredCarriers[0] = value;
245
+ this._isValid();
246
+ }
247
+ public get operator2(): OBTAirlinesDetails {
248
+ return this.tempParams.preferredCarriers[1];
249
+ }
250
+
251
+ public set operator2(value: OBTAirlinesDetails) {
252
+ this.tempParams.preferredCarriers[1] = value;
253
+ this._isValid();
254
+ }
255
+ public get operator3(): OBTAirlinesDetails {
256
+ return this.tempParams.preferredCarriers[2];
257
+ }
258
+
259
+ public set operator3(value: OBTAirlinesDetails) {
260
+ this.tempParams.preferredCarriers[2] = value;
261
+ this._isValid();
262
+ }
263
+ public get operator4(): OBTAirlinesDetails {
264
+ return this.tempParams.preferredCarriers[3];
265
+ }
266
+
267
+ public set operator4(value: OBTAirlinesDetails) {
268
+ this.tempParams.preferredCarriers[3] = value;
269
+ this._isValid();
270
+ }
271
+
272
+ private _minDate: NgbDateStruct;
273
+ public get minDate(): NgbDateStruct {
274
+ this._minDate = this._minDate || this.helpers.momentToNgDate(moment());
275
+ return this._minDate;
276
+ }
277
+
278
+ public get adults(): number {
279
+ return this.tempParams.adults;
280
+ }
281
+
282
+ public set adults(value: number) {
283
+ this.tempParams.adults = Number(value);
284
+ this.updateTravellers();
285
+ }
286
+
287
+ public get children(): number {
288
+ return this.tempParams.children;
289
+ }
290
+
291
+ public set children(value: number) {
292
+ this.tempParams.children = Number(value);
293
+ this.updateTravellers();
294
+ }
295
+
296
+ public get departLocation(): string | OBTAirportDetails {
297
+ return this.tempParams.departLocation;
298
+ }
299
+
300
+ public set departLocation(value: string | OBTAirportDetails) {
301
+ this.tempParams.departLocation = value;
302
+ if (typeof value === 'string') {
303
+ this._originAirport = '';
304
+ } else if (value && value.gateway) {
305
+ this._originAirport = value.gateway;
306
+ } else {
307
+ this._originAirport = null;
308
+ }
309
+ this._isValid();
310
+ }
311
+
312
+ public get queryOriginAiport(): string {
313
+ return this._originAirport;
314
+ }
315
+
316
+ public get queryDestinationAiport(): string {
317
+ return this._destinationAirport;
318
+ }
319
+
320
+ public get departDate(): NgbDateStruct {
321
+ return this._outDate;
322
+ }
323
+
324
+ public set departDate(value: NgbDateStruct) {
325
+ this._outDate = value;
326
+ this.outBoundDate = this.helpers.ngDateToMoment(
327
+ this._outDate,
328
+ this._outTime
329
+ );
330
+ }
331
+
332
+ public get departTime(): string {
333
+ return this._outTime;
334
+ }
335
+
336
+ public set departTime(value: string) {
337
+ this._outTime = value;
338
+ this.outBoundDate = this.helpers.ngDateToMoment(
339
+ this._outDate,
340
+ this._outTime
341
+ );
342
+ }
343
+
344
+ public get outBoundDate(): moment.Moment {
345
+ return this.tempParams.outBoundDate;
346
+ }
347
+
348
+ public set outBoundDate(value: moment.Moment) {
349
+ value = moment(value);
350
+ this.tempParams.outBoundDate = value.isValid() ? value : null;
351
+ this.minimumInBoundDate = {
352
+ year: value.year(),
353
+ month: value.month() + 1,
354
+ day: value.date()
355
+ };
356
+
357
+ if (
358
+ this.tempParams.outBoundDate &&
359
+ this.tempParams.inboundDate &&
360
+ this.tempParams.outBoundDate.isAfter(this.tempParams.inboundDate)
361
+ ) {
362
+ this.inboundDate = moment(this.tempParams.outBoundDate).add(1, 'day');
363
+ }
364
+ this._outDate = this.helpers.momentToNgDate(value);
365
+ this._outTime = this.helpers.formatTimeColon(value);
366
+ this._isValid();
367
+ }
368
+
369
+ public get returnDate(): NgbDateStruct {
370
+ return this._inDate;
371
+ }
372
+
373
+ public set returnDate(value: NgbDateStruct) {
374
+ this._inDate = value;
375
+ this.inboundDate = this.helpers.ngDateToMoment(this._inDate, this._inTime);
376
+ }
377
+
378
+ public get arriveTime(): string {
379
+ return this._inTime;
380
+ }
381
+
382
+ public set arriveTime(value: string) {
383
+ this._inTime = value;
384
+ this.inboundDate = this.helpers.ngDateToMoment(this._inDate, this._inTime);
385
+ }
386
+
387
+ public get inboundDate(): moment.Moment {
388
+ return this.tempParams.inboundDate;
389
+ }
390
+
391
+ public set inboundDate(value: moment.Moment) {
392
+ value = moment(value);
393
+ this.tempParams.inboundDate = value.isValid() ? value : null;
394
+ this._inDate = this.helpers.momentToNgDate(value);
395
+ this._inTime = this.helpers.formatTimeColon(value);
396
+ this._isValid();
397
+ }
398
+
399
+ public get arriveLocation(): string | OBTAirportDetails {
400
+ return this.tempParams.arriveLocation;
401
+ }
402
+
403
+ public set arriveLocation(value: string | OBTAirportDetails) {
404
+ this.tempParams.arriveLocation = value;
405
+ if (typeof value === 'string') {
406
+ this._destinationAirport = '';
407
+ } else if (value && value.gateway) {
408
+ this._destinationAirport = value.gateway;
409
+ } else {
410
+ this._destinationAirport = null;
411
+ }
412
+ this._isValid();
413
+ }
414
+
415
+ get cabinClass(): FlightCabinClass | null {
416
+ return this.tempParams.cabinClass;
417
+ }
418
+
419
+ set cabinClass(value: FlightCabinClass | null) {
420
+ this.tempParams.cabinClass = value;
421
+ this._isValid();
422
+ }
423
+
424
+ get returnCabinClass(): FlightCabinClass | null {
425
+ return this.tempParams.returnCabinClass;
426
+ }
427
+
428
+ set returnCabinClass(value: FlightCabinClass | null) {
429
+ this.tempParams.returnCabinClass = value;
430
+ this._isValid();
431
+ }
432
+
433
+ get chosenSearchType(): EurostarSearchType {
434
+ return this.tempParams.chosenSearchType;
435
+ }
436
+
437
+ set chosenSearchType(type: EurostarSearchType) {
438
+ this.tempParams.chosenSearchType = type;
439
+ this._isValid();
440
+ }
441
+
442
+ get isReturn(): boolean {
443
+ return this.tempParams.chosenSearchType === EurostarSearchType.return;
444
+ }
445
+
446
+ get outTimeCriteria(): TimeWindow {
447
+ return this.tempParams.outTimeCriteria;
448
+ }
449
+
450
+ set outTimeCriteria(value: TimeWindow) {
451
+ this.tempParams.outTimeCriteria = value;
452
+ this._isValid();
453
+ }
454
+
455
+ get inTimeCriteria(): TimeWindow {
456
+ return this.tempParams.inTimeCriteria;
457
+ }
458
+
459
+ set inTimeCriteria(value: TimeWindow) {
460
+ this.tempParams.inTimeCriteria = value;
461
+ this._isValid();
462
+ }
463
+ get maxConnections(): number {
464
+ return this.tempParams.maxConnections;
465
+ }
466
+
467
+ set maxConnections(value: number) {
468
+ this.tempParams.maxConnections = value;
469
+ }
470
+
471
+ private _multiDestination: DestinationEntry[] = [];
472
+ get multiDestination(): IMultiDestination[] {
473
+ return this.tempParams.multiDestination;
474
+ }
475
+
476
+ set multiDestination(valueArray: IMultiDestination[]) {
477
+ this.tempParams.multiDestination = valueArray;
478
+ this._isValid();
479
+ }
480
+
481
+ setMultiDestinationQuery(multiDestination: IMultiDestination[]) {
482
+ const newMultiDestination = this.helpers.clone(multiDestination);
483
+ return newMultiDestination.reduce(
484
+ (destinationArray: DestinationEntry[], item: IMultiDestination) => {
485
+ const destinationObject = {} as DestinationEntry;
486
+ destinationObject.orig = item.orig.gateway;
487
+ destinationObject.dest = item.dest.gateway;
488
+ destinationObject.date = this.helpers.formatIsoDate(item.date);
489
+ destinationArray.push(destinationObject);
490
+ return destinationArray;
491
+ },
492
+ [] as DestinationEntry[]
493
+ );
494
+ }
495
+
496
+ // get only
497
+ get sortDropdownValues(): SortTypeEurostar[] {
498
+ return this._sortArray;
499
+ }
500
+
501
+ get fareTypesValues(): ValueDisplay[] {
502
+ return this._fareTypeArray;
503
+ }
504
+
505
+ get fareType(): FareType {
506
+ return this.tempParams.fareType;
507
+ }
508
+
509
+ set fareType(value: FareType) {
510
+ this.tempParams.fareType = value;
511
+ this._isValid();
512
+ }
513
+
514
+ get negotiated(): boolean {
515
+ return this._negotiated;
516
+ }
517
+
518
+ set negotiated(value: boolean) {
519
+ this._negotiated = value;
520
+ }
521
+
522
+ get includeNearbyAirports(): boolean {
523
+ return this.tempParams.includeNearbyAirports;
524
+ }
525
+
526
+ set includeNearbyAirports(value: boolean) {
527
+ this.tempParams.includeNearbyAirports = value;
528
+ }
529
+ constructor(
530
+ private eurostarFetcher: BaseEurostarQuoteFetcher<SE_Q>,
531
+ private helpers: BaseHelperRoutines,
532
+ userService: UserServiceInterface,
533
+ private basketService: EnterpriseBasketServiceInterface,
534
+ storageService: BaseStorageService,
535
+ private searchService: EnterpriseSearchServiceInterface
536
+ ) {
537
+ super(
538
+ storageService,
539
+
540
+ (results1: EurostarQuoteResult): EurostarQuoteResultArray => {
541
+ this.resultQuery = this.getSearchQuery();
542
+ delete this.resultQuery.withGrouped;
543
+ if(results1 && this.searchService.isFlightsGrouped()){
544
+ const returndata = (results1.journeys || []).reduce(
545
+ (acc: EurostarResults, result: FlightItinerary): EurostarResults => {
546
+ if (result.outboundFlights.length) {
547
+ const euroResult = this.formatEurostarResults(
548
+ result.outboundFlights,
549
+ result.total
550
+ );
551
+ euroResult.co2PerPassenger = result.co2PerPassenger;
552
+ euroResult.co2PerItem = result.co2PerItem;
553
+ euroResult.sourceId = result.sourceId;
554
+ euroResult.total = result.total;
555
+ euroResult.duration = this.minToHour(result.outboundTotalDuration);
556
+ if (
557
+ !acc.outbound.find(
558
+ (item: EurostarItem) =>
559
+ item.dateDeparture === euroResult.dateDeparture
560
+ )
561
+ ) {
562
+ acc.outbound.push(euroResult);
563
+ }
564
+ }
565
+
566
+ if (result.inboundFlights.length) {
567
+ const euroResult = this.formatEurostarResults(
568
+ result.inboundFlights,
569
+ result.total
570
+ );
571
+ euroResult.co2PerPassenger = result.co2PerPassenger;
572
+ euroResult.co2PerItem = result.co2PerItem;
573
+ euroResult.sourceId = result.sourceId;
574
+ euroResult.total = result.total;
575
+ euroResult.duration = this.minToHour(result.inboundTotalDuration);
576
+ if (
577
+ !acc.inbound.find(
578
+ (item: EurostarItem) =>
579
+ item.dateDeparture === euroResult.dateDeparture
580
+ )
581
+ ) {
582
+ acc.inbound.push(euroResult);
583
+ }
584
+ }
585
+ return acc;
586
+ }, { outbound: [], inbound: [] } as EurostarResults);
587
+ return [returndata];
588
+ } else {
589
+ return results1 ? [results1] : [];
590
+ }
591
+
592
+ }
593
+ );
594
+
595
+ const data: {
596
+ tempParams: EurostarTempParams;
597
+ originalUserSearch: EurostarTempParams;
598
+ } = storageService.getSessionItem(
599
+ EurostarEnterpriseSearch.STORAGE_SESSION_PARAMS
600
+ ) || {
601
+ tempParams: {} as EurostarTempParams,
602
+ originalUserSearch: {} as EurostarTempParams
603
+ };
604
+ // data.tempParams.adults = 1;
605
+ // data.tempParams.cabinClass = [FlightCabinClass.Economy];
606
+ const query = searchService.makeEurostarQuery(data.tempParams);
607
+ this.updateTempParams(query);
608
+ this._originalUserSearch = data.originalUserSearch;
609
+ if (searchService.shouldAddTravellerSubscription()) {
610
+ searchService.travellerInformation.subscribe(
611
+ (travellers: Traveller[]) => {
612
+ this.travellers = travellers;
613
+ const splitTravellers = this.helpers.selectedTravellers(
614
+ travellers,
615
+ ServiceType.Eurostar
616
+ );
617
+ this.tempParams.adults = splitTravellers.adults.length;
618
+ this.tempParams.children = splitTravellers.children.length;
619
+ // this.tempParams.infants = splitTravellers.infants.length;
620
+
621
+ this.updateTravellers();
622
+ this._isValid();
623
+ }
624
+ );
625
+ }
626
+
627
+ userService.changeUser.subscribe((user: FullUserDetails) => {
628
+ this.timeCriteriaOptions.next([
629
+ TimeWindow.Anytime,
630
+ TimeWindow.Arrive,
631
+ TimeWindow.Depart
632
+ ]); // TODO update with any UFs
633
+ this.updateAvaliableClasses();
634
+ });
635
+
636
+ this.updateTravellers();
637
+ const results: EurostarSessionType = storageService.getSessionItem(
638
+ this.resultsSessionName
639
+ ) || {
640
+ results: [],
641
+ groupData: {},
642
+ grouped: [],
643
+ query: {} as SearchFlightsV2QueryVariables
644
+ };
645
+ this.fullResults = this.helpers.clone(results.results);
646
+ this.flightsToGroup = results.groupData || {};
647
+ this.resultQuery = results.query;
648
+ this.results.next(results.results || ([] as EurostarQuoteResultArray));
649
+ this._isValid();
650
+ this.negotiated =
651
+ this.tempParams.fareType === FareType.Negotiated ? true : false;
652
+ }
653
+ formatEurostarResults(
654
+ results: FlightJourney[],
655
+ total: FlightFareTotal
656
+ ): EurostarItem {
657
+ const returnObject: EurostarItem = {
658
+ dateArrival: null,
659
+ dateDeparture: null,
660
+ duration: null,
661
+ timeArrival: null,
662
+ timeDeparture: null,
663
+ co2PerItem: 0,
664
+ co2PerPassenger: 0,
665
+ sourceId: null,
666
+ total: null,
667
+ uid: null,
668
+
669
+ businessPremierFare: {
670
+ class: null,
671
+ fare: null,
672
+ isDisabled: true,
673
+ price: NaN,
674
+ currency: 'GBP'
675
+ },
676
+ standardFare: {
677
+ class: null,
678
+ fare: null,
679
+ isDisabled: true,
680
+ price: NaN,
681
+ currency: 'GBP'
682
+ },
683
+ standardPremierFare: {
684
+ class: null,
685
+ fare: null,
686
+ isDisabled: true,
687
+ price: NaN,
688
+ currency: 'GBP'
689
+ }
690
+ };
691
+ // returnObject.duration = results.outboundTotalDuration;
692
+ results.forEach((flight, index) => {
693
+ returnObject.dateArrival = flight.dateTimeArriving;
694
+ returnObject.dateDeparture = flight.dateTimeDeparting;
695
+ returnObject.duration = this.minToHour(flight.totalDuration);
696
+ returnObject.timeArrival = moment(flight.dateTimeArriving).format(
697
+ 'HH:mm'
698
+ );
699
+ returnObject.timeDeparture = moment(flight.dateTimeDeparting).format(
700
+ 'HH:mm'
701
+ );
702
+ returnObject.uid = index;
703
+ switch (flight.fareInfo.title) {
704
+ case EurostarClassEnum.STANDARD:
705
+ returnObject.standardFare.isDisabled = false;
706
+ returnObject.standardFare.fare = flight;
707
+ returnObject.standardFare.price = total.price;
708
+ returnObject.standardFare.currency = total.currency;
709
+ returnObject.standardFare.class = flight.cabinClass;
710
+ break;
711
+ case EurostarClassEnum.STANDARD_PREMIER:
712
+ returnObject.standardPremierFare.isDisabled = false;
713
+ returnObject.standardPremierFare.fare = flight;
714
+ returnObject.standardPremierFare.price = total.price;
715
+ returnObject.standardPremierFare.currency = total.currency;
716
+ returnObject.standardPremierFare.class = flight.cabinClass;
717
+ break;
718
+ case EurostarClassEnum.BUSINESS_PREMIER:
719
+ returnObject.businessPremierFare.isDisabled = false;
720
+ returnObject.businessPremierFare.fare = flight;
721
+ returnObject.businessPremierFare.price = total.price;
722
+ returnObject.businessPremierFare.currency = total.currency;
723
+ returnObject.businessPremierFare.class = flight.cabinClass;
724
+ break;
725
+ default:
726
+ console.log('new class to be implemented: ', flight.fareInfo.title);
727
+ }
728
+ });
729
+ return returnObject;
730
+ }
731
+
732
+ protected resetQuery(checkIsValid: boolean = true): void {
733
+ this.updateTempParams(this.searchService.makeEurostarQuery());
734
+ if (checkIsValid) {
735
+ this._isValid();
736
+ }
737
+ }
738
+
739
+ public resetParams(): void {
740
+ this.reset();
741
+ this.resetQuery();
742
+ }
743
+
744
+ private _isValid() {
745
+ if (!this.doChecks) {
746
+ return;
747
+ }
748
+ this.storageService.setSessionItem(
749
+ EurostarEnterpriseSearch.STORAGE_SESSION_PARAMS,
750
+ {
751
+ tempParams: this.tempParams,
752
+ originalUserSearch: this.originalUserSearch
753
+ }
754
+ );
755
+
756
+ this.validationMessages = [];
757
+ if (!this._originAirport) {
758
+ this.validationMessages.push('Please add in a departutre location');
759
+ }
760
+ if (!this._destinationAirport) {
761
+ this.validationMessages.push('Please add in a arrival destination');
762
+ }
763
+ if (!this.tempParams.outBoundDate.isAfter(moment())) {
764
+ this.validationMessages.push('Departure date can not be in the past');
765
+ }
766
+
767
+ if (
768
+ this._originAirport &&
769
+ this._destinationAirport &&
770
+ this._destinationAirport === this._originAirport
771
+ ) {
772
+ this.validationMessages.push(
773
+ 'Origin and destination station cannot be the same'
774
+ );
775
+ }
776
+ if (this.isReturn) {
777
+ // TODO check that return details are set
778
+ if (
779
+ this.tempParams.outBoundDate.isSameOrAfter(
780
+ this.tempParams.inTimeCriteria
781
+ )
782
+ ) {
783
+ this.validationMessages.push(
784
+ 'Return date must be after the departure date'
785
+ );
786
+ }
787
+ }
788
+ this.isValid.next(this.validationMessages.length === 0);
789
+ this.messages.next(this.validationMessages);
790
+ }
791
+
792
+ startSearch(): Promise<boolean> {
793
+ this.results.next([]);
794
+ this._isValid();
795
+
796
+ if (this.isValid.value) {
797
+ this._originalUserSearch = Object.freeze({ ...this.tempParams });
798
+ this.storageService.setSessionItem(
799
+ EurostarEnterpriseSearch.STORAGE_SESSION_PARAMS,
800
+ {
801
+ tempParams: this.tempParams,
802
+ originalUserSearch: this.originalUserSearch
803
+ }
804
+ );
805
+ return this._startSearch(
806
+ this.eurostarFetcher.fetchList(this.getSearchQuery())
807
+ );
808
+ } else {
809
+ return Promise.resolve(false);
810
+ }
811
+ }
812
+
813
+ public startRecentSearch(recentSearch: RecentSearch): void { }
814
+
815
+ private makeDepartureTimeWindow(
816
+ dateTime: moment.Moment,
817
+ window: TimeWindow
818
+ ): string {
819
+ return window === TimeWindow.Depart
820
+ ? this.helpers.makeTimeWindow(dateTime, -2, 2)
821
+ : null;
822
+ }
823
+
824
+ private makeArrivalTimeWindow(
825
+ dateTime: moment.Moment,
826
+ window: TimeWindow
827
+ ): string {
828
+ if (window !== TimeWindow.Arrive) {
829
+ return null;
830
+ }
831
+
832
+ return this.helpers.makeTimeWindow(dateTime, -2, 2);
833
+ }
834
+
835
+ getSearchQuery(): SearchFlightsV2QueryVariables {
836
+ return this.helpers.removeNulls<SearchFlightsV2QueryVariables>(
837
+ Object.assign(
838
+ {},
839
+ {
840
+ originAirport: this._originAirport,
841
+ destinationAirport: this._destinationAirport,
842
+ outboundDate: this.helpers.formatIsoDate(
843
+ this.tempParams.outBoundDate
844
+ ),
845
+ outboundDepartureTimeWindow: this.makeDepartureTimeWindow(
846
+ this.tempParams.outBoundDate,
847
+ this.tempParams.outTimeCriteria
848
+ ),
849
+ outboundArrivalTimeWindow: this.makeArrivalTimeWindow(
850
+ this.tempParams.outBoundDate,
851
+ this.tempParams.outTimeCriteria
852
+ )
853
+ },
854
+ {
855
+ passengers: this._passengers,
856
+ returnTrip: this.isReturn,
857
+ outboundCabinClass: this.tempParams.cabinClass
858
+ ? [this.tempParams.cabinClass]
859
+ : null,
860
+ requireFreeBag: null,
861
+ maxConnections: this.tempParams.maxConnections,
862
+ includeNearbyAirports: this.tempParams.includeNearbyAirports,
863
+ preferredCarriers: this.tempParams.preferredCarriers.map(
864
+ (carrier: OBTAirlinesDetails) =>
865
+ carrier?.code ? carrier.code : null
866
+ ),
867
+ fareType: this.tempParams.fareType,
868
+ withGrouped: null
869
+ },
870
+ this.isReturn
871
+ ? {
872
+ returnDate: this.helpers.formatIsoDate(
873
+ this.tempParams.inboundDate
874
+ ),
875
+ returnDepartureTimeWindow: this.makeDepartureTimeWindow(
876
+ this.tempParams.inboundDate,
877
+ this.tempParams.inTimeCriteria
878
+ ),
879
+ returnArrivalTimeWindow: this.makeArrivalTimeWindow(
880
+ this.tempParams.inboundDate,
881
+ this.tempParams.inTimeCriteria
882
+ ),
883
+ returnCabinClass: this.tempParams.returnCabinClass
884
+ ? [this.tempParams.returnCabinClass]
885
+ : null
886
+ }
887
+ : {}
888
+ )
889
+ );
890
+ }
891
+
892
+ private updateTravellers() {
893
+ const travellers: FlightPassengerObject[] = [];
894
+ for (let loop = 0; loop < this.tempParams.adults; loop += 1) {
895
+ travellers.push({ type: FlightPassengerType.Adult });
896
+ }
897
+ for (let loop = 0; loop < this.tempParams.children; loop += 1) {
898
+ travellers.push({ type: FlightPassengerType.Child });
899
+ }
900
+
901
+ this._passengers = travellers;
902
+ this._isValid();
903
+ }
904
+
905
+ private updateAvaliableClasses() {
906
+ this.avaliableClasses.next([
907
+ {
908
+ name: 'Any',
909
+ type: EurostarClassEnum.ANY
910
+ },
911
+ {
912
+ name: 'Standard (semi flexible)',
913
+ type: EurostarClassEnum.STANDARD
914
+ },
915
+ {
916
+ name: 'Standard premier (semi flexible)',
917
+ type: EurostarClassEnum.STANDARD_PREMIER
918
+ },
919
+ {
920
+ name: 'Business premier (fully flexible)',
921
+ type: EurostarClassEnum.BUSINESS_PREMIER
922
+ }
923
+ ]);
924
+ }
925
+
926
+ /**
927
+ * @description - sort the flight results
928
+ * @todo - Fill out Preferred and Co2 sorting when we have that data
929
+ */
930
+ public sortResults(
931
+ sortMethodValue: SortTypesEurostar,
932
+ givenResults?: EurostarResults[]
933
+ ): void {
934
+ let results = this.helpers.clone(
935
+ givenResults
936
+ ? givenResults
937
+ : <EurostarResults[]>(<unknown>this.fullResults)
938
+ );
939
+
940
+ switch (sortMethodValue) {
941
+ case SortTypesEurostar.CheapestFirst:
942
+ results = this.sortByPrice(results);
943
+ break;
944
+ case SortTypesEurostar.EarliestFirst:
945
+ results = this.sortByDate(results);
946
+ break;
947
+ default:
948
+ console.error(`+++ Unknown sorting method: ${sortMethodValue} +++`);
949
+ }
950
+
951
+ this.results.next(results);
952
+ }
953
+
954
+ /**
955
+ * Sort results by departure time
956
+ *
957
+ * @param {EurostarResults[]} results
958
+ * @returns
959
+ * @memberof EurostarInfo
960
+ */
961
+ sortByDate(results: EurostarResults[]): EurostarResults[] {
962
+ const byDate = (a: EurostarItem, b: EurostarItem) => {
963
+ return (
964
+ moment(a.timeDeparture, 'HH:mm').unix() -
965
+ moment(b.timeDeparture, 'HH:mm').unix()
966
+ );
967
+ };
968
+
969
+ const sortedResults = {
970
+ outbound: results[0].outbound.sort(byDate),
971
+ inbound: results[0].inbound.sort(byDate)
972
+ };
973
+ return [sortedResults];
974
+ }
975
+
976
+ /**
977
+ * Sort results by price
978
+ *
979
+ * @param {EurostarResults[]} results
980
+ * @returns
981
+ * @memberof EurostarInfo
982
+ */
983
+ sortByPrice(results: EurostarResults[], dir?: boolean): EurostarResults[] {
984
+ const byPrice = (a: EurostarItem, b: EurostarItem) => {
985
+ const aPrice =
986
+ +a.standardFare.price ||
987
+ +a.standardPremierFare.price ||
988
+ +a.businessPremierFare.price;
989
+ const bPrice =
990
+ +b.standardFare.price ||
991
+ +b.standardPremierFare.price ||
992
+ +b.businessPremierFare.price;
993
+ if (dir) {
994
+ return bPrice - aPrice;
995
+ }
996
+ return aPrice - bPrice;
997
+ };
998
+
999
+ const sortedResults = {
1000
+ outbound: results[0].outbound.sort(byPrice),
1001
+ inbound: results[0].inbound.sort(byPrice)
1002
+ };
1003
+ return [sortedResults];
1004
+ }
1005
+
1006
+ updateFromPreviousSearches(
1007
+ previousItems: Record<ServiceType, BasketItem>
1008
+ ): void {
1009
+ const flightItem: SearchFlightsV2QueryVariables =
1010
+ previousItems[ServiceType.Flight]?.searchQuery;
1011
+ if (flightItem) {
1012
+ // TODO flights haven't been done yet.
1013
+ }
1014
+ }
1015
+
1016
+ getTotalBaggage(result: FlightItinerary): number {
1017
+ let total = 0;
1018
+
1019
+ const parsedAdditional = JSON.parse(result.additional);
1020
+ if (parsedAdditional && parsedAdditional.outboundFlights) {
1021
+ parsedAdditional.outboundFlights.forEach((flight: any) => {
1022
+ flight.baggage.forEach((bag: any) => {
1023
+ if (bag.allowance && bag.allowance > total) {
1024
+ total = bag.allowance;
1025
+ }
1026
+ });
1027
+ });
1028
+ } else if (parsedAdditional && parsedAdditional.baggageAllowance) {
1029
+ parsedAdditional.baggageAllowance.forEach((baggageAllow: any) => {
1030
+ if (
1031
+ baggageAllow.baggage.qty &&
1032
+ Number(baggageAllow.baggage.qty) > total
1033
+ ) {
1034
+ total = Number(baggageAllow.baggage.qty);
1035
+ }
1036
+ });
1037
+ }
1038
+
1039
+ return total;
1040
+ }
1041
+
1042
+ /**
1043
+ * @description - give the correct format for transfering minuetes on the sliders
1044
+ * @param min - the min in 100th's to transform onto 60th's
1045
+ */
1046
+ transformMin(min: number): string {
1047
+ let num = (Number(min) * 60) / 100;
1048
+ // console.log('+++ Num Copy: ', _.clone(num), ' +++');
1049
+ if (num % 1 < 0.5) {
1050
+ num = Math.floor(num);
1051
+ } else {
1052
+ num = Math.ceil(num);
1053
+ }
1054
+
1055
+ return num.toString().padStart(2, '0');
1056
+ }
1057
+
1058
+ filterByDuration(
1059
+ minDuration: number,
1060
+ maxDuration: number,
1061
+ results: FlightItinerary[],
1062
+ isReturn = false
1063
+ ): FlightItinerary[] {
1064
+ results = results.filter((result) => {
1065
+ let dur = 0;
1066
+ if (!isReturn) {
1067
+ result.outboundFlights.forEach((out: FlightJourney) => {
1068
+ dur += out.totalDuration;
1069
+ });
1070
+ }
1071
+
1072
+ if (result.inboundFlights?.length && isReturn) {
1073
+ result.inboundFlights.forEach((inb: FlightJourney) => {
1074
+ dur += inb.totalDuration;
1075
+ });
1076
+ }
1077
+
1078
+ return dur >= minDuration && dur <= maxDuration;
1079
+ });
1080
+
1081
+ return results;
1082
+ }
1083
+
1084
+ filterByDepartureTime(
1085
+ minDep: number,
1086
+ maxDep: number,
1087
+ results: FlightItinerary[]
1088
+ ): FlightItinerary[] {
1089
+ results = results.filter((result) => {
1090
+ const departureTime = Number(
1091
+ moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm')
1092
+ );
1093
+ const newNumString1 = Number(
1094
+ Math.floor(Number(minDep / 100)).toString() +
1095
+ this.transformMin(Math.ceil(Number(minDep % 100)))
1096
+ );
1097
+ const newNumString2 = Number(
1098
+ Math.floor(Number(maxDep / 100)).toString() +
1099
+ this.transformMin(Math.ceil(Number(maxDep % 100)))
1100
+ );
1101
+
1102
+ return departureTime >= newNumString1 && departureTime <= newNumString2;
1103
+ });
1104
+
1105
+ return results;
1106
+ }
1107
+
1108
+ filterByReturnDepartureTime(
1109
+ minDep: number,
1110
+ maxDep: number,
1111
+ results: FlightItinerary[]
1112
+ ): FlightItinerary[] {
1113
+ if (!minDep && !maxDep) {
1114
+ return results;
1115
+ }
1116
+
1117
+ const newNumString1 = Number(
1118
+ Math.floor(Number(minDep / 100)).toString() +
1119
+ this.transformMin(Math.ceil(Number(minDep % 100)))
1120
+ );
1121
+ const newNumString2 = Number(
1122
+ Math.floor(Number(maxDep / 100)).toString() +
1123
+ this.transformMin(Math.ceil(Number(maxDep % 100)))
1124
+ );
1125
+
1126
+ results = results.filter((result) => {
1127
+ if (!result.inboundFlights || !result.inboundFlights[0]) {
1128
+ return true;
1129
+ }
1130
+
1131
+ const departureTime = Number(
1132
+ moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm')
1133
+ );
1134
+ return departureTime >= newNumString1 && departureTime <= newNumString2;
1135
+ });
1136
+
1137
+ return results;
1138
+ }
1139
+
1140
+ filterByReturnArrivalTime(
1141
+ minArr: number,
1142
+ maxArr: number,
1143
+ results: FlightItinerary[]
1144
+ ): FlightItinerary[] {
1145
+ if (!minArr && !maxArr) {
1146
+ return results;
1147
+ }
1148
+
1149
+ const newNumString1 = Number(
1150
+ Math.floor(Number(minArr / 100)).toString() +
1151
+ this.transformMin(Math.ceil(Number(minArr % 100)))
1152
+ );
1153
+ const newNumString2 = Number(
1154
+ Math.floor(Number(maxArr / 100)).toString() +
1155
+ this.transformMin(Math.ceil(Number(maxArr % 100)))
1156
+ );
1157
+
1158
+ results = results.filter((result) => {
1159
+ if (!result.inboundFlights || !result.inboundFlights[0]) {
1160
+ return true;
1161
+ }
1162
+
1163
+ const arrivalTime = Number(
1164
+ moment(
1165
+ result.inboundFlights[result.inboundFlights.length - 1]
1166
+ .dateTimeArriving
1167
+ ).format('HHmm')
1168
+ );
1169
+ const retVal =
1170
+ arrivalTime >= newNumString1 && arrivalTime <= newNumString2;
1171
+
1172
+ // for debugging
1173
+ // if (!retVal) {
1174
+ // console.warn(`+++ Filtering Out: ${arrivalTime} +++`);
1175
+ // }
1176
+
1177
+ return retVal;
1178
+ });
1179
+
1180
+ return results;
1181
+ }
1182
+
1183
+ filterByArrivalTime(
1184
+ minArr: number,
1185
+ maxArr: number,
1186
+ results: FlightItinerary[]
1187
+ ): FlightItinerary[] {
1188
+ const newNumString1 = Number(
1189
+ Math.floor(Number(minArr / 100)).toString() +
1190
+ this.transformMin(Math.ceil(Number(minArr % 100)))
1191
+ );
1192
+ const newNumString2 = Number(
1193
+ Math.floor(Number(maxArr / 100)).toString() +
1194
+ this.transformMin(Math.ceil(Number(maxArr % 100)))
1195
+ );
1196
+
1197
+ results = results.filter((result) => {
1198
+ const arrivalTime = Number(
1199
+ moment(
1200
+ result.outboundFlights[result.outboundFlights.length - 1]
1201
+ .dateTimeArriving
1202
+ ).format('HHmm')
1203
+ );
1204
+
1205
+ return arrivalTime >= newNumString1 && arrivalTime <= newNumString2;
1206
+ });
1207
+
1208
+ return results;
1209
+ }
1210
+
1211
+ filterByBaggage(
1212
+ baggageFilters: SelectFilter[],
1213
+ results: FlightItinerary[]
1214
+ ): FlightItinerary[] {
1215
+ const selected = baggageFilters.filter((x) => x.selected);
1216
+
1217
+ if (selected?.length >= 1 && selected.length !== baggageFilters.length) {
1218
+ results = results.filter((result) => {
1219
+ try {
1220
+ const totalBags = this.getTotalBaggage(result);
1221
+
1222
+ return selected.find((x) => x.value === totalBags);
1223
+ } catch (error) {
1224
+ console.error('+++ Error determening baggage: ${error} +++');
1225
+ return false;
1226
+ }
1227
+ });
1228
+ }
1229
+
1230
+ return results;
1231
+ }
1232
+
1233
+ filterByPrice(
1234
+ minPrice: number,
1235
+ maxPrice: number,
1236
+ results: FlightItinerary[]
1237
+ ): FlightItinerary[] {
1238
+ results = results.filter((result) => {
1239
+ // console.log(`+++ Price: ${result.total.price} is between: ${minPrice} and ${maxPrice}: ${result.total.price >= minPrice && result.total.price <= maxPrice} +++`)
1240
+
1241
+ return result.total.price >= minPrice && result.total.price <= maxPrice;
1242
+ });
1243
+
1244
+ return results;
1245
+ }
1246
+
1247
+ /**
1248
+ * @description - filter the results by the number of stops
1249
+ * @param stopFilters - the selected stops
1250
+ * @param fullResults - all of our results so far
1251
+ */
1252
+ filterResultsByStops(
1253
+ stopFilters: SelectFilter[],
1254
+ fullResults: FlightItinerary[]
1255
+ ): FlightItinerary[] {
1256
+ const selected = stopFilters.filter((x) => x.selected);
1257
+
1258
+ if (selected?.length >= 1 && selected.length !== stopFilters.length) {
1259
+ fullResults = fullResults.filter((result) => {
1260
+ const totalStops = result.outboundFlights.length - 1;
1261
+
1262
+ const haveStop = selected.find(
1263
+ (selected1: SelectFilter) => selected1.value === totalStops
1264
+ );
1265
+
1266
+ return haveStop;
1267
+ });
1268
+ }
1269
+
1270
+ return fullResults;
1271
+ }
1272
+
1273
+ filterResultsByAirline(
1274
+ airlineFilters: SelectFilter[],
1275
+ results: FlightItinerary[]
1276
+ ): FlightItinerary[] {
1277
+ const selected = airlineFilters.filter((x) => x.selected);
1278
+
1279
+ if (selected?.length >= 1 && selected.length !== airlineFilters.length) {
1280
+ results = results.filter((result) => {
1281
+ return selected.find(
1282
+ (x) => x.value === result.outboundFlights[0].operatingCarrier
1283
+ );
1284
+ });
1285
+ }
1286
+
1287
+ return results;
1288
+ }
1289
+
1290
+ filterResultsByClass(
1291
+ classFilters: SelectFilter[],
1292
+ results: FlightItinerary[]
1293
+ ): FlightItinerary[] {
1294
+ const selected = classFilters.filter((x) => x.selected);
1295
+
1296
+ if (selected?.length >= 1 && selected.length !== classFilters.length) {
1297
+ results = results.filter((result) => {
1298
+ return selected.find(
1299
+ (x) => x.value === result.outboundFlights[0].cabinClass
1300
+ );
1301
+ });
1302
+ }
1303
+
1304
+ return results;
1305
+ }
1306
+
1307
+ filterByDepartureAirport(
1308
+ departureAirports: SelectFilter[],
1309
+ results: FlightItinerary[]
1310
+ ): FlightItinerary[] {
1311
+ const selected = departureAirports.filter((x) => x.selected);
1312
+
1313
+ if (selected?.length >= 1 && selected.length !== departureAirports.length) {
1314
+ results = results.filter((result) => {
1315
+ return selected.find(
1316
+ (x) => x.value === result.outboundFlights[0].originAirport
1317
+ );
1318
+ });
1319
+ }
1320
+
1321
+ return results;
1322
+ }
1323
+
1324
+ filterByArrivalAirport(
1325
+ arrivalAirports: SelectFilter[],
1326
+ results: FlightItinerary[]
1327
+ ): FlightItinerary[] {
1328
+ const selected = arrivalAirports.filter((x) => x.selected);
1329
+
1330
+ if (selected?.length >= 1 && selected.length !== arrivalAirports.length) {
1331
+ results = results.filter((result) => {
1332
+ const destinationAirport =
1333
+ result.outboundFlights[result.outboundFlights.length - 1]
1334
+ .destinationAirport;
1335
+ return selected.find((x) => x.value === destinationAirport);
1336
+ });
1337
+ }
1338
+
1339
+ return results;
1340
+ }
1341
+
1342
+ filterByDepartureReturnAirport(
1343
+ departureAirports: SelectFilter[],
1344
+ results: FlightItinerary[]
1345
+ ): FlightItinerary[] {
1346
+ const selected = departureAirports.filter((x) => x.selected);
1347
+
1348
+ if (selected?.length >= 1 && selected.length !== departureAirports.length) {
1349
+ results = results.filter((result) => {
1350
+ if (!result.inboundFlights?.length) {
1351
+ return true;
1352
+ }
1353
+
1354
+ return selected.find(
1355
+ (x) => x.value === result.inboundFlights[0].originAirport
1356
+ );
1357
+ });
1358
+ }
1359
+
1360
+ return results;
1361
+ }
1362
+
1363
+ filterByArrivalReturnAirport(
1364
+ arrivalAirports: SelectFilter[],
1365
+ results: FlightItinerary[]
1366
+ ): FlightItinerary[] {
1367
+ const selected = arrivalAirports.filter((x) => x.selected);
1368
+
1369
+ if (selected?.length >= 1 && selected.length !== arrivalAirports.length) {
1370
+ results = results.filter((result) => {
1371
+ if (!result.inboundFlights?.length) {
1372
+ return true;
1373
+ }
1374
+
1375
+ const destinationAirport =
1376
+ result.inboundFlights[result.inboundFlights.length - 1]
1377
+ .destinationAirport;
1378
+ return selected.find((x) => x.value === destinationAirport);
1379
+ });
1380
+ }
1381
+
1382
+ return results;
1383
+ }
1384
+
1385
+ createFilters(results: FlightItinerary[] = []): FlightFilters {
1386
+ const minPrice = this.getMinPrice(results);
1387
+ const maxPrice = this.getMaxPrice(results);
1388
+
1389
+ const newFilters: FlightFilters = {
1390
+ stops: this.getAllStops(results),
1391
+ mustInclude: [],
1392
+ classes: this.getAllClasses(results),
1393
+ airlines: this.getAllAirlines(results),
1394
+ travelPolicy: [],
1395
+ depatureAirport: this.getAllDepartureAirports(results),
1396
+ arrivalAirport: this.getAllArrivalAirports(results),
1397
+ minPrice,
1398
+ maxPrice,
1399
+ depatureReturnAirport: this.getAllDepartureAirports(results, true),
1400
+ arrivalReturnAirport: this.getAllArrivalAirports(results, true),
1401
+ baggage: this.getBaggage(results),
1402
+ fareTypes: [],
1403
+ minDuration: this.getMinDuration(results),
1404
+ maxDuration: this.getMaxDuration(results),
1405
+ minReturnDuration: this.getMinDuration(results, true),
1406
+ maxReturnDuration: this.getMaxDuration(results, true),
1407
+ minDepartureTime: this.getMinDepartureTime(results),
1408
+ maxDepartureTime: this.getMaxDepartureTime(results),
1409
+ minArrivalTime: this.getMinArrivalTime(results),
1410
+ maxArrivalTime: this.getMaxArrivalTime(results),
1411
+ minReturnDepartureTime: this.getMinReturnDepartureTime(results),
1412
+ maxReturnDepartureTime: this.getMaxReturnDepartureTime(results),
1413
+ maxReturnArrivalTime: this.getMaxReturnArrivalTime(results),
1414
+ minReturnArrivalTime: this.getMinReturnArrivalTime(results),
1415
+ flightNumber: ''
1416
+ };
1417
+
1418
+ return newFilters;
1419
+ }
1420
+
1421
+ getMinDuration(results: FlightItinerary[], isReturn = false): number {
1422
+ let min = 0;
1423
+
1424
+ results.forEach((result) => {
1425
+ let dur = 0;
1426
+
1427
+ if (!isReturn) {
1428
+ result.outboundFlights.forEach((out: FlightJourney) => {
1429
+ dur += out.totalDuration;
1430
+ });
1431
+ }
1432
+
1433
+ if (result.inboundFlights?.length && isReturn) {
1434
+ result.inboundFlights.forEach((inb: FlightJourney) => {
1435
+ dur += inb.totalDuration;
1436
+ });
1437
+ }
1438
+
1439
+ if (!min || dur < min) {
1440
+ min = dur;
1441
+ }
1442
+ });
1443
+
1444
+ return min;
1445
+ }
1446
+
1447
+ getMaxDuration(results: FlightItinerary[], isReturn = false): number {
1448
+ let max = 0;
1449
+
1450
+ results.forEach((result) => {
1451
+ let dur = 0;
1452
+ if (!isReturn) {
1453
+ result.outboundFlights.forEach((out: FlightJourney) => {
1454
+ dur += out.totalDuration;
1455
+ });
1456
+ }
1457
+
1458
+ if (result.inboundFlights?.length && isReturn) {
1459
+ result.inboundFlights.forEach((inb: FlightJourney) => {
1460
+ dur += inb.totalDuration;
1461
+ });
1462
+ }
1463
+
1464
+ if (!max || dur > max) {
1465
+ max = dur;
1466
+ }
1467
+ });
1468
+
1469
+ return max;
1470
+ }
1471
+
1472
+ getMinArrivalTime(results: FlightItinerary[]): number {
1473
+ let min: number;
1474
+
1475
+ results.forEach((result) => {
1476
+ let minDepTime = Number(
1477
+ moment(
1478
+ result.outboundFlights[result.outboundFlights.length - 1]
1479
+ .dateTimeArriving
1480
+ ).format('HHmm')
1481
+ );
1482
+ minDepTime = Math.floor(minDepTime / 100) * 100;
1483
+ if (!min || minDepTime < min) {
1484
+ min = minDepTime;
1485
+ }
1486
+ });
1487
+
1488
+ return min;
1489
+ }
1490
+
1491
+ getMinReturnArrivalTime(results: FlightItinerary[]): number {
1492
+ let min: number;
1493
+
1494
+ results.forEach((result) => {
1495
+ if (result.inboundFlights && result.inboundFlights.length) {
1496
+ let minDepTime = Number(
1497
+ moment(
1498
+ result.inboundFlights[result.inboundFlights.length - 1]
1499
+ .dateTimeArriving
1500
+ ).format('HHmm')
1501
+ );
1502
+ minDepTime = Math.floor(minDepTime / 100) * 100;
1503
+ if (!min || minDepTime < min) {
1504
+ min = minDepTime;
1505
+ }
1506
+ }
1507
+ });
1508
+
1509
+ return min;
1510
+ }
1511
+
1512
+ getMaxReturnArrivalTime(results: FlightItinerary[]): number {
1513
+ let max: number;
1514
+
1515
+ results.forEach((result) => {
1516
+ if (result.inboundFlights && result.inboundFlights.length) {
1517
+ let maxDepTime = Number(
1518
+ moment(
1519
+ result.inboundFlights[result.inboundFlights.length - 1]
1520
+ .dateTimeArriving
1521
+ ).format('HHmm')
1522
+ );
1523
+ maxDepTime = Math.ceil(maxDepTime / 100) * 100;
1524
+ if (!max || maxDepTime > max) {
1525
+ max = maxDepTime;
1526
+ }
1527
+ }
1528
+ });
1529
+
1530
+ return max;
1531
+ }
1532
+
1533
+ getMaxArrivalTime(results: FlightItinerary[]): number {
1534
+ let max: number;
1535
+
1536
+ results.forEach((result) => {
1537
+ let maxDepTime = Number(
1538
+ moment(
1539
+ result.outboundFlights[result.outboundFlights.length - 1]
1540
+ .dateTimeArriving
1541
+ ).format('HHmm')
1542
+ );
1543
+
1544
+ maxDepTime = Math.ceil(maxDepTime / 100) * 100;
1545
+ if (!max || maxDepTime > max) {
1546
+ max = maxDepTime;
1547
+ }
1548
+ });
1549
+ return max;
1550
+ }
1551
+
1552
+ getMinDepartureTime(results: FlightItinerary[]): number {
1553
+ let min: number;
1554
+
1555
+ results.forEach((result) => {
1556
+ let minDepTime = Number(
1557
+ moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm')
1558
+ );
1559
+ minDepTime = Math.floor(minDepTime / 100) * 100;
1560
+ if (!min || minDepTime < min) {
1561
+ min = minDepTime;
1562
+ }
1563
+ });
1564
+
1565
+ return min;
1566
+ }
1567
+
1568
+ getMinReturnDepartureTime(results: FlightItinerary[]): number {
1569
+ let min: number;
1570
+
1571
+ results.forEach((result) => {
1572
+ if (result.inboundFlights && result.inboundFlights[0]) {
1573
+ let minDepTime = Number(
1574
+ moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm')
1575
+ );
1576
+ minDepTime = Math.floor(minDepTime / 100) * 100;
1577
+ if (!min || minDepTime < min) {
1578
+ min = minDepTime;
1579
+ }
1580
+ }
1581
+ });
1582
+
1583
+ return min;
1584
+ }
1585
+
1586
+ getMaxReturnDepartureTime(results: FlightItinerary[]): number {
1587
+ let max: number;
1588
+
1589
+ results.forEach((result) => {
1590
+ if (result.inboundFlights && result.inboundFlights[0]) {
1591
+ let maxDepTime = Number(
1592
+ moment(result.inboundFlights[0].dateTimeDeparting).format('HHmm')
1593
+ );
1594
+
1595
+ maxDepTime = Math.ceil(maxDepTime / 100) * 100;
1596
+
1597
+ if (!max || maxDepTime > max) {
1598
+ max = maxDepTime;
1599
+ }
1600
+ }
1601
+ });
1602
+
1603
+ return max;
1604
+ }
1605
+
1606
+ getMaxDepartureTime(results: FlightItinerary[]): number {
1607
+ let max: number;
1608
+
1609
+ results.forEach((result) => {
1610
+ let maxDepTime = Number(
1611
+ moment(result.outboundFlights[0].dateTimeDeparting).format('HHmm')
1612
+ );
1613
+
1614
+ maxDepTime = Math.ceil(maxDepTime / 100) * 100;
1615
+
1616
+ if (!max || maxDepTime > max) {
1617
+ max = maxDepTime;
1618
+ }
1619
+ });
1620
+
1621
+ return max;
1622
+ }
1623
+
1624
+ getBaggage(results: FlightItinerary[]): SelectFilter[] {
1625
+ const baggage: any = {};
1626
+
1627
+ results.forEach((result) => {
1628
+ try {
1629
+ const parsedAdditional = JSON.parse(result.additional);
1630
+
1631
+ let total = 0;
1632
+
1633
+ if (parsedAdditional && parsedAdditional.outboundFlights) {
1634
+ parsedAdditional.outboundFlights.forEach((flight: any) => {
1635
+ flight.baggage.forEach((bag: any) => {
1636
+ if (bag.allowance && bag.allowance > total) {
1637
+ total = bag.allowance;
1638
+ }
1639
+ });
1640
+ });
1641
+ } else if (parsedAdditional && parsedAdditional.baggageAllowance) {
1642
+ parsedAdditional.baggageAllowance.forEach((baggageAllow: any) => {
1643
+ if (
1644
+ baggageAllow.baggage.qty &&
1645
+ Number(baggageAllow.baggage.qty) > total
1646
+ ) {
1647
+ total = Number(baggageAllow.baggage.qty);
1648
+ }
1649
+ });
1650
+ }
1651
+
1652
+ baggage[total] = {
1653
+ selected: false,
1654
+ value: total,
1655
+ display: `${total} bag${total !== 1 ? 's' : ''}`
1656
+ };
1657
+ } catch (error) {
1658
+ console.error(`+++ Error parsing additional flight data: ${error} +++`);
1659
+ }
1660
+ });
1661
+
1662
+ return Object.values(baggage);
1663
+ }
1664
+
1665
+ getMinPrice(results: FlightItinerary[]): number {
1666
+ let minPrice: number;
1667
+
1668
+ results.forEach((result) => {
1669
+ if (!minPrice || result.total.price < minPrice) {
1670
+ minPrice = result.total.price;
1671
+ }
1672
+ });
1673
+
1674
+ return minPrice;
1675
+ }
1676
+
1677
+ getMaxPrice(results: FlightItinerary[]): number {
1678
+ let maxPrice: any;
1679
+
1680
+ results.forEach((result) => {
1681
+ if (!maxPrice || result.total.price > maxPrice) {
1682
+ maxPrice = result.total.price;
1683
+ }
1684
+ });
1685
+
1686
+ return maxPrice;
1687
+ }
1688
+
1689
+ getAllStops(results: FlightItinerary[]): SelectFilter[] {
1690
+ const allStops: any = {};
1691
+
1692
+ results.forEach((result) => {
1693
+ const totalStops = result.outboundFlights.length - 1; // might have to recalculate this
1694
+ allStops[totalStops] = {
1695
+ value: totalStops,
1696
+ display: `${totalStops} stop` + (totalStops !== 1 ? 's' : ''),
1697
+ selected: false
1698
+ };
1699
+ });
1700
+
1701
+ return Object.values(allStops);
1702
+ }
1703
+
1704
+ getAllClasses(results: FlightItinerary[]): SelectFilter[] {
1705
+ const allClasses: any = [];
1706
+
1707
+ results.forEach((result) => {
1708
+ result.outboundFlights.forEach((outFlight: FlightJourney) => {
1709
+ allClasses[outFlight.cabinClass] = {
1710
+ value: outFlight.cabinClass,
1711
+ display: outFlight.cabinClass,
1712
+ selected: false
1713
+ } as SelectFilter;
1714
+ });
1715
+
1716
+ if (result.inboundFlights) {
1717
+ result.inboundFlights.forEach((inFlight: FlightJourney) => {
1718
+ allClasses[inFlight.cabinClass] = {
1719
+ value: inFlight.cabinClass,
1720
+ display: inFlight.cabinClass,
1721
+ selected: false
1722
+ } as SelectFilter;
1723
+ });
1724
+ }
1725
+ });
1726
+
1727
+ return Object.values(allClasses);
1728
+ }
1729
+
1730
+ /**
1731
+ * @description - create select filters for all unique departure airports returned in the search
1732
+ * @param results - the flight results
1733
+ */
1734
+ getAllDepartureAirports(
1735
+ results: FlightItinerary[],
1736
+ inbound = false
1737
+ ): SelectFilter[] {
1738
+ const allAirports: any = {};
1739
+
1740
+ results.forEach((result) => {
1741
+ if (result.outboundFlights.length && !inbound) {
1742
+ allAirports[result.outboundFlights[0].originAirport] = {
1743
+ value: result.outboundFlights[0].originAirport,
1744
+ display: result.outboundFlights[0].originAirportName,
1745
+ selected: false
1746
+ };
1747
+ }
1748
+
1749
+ if (result.inboundFlights?.length && inbound) {
1750
+ allAirports[result.inboundFlights[0].originAirport] = {
1751
+ value: result.inboundFlights[0].originAirport,
1752
+ display: result.inboundFlights[0].originAirportName,
1753
+ selected: false
1754
+ };
1755
+ }
1756
+ });
1757
+
1758
+ return Object.values(allAirports);
1759
+ }
1760
+
1761
+ /**
1762
+ * @description - create select filters for all unique departure airports returned in the search
1763
+ * @param results - the flight results
1764
+ */
1765
+ getAllArrivalAirports(
1766
+ results: FlightItinerary[],
1767
+ inbound = false
1768
+ ): SelectFilter[] {
1769
+ const allAirports: any = {};
1770
+
1771
+ results.forEach((result) => {
1772
+ if (result.outboundFlights.length && !inbound) {
1773
+ allAirports[
1774
+ result.outboundFlights[
1775
+ result.outboundFlights.length - 1
1776
+ ].destinationAirport
1777
+ ] = {
1778
+ value:
1779
+ result.outboundFlights[result.outboundFlights.length - 1]
1780
+ .destinationAirport,
1781
+ display:
1782
+ result.outboundFlights[result.outboundFlights.length - 1]
1783
+ .destinationAirportName,
1784
+ selected: false
1785
+ };
1786
+ }
1787
+
1788
+ if (result.inboundFlights?.length && inbound) {
1789
+ allAirports[
1790
+ result.inboundFlights[
1791
+ result.inboundFlights.length - 1
1792
+ ].destinationAirport
1793
+ ] = {
1794
+ value:
1795
+ result.inboundFlights[result.inboundFlights.length - 1]
1796
+ .destinationAirport,
1797
+ display:
1798
+ result.inboundFlights[result.inboundFlights.length - 1]
1799
+ .destinationAirportName,
1800
+ selected: false
1801
+ };
1802
+ }
1803
+ });
1804
+
1805
+ return Object.values(allAirports);
1806
+ }
1807
+
1808
+ /**
1809
+ * @description - create select filters for all unique airlines returned in the search
1810
+ * @param results - the flight results
1811
+ */
1812
+ getAllAirlines(results: FlightItinerary[]): SelectFilter[] {
1813
+ const allAirlines: any = {};
1814
+
1815
+ results.forEach((result: FlightItinerary) => {
1816
+ result.outboundFlights.forEach((outFlight: FlightJourney) => {
1817
+ allAirlines[outFlight.operatingCarrier] = {
1818
+ value: outFlight.operatingCarrier,
1819
+ display: outFlight.operatingCarrierName,
1820
+ selected: false
1821
+ } as SelectFilter;
1822
+ });
1823
+
1824
+ if (result.inboundFlights) {
1825
+ result.inboundFlights.forEach((inFlight: FlightJourney) => {
1826
+ allAirlines[inFlight.operatingCarrier] = {
1827
+ value: inFlight.operatingCarrier,
1828
+ display: inFlight.operatingCarrierName,
1829
+ selected: false
1830
+ } as SelectFilter;
1831
+ });
1832
+ }
1833
+ });
1834
+
1835
+ return Object.values(allAirlines);
1836
+ }
1837
+
1838
+ async selectGroupedEurostar(
1839
+ selectedEurostar: EurostarItem,
1840
+ fare: EurostarFare,
1841
+ direction: FlightDirectionEnum
1842
+ ) {
1843
+ const intBasket: InternalBasketInterface =
1844
+ await this.basketService.getDefaultBasket();
1845
+ const basket = intBasket?.subject.value;
1846
+
1847
+ if (
1848
+ basket &&
1849
+ this.originalUserSearch.chosenSearchType === EurostarSearchType.oneWay &&
1850
+ direction === FlightDirectionEnum.Outbound
1851
+ ) {
1852
+ this.doBooking(
1853
+ intBasket,
1854
+ selectedEurostar,
1855
+ {
1856
+ outboundFlights:
1857
+ [this.makeSchemaFlights(fare.fare, 'outbound', 0)],
1858
+ inboundFlights: [],
1859
+ journeyType: 'single'
1860
+ },
1861
+ selectedEurostar.dateDeparture
1862
+ );
1863
+ return;
1864
+ }
1865
+ if (
1866
+ basket &&
1867
+ this.originalUserSearch.chosenSearchType === EurostarSearchType.return &&
1868
+ direction === FlightDirectionEnum.Outbound
1869
+ ) {
1870
+ this.selectedGroupEurostar = selectedEurostar;
1871
+ this.selectedEurostarFare = fare;
1872
+ const index = selectedEurostar.uid;
1873
+
1874
+ this.results.next(
1875
+ (this.fullResults as EurostarResults[]).map((result:EurostarResults) => {
1876
+ const outbound = result.outbound.filter((item:EurostarItem, groupIndex) => index === groupIndex);
1877
+ return { inbound: result.inbound, outbound }
1878
+ })
1879
+ );
1880
+ }
1881
+ if (
1882
+ basket &&
1883
+ this.originalUserSearch.chosenSearchType === EurostarSearchType.return &&
1884
+ direction === FlightDirectionEnum.Inbound &&
1885
+ this.selectedGroupEurostar
1886
+ ) {
1887
+ this.doBooking(
1888
+ intBasket,
1889
+ selectedEurostar,
1890
+ {
1891
+ outboundFlights: [
1892
+ this.makeSchemaFlights(this.selectedEurostarFare.fare, 'outbound', 0)
1893
+ ],
1894
+ inboundFlights: [
1895
+ this.makeSchemaFlights(fare.fare, 'inbound', 0)
1896
+
1897
+ ],
1898
+ journeyType: 'roundtrip'
1899
+ },
1900
+ selectedEurostar.dateDeparture,
1901
+ this.selectedGroupEurostar.dateArrival
1902
+ );
1903
+ this.results.next(this.fullResults);
1904
+ }
1905
+ }
1906
+ updateLowestPrice(results: EurostarResults[]): ICheapestPrice {
1907
+ return null;
1908
+ // add in once filght result is updated///
1909
+ // const results = this.storageService.getSessionItemAsList<FlightQuoteResultArray>(this.resultsSessionName) || [] as FlightQuoteResultArray;
1910
+ // if(!results.length) return;
1911
+ // this._cheapestResultPrice.currencyCode = results[0].total.currency;
1912
+ // results.map(result => {
1913
+ // const price = result.total.price;
1914
+ // if( this._cheapestResultPrice.amount > price || this._cheapestResultPrice.amount === null){
1915
+ // this._cheapestResultPrice.amount = price;
1916
+ // }
1917
+ // })
1918
+ }
1919
+
1920
+ doBooking(
1921
+ intBasket: InternalBasketInterface,
1922
+ selectedFlight: EurostarItem,
1923
+ schemaDetails: any,
1924
+ outboundDate: string,
1925
+ inboundDate?: string
1926
+ ): void {
1927
+ const { sourceId, co2PerItem, co2PerPassenger, total } = selectedFlight;
1928
+ const booking: AddItemToBasketMutationVariables = {
1929
+ adults: this.adults,
1930
+ basket: intBasket.id,
1931
+ children: this.children,
1932
+ co2PerItem,
1933
+ co2PerPassenger,
1934
+ currency: total.currency as CurrencyCode,
1935
+ detail: schemaDetails,
1936
+ price: total.price,
1937
+ searchQuery: this.resultQuery,
1938
+ service: sourceId.toString(),
1939
+ outboundDate
1940
+ };
1941
+ if (inboundDate) {
1942
+ booking.inboundDate = inboundDate;
1943
+ }
1944
+ this.basketService.addToBasket(
1945
+ booking,
1946
+ intBasket,
1947
+ this.searchService,
1948
+ this.travellers
1949
+ );
1950
+ }
1951
+
1952
+ makeSchemaFlights(
1953
+ selectedFlight: FlightJourney,
1954
+ flightGroup: 'outbound' | 'inbound',
1955
+ groupIndex: number,
1956
+ segmentIndex?: number
1957
+ ): any {
1958
+ return {
1959
+ cabinClass: selectedFlight.cabinClass,
1960
+ dateTimeArriving: selectedFlight.dateTimeArriving,
1961
+ dateTimeArrivingUTC: selectedFlight.dateTimeArrivingUTC,
1962
+ dateTimeDeparting: selectedFlight.dateTimeDeparting,
1963
+ dateTimeDepartingUTC: selectedFlight.dateTimeDepartingUTC,
1964
+ destinationAirport: selectedFlight.destinationAirport,
1965
+ journeyInfo: {
1966
+ flightGroup,
1967
+ groupIndex,
1968
+ segmentIndex
1969
+ },
1970
+ marketingCarrier: selectedFlight.marketingCarrier,
1971
+ marketingFlightNumber: selectedFlight.marketingFlightNumber,
1972
+ operatingCarrier: selectedFlight.operatingCarrier,
1973
+ operatingFlightNumber: selectedFlight.operatingFlightNumber,
1974
+ originAirport: selectedFlight.originAirport,
1975
+ totalDuration: selectedFlight.totalDuration,
1976
+ fareType: selectedFlight.fareInfo.title
1977
+ };
1978
+ }
1979
+
1980
+ private createGroupedItem(
1981
+ returnObject: EurostarGroupedQuoteResult,
1982
+ source: string,
1983
+ outboundFlights: FlightJourney[],
1984
+ outboundTotalDuration: number,
1985
+ inboundFlights: FlightJourney[],
1986
+ inboundTotalDuration: number
1987
+ ) {
1988
+ if (outboundFlights?.length && !returnObject.departDateTime) {
1989
+ const first = outboundFlights[0];
1990
+ const last = outboundFlights[outboundFlights.length - 1];
1991
+ returnObject.originAirport = first.originAirport;
1992
+ returnObject.originAirportName = first.originAirportName;
1993
+ returnObject.destinationAirport = last.destinationAirport;
1994
+ returnObject.destinationAirportName = last.destinationAirportName;
1995
+ returnObject.departDateTime = first.dateTimeDeparting;
1996
+ returnObject.arrivalDateTime = last.dateTimeArriving;
1997
+ returnObject.outboundTotalDuration = outboundTotalDuration;
1998
+ returnObject.dataSource = source;
1999
+ returnObject.operator = first.operatingCarrier;
2000
+ returnObject.operatorFull = first.operatingCarrierName;
2001
+ returnObject.outlegsCount = outboundFlights.length;
2002
+ returnObject.outlegs = outboundFlights;
2003
+ returnObject.outboundFlightNumber =
2004
+ this.helpers.joinFromAttribute<FlightJourney>(
2005
+ '-',
2006
+ 'operatingFlightNumber',
2007
+ outboundFlights
2008
+ );
2009
+
2010
+ returnObject.isReturn = false;
2011
+ }
2012
+
2013
+ if (inboundFlights?.length && !returnObject.inboundTotalDuration) {
2014
+ returnObject.inboundTotalDuration = inboundTotalDuration;
2015
+ returnObject.inlegsCount = inboundFlights.length;
2016
+ returnObject.inlegs = inboundFlights;
2017
+ returnObject.inboundFlightNumber =
2018
+ this.helpers.joinFromAttribute<FlightJourney>(
2019
+ '-',
2020
+ 'operatingFlightNumber',
2021
+ inboundFlights
2022
+ );
2023
+
2024
+ returnObject.isReturn = true;
2025
+ }
2026
+ }
2027
+
2028
+ protected makeSessionResults(
2029
+ data: EurostarQuoteResultArray
2030
+ ): EurostarSessionType {
2031
+ return {
2032
+ results: data,
2033
+ groupData: this.flightsToGroup,
2034
+ grouped: this.grouped,
2035
+ query: this.resultQuery
2036
+ };
2037
+ }
2038
+
2039
+ getMinFlightPriceForBrand(matchingBrandFlights: FlightItinerary[]): number {
2040
+ let min = Number.MAX_SAFE_INTEGER;
2041
+ matchingBrandFlights.forEach((flight) => {
2042
+ if (min > flight?.total?.price) {
2043
+ min = flight.total.price;
2044
+ }
2045
+ });
2046
+ return min;
2047
+ }
2048
+
2049
+ getMaxFlightPriceForBrand(matchingBrandFlights: FlightItinerary[]): number {
2050
+ let max = 0;
2051
+ matchingBrandFlights.forEach((flight) => {
2052
+ if (max < flight?.total?.price) {
2053
+ max = flight.total.price;
2054
+ }
2055
+ });
2056
+ return max;
2057
+ }
2058
+
2059
+ isOverNight(): boolean {
2060
+ const outwardDay = this.outBoundDate.date();
2061
+ const returnDay = this.inboundDate.date();
2062
+ if (returnDay - outwardDay >= 1) {
2063
+ return true;
2064
+ }
2065
+ return false;
2066
+ }
2067
+
2068
+ minToHour = (dur: number): string => `${Math.floor(dur / 60)}h ${dur % 60}m`;
2069
+
2070
+ async addEurostarJourneysToBasket(
2071
+ eurostarQuote: FlightItinerary
2072
+ ): Promise<boolean> {
2073
+ if (eurostarQuote.unavailable) {
2074
+ return Promise.resolve(false);
2075
+ }
2076
+ const intBasket: InternalBasketInterface =
2077
+ await this.basketService.getDefaultBasket();
2078
+ const basket = intBasket?.subject.value;
2079
+ if (basket) {
2080
+
2081
+ const { sourceId, co2PerItem, co2PerPassenger, total } = eurostarQuote;
2082
+ const outboundDate: any = moment(eurostarQuote.outboundFlights[0].dateTimeDeparting);
2083
+ const inboundDate: any = eurostarQuote.inboundFlights.length ? moment(eurostarQuote.inboundFlights[0].dateTimeDeparting) : null;
2084
+
2085
+ const schemaDetails = {
2086
+ outboundFlights: [
2087
+ ...eurostarQuote.outboundFlights.map(
2088
+ (flight: FlightJourney, segmentIndex: number) =>
2089
+ this.makeSchemaFlights(flight, 'outbound', 0, segmentIndex)
2090
+ )],
2091
+ inboundFlights: [
2092
+ ...eurostarQuote.inboundFlights.map(
2093
+ (flight: FlightJourney, segmentIndex: number) =>
2094
+ this.makeSchemaFlights(flight, 'inbound', 0, segmentIndex)
2095
+ )
2096
+ ],
2097
+ journeyType: 'single'
2098
+ }
2099
+ const booking: AddItemToBasketMutationVariables = {
2100
+ adults: this.adults,
2101
+ basket: intBasket.id,
2102
+ children: this.children,
2103
+ co2PerItem,
2104
+ co2PerPassenger,
2105
+ currency: total.currency as CurrencyCode,
2106
+ detail: schemaDetails,
2107
+ price: total.price,
2108
+ searchQuery: this.resultQuery,
2109
+ service: sourceId.toString(),
2110
+ outboundDate: outboundDate.format()
2111
+ };
2112
+ if (inboundDate) {
2113
+ booking.inboundDate = inboundDate.format();
2114
+ schemaDetails.journeyType = 'roundtrip';
2115
+ }
2116
+
2117
+ return this.basketService.addToBasket(
2118
+ booking,
2119
+ intBasket,
2120
+ this.searchService,
2121
+ this.travellers
2122
+ );
2123
+ }
2124
+ return Promise.resolve(false); // TODO should this throw an error?
2125
+ }
2126
+ }