commit 53d92ab02139f7a43d1096976ababafa8474ccf0 Author: joseph.pintozzi Date: Sun Dec 11 12:59:19 2016 -0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8c09524 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc +*.swp \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a0e690 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# SW Checkin + +## Usage + +```bash +$ python ./checkin.py CONFIRMATION_NUMBER FIRST_NAME LAST_NAME +``` diff --git a/checkin.py b/checkin.py new file mode 100644 index 0000000..9e49bec --- /dev/null +++ b/checkin.py @@ -0,0 +1,30 @@ +import requests +import sys + +# Pulled from proxying the Southwest iOS App +headers = {'Host': 'mobile.southwest.com', 'Content-Type': 'application/vnd.swacorp.com.mobile.reservations-v1.0+json', 'X-API-Key': 'l7xxab4b3533b8d54bad9df230deb96a6f90', 'Accept': '*/*'} + +reservation_number = sys.argv[1] +first_name = sys.argv[2] +last_name = sys.argv[3] + +# Find our existing record +url = "https://mobile.southwest.com/api/extensions/v1/mobile/reservations/record-locator/{}?first-name={}&last-name={}".format(reservation_number, first_name, last_name) + +r = requests.get(url, headers=headers) +body = r.json() + +# Get our passengers to get boarding passes for +passengers = [] +for passenger in body['passengers']: + passengers.append({'firstName': passenger['secureFlightName']['firstName'], 'lastName': passenger['secureFlightName']['lastName']}) + +# Check in +headers['Content-Type'] = 'application/vnd.swacorp.com.mobile.boarding-passes-v1.0+json' +url = "https://mobile.southwest.com/api/extensions/v1/mobile/reservations/record-locator/{}/boarding-passes".format(reservation_number) +r = requests.post(url, headers=headers, json={'names': passengers}) + +# Spit out info about boarding number +for checkinDocument in r.json()['passengerCheckInDocuments']: + for doc in checkinDocument['checkinDocuments']: + print "You got {}{}!".format(doc['boardingGroup'], doc['boardingGroupNumber']) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f229360 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests