How to use the easypost.Pickup.create function in easypost

To help you get started, we’ve selected a few easypost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EasyPost / easypost-python / tests / test_pickup.py View on Github external
'name': 'Customer',
            'street1': '8308 Fenway Rd',
            'city': 'Bethesda',
            'state': 'MD',
            'zip': '20817',
            'country': 'US'
        },
        from_address=pickup_address,
        parcel={
            'weight': 21.2
        },
    )

    shipment.buy(rate=shipment.lowest_rate('USPS', 'Priority'), insurance=100.00)

    pickup = easypost.Pickup.create(
        address=pickup_address,
        shipment=shipment,
        reference='internal_id_1234',
        min_datetime=noon_on_next_monday.isoformat(),
        max_datetime=(noon_on_next_monday + ONE_DAY).isoformat(),
        is_account_address=True,
        instructions='Special pickup instructions'
    )

    assert pickup.pickup_rates != []

    pickup.buy(
        carrier=pickup.pickup_rates[0].carrier,
        service=pickup.pickup_rates[0].service
    )
github EasyPost / easypost-python / tests / test_pickup.py View on Github external
'carrier': 'USPS',
            'service': 'Priority'
        }
    ]

    batch = easypost.Batch.create_and_buy(shipments=shipments)
    while batch.state in ('creating', 'queued_for_purchase', 'purchasing'):
        time.sleep(0.1)
        batch.refresh()

    # Insure the shipments after purchase
    if batch.state == 'purchased':
        for shipment in batch.shipments:
            shipment.insure(amount=100)

    pickup = easypost.Pickup.create(
        address=pickup_address,
        batch=batch,
        reference='internal_id_1234',
        min_datetime=noon_on_next_monday.isoformat(),
        max_datetime=(noon_on_next_monday + ONE_DAY).isoformat(),
        is_account_address=True,
        instructions='Special pickup instructions'
    )

    assert pickup.pickup_rates != [], pickup.messages

    pickup.buy(
        carrier=pickup.pickup_rates[0].carrier,
        service=pickup.pickup_rates[0].service
    )
github EasyPost / easypost-python / examples / pickup_batch.py View on Github external
'service': "NextDayAir"
    }
]

batch = easypost.Batch.create_and_buy(shipments=shipments)
while batch.state in ("creating", "queued_for_purchase", "purchasing"):
    print(batch.state)
    time.sleep(5)
    batch.refresh()

# Insure the shipments after purchase
if batch.state == "purchased":
    for shipment in batch.shipments:
        shipment.insure(amount=100)

pickup = easypost.Pickup.create(
    address={
        'name': "Sawyer Bateman",
        'company': "EasyPost",
        'street1': "164 Townsend St",
        'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    batch=batch,
    reference="internal_id_1234",
    min_datetime=time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()),
    max_datetime=time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()),  # this should be later than min
    is_account_address=True,
    instructions="Special pickup instructions"
)
github EasyPost / easypost-python / examples / pickup_single_shipment.py View on Github external
'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    parcel={
        'weight': 21.2
    }
)
print(shipment.rates)
# Purchase the postage label
shipment.buy(rate=shipment.lowest_rate('ups'))
# Insure the parcel
shipment.insure(amount=100)

pickup = easypost.Pickup.create(
    address={
        'name': "Sawyer Bateman",
        'company': "EasyPost",
        'street1': "164 Townsend St",
        'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    shipment=shipment,
    reference="internal_id_1234",
    min_datetime=strftime("%Y-%m-%d %H:%M:%S", gmtime()),
    max_datetime=strftime("%Y-%m-%d %H:%M:%S", gmtime()),  # this should be later than min
    is_account_address=True,
    instructions="Special pickup instructions"
)