How to use the easypost.Address 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_address.py View on Github external
def test_address_unicode():
    # Create an address with unicode field and assert if it was created correctly.
    state = u'DELEGACI\xf3N BENITO JU\xe1REZ'

    address = easypost.Address.create(state=state)
    assert address.state == state
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 = [{
github EasyPost / easypost-python / tests / test_shipment.py View on Github external
def test_shipment_creation():
    # We create a shipment and assert on values saved.

    # create a to address and a from address
    to_address = easypost.Address.create(
        name="Sawyer Bateman",
        street1="1A Larkspur Cres.",
        street2="",
        city="St. Albert",
        state="AB",
        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
    )
github EasyPost / easypost-python / tests / test_shipment.py View on Github external
def test_shipment_creation():
    # We create a shipment and assert on values saved.

    # create a to address and a from address
    to_address = easypost.Address.create(
        name="Sawyer Bateman",
        street1="1A Larkspur Cres.",
        street2="",
        city="St. Albert",
        state="AB",
        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",
github EasyPost / easypost-python / examples / address.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

# create address
address = easypost.Address.create(
    company="EasyPost",
    street1="118 2nd St",
    street2="4th Fl",
    city="San Francisco",
    state="CA",
    zip="94105",
    phone="415-456-7890"
)

verified_address = address.verify()

print(verified_address)
github EasyPost / easypost-python / examples / example.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# easypost.api_base = 'http://localhost:5000/v2'

# create addresses
to_address = easypost.Address.create(
    name="Sawyer Bateman",
    street1="1A Larkspur Cres.",
    street2="",
    city="St. Albert",
    state="AB",
    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",
github EasyPost / easypost-python / examples / unicode.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

# unicode
state = u'DELEGACI\xf3N BENITO JU\xe1REZ'

address = easypost.Address.create(state=state)

assert address.state == state

# bytestring
address = easypost.Address.create(state=state.encode('utf-8'))
assert address.state == state
github EasyPost / easypost-python / examples / example.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'
# easypost.api_base = 'http://localhost:5000/v2'

# create addresses
to_address = easypost.Address.create(
    name="Sawyer Bateman",
    street1="1A Larkspur Cres.",
    street2="",
    city="St. Albert",
    state="AB",
    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"
)

# 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
github EasyPost / easypost-python / examples / unicode.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

# unicode
state = u'DELEGACI\xf3N BENITO JU\xe1REZ'

address = easypost.Address.create(state=state)

assert address.state == state

# bytestring
address = easypost.Address.create(state=state.encode('utf-8'))
assert address.state == state
github EasyPost / easypost-python / examples / address_verify_strict_failure.py View on Github external
import easypost
easypost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

try:
    # this request will raise an error
    address = easypost.Address.create(
        verify_strict=["delivery"],
        street1="UNDELIEVRABLE ST",
        city="San Francisco",
        state="CA",
        zip="94105",
        country="US",
        company="EasyPost",
        phone="415-456-7890"
    )
except easypost.Error as e:
    print(e.http_body)