darbiadev_ups.ups_services

UPSServices.

Classes

_AuthType

An enum for the authentication types.

UPSServices

A class wrapping UPS' API.

Module Contents

class darbiadev_ups.ups_services._AuthType(*args, **kwds)[source]

Bases: enum.Enum

An enum for the authentication types.

HEADERS[source]
JSON[source]
class darbiadev_ups.ups_services.UPSServices(base_url: str, username: str, password: str, access_license_number: str)[source]

A class wrapping UPS’ API.

TRACKING_REGEX: Final[str] = '1Z[A-Z0-9]{6}[0-9]{10}'[source]
TRACKING_URL: Final[str] = 'https://wwwapps.ups.com/WebTracking/processInputRequest?TypeOfInquiryNumber=T&InquiryNumber1={tr...[source]
base_url: str[source]
__username: str[source]
__password: str[source]
__access_license_number: str[source]
__auth_headers() dict[str, str][source]

Return authentication headers as a dictionary.

__auth_dict() dict[str, dict[str, dict[str, str]]][source]

Return authentication JSON as a dictionary.

make_request(method: str, auth_type: _AuthType, service: str, data: dict[str, Any], timeout: int = 500) dict[source]

Make a request to UPS’ API.

track(tracking_number: str) dict[source]

Get tracking details for a tracking number.

validate_address(street_lines: list[str], city: str, state: str, postal_code: str, country: str) dict[str, str][source]

Validate an address.

time_in_transit(from_state: str, from_postal_code: str, from_country: str, to_state: str, to_postal_code: str, to_country: str, weight: str, pickup_date: str | None = None) dict[str, str | list[dict[str, str]]][source]

Estimate transit time.