Skip to content

Instantly share code, notes, and snippets.

@corykeane
Created January 20, 2016 20:30
Show Gist options
  • Save corykeane/1094c53dcbf00ebbfd35 to your computer and use it in GitHub Desktop.
Save corykeane/1094c53dcbf00ebbfd35 to your computer and use it in GitHub Desktop.
Python manifester for EasyPost shipments
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