How to use the easypost.Parcel 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_parcel.py View on Github external
def test_parcel_creation():
    # Simply create a Parcel and assert on saved data.
    parcel = easypost.Parcel.create(
        predefined_package="RegionalRateBoxA",
        length=10.2,
        width=7.8,
        height=4.3,
        weight=21.2
    )

    assert parcel.height == 4.3
    assert parcel.width == 7.8
    assert parcel.weight == 21.2
    assert parcel.predefined_package == 'RegionalRateBoxA'
github EasyPost / easypost-python / tests / test_shipment.py View on Github external
zip="t8n2m4",
        country="CA",
        phone="780-283-9384"
    )
    from_address = easypost.Address.create(
        company="EasyPost",
        street1="118 2nd St",
        street2="4th Fl",
        city="San Francisco",
        state="CA",
        zip="94105",
        phone="415-456-7890"
    )

    # create a parcel
    parcel = easypost.Parcel.create(
        length=10.2,
        width=7.8,
        height=4.3,
        weight=21.2
    )

    # create customs_info form for intl shipping
    customs_item = easypost.CustomsItem.create(
        description="EasyPost t-shirts",
        hs_tariff_number=123456,
        origin_country="US",
        quantity=2,
        value=96.27,
        weight=21.1
    )
    customs_info = easypost.CustomsInfo.create(
github EasyPost / easypost-python / tests / test_batch.py View on Github external
def test_batch_create_and_buy():
    # We create Address and Parcel objects. We then try to create a Batch containing a shipment. Finally,
    # Finally, we assert on saved and returned data.

    # from address and parcel don't change
    from_address = easypost.Address.create(
        name='Simpler Postage Inc.',
        street1='388 Townsend St',
        street2='Apt 20',
        city='San Francisco',
        state='CA',
        zip='94107',
        phone='415-456-7890'
    )

    parcel = easypost.Parcel.create(
        predefined_package='RegionalRateBoxA',
        weight=64
    )

    # # populate order_list from db, csv, etc.
    order_list = [{
        'address': {
            'name': 'Jon Calhoun',
            'street1': '388 Townsend St',
            'street2': 'Apt 30',
            'city': 'San Francisco',
            'state': 'CA',
            'zip': '94107',
            'phone': '415-456-7890'
        },
        'order_number': '1234567890'
github EasyPost / easypost-python / examples / example.py View on Github external
zip="94105",
    phone="415-456-7890"
)

# verify address
try:
    verified_from_address = from_address.verify()
except easypost.Error as e:
    raise e
if hasattr(verified_from_address, 'message'):
    # the from address is not invalid, but it has an issue
    pass

# create parcel
try:
    parcel = easypost.Parcel.create(
        predefined_package="InvalidPackageName",
        weight=21.2
    )
except easypost.Error as e:
    print(e)
    if e.param is not None:
        print('Specifically an invalid param: ' + e.param)

try:
    parcel = easypost.Parcel.create(
        length=10.2,
        width=7.8,
        height=4.3,
        weight=21.2
    )
except easypost.Error as e:
github EasyPost / easypost-python / examples / batch.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# easypost.api_base = 'http://localhost:5000/v2'

# from address and parcel don't change
from_address = easypost.Address.create(
    name="Simpler Postage Inc.",
    street1="388 Townsend St",
    street2="Apt 20",
    city="San Francisco",
    state="CA",
    zip="94107",
    phone="415-456-7890"
)

parcel = easypost.Parcel.create(
    predefined_package="RegionalRateBoxA",
    weight=64
)

# # populate order_list from db, csv, etc.
order_list = [{
    'address': {
        'name': "Jon Calhoun",
        'street1': "388 Townsend St",
        'street2': "Apt 30",
        'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    'order_number': '1234567890'
github EasyPost / easypost-python / examples / order.py View on Github external
'zip': "94618",
        'country': 'US',
        'phone': '800-777-0133'
    },
    from_address={
        'name': "EasyPost",
        'company': "EasyPost",
        'street1': "164 Townsend St",
        'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    shipments=[
        {
            "parcel": easypost.Parcel.create(
                weight=21.2,
                length=12,
                width=12,
                height=3),
            "options": {"label_format": "PDF"}
        },
        {
            "parcel": easypost.Parcel.create(
                weight=16,
                length=8,
                width=5,
                height=5),
            "options": {"label_format": "PDF"}
        }])

print(order)
github EasyPost / easypost-python / examples / example.py View on Github external
# the from address is not invalid, but it has an issue
    pass

# create parcel
try:
    parcel = easypost.Parcel.create(
        predefined_package="InvalidPackageName",
        weight=21.2
    )
except easypost.Error as e:
    print(e)
    if e.param is not None:
        print('Specifically an invalid param: ' + e.param)

try:
    parcel = easypost.Parcel.create(
        length=10.2,
        width=7.8,
        height=4.3,
        weight=21.2
    )
except easypost.Error as e:
    raise e

# create customs_info form for intl shipping
customs_item = easypost.CustomsItem.create(
    description="EasyPost t-shirts",
    hs_tariff_number=123456,
    origin_country="US",
    quantity=2,
    value=96.27,
    weight=21.1
github EasyPost / easypost-python / examples / order.py View on Github external
'city': "San Francisco",
        'state': "CA",
        'zip': "94107",
        'phone': "415-456-7890"
    },
    shipments=[
        {
            "parcel": easypost.Parcel.create(
                weight=21.2,
                length=12,
                width=12,
                height=3),
            "options": {"label_format": "PDF"}
        },
        {
            "parcel": easypost.Parcel.create(
                weight=16,
                length=8,
                width=5,
                height=5),
            "options": {"label_format": "PDF"}
        }])

print(order)

order.buy(carrier="USPS", service="Priority")

for shipment in order.shipments:
    # Insure the parcel
    shipment.insure(amount=100)
    print(shipment.postage_label.label_url)
    print(shipment.tracking_code)