-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
1625 lines (1341 loc) · 61.3 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import flask
from flask import request, jsonify
import requests
import json
import time
from typing import Any, Optional, List, Union, TypeVar, Type, cast, Callable
from enum import Enum
from datetime import datetime, timedelta
import dateutil.parser
import base64
import CreatePNRModel as CreatePNRModel
import HotelRateModel as HotelRateModel
import HotelPriceCheckModel as HotelPriceCheckModel
import CommonHelper as CommonHelper
app = flask.Flask(__name__)
app.config["DEBUG"] = True
PCC_Code = '5HYH'
Authenticate_Endpoint = "https://api-crt.cert.havail.sabre.com/v2/auth/token"
BFM_Endpoint = "https://api-crt.cert.havail.sabre.com/v1/offers/shop"
PNR_Endpoint = "https://api-crt.cert.havail.sabre.com/v2.3.0/passenger/records?mode=create"
HotelRateInfo_Endpoint = "https://api-crt.cert.havail.sabre.com/v3.0.0/get/hotelrateinfo"
HotelPriceCheck_Endpoint = "https://api-crt.cert.havail.sabre.com/v2.1.0/hotel/pricecheck"
HotelAvailability_Endpoint = "https://api-crt.cert.havail.sabre.com/v3.0.0/get/hotelavail"
HotelDetail_Endpoint = "https://api-crt.cert.havail.sabre.com/v2.0.0/get/hoteldetails"
API_KEY = ''
AuthorizationHeader = {}
T = TypeVar("T")
EnumT = TypeVar("EnumT", bound=Enum)
def from_int(x: Any) -> int:
return x
def from_bool(x: Any) -> bool:
assert isinstance(x, bool)
return x
def from_none(x: Any) -> Any:
assert x is None
return x
def from_union(fs, x):
for f in fs:
try:
return f(x)
except:
pass
assert False
def to_class(c: Type[T], x: Any) -> dict:
assert isinstance(x, c)
return cast(Any, x).to_dict()
def from_str(x: Any) -> str:
assert isinstance(x, str)
return x
def from_datetime(x: Any) -> datetime:
return dateutil.parser.parse(x)
def from_list(f: Callable[[Any], T], x: Any) -> List[T]:
assert isinstance(x, list)
return [f(y) for y in x]
def to_enum(c: Type[EnumT], x: Any) -> EnumT:
assert isinstance(x, c)
return x.value
def from_float(x: Any) -> float:
assert isinstance(x, (float, int)) and not isinstance(x, bool)
return float(x)
def to_float(x: Any) -> float:
assert isinstance(x, float)
return x
def is_type(t: Type[T], x: Any) -> T:
assert isinstance(x, t)
return x
class BaggageAllowanceDesc:
id: int
pieceCount: int
def __init__(self, id: int, pieceCount: int) -> None:
self.id = id
self.pieceCount = pieceCount
@staticmethod
def from_dict(obj: Any) -> 'BaggageAllowanceDesc':
assert isinstance(obj, dict)
id = from_int(obj.get("id"))
pieceCount = from_int(obj.get("pieceCount"))
return BaggageAllowanceDesc(id, pieceCount)
def to_dict(self) -> dict:
result: dict = {}
result["id"] = from_int(self.id)
result["pieceCount"] = from_int(self.pieceCount)
return result
# class Direction(Enum):
# WH = "WH"
# class Directionality(Enum):
# FROM = "FROM"
# class FareCurrency(Enum):
# USD = "USD"
class PassengerType(Enum):
ADT = "ADT"
# class FareType(Enum):
# END = "END"
# EOU = "EOU"
# SIP = "SIP"
# class GoverningCarrier(Enum):
# AA = "AA"
# AS = "AS"
# B6 = "B6"
# DL = "DL"
# UA = "UA"
class PurpleSegment:
stopover: Optional[bool]
def __init__(self, stopover: Optional[bool]) -> None:
self.stopover = stopover
@staticmethod
def from_dict(obj: Any) -> 'PurpleSegment':
# assert isinstance(obj, dict)
stopover = from_union([from_bool, from_none], obj.get("stopover"))
return PurpleSegment(stopover)
def to_dict(self) -> dict:
result: dict = {}
result["stopover"] = from_union([from_bool, from_none], self.stopover)
return result
class FareComponentDescSegment:
segment: PurpleSegment
def __init__(self, segment: PurpleSegment) -> None:
self.segment = segment
@staticmethod
def from_dict(obj: Any) -> 'FareComponentDescSegment':
assert isinstance(obj, dict)
segment = PurpleSegment.from_dict(obj.get("segment"))
return FareComponentDescSegment(segment)
def to_dict(self) -> dict:
result: dict = {}
result["segment"] = to_class(PurpleSegment, self.segment)
return result
class VendorCode(Enum):
ATP = "ATP"
class FareComponentDesc:
applicablePricingCategories: str
direction: str
directionality: str
fareAmount: int
fareBasisCode: str
fareCurrency: str
farePassengerType: PassengerType
fareRule: str
fareTariff: int
fareType: str
fareTypeBitmap: str
governingCarrier: str
id: int
notValidAfter: datetime
oneWayFare: bool
publishedFareAmount: int
segments: List[FareComponentDescSegment]
vendorCode: VendorCode
notValidBefore: Optional[datetime]
def __init__(self, applicablePricingCategories: str, direction: str, directionality: str,
fareAmount: int, fareBasisCode: str, fareCurrency: str, farePassengerType: PassengerType,
fareRule: str, fareTariff: int, fareType: str, fareTypeBitmap: str,
governingCarrier: str, id: int, notValidAfter: datetime, oneWayFare: bool,
publishedFareAmount: int, segments: List[FareComponentDescSegment], vendorCode: VendorCode,
notValidBefore: Optional[datetime]) -> None:
self.applicablePricingCategories = applicablePricingCategories
self.direction = direction
self.directionality = directionality
self.fareAmount = fareAmount
self.fareBasisCode = fareBasisCode
self.fareCurrency = fareCurrency
self.farePassengerType = farePassengerType
self.fareRule = fareRule
self.fareTariff = fareTariff
self.fareType = fareType
self.fareTypeBitmap = fareTypeBitmap
self.governingCarrier = governingCarrier
self.id = id
self.notValidAfter = notValidAfter
self.oneWayFare = oneWayFare
self.publishedFareAmount = publishedFareAmount
self.segments = segments
self.vendorCode = vendorCode
self.notValidBefore = notValidBefore
@staticmethod
def from_dict(obj: Any) -> 'FareComponentDesc':
assert isinstance(obj, dict)
applicablePricingCategories = from_str(obj.get("applicablePricingCategories"))
direction = obj.get("direction")
directionality = obj.get("directionality")
fareAmount = obj.get("fareAmount")
fareBasisCode = from_str(obj.get("fareBasisCode"))
fareCurrency = (obj.get("fareCurrency"))
farePassengerType = PassengerType(obj.get("farePassengerType"))
fareRule = from_str(obj.get("fareRule"))
fareTariff = int(from_str(obj.get("fareTariff")))
fareType = obj.get("fareType")
fareTypeBitmap = from_str(obj.get("fareTypeBitmap"))
governingCarrier = obj.get("governingCarrier")
id = from_int(obj.get("id"))
notValidAfter = obj.get("notValidAfter")
oneWayFare = obj.get("oneWayFare")
publishedFareAmount = obj.get("publishedFareAmount")
segments = obj.get("segments")
vendorCode = VendorCode(obj.get("vendorCode"))
notValidBefore = obj.get("notValidBefore")
return FareComponentDesc(applicablePricingCategories, direction, directionality, fareAmount, fareBasisCode,
fareCurrency, farePassengerType, fareRule, fareTariff, fareType, fareTypeBitmap,
governingCarrier, id, notValidAfter, oneWayFare, publishedFareAmount, segments,
vendorCode, notValidBefore)
def to_dict(self) -> dict:
result: dict = {}
result["applicablePricingCategories"] = from_str(self.applicablePricingCategories)
result["direction"] = self.direction
result["directionality"] = self.directionality
result["fareAmount"] = self.fareAmount
result["fareBasisCode"] = from_str(self.fareBasisCode)
result["fareCurrency"] = self.fareCurrency
result["farePassengerType"] = to_enum(PassengerType, self.farePassengerType)
result["fareRule"] = from_str(self.fareRule)
result["fareTariff"] = from_str(str(self.fareTariff))
result["fareType"] = self.fareType
result["fareTypeBitmap"] = from_str(self.fareTypeBitmap)
result["governingCarrier"] = self.governingCarrier
result["id"] = from_int(self.id)
result["notValidAfter"] = self.notValidAfter
result["oneWayFare"] = self.oneWayFare
result["publishedFareAmount"] = self.publishedFareAmount
result["segments"] = self.segments
result["vendorCode"] = to_enum(VendorCode, self.vendorCode)
result["notValidBefore"] = self.notValidBefore
return result
# class Station(Enum):
# DTW = "DTW"
# EWR = "EWR"
# JFK = "JFK"
# PHX = "PHX"
# SFO = "SFO"
# LGA = "LGA"
class LegDescription:
arrivalLocation: str
departureDate: datetime
departureLocation: str
def __init__(self, arrivalLocation: str, departureDate: datetime, departureLocation: str) -> None:
self.arrivalLocation = arrivalLocation
self.departureDate = departureDate
self.departureLocation = departureLocation
@staticmethod
def from_dict(obj: Any) -> 'LegDescription':
assert isinstance(obj, dict)
arrivalLocation = obj.get("arrivalLocation")
departureDate = obj.get("departureDate")
departureLocation = obj.get("departureLocation")
return LegDescription(arrivalLocation, departureDate, departureLocation)
def to_dict(self) -> dict:
result: dict = {}
result["arrivalLocation"] = self.arrivalLocation
result["departureDate"] = self.departureDate
result["departureLocation"] = self.departureLocation
return result
class GroupDescription:
legDescriptions: List[LegDescription]
def __init__(self, legDescriptions: List[LegDescription]) -> None:
self.legDescriptions = legDescriptions
@staticmethod
def from_dict(obj: Any) -> 'GroupDescription':
assert isinstance(obj, dict)
legDescriptions = from_list(LegDescription.from_dict, obj.get("legDescriptions"))
return GroupDescription(legDescriptions)
def to_dict(self) -> dict:
result: dict = {}
result["legDescriptions"] = from_list(lambda x: to_class(LegDescription, x), self.legDescriptions)
return result
class DiversitySwapper:
weighedPrice: float
def __init__(self, weighedPrice: float) -> None:
self.weighedPrice = weighedPrice
@staticmethod
def from_dict(obj: Any) -> 'DiversitySwapper':
assert isinstance(obj, dict)
weighedPrice = from_float(obj.get("weighedPrice"))
return DiversitySwapper(weighedPrice)
def to_dict(self) -> dict:
result: dict = {}
result["weighedPrice"] = to_float(self.weighedPrice)
return result
class Schedule:
ref: int
def __init__(self, ref: int) -> None:
self.ref = ref
@staticmethod
def from_dict(obj: Any) -> 'Schedule':
assert isinstance(obj, dict)
ref = from_int(obj.get("ref"))
return Schedule(ref)
def to_dict(self) -> dict:
result: dict = {}
result["ref"] = from_int(self.ref)
return result
# class GoverningCarriers(Enum):
# AA_AA = "AA AA"
# AS_AS = "AS AS"
# B6_B6 = "B6 B6"
# DL_AS = "DL AS"
# DL_DL = "DL DL"
# UA_UA = "UA UA"
# class TerminalEnum(Enum):
# A = "A"
# B = "B"
# C = "C"
# EM = "EM"
class BaggageInformationSegment:
id: int
def __init__(self, id: int) -> None:
self.id = id
@staticmethod
def from_dict(obj: Any) -> 'BaggageInformationSegment':
assert isinstance(obj, dict)
id = from_int(obj.get("id"))
return BaggageInformationSegment(id)
def to_dict(self) -> dict:
result: dict = {}
result["id"] = from_int(self.id)
return result
class BaggageInformation:
airlineCode: str
allowance: Schedule
provisionType: str
segments: List[BaggageInformationSegment]
def __init__(self, airlineCode: str, allowance: Schedule, provisionType: str,
segments: List[BaggageInformationSegment]) -> None:
self.airlineCode = airlineCode
self.allowance = allowance
self.provisionType = provisionType
self.segments = segments
@staticmethod
def from_dict(obj: Any) -> 'BaggageInformation':
assert isinstance(obj, dict)
airlineCode = obj.get("airlineCode")
allowance = Schedule.from_dict(obj.get("allowance"))
provisionType = obj.get("provisionType")
segments = from_list(BaggageInformationSegment.from_dict, obj.get("segments"))
return BaggageInformation(airlineCode, allowance, provisionType, segments)
def to_dict(self) -> dict:
result: dict = {}
result["airlineCode"] = self.airlineCode
result["allowance"] = to_class(Schedule, self.allowance)
result["provisionType"] = self.provisionType
result["segments"] = from_list(lambda x: to_class(BaggageInformationSegment, x), self.segments)
return result
class CurrencyConversion:
exchangeRateUsed: int
currencyConversion_from: str
to: str
def __init__(self, exchangeRateUsed: int, currencyConversion_from: str, to: str) -> None:
self.exchangeRateUsed = exchangeRateUsed
self.currencyConversion_from = currencyConversion_from
self.to = to
@staticmethod
def from_dict(obj: Any) -> 'CurrencyConversion':
assert isinstance(obj, dict)
exchangeRateUsed = obj.get("exchangeRateUsed")
currencyConversion_from = (obj.get("from"))
to = (obj.get("to"))
return CurrencyConversion(exchangeRateUsed, currencyConversion_from, to)
def to_dict(self) -> dict:
result: dict = {}
result["exchangeRateUsed"] = self.exchangeRateUsed
result["from"] = self.currencyConversion_from
result["to"] = self.to
return result
class DotRating(Enum):
B = "B"
K = "K"
L = "L"
N = "N"
Q = "Q"
R = "R"
U = "U"
X = "X"
# class CabinCode(Enum):
# Y = "Y"
# class MealCode(Enum):
# F = "F"
# G = "G"
# S = "S"
class FluffySegment:
availabilityBreak: Optional[bool]
bookingCode: DotRating
cabinCode: str
mealCode: Optional[str]
seatsAvailable: int
def __init__(self, availabilityBreak: Optional[bool], bookingCode: DotRating, cabinCode: str,
mealCode: Optional[str], seatsAvailable: int) -> None:
self.availabilityBreak = availabilityBreak
self.bookingCode = bookingCode
self.cabinCode = cabinCode
self.mealCode = mealCode
self.seatsAvailable = seatsAvailable
@staticmethod
def from_dict(obj: Any) -> 'FluffySegment':
assert isinstance(obj, dict)
availabilityBreak = from_union([from_bool, from_none], obj.get("availabilityBreak"))
bookingCode = obj.get("bookingCode")
cabinCode = (obj.get("cabinCode"))
mealCode = obj.get("mealCode")
seatsAvailable = from_int(obj.get("seatsAvailable"))
return FluffySegment(availabilityBreak, bookingCode, cabinCode, mealCode, seatsAvailable)
def to_dict(self) -> dict:
result: dict = {}
result["availabilityBreak"] = from_union([from_bool, from_none], self.availabilityBreak)
result["bookingCode"] = self.bookingCode
result["cabinCode"] = self.cabinCode
result["mealCode"] = self.mealCode
result["seatsAvailable"] = from_int(self.seatsAvailable)
return result
class FareComponentSegment:
segment: FluffySegment
def __init__(self, segment: FluffySegment) -> None:
self.segment = segment
@staticmethod
def from_dict(obj: Any) -> 'FareComponentSegment':
assert isinstance(obj, dict)
# segment = FluffySegment.from_dict(obj.get("segment"))
segment = obj.get("segment")
return FareComponentSegment(segment)
def to_dict(self) -> dict:
result: dict = {}
result["segment"] = self.segment
return result
class FareComponent:
ref: int
segments: List[FareComponentSegment]
def __init__(self, ref: int, segments: List[FareComponentSegment]) -> None:
self.ref = ref
self.segments = segments
@staticmethod
def from_dict(obj: Any) -> 'FareComponent':
assert isinstance(obj, dict)
ref = from_int(obj.get("ref"))
segments = from_list(FareComponentSegment.from_dict, obj.get("segments"))
return FareComponent(ref, segments)
def to_dict(self) -> dict:
result: dict = {}
result["ref"] = from_int(self.ref)
result["segments"] = from_list(lambda x: to_class(FareComponentSegment, x), self.segments)
return result
class Info(Enum):
ALTERNATE_VALIDATING_CARRIER_S_AS = "ALTERNATE VALIDATING CARRIER/S - AS"
CAT_15_SALES_RESTRICTIONS_FREE_TEXT_FOUND_VERIFY_RULES = "CAT 15 SALES RESTRICTIONS FREE TEXT FOUND - VERIFY RULES"
NONREF_NOCBBG_NOASR = "NONREF/NOCBBG/NOASR"
NONREF_NOCHGS = "NONREF/NOCHGS"
NONREF_NOCHGS_VALID_AS = "NONREF/NOCHGS/VALID AS/"
NONREF_NOCHG_BESH_NOSEAT = "NONREF/NOCHG/BESH/NOSEAT"
NONREF_PENALTY_APPLIES = "NONREF/PENALTY APPLIES"
NONREF_SVCCHGPLUSFAREDIF_CXL_BY_FLT_TIME_OR_NOVALUE_VALID_AS = "NONREF/SVCCHGPLUSFAREDIF/CXL BY FLT TIME OR NOVALUE/VALID AS/"
VALIDATING_CARRIER_AA = "VALIDATING CARRIER - AA"
VALIDATING_CARRIER_AS = "VALIDATING CARRIER - AS"
VALIDATING_CARRIER_B6 = "VALIDATING CARRIER - B6"
VALIDATING_CARRIER_DL = "VALIDATING CARRIER - DL"
VALIDATING_CARRIER_UA = "VALIDATING CARRIER - UA"
class TypeForFirstLegEnum(Enum):
N = "N"
W = "W"
class FareMessage:
carrier: str
code: int
info: Info
type: TypeForFirstLegEnum
def __init__(self, carrier: str, code: int, info: Info, type: TypeForFirstLegEnum) -> None:
self.carrier = carrier
self.code = code
self.info = info
self.type = type
@staticmethod
def from_dict(obj: Any) -> 'FareMessage':
assert isinstance(obj, dict)
carrier = obj.get("carrier")
code = int(from_str(obj.get("code")))
info = obj.get("info")
type = TypeForFirstLegEnum(obj.get("type"))
return FareMessage(carrier, code, info, type)
def to_dict(self) -> dict:
result: dict = {}
result["carrier"] = self.carrier
result["code"] = from_str(str(self.code))
result["info"] = self.info
result["type"] = to_enum(TypeForFirstLegEnum, self.type)
return result
class PassengerTotalFare:
baseFareAmount: int
baseFareCurrency: str
commissionAmount: int
commissionPercentage: int
constructionAmount: int
constructionCurrency: str
currency: str
equivalentAmount: int
equivalentCurrency: str
exchangeRateOne: int
totalFare: float
totalTaxAmount: float
def __init__(self, baseFareAmount: int, baseFareCurrency: str, commissionAmount: int,
commissionPercentage: int, constructionAmount: int, constructionCurrency: str,
currency: str, equivalentAmount: int, equivalentCurrency: str, exchangeRateOne: int,
totalFare: float, totalTaxAmount: float) -> None:
self.baseFareAmount = baseFareAmount
self.baseFareCurrency = baseFareCurrency
self.commissionAmount = commissionAmount
self.commissionPercentage = commissionPercentage
self.constructionAmount = constructionAmount
self.constructionCurrency = constructionCurrency
self.currency = currency
self.equivalentAmount = equivalentAmount
self.equivalentCurrency = equivalentCurrency
self.exchangeRateOne = exchangeRateOne
self.totalFare = totalFare
self.totalTaxAmount = totalTaxAmount
@staticmethod
def from_dict(obj: Any) -> 'PassengerTotalFare':
assert isinstance(obj, dict)
baseFareAmount = obj.get("baseFareAmount")
baseFareCurrency = obj.get("baseFareCurrency")
commissionAmount = obj.get("commissionAmount")
commissionPercentage = obj.get("commissionPercentage")
constructionAmount = obj.get("constructionAmount")
constructionCurrency = obj.get("constructionCurrency")
currency = obj.get("currency")
equivalentAmount = obj.get("equivalentAmount")
equivalentCurrency = obj.get("equivalentCurrency")
exchangeRateOne = obj.get("exchangeRateOne")
totalFare = from_float(obj.get("totalFare"))
totalTaxAmount = from_float(obj.get("totalTaxAmount"))
return PassengerTotalFare(baseFareAmount, baseFareCurrency, commissionAmount, commissionPercentage,
constructionAmount, constructionCurrency, currency, equivalentAmount,
equivalentCurrency, exchangeRateOne, totalFare, totalTaxAmount)
def to_dict(self) -> dict:
result: dict = {}
result["baseFareAmount"] = self.baseFareAmount
result["baseFareCurrency"] = self.baseFareCurrency
result["commissionAmount"] = from_int(self.commissionAmount)
result["commissionPercentage"] = from_int(self.commissionPercentage)
result["constructionAmount"] = from_int(self.constructionAmount)
result["constructionCurrency"] = self.constructionCurrency
result["currency"] = self.currency
result["equivalentAmount"] = from_int(self.equivalentAmount)
result["equivalentCurrency"] = self.equivalentCurrency
result["exchangeRateOne"] = from_int(self.exchangeRateOne)
result["totalFare"] = to_float(self.totalFare)
result["totalTaxAmount"] = to_float(self.totalTaxAmount)
return result
class PassengerInfo:
baggageInformation: List[BaggageInformation]
currencyConversion: CurrencyConversion
fareComponents: List[FareComponent]
fareMessages: List[FareMessage]
nonRefundable: bool
passengerNumber: int
passengerTotalFare: PassengerTotalFare
passengerType: PassengerType
taxSummaries: List[Schedule]
taxes: List[Schedule]
def __init__(self, baggageInformation: List[BaggageInformation], currencyConversion: CurrencyConversion,
fareComponents: List[FareComponent], fareMessages: List[FareMessage], nonRefundable: bool,
passengerNumber: int, passengerTotalFare: PassengerTotalFare, passengerType: PassengerType,
taxSummaries: List[Schedule], taxes: List[Schedule]) -> None:
self.baggageInformation = baggageInformation
self.currencyConversion = currencyConversion
self.fareComponents = fareComponents
self.fareMessages = fareMessages
self.nonRefundable = nonRefundable
self.passengerNumber = passengerNumber
self.passengerTotalFare = passengerTotalFare
self.passengerType = passengerType
self.taxSummaries = taxSummaries
self.taxes = taxes
@staticmethod
def from_dict(obj: Any) -> 'PassengerInfo':
assert isinstance(obj, dict)
# if 'None' in obj.get("baggageInformation"):
# baggageInformation = from_list(BaggageInformation.from_dict, obj.get("baggageInformation"))
# else:
baggageInformation = obj.get("baggageInformation")
currencyConversion = CurrencyConversion.from_dict(obj.get("currencyConversion"))
fareComponents = from_list(FareComponent.from_dict, obj.get("fareComponents"))
fareMessages = from_list(FareMessage.from_dict, obj.get("fareMessages"))
nonRefundable = from_bool(obj.get("nonRefundable"))
passengerNumber = from_int(obj.get("passengerNumber"))
passengerTotalFare = PassengerTotalFare.from_dict(obj.get("passengerTotalFare"))
passengerType = PassengerType(obj.get("passengerType"))
taxSummaries = from_list(Schedule.from_dict, obj.get("taxSummaries"))
taxes = from_list(Schedule.from_dict, obj.get("taxes"))
return PassengerInfo(baggageInformation, currencyConversion, fareComponents, fareMessages, nonRefundable,
passengerNumber, passengerTotalFare, passengerType, taxSummaries, taxes)
def to_dict(self) -> dict:
result: dict = {}
# result["baggageInformation"] = from_list(lambda x: to_class(BaggageInformation, x), self.baggageInformation)
result["baggageInformation"] = self.baggageInformation
result["currencyConversion"] = to_class(CurrencyConversion, self.currencyConversion)
result["fareComponents"] = from_list(lambda x: to_class(FareComponent, x), self.fareComponents)
result["fareMessages"] = from_list(lambda x: to_class(FareMessage, x), self.fareMessages)
result["nonRefundable"] = from_bool(self.nonRefundable)
result["passengerNumber"] = from_int(self.passengerNumber)
result["passengerTotalFare"] = to_class(PassengerTotalFare, self.passengerTotalFare)
result["passengerType"] = to_enum(PassengerType, self.passengerType)
result["taxSummaries"] = from_list(lambda x: to_class(Schedule, x), self.taxSummaries)
result["taxes"] = from_list(lambda x: to_class(Schedule, x), self.taxes)
return result
class PassengerInfoList:
passengerInfo: PassengerInfo
def __init__(self, passengerInfo: PassengerInfo) -> None:
self.passengerInfo = passengerInfo
@staticmethod
def from_dict(obj: Any) -> 'PassengerInfoList':
assert isinstance(obj, dict)
passengerInfo = PassengerInfo.from_dict(obj.get("passengerInfo"))
return PassengerInfoList(passengerInfo)
def to_dict(self) -> dict:
result: dict = {}
result["passengerInfo"] = to_class(PassengerInfo, self.passengerInfo)
return result
class TotalFare:
baseFareAmount: int
baseFareCurrency: str
constructionAmount: int
constructionCurrency: str
currency: str
equivalentCurrency: str
totalPrice: float
totalTaxAmount: float
def __init__(self, baseFareAmount: int, baseFareCurrency: str, constructionAmount: int,
constructionCurrency: str, currency: str, equivalentCurrency: str,
totalPrice: float, totalTaxAmount: float) -> None:
self.baseFareAmount = baseFareAmount
self.baseFareCurrency = baseFareCurrency
self.constructionAmount = constructionAmount
self.constructionCurrency = constructionCurrency
self.currency = currency
self.equivalentCurrency = equivalentCurrency
self.totalPrice = totalPrice
self.totalTaxAmount = totalTaxAmount
@staticmethod
def from_dict(obj: Any) -> 'TotalFare':
assert isinstance(obj, dict)
baseFareAmount = obj.get("baseFareAmount")
baseFareCurrency = (obj.get("baseFareCurrency"))
constructionAmount = obj.get("constructionAmount")
constructionCurrency = (obj.get("constructionCurrency"))
currency = (obj.get("currency"))
equivalentCurrency = (obj.get("equivalentCurrency"))
totalPrice = from_float(obj.get("totalPrice"))
totalTaxAmount = from_float(obj.get("totalTaxAmount"))
return TotalFare(baseFareAmount, baseFareCurrency, constructionAmount, constructionCurrency, currency,
equivalentCurrency, totalPrice, totalTaxAmount)
def to_dict(self) -> dict:
result: dict = {}
result["baseFareAmount"] = from_int(self.baseFareAmount)
result["baseFareCurrency"] = self.baseFareCurrency
result["constructionAmount"] = from_int(self.constructionAmount)
result["constructionCurrency"] = self.constructionCurrency
result["currency"] = self.currency
result["equivalentCurrency"] = self.equivalentCurrency
result["totalPrice"] = to_float(self.totalPrice)
result["totalTaxAmount"] = to_float(self.totalTaxAmount)
return result
class Fare:
eTicketable: bool
governingCarriers: str
lastTicketDate: datetime
passengerInfoList: List[PassengerInfoList]
totalFare: TotalFare
validatingCarrierCode: str
validatingCarriers: List[Schedule]
vita: bool
def __init__(self, eTicketable: bool, governingCarriers: str, lastTicketDate: datetime,
passengerInfoList: List[PassengerInfoList], totalFare: TotalFare,
validatingCarrierCode: str, validatingCarriers: List[Schedule], vita: bool) -> None:
self.eTicketable = eTicketable
self.governingCarriers = governingCarriers
self.lastTicketDate = lastTicketDate
self.passengerInfoList = passengerInfoList
self.totalFare = totalFare
self.validatingCarrierCode = validatingCarrierCode
self.validatingCarriers = validatingCarriers
self.vita = vita
@staticmethod
def from_dict(obj: Any) -> 'Fare':
assert isinstance(obj, dict)
eTicketable = from_bool(obj.get("eTicketable"))
governingCarriers = obj.get("governingCarriers")
lastTicketDate = obj.get("lastTicketDate")
passengerInfoList = from_list(PassengerInfoList.from_dict, obj.get("passengerInfoList"))
totalFare = TotalFare.from_dict(obj.get("totalFare"))
validatingCarrierCode = obj.get("validatingCarrierCode")
validatingCarriers = from_list(Schedule.from_dict, obj.get("validatingCarriers"))
vita = from_bool(obj.get("vita"))
return Fare(eTicketable, governingCarriers, lastTicketDate, passengerInfoList, totalFare, validatingCarrierCode,
validatingCarriers, vita)
def to_dict(self) -> dict:
result: dict = {}
result["eTicketable"] = from_bool(self.eTicketable)
result["governingCarriers"] = self.governingCarriers
result["lastTicketDate"] = self.lastTicketDate
result["passengerInfoList"] = from_list(lambda x: to_class(PassengerInfoList, x), self.passengerInfoList)
result["totalFare"] = to_class(TotalFare, self.totalFare)
result["validatingCarrierCode"] = self.validatingCarrierCode
result["validatingCarriers"] = from_list(lambda x: to_class(Schedule, x), self.validatingCarriers)
result["vita"] = from_bool(self.vita)
return result
class PricingSubsource(Enum):
MIP = "MIP"
class PricingInformation:
fare: Fare
pricingSubsource: PricingSubsource
def __init__(self, fare: Fare, pricingSubsource: PricingSubsource) -> None:
self.fare = fare
self.pricingSubsource = pricingSubsource
@staticmethod
def from_dict(obj: Any) -> 'PricingInformation':
assert isinstance(obj, dict)
fare = Fare.from_dict(obj.get("fare"))
pricingSubsource = PricingSubsource(obj.get("pricingSubsource"))
return PricingInformation(fare, pricingSubsource)
def to_dict(self) -> dict:
result: dict = {}
result["fare"] = to_class(Fare, self.fare)
result["pricingSubsource"] = to_enum(PricingSubsource, self.pricingSubsource)
return result
class PricingSource(Enum):
ADVJR1 = "ADVJR1"
class Itinerary:
diversitySwapper: DiversitySwapper
id: int
legs: List[Schedule]
pricingInformation: List[PricingInformation]
pricingSource: PricingSource
def __init__(self, diversitySwapper: DiversitySwapper, id: int, legs: List[Schedule],
pricingInformation: List[PricingInformation], pricingSource: PricingSource) -> None:
self.diversitySwapper = diversitySwapper
self.id = id
self.legs = legs
self.pricingInformation = pricingInformation
self.pricingSource = pricingSource
@staticmethod
def from_dict(obj: Any) -> 'Itinerary':
assert isinstance(obj, dict)
diversitySwapper = DiversitySwapper.from_dict(obj.get("diversitySwapper"))
id = from_int(obj.get("id"))
legs = from_list(Schedule.from_dict, obj.get("legs"))
pricingInformation = from_list(PricingInformation.from_dict, obj.get("pricingInformation"))
pricingSource = PricingSource(obj.get("pricingSource"))
return Itinerary(diversitySwapper, id, legs, pricingInformation, pricingSource)
def to_dict(self) -> dict:
result: dict = {}
result["diversitySwapper"] = to_class(DiversitySwapper, self.diversitySwapper)
result["id"] = from_int(self.id)
result["legs"] = from_list(lambda x: to_class(Schedule, x), self.legs)
result["pricingInformation"] = from_list(lambda x: to_class(PricingInformation, x), self.pricingInformation)
result["pricingSource"] = to_enum(PricingSource, self.pricingSource)
return result
class ItineraryGroup:
groupDescription: GroupDescription
itineraries: List[Itinerary]
def __init__(self, groupDescription: GroupDescription, itineraries: List[Itinerary]) -> None:
self.groupDescription = groupDescription
self.itineraries = itineraries
@staticmethod
def from_dict(obj: Any) -> 'ItineraryGroup':
assert isinstance(obj, dict)
groupDescription = GroupDescription.from_dict(obj.get("groupDescription"))
itineraries = from_list(Itinerary.from_dict, obj.get("itineraries"))
return ItineraryGroup(groupDescription, itineraries)
def to_dict(self) -> dict:
result: dict = {}
result["groupDescription"] = to_class(GroupDescription, self.groupDescription)
result["itineraries"] = from_list(lambda x: to_class(Itinerary, x), self.itineraries)
return result
class LegDesc:
id: int
schedules: List[Schedule]
def __init__(self, id: int, schedules: List[Schedule]) -> None:
self.id = id
self.schedules = schedules
@staticmethod
def from_dict(obj: Any) -> 'LegDesc':
assert isinstance(obj, dict)
id = from_int(obj.get("id"))
schedules = from_list(Schedule.from_dict, obj.get("schedules"))
return LegDesc(id, schedules)
def to_dict(self) -> dict:
result: dict = {}
result["id"] = from_int(self.id)
result["schedules"] = from_list(lambda x: to_class(Schedule, x), self.schedules)
return result
class Message:
code: str
severity: str
text: str
type: str
def __init__(self, code: str, severity: str, text: str, type: str) -> None:
self.code = code
self.severity = severity
self.text = text
self.type = type
@staticmethod
def from_dict(obj: Any) -> 'Message':
assert isinstance(obj, dict)
code = from_str(obj.get("code"))
severity = from_str(obj.get("severity"))
text = from_str(obj.get("text"))
type = from_str(obj.get("type"))
return Message(code, severity, text, type)
def to_dict(self) -> dict:
result: dict = {}
result["code"] = from_str(self.code)
result["severity"] = from_str(self.severity)
result["text"] = from_str(self.text)
result["type"] = from_str(self.type)
return result