Created
January 20, 2016 20:30
-
-
Save corykeane/1094c53dcbf00ebbfd35 to your computer and use it in GitHub Desktop.
Python manifester for EasyPost shipments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import easypost | |
import argparse | |
import time | |
def manifest(tracking_codes): | |
print("Manifesting: %s" % ", ".join(tracking_codes)) | |
shipments = [easypost.Shipment.retrieve(tracking_code) | |
for tracking_code in tracking_codes] | |
batch = easypost.Batch.create(shipments=shipments) | |
batch.create_scan_form() | |
time.sleep(60) | |
batch.refresh() | |
while batch.scan_form.status == "creating": | |
time.sleep(1) | |
batch.scan_form.refresh() | |
print(batch.scan_form) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description='Manifest shipments') | |
parser.add_argument( | |
'--api_key', help='Your EasyPost API Key', required=True) | |
parser.add_argument('tracking_codes', metavar='TRACKING_CODE', nargs='+', | |
help='Tracking codes to manifest') | |
arguments = parser.parse_args() | |
easypost.api_key = arguments.api_key | |
manifest(arguments.tracking_codes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment