@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,1380 @@
1
+ import moment, { Moment } from 'moment';
2
+ import { of, Observable, BehaviorSubject } from 'rxjs';
3
+ import { map, take, tap } from 'rxjs/operators';
4
+ import { BaseEnterpriseSearch } from './base-enterprise';
5
+ import { BaseStorageService } from '../services/storage.service';
6
+ import { BaseHelperRoutines } from './helpers';
7
+ import { RailTicketGroups } from '../interfaces/rail-ticket-groups.interface';
8
+ import {
9
+ RailResultIndifiers,
10
+ RailTicketGroup,
11
+ TicketGroups
12
+ } from '../interfaces/rail-ticket-group.interface';
13
+ import { RailDirection } from './rail-direction.enum';
14
+ import { ValueDisplay } from '../interfaces/value-display';
15
+ import {
16
+ NgbDateStruct,
17
+ IrlQuoteResultArray,
18
+ RecursivePartial,
19
+ RecentSearch
20
+ } from '../types/types';
21
+ import {
22
+ BasketItem,
23
+ CurrencyCode,
24
+ IrlClass,
25
+ IrlJourneyOption,
26
+ IrlJourneyOptions,
27
+ IrlProvider,
28
+ IrlTicketOption,
29
+ SearchIrlQueryVariables,
30
+ ServiceType,
31
+ IrlJourneyType, IrlSupplier
32
+ } from '../types/graphql.types';
33
+ import {
34
+ BaseIrlQuoteFetcher,
35
+ IrlQuoteFetcherType
36
+ } from '../fetchers/irl-quote-fetcher';
37
+ import {
38
+ BaseGetRailStationFetcher,
39
+ GetRailStationFetcherType
40
+ } from '../fetchers/get-rail-station.fetcher';
41
+ import {
42
+ EnterpriseBasketServiceInterface,
43
+ InternalBasketInterface
44
+ } from '../interfaces/Ienterprise-basket.service';
45
+ import { EnterpriseSearchServiceInterface } from '../interfaces/Isearch.service';
46
+ import {
47
+ IRLEnterpriseSearchInterface,
48
+ IrlTempParams
49
+ } from '../interfaces/Iirl-enterprise-search';
50
+ import { Traveller } from '../models/traveller.object';
51
+ import { ICheapestPrice } from '../interfaces/cheapest-price';
52
+
53
+ export enum IrlSearchCriteria {
54
+ Depart = 'Depart After',
55
+ Arrive = 'Arrive Before'
56
+ }
57
+
58
+ export class IRLEnterpriseSearch<
59
+ Q extends IrlQuoteFetcherType
60
+ // ,
61
+ // GRS_Q extends GetRailStationFetcherType
62
+ >
63
+ extends BaseEnterpriseSearch<
64
+ IrlTempParams,
65
+ IrlQuoteResultArray,
66
+ IrlQuoteResultArray
67
+ >
68
+ implements IRLEnterpriseSearchInterface
69
+ {
70
+ static readonly STORAGE_SESSION_PARAMS = 'search_irl';
71
+ static readonly STORAGE_SESSION_RESULTS = 'irl_results';
72
+ static readonly PASSING_POINT = 'Passing';
73
+ private travellers: Traveller[];
74
+
75
+ protected resultsSessionName = IRLEnterpriseSearch.STORAGE_SESSION_RESULTS;
76
+
77
+ public searchTypes = [
78
+ { display: 'Return', value: IrlJourneyType.ReturnJourney },
79
+ { display: 'One-Way', value: IrlJourneyType.SingleJourney }
80
+ // { display: 'Open Return', value: IrlJourneyType.OpenReturnJourney },
81
+ // { display: 'Dual Singles', value: IrlJourneyType.DualSingleJourney },
82
+ ];
83
+
84
+ public classTypes = [
85
+ { display: 'Any', value: IrlClass.All },
86
+ { display: 'Standard', value: IrlClass.Standard },
87
+ { display: 'First', value: IrlClass.First }
88
+ ];
89
+
90
+ public ageRanges = [{ key: 'child', value: 'Child (0-3)' }, { key: 'child', value: 'Child (4-5)' }, { key: 'child', value: 'Child (6-11)' }, { key: 'youth', value: 'Youth (12-14)' }, { key: 'youth', value: 'Youth (15-25)' }, { key: 'adult', value: 'Adult (26-59)' }, { key: 'senior', value: 'Senior (60+)'}];
91
+
92
+
93
+
94
+ public railCriteria = [IrlSearchCriteria.Depart, IrlSearchCriteria.Arrive];
95
+
96
+ public travelCards = [
97
+ { display: 'Young persons railcard', value: 'YNG' },
98
+ { display: 'Disability railcard', value: 'DIS' },
99
+ { display: 'Family railcard', value: 'FAM' },
100
+ { display: 'Forces railcard', value: 'HMF' },
101
+ { display: 'Travel agency discount', value: 'TAD' }
102
+ ];
103
+
104
+
105
+ public type: ServiceType = ServiceType.InternationalRail;
106
+ public minOutboundDate: NgbDateStruct = {
107
+ year: moment().year(),
108
+ month: moment().month() + 1,
109
+ day: moment().date()
110
+ };
111
+ public minInboundDate: NgbDateStruct = {
112
+ year: moment().year(),
113
+ month: moment().month() + 1,
114
+ day: moment().date()
115
+ };
116
+ private _timeArray: ValueDisplay[];
117
+ private _canCombine: any;
118
+ // private _chosenOutboundTicket: RecursivePartial<IrlTicketOption>;
119
+ // private _chosenInboundTicket: RecursivePartial<IrlTicketOption>;
120
+ // private _chosenOutboundJourney: RecursivePartial<IrlJourneyOption>;
121
+ // private _chosenInboundJourney: RecursivePartial<IrlJourneyOption>;
122
+ private _viaLocation: any;
123
+ private _travellingFrom: string;
124
+ private _travellingTo: string;
125
+ protected _originalUserSearch: IrlTempParams;
126
+
127
+ // get chosenTotalPrice(): number {
128
+ // if (this._chosenOutboundTicket) {
129
+ // if (this._chosenInboundTicket) {
130
+ // // now check if they are returns or dual
131
+ // if (
132
+ // this._chosenOutboundTicket.singleOrReturn === 'Return' &&
133
+ // this._chosenInboundTicket.singleOrReturn === 'Return'
134
+ // ) {
135
+ // // they should both have the same price
136
+ // return this._chosenOutboundTicket.price;
137
+ // }
138
+ // return (
139
+ // this._chosenOutboundTicket.price + this._chosenInboundTicket.price
140
+ // );
141
+ // }
142
+
143
+ // return this._chosenOutboundTicket.price;
144
+ // }
145
+
146
+ // return 0;
147
+ // }
148
+
149
+ // get chosenTickets(): any {
150
+ // return {
151
+ // Outbound: this._chosenOutboundTicket,
152
+ // Inbound: this._chosenInboundTicket
153
+ // };
154
+ // }
155
+
156
+ // get chosenOutboundJourney(): RecursivePartial<RailJourneyOption> {
157
+ // return this._chosenOutboundJourney;
158
+ // }
159
+
160
+ // get chosenInboundJourney(): RecursivePartial<RailJourneyOption> {
161
+ // return this._chosenInboundJourney;
162
+ // }
163
+
164
+ // get openReturn(): boolean {
165
+ // return this.tempParams.openReturn;
166
+ // }
167
+
168
+ // set openReturn(newVal: boolean) {
169
+ // this.tempParams.openReturn = newVal;
170
+
171
+ // if (newVal) {
172
+ // this.tempParams.chosenSearchType = IrlJourneyType.OpenReturnJourney;
173
+ // }
174
+ // this._isValid();
175
+ // }
176
+
177
+ // get chosenSearchType(): IrlJourneyType {
178
+ // return this.tempParams.chosenSearchType;
179
+ // }
180
+
181
+ // set chosenSearchType(newType: IrlJourneyType) {
182
+ // this.tempParams.chosenSearchType = newType;
183
+ // this._isValid();
184
+ // }
185
+
186
+ get noOfAdults(): number {
187
+ return this.tempParams.adults;
188
+ }
189
+
190
+ set noOfAdults(adults: number) {
191
+ this.tempParams.adults = adults;
192
+ this._isValid();
193
+ }
194
+
195
+ get noOfChildren(): number {
196
+ return this.tempParams.children;
197
+ }
198
+
199
+ set noOfChildren(children: number) {
200
+ this.tempParams.children = children;
201
+ this._isValid();
202
+ }
203
+
204
+ get travellingTo(): any {
205
+ return this.tempParams.arrivalLocationId;
206
+ }
207
+
208
+ set travellingTo(tt: any) {
209
+ this.tempParams.arrivalLocationId = tt;
210
+
211
+ this._travellingTo = '';
212
+ if (tt?.railstation?.id) {
213
+ this._travellingTo = tt.railstation.id;
214
+ }
215
+
216
+ this._isValid();
217
+ }
218
+
219
+ get travellingFrom(): any {
220
+ return this.tempParams.departureLocationId;
221
+ }
222
+
223
+ set travellingFrom(tt: any) {
224
+ this.tempParams.departureLocationId = tt;
225
+ this._travellingFrom = '';
226
+ if (tt?.railstation?.id) {
227
+ this._travellingFrom = tt.railstation.id;
228
+ }
229
+
230
+ this._isValid();
231
+ }
232
+
233
+ private _supplier: IrlSupplier = null
234
+ get supplier():IrlSupplier {
235
+ return this._supplier;
236
+ }
237
+ set supplier(data: IrlSupplier) {
238
+ this._supplier = data;
239
+ }
240
+
241
+ private _countryCode: string = null
242
+ get countryCode():string {
243
+ return this._countryCode;
244
+ }
245
+ set countryCode(data: string) {
246
+ this._countryCode = data;
247
+ }
248
+
249
+ private _class: IrlClass = null
250
+ get class():IrlClass {
251
+ return this._class;
252
+ }
253
+ set class(data: IrlClass) {
254
+ this._class = data;
255
+ }
256
+
257
+ private _outboundDepartureDateTime: Moment = null
258
+ get outboundDepartureDateTime():Moment {
259
+ return this._outboundDepartureDateTime;
260
+ }
261
+ set outboundDepartureDateTime(data: Moment) {
262
+ this._outboundDepartureDateTime = data;
263
+ }
264
+
265
+ private _departureLocationId: string = null
266
+ get departureLocationId():string {
267
+ return this._departureLocationId;
268
+ }
269
+ set departureLocationId(data: string) {
270
+ this._departureLocationId = data;
271
+ }
272
+
273
+ private _arrivalLocationId: string = null
274
+ get arrivalLocationId():string {
275
+ return this._arrivalLocationId;
276
+ }
277
+ set arrivalLocationId(data: string) {
278
+ this._arrivalLocationId = data;
279
+ }
280
+
281
+ private _adults: number = 0
282
+ get adults():number {
283
+ return this._adults;
284
+ }
285
+ set adults(data: number) {
286
+ this._adults = data;
287
+ }
288
+
289
+ private _children: number = 0
290
+ get children():number {
291
+ return this._children;
292
+ }
293
+ set children(data: number) {
294
+ this._children = data;
295
+ }
296
+
297
+ private _returnDepartureDateTime: Moment = null
298
+ get returnDepartureDateTime():Moment {
299
+ return this._returnDepartureDateTime;
300
+ }
301
+ set returnDepartureDateTime(data: Moment) {
302
+ this._returnDepartureDateTime = data;
303
+ }
304
+
305
+ private _ageRange: string = null
306
+ get ageRange():string {
307
+ return this._ageRange;
308
+ }
309
+ set ageRange(data: string) {
310
+ this._ageRange = data;
311
+ }
312
+
313
+
314
+
315
+
316
+ // get chosenRailClass(): RailClass {
317
+ // return this.tempParams.chosenSearchClass;
318
+ // }
319
+
320
+ get chosenSearchClass(): IrlClass {
321
+ return this.tempParams.class;
322
+ }
323
+
324
+ set chosenSearchClass(classR: IrlClass) {
325
+ this.tempParams.class = classR;
326
+ this._isValid();
327
+ }
328
+
329
+ get outBoundDateTime(): moment.Moment {
330
+ return this.tempParams.outboundDepartureDateTime;
331
+ }
332
+
333
+ set outBoundDateTime(newDateTime: moment.Moment) {
334
+ this.tempParams.outboundDepartureDateTime = moment(newDateTime);
335
+
336
+ this.minInboundDate = {
337
+ year: newDateTime.year(),
338
+ month: newDateTime.month() + 1,
339
+ day: newDateTime.date()
340
+ };
341
+
342
+ // if (
343
+ // this.outBoundDateTime &&
344
+ // // this.inBoundDateTime &&
345
+ // this.outBoundDateTime.isAfter(this.inBoundDateTime)
346
+ // ) {
347
+ // this.inBoundDateTime = this.outBoundDateTime.clone().add(1, 'day');
348
+ // }
349
+
350
+ this._isValid();
351
+ }
352
+
353
+ // get outboundCriteria(): IrlSearchCriteria {
354
+ // return this.tempParams.outboundCriteria;
355
+ // }
356
+
357
+ // set outboundCriteria(newCrit: IrlSearchCriteria) {
358
+ // // console.warn(`+++ Setting New Criteria: ${newCrit} +++`);
359
+ // this.tempParams.outboundCriteria = newCrit;
360
+
361
+ // this._isValid();
362
+ // }
363
+
364
+ // ! might not need this?
365
+ // get inBoundDateTime(): moment.Moment {
366
+ // return this.tempParams.inBoundDateTime;
367
+ // }
368
+
369
+ // set inBoundDateTime(newDateTime: moment.Moment) {
370
+ // this.tempParams.inBoundDateTime = moment(newDateTime);
371
+ // this._isValid();
372
+ // }
373
+
374
+ // !date and time is handled differently for LU
375
+ private _outbound_date: NgbDateStruct = null;
376
+
377
+ get outbound_date(): NgbDateStruct {
378
+ return this._outbound_date;
379
+ }
380
+
381
+ set outbound_date(value: NgbDateStruct) {
382
+ this._outbound_date = value;
383
+ this._updateOutboundDateTime();
384
+ }
385
+
386
+ private _outbound_time: string = null;
387
+ get outbound_time(): string {
388
+ return this._outbound_time;
389
+ }
390
+
391
+ set outbound_time(value: string) {
392
+ this._outbound_time = value;
393
+ this._updateOutboundDateTime();
394
+ }
395
+
396
+ private _return_date: NgbDateStruct = null;
397
+
398
+ get return_date(): NgbDateStruct {
399
+ return this._return_date;
400
+ }
401
+
402
+ set return_date(value: NgbDateStruct) {
403
+ this._return_date = value;
404
+ this._updateReturnDateTime();
405
+ }
406
+
407
+ private _return_time: string = null;
408
+ get return_time(): string {
409
+ return this._return_time;
410
+ }
411
+
412
+ set return_time(value: string) {
413
+ this._return_time = value;
414
+ this._updateReturnDateTime();
415
+ }
416
+
417
+ // get returnCriteria(): IrlSearchCriteria {
418
+ // return this.tempParams.returnCriteria;
419
+ // }
420
+
421
+ // set returnCriteria(newCrit: IrlSearchCriteria) {
422
+ // this.tempParams.returnCriteria = newCrit;
423
+ // this._isValid();
424
+ // }
425
+
426
+ // set railCards(newRailCards: string[]) {
427
+ // this.tempParams.railCards = newRailCards;
428
+ // this._isValid();
429
+ // }
430
+
431
+ // get carnetTicket(): boolean {
432
+ // return this.tempParams.carnetTicket;
433
+ // }
434
+
435
+ // set carnetTicket(newCarnet: boolean) {
436
+ // this.tempParams.carnetTicket = newCarnet;
437
+ // this._isValid();
438
+ // }
439
+
440
+ // get disableAutoDiscounts(): boolean {
441
+ // return this.tempParams.disableAutoDiscounts;
442
+ // }
443
+
444
+ // set disableAutoDiscounts(newDis: boolean) {
445
+ // this.tempParams.disableAutoDiscounts = newDis;
446
+ // this._isValid();
447
+ // }
448
+
449
+ // get prioritiseByPrice(): boolean {
450
+ // return this.tempParams.prioritiseByPrice;
451
+ // }
452
+
453
+ // set prioritiseByPrice(newPriority: boolean) {
454
+ // this.tempParams.prioritiseByPrice = newPriority;
455
+ // this._isValid();
456
+ // }
457
+
458
+
459
+ public get timeArray(): ValueDisplay[] {
460
+ this._timeArray =
461
+ this._timeArray ||
462
+ Array(48)
463
+ .fill(0)
464
+ .map((_, index: number) => {
465
+ return {
466
+ value:
467
+ Math.floor(index / 2)
468
+ .toString()
469
+ .padStart(2, '0') +
470
+ ((index % 2) * 30).toString().padStart(2, '0'),
471
+ display:
472
+ Math.floor(index / 2)
473
+ .toString()
474
+ .padStart(2, '0') +
475
+ ':' +
476
+ ((index % 2) * 30).toString().padStart(2, '0')
477
+ };
478
+ });
479
+ return this._timeArray;
480
+ }
481
+
482
+
483
+ private _cheapestStandard: IrlTicketOption = null;
484
+ get cheapestStandard(): IrlTicketOption {
485
+ return this._cheapestStandard;
486
+ }
487
+ private _cheapestFirst: IrlTicketOption = null;
488
+ get cheapestFirst(): IrlTicketOption {
489
+ return this._cheapestFirst;
490
+ }
491
+
492
+ private _irlClass: IrlClass = null;
493
+ get irlClass(): IrlClass {
494
+ return this._irlClass
495
+ }
496
+
497
+ set irlClass(data : IrlClass) {
498
+ this._irlClass = data;
499
+ }
500
+
501
+ private _journeytype: IrlJourneyType = null;
502
+ get journeyType(): IrlJourneyType {
503
+ return this._journeytype
504
+ }
505
+
506
+ set journeyType(data : IrlJourneyType) {
507
+ this._journeytype = data;
508
+ }
509
+
510
+ constructor(
511
+ private Irlfetcher: BaseIrlQuoteFetcher<Q>,
512
+ // private getRailStationFetcher: BaseGetRailStationFetcher<GRS_Q>, // doesnt exist yet
513
+ private helpers: BaseHelperRoutines,
514
+ private basketService: EnterpriseBasketServiceInterface,
515
+ storageService: BaseStorageService,
516
+ private searchService: EnterpriseSearchServiceInterface
517
+ ) {
518
+ super(storageService);
519
+
520
+ const data: {
521
+ query: {};
522
+ tempParams: IrlTempParams;
523
+ originalUserSearch: IrlTempParams;
524
+ } = storageService.getSessionItem(
525
+ IRLEnterpriseSearch.STORAGE_SESSION_PARAMS
526
+ ) || {
527
+ query: {},
528
+ tempParams: {} as IrlTempParams,
529
+ originalUserSearch: {} as IrlTempParams
530
+ };
531
+
532
+ this.updateTempParams(this.searchService.makeIrlQuery(data.tempParams));
533
+ this._originalUserSearch = data.originalUserSearch;
534
+
535
+ if (searchService.shouldAddTravellerSubscription()) {
536
+ searchService.travellerInformation.subscribe(
537
+ (travellers: Traveller[]) => {
538
+ this.travellers = travellers;
539
+ const splitTravellers = this.helpers.selectedTravellers(
540
+ travellers,
541
+ ServiceType.Rail
542
+ );
543
+ this.tempParams.adults = splitTravellers.adults.length;
544
+ this.tempParams.children = splitTravellers.children.length;
545
+ this.travellers = travellers;
546
+ this._isValid();
547
+ }
548
+ );
549
+ }
550
+ this._isValid();
551
+ const results =
552
+ storageService.getSessionItemAsList<IrlQuoteResultArray>(
553
+ this.resultsSessionName
554
+ ) || [];
555
+ // if (results == null && this.isValid) {
556
+ // searchService.startSearches();
557
+ // }
558
+ this._cheapestResultPrice = this.updateLowestPrice(results);
559
+ this.results.next(results || []);
560
+ }
561
+
562
+ protected resetQuery(): void {
563
+ this.updateTempParams(this.searchService.makeIrlQuery());
564
+ this._isValid();
565
+ }
566
+
567
+ private _isValid() {
568
+ this.storageService.setSessionItem(
569
+ IRLEnterpriseSearch.STORAGE_SESSION_PARAMS,
570
+ {
571
+ tempParams: this.tempParams,
572
+ originalUserSearch: this.originalUserSearch
573
+ }
574
+ );
575
+
576
+ this.validationMessages = [];
577
+
578
+ const now = moment();
579
+
580
+ if (!this._travellingFrom) {
581
+ this.validationMessages.push('Please Enter a From Location.');
582
+ }
583
+
584
+ if (!this._travellingTo) {
585
+ this.validationMessages.push('Please Enter a To Location.');
586
+ }
587
+
588
+ if (this.outBoundDateTime?.isBefore(now)) {
589
+ this.validationMessages.push(
590
+ 'Departure Date/Time cannot be in the past.'
591
+ );
592
+ }
593
+
594
+ // if (
595
+ // this.chosenSearchType === IrlJourneyType.ReturnJourney
596
+ // ) {
597
+ // // check for return specific validations in here
598
+
599
+ // if (this.inBoundDateTime?.isSameOrBefore(this.outBoundDateTime)) {
600
+ // this.validationMessages.push(
601
+ // 'Return Date/Time must be after Departure Date/Time'
602
+ // );
603
+ // }
604
+ // }
605
+
606
+ // if (this.via) {
607
+ // if (!this.tempParams.viaLocation) {
608
+ // this.validationMessages.push('Please enter a via location.');
609
+ // }
610
+ // }
611
+
612
+ if (this.tempParams.adults + this.tempParams.children < 1) {
613
+ this.validationMessages.push('There must be at least 1 traveller');
614
+ }
615
+
616
+ this.isValid.next(this.validationMessages.length === 0);
617
+ this.messages.next(this.validationMessages);
618
+ }
619
+
620
+ startSearch(): Promise<boolean> {
621
+ this.results.next([]);
622
+
623
+ if (this.isValid.value) {
624
+ this._originalUserSearch = Object.freeze({ ...this.tempParams });
625
+ this.storageService.setSessionItem(
626
+ IRLEnterpriseSearch.STORAGE_SESSION_PARAMS,
627
+ {
628
+ tempParams: this.tempParams,
629
+ originalUserSearch: this.originalUserSearch
630
+ }
631
+ );
632
+ return this._startSearch(
633
+ this.Irlfetcher.fetchList(this.getSearchQuery()).pipe(
634
+ map(result => result)
635
+ )
636
+ );
637
+ } else {
638
+ return Promise.resolve(false);
639
+ }
640
+ }
641
+
642
+ public startRecentSearch(recentSearch: RecentSearch): void {
643
+ this.startSearch();
644
+ }
645
+
646
+ private _updateOutboundDateTime(): void {
647
+ if (this._outbound_date && this._outbound_time) {
648
+ const time = this.helpers.ngDateToMoment(
649
+ this._outbound_date,
650
+ this._outbound_time
651
+ );
652
+ this.outBoundDateTime = time.isValid() ? time : null;
653
+ this._isValid();
654
+ }
655
+ }
656
+
657
+ private _updateReturnDateTime(): void {
658
+ if (this._return_date && this._return_time) {
659
+ const time = this.helpers.ngDateToMoment(
660
+ this._return_date,
661
+ this._return_time
662
+ );
663
+ // this.inBoundDateTime = time.isValid() ? time : null;
664
+ this._isValid();
665
+ }
666
+ }
667
+
668
+ getSearchQuery(): SearchIrlQueryVariables {
669
+ const query: SearchIrlQueryVariables = {
670
+ supplier: this.supplier, // IRLSupplier!
671
+ countryCode: 'GB',
672
+ // journeyType: this.journeyType, // IRLJourneyType!
673
+ class: this.irlClass, // IRLClass
674
+ outboundDepartureDateTime: this.tempParams.outboundDepartureDateTime,
675
+ departureLocationId: this._travellingFrom,
676
+ arrivalLocationId: this._travellingTo,
677
+ adults: this.tempParams.adults,
678
+ children: this.tempParams.children,
679
+ returnDepartureDateTime: this.tempParams.returnDepartureDateTime,
680
+
681
+ journeyType: this.tempParams.journeyType,
682
+ // class: this.tempParams.chosenSearchClass,
683
+ // extraTimeToChange: this.tempParams.extraTime,
684
+ // outboundArrivalDateTime: this.tempParams.outBoundDateTime,
685
+ // returnArrivalDateTime: this.tempParams.inBoundDateTime,
686
+ // viaLocationCode: this.tempParams.viaLocation
687
+ };
688
+
689
+ if (this.tempParams.children === 0) {
690
+ query.children = null;
691
+ }
692
+
693
+ // switch (this.tempParams.outboundCriteria) {
694
+ // case IrlSearchCriteria.Depart:
695
+ // query.outboundArrivalDateTime = null;
696
+ // break;
697
+ // case IrlSearchCriteria.Arrive:
698
+ // query.outboundDepartureDateTime = null;
699
+ // break;
700
+ // default:
701
+ // console.warn(
702
+ // `+++ Unknown Criteria: ${this.tempParams.outboundCriteria} +++`
703
+ // );
704
+ // }
705
+
706
+ // switch (this.tempParams.returnCriteria) {
707
+ // case IrlSearchCriteria.Depart:
708
+ // query.returnArrivalDateTime = null;
709
+ // break;
710
+ // case IrlSearchCriteria.Arrive:
711
+ // query.returnDepartureDateTime = null;
712
+ // break;
713
+ // default:
714
+ // console.warn(
715
+ // `+++ Unknown Criteria: ${this.tempParams.returnCriteria} +++`
716
+ // );
717
+ // }
718
+
719
+ switch (this.tempParams.journeyType) {
720
+ case IrlJourneyType.SingleJourney:
721
+ query.returnDepartureDateTime = null;
722
+ break;
723
+ }
724
+ return this.helpers.removeNulls<SearchIrlQueryVariables>(query);
725
+ }
726
+
727
+ // createTicketGroups(results: IRLJourneyOptions[]): RailTicketGroups {
728
+ // let tickets: RailTicketGroups = {};
729
+ // let ticketId = '';
730
+ // this._canCombine = {};
731
+
732
+ // let ticketGroupsOutbound = this.setTicketsGroups(results[0].outbound);
733
+ // let ticketGroupsReturn = this.setTicketsGroups(results[0].return);
734
+ // ticketGroupsOutbound = this.sortTicketPrices(ticketGroupsOutbound);
735
+ // ticketGroupsReturn = this.sortTicketPrices(ticketGroupsReturn);
736
+
737
+ // Object.keys(ticketGroupsOutbound).map((key) => {
738
+ // ticketGroupsOutbound[key].map((tkt: RailTicketOption) => {
739
+ // ticketId = `${tkt.type}${tkt.singleOrReturn}`;
740
+ // const identifier = tkt.identifiers.journeyIdentifier;
741
+ // const identifierObj: RailResultIndifiers = {};
742
+ // identifierObj[identifier] = {
743
+ // price: tkt.price,
744
+ // isChild: false,
745
+ // fareIdentifier: tkt.identifiers.fareIdentifier
746
+ // };
747
+ // if (tickets[key]) {
748
+ // this.updateCanCombine(tkt);
749
+ // identifierObj[tkt.identifiers.journeyIdentifier].isChild = false;
750
+ // if (tickets[tkt.type].header.price === tkt.price) {
751
+ // tickets[tkt.type].resultIndifiers.push(identifier);
752
+ // tickets[tkt.type].resultIndifiersPrices = {
753
+ // ...tickets[tkt.type].resultIndifiersPrices,
754
+ // ...identifierObj
755
+ // };
756
+ // } else if (tkt.price) {
757
+ // identifierObj[identifier].isChild = true;
758
+ // const childTicket = {
759
+ // header: tkt,
760
+ // children: [],
761
+ // open: false,
762
+ // direction: RailDirection.Outbound,
763
+ // resultIndifiers: [identifier],
764
+ // resultIndifiersPrices: identifierObj,
765
+ // child: true,
766
+ // ticketId,
767
+ // selectedIndicies: [],
768
+ // disabledIndicies: []
769
+ // } as RailTicketGroup;
770
+ // tickets[tkt.type].children.push(childTicket);
771
+ // }
772
+ // } else {
773
+ // this._canCombine[tkt.type] = {};
774
+ // this.updateCanCombine(tkt);
775
+ // tickets[tkt.type] = {
776
+ // header: tkt,
777
+ // children: [],
778
+ // open: false,
779
+ // direction: RailDirection.Outbound,
780
+ // resultIndifiers: [identifier],
781
+ // resultIndifiersPrices: identifierObj,
782
+ // child: false,
783
+ // ticketId,
784
+ // selectedIndicies: [],
785
+ // disabledIndicies: []
786
+ // } as RailTicketGroup;
787
+ // }
788
+ // });
789
+ // });
790
+
791
+ // Object.keys(ticketGroupsReturn).map((key) => {
792
+ // ticketGroupsReturn[key].map((tkt: RailTicketOption) => {
793
+ // ticketId = `${tkt.type}${tkt.singleOrReturn}`;
794
+ // const identifier = tkt.identifiers.journeyIdentifier;
795
+ // const identifierObj: RailResultIndifiers = {};
796
+ // identifierObj[identifier] = {
797
+ // price: tkt.price,
798
+ // isChild: true,
799
+ // fareIdentifier: tkt.identifiers.fareIdentifier
800
+ // };
801
+ // if (
802
+ // tickets[tkt.type] &&
803
+ // tkt.price &&
804
+ // tkt.price !== tickets[tkt.type].header.price
805
+ // ) {
806
+ // this.updateCanCombine(tkt);
807
+ // identifierObj[identifier].isChild = true;
808
+ // const childTicket = {
809
+ // header: tkt,
810
+ // children: [],
811
+ // open: false,
812
+ // direction: RailDirection.Inbound,
813
+ // resultIndifiers: [identifier],
814
+ // resultIndifiersPrices: identifierObj,
815
+ // child: true,
816
+ // ticketId,
817
+ // selectedIndicies: [],
818
+ // disabledIndicies: []
819
+ // } as any;
820
+ // tickets[tkt.type].children.push(childTicket);
821
+ // } else if (!tickets[tkt.type]) {
822
+ // this.updateCanCombine(tkt);
823
+ // tickets[tkt.type] = {
824
+ // header: tkt,
825
+ // children: [],
826
+ // open: false,
827
+ // direction: RailDirection.Inbound,
828
+ // resultIndifiers: [identifier],
829
+ // resultIndifiersPrices: identifierObj,
830
+ // child: false,
831
+ // ticketId,
832
+ // selectedIndicies: [],
833
+ // disabledIndicies: []
834
+ // } as any;
835
+ // } else if (!tkt.price || tkt.price === tickets[tkt.type].header.price) {
836
+ // this.updateCanCombine(tkt);
837
+ // tickets[tkt.type].resultIndifiers.push(identifier);
838
+ // identifierObj[identifier].isChild = false;
839
+ // tickets[tkt.type].resultIndifiersPrices = {
840
+ // ...tickets[tkt.type].resultIndifiersPrices,
841
+ // ...identifierObj
842
+ // };
843
+ // }
844
+ // });
845
+ // });
846
+
847
+ // let combineTickets = { ...tickets };
848
+ // tickets = this.combineChildTickets(combineTickets);
849
+
850
+ // // console.log('groups: ', tickets);
851
+ // // console.log('Can Combine: ', this._canCombine);
852
+ // return tickets;
853
+ // }
854
+
855
+ combineChildTickets(tickets: RailTicketGroups): RailTicketGroups {
856
+ const values = Object.values(tickets);
857
+ for (let i = 0; i < values.length; i++) {
858
+ const childObject: { [key: string]: RailTicketGroup } = {};
859
+
860
+ for (let j = 0; j < values[i].children.length; j++) {
861
+ const child = values[i].children[j];
862
+ const fareIdentifier = child.header.identifiers.fareIdentifier;
863
+ if (childObject[fareIdentifier]) {
864
+ childObject[fareIdentifier].resultIndifiers.push(
865
+ child.resultIndifiers[0]
866
+ );
867
+ childObject[fareIdentifier].resultIndifiersPrices = {
868
+ ...childObject[fareIdentifier].resultIndifiersPrices,
869
+ ...child.resultIndifiersPrices
870
+ };
871
+ } else {
872
+ childObject[fareIdentifier] = child;
873
+ }
874
+ }
875
+ // console.log(childObject);
876
+ // console.log(values[i]['header']['type']);
877
+ tickets[values[i].header.type].children = Object.values(childObject);
878
+ }
879
+ // tickets = this.sortTicketChildrenPrices(tickets);
880
+ return tickets;
881
+ }
882
+ setTicketsGroups(results: IrlJourneyOption[]): any {
883
+ let ticketGroups: any = {};
884
+ results.forEach((out: IrlJourneyOption) => {
885
+ out.providers.forEach((prov: IrlProvider) => {
886
+ prov.ticketOptions.forEach((tkt: IrlTicketOption) => {
887
+ ticketGroups[tkt.type]
888
+ ? ticketGroups[tkt.type].push(tkt)
889
+ : (ticketGroups[tkt.type] = [tkt]);
890
+ });
891
+ });
892
+ });
893
+ return ticketGroups;
894
+ }
895
+
896
+ updateFromPreviousSearches(
897
+ previousItems: Record<ServiceType, BasketItem>
898
+ ): void {}
899
+
900
+ updateCanCombine(tkt: IrlTicketOption): void {
901
+ (tkt.identifiers.allowedWith || []).forEach((allowed) => {
902
+ if (!this._canCombine[tkt.type][allowed.journeyIdentifier]) {
903
+ this._canCombine[tkt.type][allowed.journeyIdentifier] = [
904
+ allowed.fareIdentifier
905
+ ];
906
+ } else {
907
+ this._canCombine[tkt.type][allowed.journeyIdentifier].push(
908
+ allowed.fareIdentifier
909
+ );
910
+ }
911
+ });
912
+ }
913
+
914
+ // toggleTicketSelect(
915
+ // ticket: IrlTicketGroup,
916
+ // way: 'departs' | 'returns',
917
+ // timeSlotId: string,
918
+ // ticketId: string,
919
+ // fareIdentifier: string,
920
+ // ticketsGroups: IrlTicketGroups
921
+ // ): IrlTicketGroups {
922
+ // if (!ticket) {
923
+ // return;
924
+ // }
925
+ // const keys = Object.keys(ticketsGroups);
926
+ // let selectedTicket = null;
927
+ // let departsTicket: IrlTicketOption[] = [];
928
+ // let returnTicket: IrlTicketOption[] = [];
929
+ // let isUnselected = false;
930
+ // keys.forEach((key) => {
931
+ // let group = ticketsGroups[key] as RailTicketGroup;
932
+
933
+ // if (
934
+ // group.ticketId === ticketId &&
935
+ // group.selectedIndicies.includes(timeSlotId)
936
+ // ) {
937
+ // if (way === 'departs') {
938
+ // group.selectedIndicies = [];
939
+ // departsTicket = [];
940
+ // returnTicket = [];
941
+ // this._chosenInboundTicket = null;
942
+ // this._chosenInboundJourney = null;
943
+ // group.children.forEach((child) => {
944
+ // child.selectedIndicies = [];
945
+ // });
946
+ // } else {
947
+ // group.selectedIndicies = group.selectedIndicies.filter(
948
+ // (Indicies) => Indicies !== timeSlotId
949
+ // );
950
+ // returnTicket = returnTicket.filter(
951
+ // (Indicies) => Indicies !== group.header
952
+ // );
953
+ // }
954
+ // } else {
955
+ // if (
956
+ // group.ticketId === ticketId &&
957
+ // group.header.identifiers.fareIdentifier === fareIdentifier &&
958
+ // way === 'departs'
959
+ // ) {
960
+ // group = this.clearUnneededTickets(way, group, timeSlotId);
961
+ // group.selectedIndicies.push(timeSlotId);
962
+ // way === 'departs'
963
+ // ? departsTicket.push(group.header)
964
+ // : returnTicket.push(group.header);
965
+ // selectedTicket = group.header;
966
+ // } else {
967
+ // // may have to modify this for dual singles
968
+ // if (way === 'departs') {
969
+ // group.selectedIndicies = [];
970
+ // } else {
971
+ // selectedTicket = group.header;
972
+ // }
973
+ // }
974
+
975
+ // group.children.forEach((child) => {
976
+ // if (child.selectedIndicies.includes(timeSlotId)) {
977
+ // if (way === 'departs') {
978
+ // child.selectedIndicies = [];
979
+ // departsTicket = [];
980
+ // returnTicket = [];
981
+ // this._chosenInboundTicket = null;
982
+ // this._chosenInboundJourney = null;
983
+ // isUnselected = true;
984
+ // } else {
985
+ // child.selectedIndicies = child.selectedIndicies.filter(
986
+ // (Indicies) => Indicies !== timeSlotId
987
+ // );
988
+ // returnTicket = returnTicket.filter(
989
+ // (Indicies) => Indicies !== group.header
990
+ // );
991
+ // }
992
+ // } else {
993
+ // if (
994
+ // child.ticketId === ticketId &&
995
+ // child.header.identifiers.fareIdentifier === fareIdentifier
996
+ // ) {
997
+ // if (
998
+ // (way === 'departs' &&
999
+ // child.direction !== RailDirection.Inbound) ||
1000
+ // (way !== 'departs' && child.direction === RailDirection.Inbound)
1001
+ // ) {
1002
+ // child = this.clearUnneededTickets(way, child, timeSlotId);
1003
+ // child.selectedIndicies.push(timeSlotId);
1004
+ // way === 'departs'
1005
+ // ? departsTicket.push(child.header)
1006
+ // : returnTicket.push(child.header);
1007
+ // selectedTicket = child.header;
1008
+ // } else if (isUnselected) {
1009
+ // child.selectedIndicies = [];
1010
+ // }
1011
+ // } else {
1012
+ // child.selectedIndicies = [];
1013
+ // }
1014
+ // }
1015
+ // });
1016
+ // }
1017
+ // });
1018
+
1019
+ // // now we need to mark tickets as disabled if they are returns that do not match the selected return
1020
+ // // or on overlapping times
1021
+ // if (way === 'departs') {
1022
+ // this._chosenOutboundTicket = this.helpers.clone(selectedTicket);
1023
+
1024
+ // // now go over the full results and find the matching timeslot
1025
+ // departsTicket.length
1026
+ // ? (this._chosenOutboundJourney = this.results.value[0].outbound.find(
1027
+ // (out: RailJourneyOption) => {
1028
+ // return out.identifiers.journeyIdentifier === timeSlotId;
1029
+ // }
1030
+ // ))
1031
+ // : (this._chosenOutboundJourney = null);
1032
+
1033
+ // if (
1034
+ // this._chosenInboundTicket &&
1035
+ // this._chosenOutboundTicket.singleOrReturn === 'Return' &&
1036
+ // this._chosenOutboundTicket.identifiers.fareIdentifier !==
1037
+ // this._chosenInboundTicket.identifiers.fareIdentifier
1038
+ // ) {
1039
+ // console.warn('+++ Cannot combine fares, clearing inbound... +++');
1040
+ // this._chosenInboundTicket = null;
1041
+ // this._chosenInboundJourney = null;
1042
+ // }
1043
+ // } else if (way === 'returns') {
1044
+ // this._chosenInboundTicket = this.helpers.clone(selectedTicket);
1045
+
1046
+ // this._chosenInboundTicket
1047
+ // ? (this._chosenInboundJourney = this.results.value[0].return.find(
1048
+ // (inT: RailJourneyOption) => {
1049
+ // return inT.identifiers.journeyIdentifier === timeSlotId;
1050
+ // }
1051
+ // ))
1052
+ // : (this._chosenInboundJourney = null);
1053
+ // }
1054
+
1055
+ // console.log(this.chosenOutboundJourney);
1056
+ // console.log(this._chosenInboundJourney);
1057
+ // return ticketsGroups;
1058
+ // }
1059
+
1060
+ /**
1061
+ * @description - determine if a fare can be combined with what we currently have selected
1062
+ */
1063
+ // canCombine(journeyIdentifier: string, fareIdentifier: string): boolean {
1064
+ // // may have to modify this for dual singles later on
1065
+ // if (
1066
+ // this._chosenOutboundTicket &&
1067
+ // this._chosenOutboundTicket.singleOrReturn === 'Return' &&
1068
+ // Number(journeyIdentifier) > 5
1069
+ // ) {
1070
+ // // greater than 5 only as we are not going to restrict outbounds
1071
+ // if (
1072
+ // this._canCombine[this._chosenOutboundTicket.type][
1073
+ // Number(journeyIdentifier)
1074
+ // ]?.includes(fareIdentifier) &&
1075
+ // this._chosenOutboundTicket.identifiers.fareIdentifier === fareIdentifier
1076
+ // ) {
1077
+ // return true;
1078
+ // }
1079
+ // return false;
1080
+ // }
1081
+
1082
+ // return false;
1083
+ // }
1084
+
1085
+ clearUnneededTickets(
1086
+ way: string,
1087
+ group: RailTicketGroup,
1088
+ timeSlotId: string
1089
+ ): RailTicketGroup {
1090
+ if (way === 'returns') {
1091
+ group.selectedIndicies = group.selectedIndicies.filter(
1092
+ (indicie: string) => {
1093
+ return Number(indicie) <= 5 || indicie === timeSlotId;
1094
+ }
1095
+ );
1096
+ } else {
1097
+ group.selectedIndicies = group.selectedIndicies.filter(
1098
+ (indicie: string) => {
1099
+ return Number(indicie) > 5 || indicie === timeSlotId;
1100
+ }
1101
+ );
1102
+ }
1103
+
1104
+ return group;
1105
+ }
1106
+
1107
+ // getRailStation(
1108
+ // code: string,
1109
+ // isLoading: BehaviorSubject<boolean>
1110
+ // ): Observable<IrlStation> {
1111
+ // if (code.length === 3) {
1112
+ // isLoading?.next(true);
1113
+ // return this.getRailStationFetcher.fetchList({ code }).pipe(
1114
+ // tap(() => isLoading?.next(false)),
1115
+ // take(1)
1116
+ // );
1117
+ // } else {
1118
+ // return of();
1119
+ // }
1120
+ // }
1121
+
1122
+ // getSelectedirlTicketOption(
1123
+ // irlJourneyOption: IrlJourneyOption,
1124
+ // irlTicketGroup: IrlTicketGroup,
1125
+ // providerIndex: number
1126
+ // ): IrlTicketOption {
1127
+ // return irlJourneyOption.providers[providerIndex].ticketOptions.find(
1128
+ // (ticketOption) =>
1129
+ // ticketOption.type === irlTicketGroup.header.type &&
1130
+ // ticketOption.price === irlTicketGroup.header.price
1131
+ // );
1132
+ // }
1133
+
1134
+ getLegsFromRailJourneyOption(railJourneyOption: IrlJourneyOption): any[] {
1135
+ let legs: any[] = [];
1136
+ if (railJourneyOption?.segments.length) {
1137
+ legs = railJourneyOption.segments.map((segment) => {
1138
+ return {
1139
+ operator: segment.operator,
1140
+ departureDateTime: segment.departDateTime,
1141
+ departureStationName: segment.depart,
1142
+ arrivalDateTime: segment.arriveDateTime,
1143
+ arrivalStationName: segment.arrive
1144
+ };
1145
+ });
1146
+ }
1147
+ return legs;
1148
+ }
1149
+
1150
+ // async addSingleJourneyToBasket(
1151
+ // serviceId: string,
1152
+ // railQuery: SearchRailQueryVariables,
1153
+ // railJourneyOption: RailJourneyOption,
1154
+ // railTicketGroup: RailTicketGroup
1155
+ // ): Promise<boolean> {
1156
+ // if (railJourneyOption.unsellable) {
1157
+ // return Promise.resolve(false);
1158
+ // }
1159
+ // const intBasket: InternalBasketInterface =
1160
+ // await this.basketService.getDefaultBasket();
1161
+ // const basket = intBasket?.subject.value;
1162
+ // if (basket) {
1163
+ // const selectedRailTicketOption = this.getSelectedRailTicketOption(
1164
+ // railJourneyOption,
1165
+ // railTicketGroup,
1166
+ // 0
1167
+ // );
1168
+ // const legs = this.getLegsFromRailJourneyOption(railJourneyOption);
1169
+ // const ticketQueueList = selectedRailTicketOption.ticketQueueList.map(
1170
+ // (ticketQueueList) => {
1171
+ // return {
1172
+ // id: ticketQueueList.id,
1173
+ // name: ticketQueueList.name,
1174
+ // type: ticketQueueList.type
1175
+ // };
1176
+ // }
1177
+ // );
1178
+
1179
+ // return this.basketService.addToBasket(
1180
+ // {
1181
+ // basket: basket.id,
1182
+ // service: serviceId,
1183
+ // detail: {
1184
+ // outwardDetail: {
1185
+ // arrivalDateTime: railJourneyOption.arriveDateTime,
1186
+ // arrivalStationName: railJourneyOption.to,
1187
+ // departureDateTime: railJourneyOption.departDateTime,
1188
+ // departureStationName: railJourneyOption.from,
1189
+ // supplierTickets: [
1190
+ // {
1191
+ // supplierName: railJourneyOption.providers[0].name,
1192
+ // ticketDescription: selectedRailTicketOption.type,
1193
+ // price: selectedRailTicketOption.price,
1194
+ // legs
1195
+ // }
1196
+ // ]
1197
+ // },
1198
+ // transactionIdentifier:
1199
+ // railJourneyOption.identifiers.transactionIdentifier,
1200
+ // outbound: {
1201
+ // fareIdentifiers: [
1202
+ // selectedRailTicketOption.identifiers.fareIdentifier
1203
+ // ],
1204
+ // journeyIdentifier:
1205
+ // selectedRailTicketOption.identifiers.journeyIdentifier
1206
+ // },
1207
+ // ticketQueueList
1208
+ // },
1209
+ // adults: railQuery.adults,
1210
+ // price: selectedRailTicketOption.price,
1211
+ // currency: selectedRailTicketOption.currency as CurrencyCode,
1212
+ // searchQuery: railQuery,
1213
+ // co2PerItem: railJourneyOption.co2PerItem,
1214
+ // co2PerPassenger: railJourneyOption.co2PerPassenger
1215
+ // },
1216
+ // intBasket,
1217
+ // this.searchService,
1218
+ // this.travellers
1219
+ // );
1220
+ // }
1221
+ // return Promise.resolve(false);
1222
+ // }
1223
+
1224
+ // async addReturnJourneyToBasket(
1225
+ // serviceId: string,
1226
+ // railQuery: SearchRailQueryVariables,
1227
+ // outbound: RailJourneyOption,
1228
+ // inbound: RailJourneyOption,
1229
+ // railTicketGroup: RailTicketGroup
1230
+ // ): Promise<boolean> {
1231
+ // if (outbound.unsellable) {
1232
+ // return Promise.resolve(false);
1233
+ // }
1234
+ // const intBasket: InternalBasketInterface =
1235
+ // await this.basketService.getDefaultBasket();
1236
+ // const basket = intBasket?.subject.value;
1237
+ // if (basket) {
1238
+ // const selectedRailTicketOption = this.getSelectedRailTicketOption(
1239
+ // outbound,
1240
+ // railTicketGroup,
1241
+ // 0
1242
+ // );
1243
+ // const outboundLegs = this.getLegsFromRailJourneyOption(outbound);
1244
+ // const inboundLegs = this.getLegsFromRailJourneyOption(inbound);
1245
+ // const ticketQueueList = selectedRailTicketOption.ticketQueueList.map(
1246
+ // (ticketQueueList1: RailTicketQueue) => {
1247
+ // return {
1248
+ // id: ticketQueueList1.id,
1249
+ // name: ticketQueueList1.name,
1250
+ // type: ticketQueueList1.type
1251
+ // };
1252
+ // }
1253
+ // );
1254
+
1255
+ // return this.basketService.addToBasket(
1256
+ // {
1257
+ // basket: basket.id,
1258
+ // service: serviceId,
1259
+ // detail: {
1260
+ // outwardDetail: {
1261
+ // arrivalDateTime: outbound.arriveDateTime,
1262
+ // arrivalStationName: outbound.to,
1263
+ // departureDateTime: outbound.departDateTime,
1264
+ // departureStationName: outbound.from,
1265
+ // supplierTickets: [
1266
+ // {
1267
+ // supplierName: outbound.providers[0].name,
1268
+ // ticketDescription: selectedRailTicketOption.type,
1269
+ // price: selectedRailTicketOption.price,
1270
+ // legs: outboundLegs
1271
+ // }
1272
+ // ]
1273
+ // },
1274
+ // inwardDetail: {
1275
+ // arrivalDateTime: inbound.arriveDateTime,
1276
+ // arrivalStationName: inbound.to,
1277
+ // departureDateTime: inbound.departDateTime,
1278
+ // departureStationName: inbound.from,
1279
+ // supplierTickets: [
1280
+ // {
1281
+ // supplierName: inbound.providers[0].name,
1282
+ // ticketDescription: selectedRailTicketOption.type,
1283
+ // legs: inboundLegs
1284
+ // }
1285
+ // ]
1286
+ // },
1287
+ // transactionIdentifier: outbound.identifiers.transactionIdentifier,
1288
+ // outbound: {
1289
+ // fareIdentifiers: [
1290
+ // selectedRailTicketOption.identifiers.fareIdentifier
1291
+ // ],
1292
+ // journeyIdentifier:
1293
+ // selectedRailTicketOption.identifiers.journeyIdentifier
1294
+ // },
1295
+ // ticketQueueList
1296
+ // },
1297
+ // adults: railQuery.adults,
1298
+ // price: railTicketGroup.header.price,
1299
+ // currency: selectedRailTicketOption.currency as CurrencyCode,
1300
+ // searchQuery: railQuery,
1301
+ // co2PerItem: outbound.co2PerItem,
1302
+ // co2PerPassenger: outbound.co2PerPassenger
1303
+ // },
1304
+ // intBasket,
1305
+ // this.searchService,
1306
+ // this.travellers
1307
+ // );
1308
+ // }
1309
+ // return Promise.resolve(false);
1310
+ // }
1311
+
1312
+ // sortTicketPrices(tickets: TicketGroups): TicketGroups {
1313
+ // const sortTicketPrices = { ...tickets };
1314
+ // Object.keys(sortTicketPrices).map((key) => {
1315
+ // sortTicketPrices[key].sort((a: IrlTicketOption, b: IrlTicketOption) => {
1316
+ // const priceA = a.price,
1317
+ // priceB = b.price;
1318
+ // return priceA < priceB ? -1 : priceA > priceB ? 1 : 0;
1319
+ // });
1320
+ // });
1321
+ // return sortTicketPrices;
1322
+ // // }
1323
+ // sortTicketChildrenPrices(tickets: RailTicketGroups): RailTicketGroups {
1324
+ // const sortTicketPrices = { ...tickets };
1325
+ // Object.keys(sortTicketPrices).map((key) => {
1326
+ // sortTicketPrices[key].children.sort(
1327
+ // (a: RailTicketGroup, b: RailTicketGroup) => {
1328
+ // const priceA = a.header.price,
1329
+ // priceB = b.header.price;
1330
+ // return priceA < priceB ? -1 : priceA > priceB ? 1 : 0;
1331
+ // }
1332
+ // );
1333
+ // });
1334
+ // return sortTicketPrices;
1335
+ // }
1336
+ updateLowestPrice(results: IrlJourneyOptions[]): ICheapestPrice {
1337
+ if (!results.length) return null;
1338
+ const currency =
1339
+ results[0].outbound[0].providers[0].cheapestTicket.currency;
1340
+ const price = this.findCheapestTicket(results);
1341
+ return {
1342
+ amount: price,
1343
+ currencyCode: currency
1344
+ };
1345
+ }
1346
+ findCheapestTicket(results: IrlJourneyOptions[]): number {
1347
+ this._cheapestFirst = null;
1348
+ this._cheapestStandard = null;
1349
+ if (!results.length) return null;
1350
+ let cheapestArr: number[] = [];
1351
+
1352
+ results.map((result) => {
1353
+ result.outbound.map((out) => {
1354
+ out.providers.map((tkt) => {
1355
+ let cheapestTicket: number = tkt.cheapestTicket.price;
1356
+ tkt.ticketOptions.map((tktOption) => {
1357
+ let tktPrice = tktOption.price;
1358
+ let tktClass = tktOption.class;
1359
+ if (
1360
+ tktClass === 'First' &&
1361
+ (this._cheapestFirst?.price > tktPrice || !this._cheapestFirst)
1362
+ ) {
1363
+ this._cheapestFirst = tktOption;
1364
+ } else if (
1365
+ tktClass === 'Standard' &&
1366
+ (this._cheapestStandard?.price > tktPrice ||
1367
+ !this._cheapestStandard)
1368
+ ) {
1369
+ this._cheapestStandard = tktOption;
1370
+ }
1371
+ if (tktPrice === cheapestTicket) {
1372
+ cheapestArr.push(cheapestTicket);
1373
+ }
1374
+ });
1375
+ });
1376
+ });
1377
+ });
1378
+ return Math.min(...cheapestArr);
1379
+ }
1380
+ }