How to use the easypost.Shipment 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_shipment.py View on Github external
weight=21.1
    )
    customs_info = easypost.CustomsInfo.create(
        customs_certify=1,
        customs_signer="Hector Hammerfall",
        contents_type="gift",
        contents_explanation="",
        eel_pfc="NOEEI 30.37(a)",
        non_delivery_option="return",
        restriction_type="none",
        restriction_comments="",
        customs_items=[customs_item]
    )

    # create shipment
    shipment = easypost.Shipment.create(
        to_address=to_address,
        from_address=from_address,
        parcel=parcel,
        customs_info=customs_info
    )

    rate_id = shipment.rates[0].id
    assert rate_id is not None

    shipment.get_rates()

    new_rate_id = shipment.rates[0].id
    assert new_rate_id is not None
    assert new_rate_id != rate_id

    # Assert address values match
github EasyPost / easypost-python / tests / test_pickup.py View on Github external
def test_single_pickup(noon_on_next_monday):
    """Create a Shipment, buy it, and then buy a pickup for it"""

    pickup_address = easypost.Address.create(
        verify=['delivery'],
        name='Jarrett Streebin',
        company='EasyPost',
        street1='1 MONTGOMERY ST STE 400',
        city='San Francisco',
        state='CA',
        zip='94104',
        phone='415-456-7890'
    )

    shipment = easypost.Shipment.create(
        to_address={
            '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)
github EasyPost / easypost-python / tests / test_scan_form.py View on Github external
"weight": 21.1
    }
    customs_info = {
        "customs_certify": 1,
        "customs_signer": "Hector Hammerfall",
        "contents_type": "gift",
        "contents_explanation": "",
        "eel_pfc": "NOEEI 30.37(a)",
        "non_delivery_option": "return",
        "restriction_type": "none",
        "restriction_comments": "",
        "customs_items": [customs_item]
    }

    # create shipment and buy
    shipment = easypost.Shipment.create(
        to_address=to_address,
        from_address=from_address,
        parcel=parcel,
        customs_info=customs_info
    )
    shipment.buy(rate=shipment.lowest_rate(['USPS', 'ups'], 'priorityMAILInternational'), insurance=100.00)

    # create scan form
    scan_form = easypost.ScanForm.create(
        shipments=[shipment]
    )

    # Assert values match
    assert scan_form.id is not None
    assert scan_form.tracking_codes[0] == shipment.tracking_code
github EasyPost / easypost-python / examples / example_1_call.py View on Github external
'weight': 21.1
}

customs_info = {
    'customs_certify': 1,
    'customs_signer': "Hector Hammerfall",
    'contents_type': "gift",
    'contents_explanation': "",
    'eel_pfc': "NOEEI 30.37(a)",
    'non_delivery_option': "return",
    'restriction_type': "none",
    'restriction_comments': "",
    'customs_items': [customs_item]
}

shipment = easypost.Shipment.create(
    to_address=to_address,
    from_address=from_address,
    parcel=parcel,
    customs_info=customs_info
)

# print shipment.rates
shipment.buy(rate=shipment.lowest_rate())
# Insure the shipment
shipment.insure(amount=100)

print(shipment)
github EasyPost / easypost-python / examples / pickup_single_shipment.py View on Github external
import easypost
from time import gmtime, strftime

easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

shipment = easypost.Shipment.create(
    to_address={
        'name': "Customer",
        'street1': "8308 Fenway Rd",
        'city': "Bethesda",
        'state': "MD",
        'zip': "20817",
        'country': "US"
    },
    from_address={
        'name': "Sawyer Bateman",
        'company': "EasyPost",
        'street1': "164 Townsend St",
        'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
github EasyPost / easypost-python / examples / example_single_request.py View on Github external
"customs_signer": "Hector Hammerfall",
    "contents_type": "gift",
    "contents_explanation": "",
    "eel_pfc": "NOEEI 30.37(a)",
    "non_delivery_option": "return",
    "restriction_type": "none",
    "customs_items": [{
        "description": "EasyPost t-shirts",
        "hs_tariff_number": "123456",
        "origin_country": "US",
        "quantity": 2,
        "value": 96.27,
        "weight": 21.1}]
}

shipment = easypost.Shipment.create(
    to_address=to_address,
    from_address=from_address,
    parcel=parcel,
    customs_info=customs_info)

# Can also be done like so:
#shipment = easypost.Shipment.create(
#    {"to_address": to_address,
#     "from_address": from_address,
#     "parcel": parcel,
#     "customs_info": customs_info})


shipment.buy(rate=shipment.lowest_rate(
    ['USPS', 'ups'],
    'priorityMAILInternational'))
github EasyPost / easypost-python / examples / example.py View on Github external
weight=21.1
)
customs_info = easypost.CustomsInfo.create(
    customs_certify=1,
    customs_signer="Hector Hammerfall",
    contents_type="gift",
    contents_explanation="",
    eel_pfc="NOEEI 30.37(a)",
    non_delivery_option="return",
    restriction_type="none",
    restriction_comments="",
    customs_items=[customs_item]
)

# create shipment
shipment = easypost.Shipment.create(
    to_address=to_address,
    from_address=verified_from_address,
    parcel=parcel,
    customs_info=customs_info
)

# buy postage label with one of the rate objects
# shipment.buy(rate = shipment.rates[0])
# shipment.buy(rate = shipment.lowest_rate('usps'))
shipment.buy(rate=shipment.lowest_rate(
    ['USPS', 'ups'], 'priorityMAILInternational'))
# Insure the shipment for the value
shipment.insure(amount=100)

# shipment.refund()
# print(shipment.refund_status)
github EasyPost / easypost-python / examples / shipment_retrieve_by_tracking_code.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

# retrieve a shipment by tracking_code
shipment = easypost.Shipment.retrieve("LN123456789US")

print(shipment.id)

shipment.refresh()

print(shipment.id)

print(shipment.label(file_format='PDF'))