-
Notifications
You must be signed in to change notification settings - Fork 1
Useful Scripts
James Elgar edited this page Jan 26, 2022
·
2 revisions
import requests
import uuid
# These are global ids
performance_id = ""
seat_group_id = ""
concession_type_id = ""
url = "<API_BASE_URL>/graphql/"
def send_query(query,token = None):
return requests.post(url, json={'query': query}, headers={"Authorization": f"JWT {token}"}).json()
login_query = """
mutation {
login(email: "[email protected]", password: "strongpassword") {
token
}
}
"""
user_token = send_query(login_query)["data"]["login"]["token"]
for i in range(204):
create_query = """
mutation {
createBooking(performanceId: "%s", tickets: [{seatGroupId: "%s", concessionTypeId: "%s"}]) {
success
booking {
id
reference
priceBreakdown {
totalPrice
}
}
errors {
... on NonFieldError {
message
}
}
}
}
""" % (performance_id, seat_group_id, concession_type_id)
response = send_query(create_query, user_token)
print(response)
price = response["data"]["createBooking"]["booking"]["priceBreakdown"]["totalPrice"]
id = response["data"]["createBooking"]["booking"]["id"]
pay_query = """
mutation {
payBooking(bookingId: "%s", nonce: "cnon:card-nonce-ok", paymentProvider: SQUARE_ONLINE, idempotencyKey: "%s", price: %s) {
success
}
}
""" % (id, uuid.uuid4(), price)
response = send_query(pay_query, user_token)
if response["data"]["payBooking"]["success"]:
print("Booking created")