The actual changed code
This commit is contained in:
parent
4819c7dfcd
commit
129093bda8
@ -1,10 +1,12 @@
|
||||
from utils import raiseDiscord
|
||||
import config
|
||||
import json
|
||||
|
||||
class Travel():
|
||||
def __init__(self, data):
|
||||
self.orderId = data["orderId"]
|
||||
self.serviceItemId = data["serviceItemId"]
|
||||
self.dvNumber = data["dvNumber"]
|
||||
self.dvNumber = data["dvNumber"] # or marketingCarrierRef, the ref of the visible ticket's ref
|
||||
self.origin = data["origin"]
|
||||
self.destination = data["destination"]
|
||||
self.departureDateTime = data["departureDateTime"]
|
||||
@ -16,9 +18,11 @@ class Travel():
|
||||
self.seatNumber = data["seatNumber"]
|
||||
|
||||
self.reservationDate = data["reservationDate"]
|
||||
self.travelConfirmed = data["travelConfirmed"] # CONFIRMED, TOO_EARLY_TO_CONFIRM
|
||||
self.travelConfirmed = data["travelConfirmed"] # CONFIRMED, TOO_EARLY_TO_CONFIRM, TO_BE_CONFIRMED
|
||||
self.travelStatus = data["travelStatus"]
|
||||
|
||||
self.tcn = None
|
||||
|
||||
def confirm(self, session, headers):
|
||||
"""
|
||||
https://www.maxjeune-tgvinoui.sncf/api/public/reservation/travel-confirm
|
||||
@ -42,4 +46,30 @@ class Travel():
|
||||
|
||||
return r
|
||||
|
||||
def get(self, s, headers):
|
||||
r = s.post(
|
||||
"https://www.maxjeune-tgvinoui.sncf/api/public/reservation/get-travel",
|
||||
headers=headers,
|
||||
json = {
|
||||
"customerName": config.customer_name,
|
||||
"departureDateTime": self.departureDateTime,
|
||||
"marketingCarrierRef": self.dvNumber,
|
||||
"trainNumber": self.trainNumber
|
||||
})
|
||||
data = json.loads(r.content.decode("utf-8"))
|
||||
self.tcn = data["tcn"]
|
||||
return data
|
||||
|
||||
def tprint(self, s, headers):
|
||||
if self.tcn is None:
|
||||
self.get(s, headers)
|
||||
|
||||
return s.post(
|
||||
"https://www.maxjeune-tgvinoui.sncf/api/public/reservation/print-travel",
|
||||
headers=headers,
|
||||
json = {
|
||||
"orderId": self.orderId,
|
||||
"serviceItemId": self.serviceItemId,
|
||||
"tcn": [self.tcn]
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user