parcelbright package

Module contents

class parcelbright.Address(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

company = <schematics.types.base.StringType object>
country_code = <schematics.types.base.StringType object>
line1 = <schematics.types.base.StringType object>
line2 = <schematics.types.base.StringType object>
name = <schematics.types.base.StringType object>
phone = <schematics.types.base.StringType object>
postcode = <schematics.types.base.StringType object>
town = <schematics.types.base.StringType object>
exception parcelbright.BadRequest(message, response=None)[source]

Bases: parcelbright.ParcelBrightAPIException

Raised when server response is 400

class parcelbright.Client(api_key, sandbox=False, **kwargs)[source]

Bases: object

Client to send configurated requests

delete(request, **kwargs)[source]
get(request, **kwargs)[source]
head(request, **kwargs)[source]
classmethod instance(**kwargs)[source]
patch(request, **kwargs)[source]
post(request, **kwargs)[source]
put(request, **kwargs)[source]
request(verb, request, **kwargs)[source]
set_headers()[source]
class parcelbright.DateTimeType(formats=None, serialized_format=None, **kwargs)[source]

Bases: schematics.types.base.DateTimeType

MESSAGES = {'parse': u'Could not parse {0}. Should be ISO8601.', 'required': u'This field is required.', 'parse_formats': u'Could not parse {0}. Valid formats: {1}', 'choices': u'Value must be one of {0}.'}
to_native(value, context=None)[source]
exception parcelbright.NotFound(message, response=None)[source]

Bases: parcelbright.ParcelBrightAPIException

Raised when server response is 404

class parcelbright.Parcel(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

Parcel container

height = <schematics.types.base.DecimalType object>
length = <schematics.types.base.DecimalType object>
weight = <schematics.types.base.DecimalType object>
width = <schematics.types.base.DecimalType object>
exception parcelbright.ParcelBrightAPIException(message, response=None)[source]

Bases: parcelbright.ParcelBrightException

ParcelBright errors Base

Args:
message: error message response: requests.response instance
class parcelbright.ParcelBrightError(response)[source]

Bases: object

Handler for API errors

error_400()[source]
error_404()[source]
process()[source]
exception parcelbright.ParcelBrightException[source]

Bases: exceptions.Exception

class parcelbright.Shipment(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

book(rate_code, pickup_date=None)[source]
cancel()[source]
consignment = <schematics.types.base.StringType object>
contents = <schematics.types.base.StringType object>
create()[source]
customer_reference = <schematics.types.base.StringType object>
customs = <schematics.types.base.StringType object>
customs_url = <schematics.types.base.URLType object>
estimated_value = <schematics.types.base.DecimalType object>
classmethod find(id)[source]
from_address = <schematics.types.compound.ModelType object at 0x7fc64536f210 for <class 'parcelbright.Address'>>
id = <schematics.types.base.StringType object>
label_url = <schematics.types.base.URLType object>
liability_amount = <schematics.types.base.DecimalType object>
parcel = <schematics.types.compound.ModelType object at 0x7fc64536f090 for <class 'parcelbright.Parcel'>>
pickup_confirmation = <schematics.types.base.StringType object>
pickup_date = <schematics.types.base.DateType object>
rates = <schematics.types.compound.ListType object>
service = <schematics.types.compound.ModelType object at 0x7fc64536f510 for <class 'parcelbright.ShipmentService'>>
state = <schematics.types.base.StringType object>
to_address = <schematics.types.compound.ModelType object at 0x7fc64536f150 for <class 'parcelbright.Address'>>
track(refresh=False)[source]
exception parcelbright.ShipmentNotCompletedException[source]

Bases: parcelbright.ParcelBrightException

Raised when Shipment.state is different than completed

class parcelbright.ShipmentRate(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

carrier = <schematics.types.base.StringType object>
code = <schematics.types.base.StringType object>
cutoff = <parcelbright.DateTimeType object>
delivery_estimate = <parcelbright.DateTimeType object>
name = <schematics.types.base.StringType object>
pickup_date = <schematics.types.base.DateType object>
price = <schematics.types.base.DecimalType object>
service_type = <schematics.types.base.StringType object>
transit_days = <schematics.types.base.IntType object>
vat = <schematics.types.base.DecimalType object>
class parcelbright.ShipmentService(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

carrier = <schematics.types.base.StringType object>
code = <schematics.types.base.StringType object>
name = <schematics.types.base.StringType object>
price = <schematics.types.base.DecimalType object>
service_type = <schematics.types.base.StringType object>
vat = <schematics.types.base.DecimalType object>
class parcelbright.ShipmentTrack(raw_data=None, deserialize_mapping=None, strict=True)[source]

Bases: schematics.models.Model

description = <schematics.types.base.StringType object>
detail = <schematics.types.base.StringType object>
location = <schematics.types.base.StringType object>
timestamp = <schematics.types.base.DateType object>
exception parcelbright.TrackingError(message, response=None)[source]

Bases: parcelbright.BadRequest

Raised when Shipment.track() responses with 400

exception parcelbright.ValidationError[source]

Bases: parcelbright.ParcelBrightException

Raised when parcelbright entity like Address, Parcel or Shipment is invalid

parcelbright.api_key = None

api_key used to authorize with API

parcelbright.base_url = 'https://api.parcelbright.com/'

Base url for production version

parcelbright.sandbox = False

Whether use sandbox API version not

parcelbright.sandbox_base_url = 'https://api.sandbox.parcelbright.com/'

Base url for sandbox version