Quoter Module

The Quoter module handles ABC API quote operations with support for Quick Quote (qq) and Quote Request (qr) modes.

class ABConnect.Quoter.Quoter(*args, **kwargs)[source]

Bases: object

Provides functionality for requesting and handling quotes via the ABC API.

Parameters:
  • env (str) – ‘staging’ or ‘’ for production.

  • JobType (str) – ‘Regular’ for full service, ‘3PL’ for eLabel. Default is ‘Regular’.

  • type (str) – ‘qr’ for quote request or ‘qq’ for quick quote. Default is ‘qq’.

  • auto_book (bool) – If True, attempts to book the quote automatically.

Usage:

q = Quoter(env=’staging’, type=’qr’, auto_book=True) or q = Quoter()

__init__(*args, **kwargs)[source]
load_request(data)[source]

Loads the request payload.

Parameters:

data (dict) – The JSON payload to be sent to the API.

call_quoter()[source]

Calls the ABC API with the current request data. Raises an exception if the API call fails.

parse_qr_response()[source]

Parses the quote request (qr) response from the API.

parse_qq_response()[source]

Parses the quick quote (qq) response from the API.

parse_response()[source]

Parses the API response based on the request type.

book()[source]

Attempts to book the quote using the booking URL. Raises an exception if the booking fails.

cleanup()[source]

Cleans up stored request and response data.

run()[source]

Executes the full quoting process.

Raises:

Exception – If no request data is loaded or if any step fails.

Returns:

The Quoter instance after processing.

Return type:

self

get_quote_summary()[source]

Returns a formatted summary of the quote.

Return type:

str

Returns:

A string with quote details.

Quoter Class

class ABConnect.Quoter.Quoter(*args, **kwargs)[source]

Bases: object

Provides functionality for requesting and handling quotes via the ABC API.

Parameters:
  • env (str) – ‘staging’ or ‘’ for production.

  • JobType (str) – ‘Regular’ for full service, ‘3PL’ for eLabel. Default is ‘Regular’.

  • type (str) – ‘qr’ for quote request or ‘qq’ for quick quote. Default is ‘qq’.

  • auto_book (bool) – If True, attempts to book the quote automatically.

Usage:

q = Quoter(env=’staging’, type=’qr’, auto_book=True) or q = Quoter()

__init__(*args, **kwargs)[source]
load_request(data)[source]

Loads the request payload.

Parameters:

data (dict) – The JSON payload to be sent to the API.

call_quoter()[source]

Calls the ABC API with the current request data. Raises an exception if the API call fails.

parse_qr_response()[source]

Parses the quote request (qr) response from the API.

parse_qq_response()[source]

Parses the quick quote (qq) response from the API.

parse_response()[source]

Parses the API response based on the request type.

book()[source]

Attempts to book the quote using the booking URL. Raises an exception if the booking fails.

cleanup()[source]

Cleans up stored request and response data.

run()[source]

Executes the full quoting process.

Raises:

Exception – If no request data is loaded or if any step fails.

Returns:

The Quoter instance after processing.

Return type:

self

get_quote_summary()[source]

Returns a formatted summary of the quote.

Return type:

str

Returns:

A string with quote details.

Quote Types

Quick Quote (qq)

Quick quotes provide immediate pricing information without creating a job:

from ABConnect.Quoter import Quoter

quoter = Quoter(env='staging')

# Get a quick quote
response = quoter.qq(
    customer_id='CUST123',
    origin_zip='10001',
    destination_zip='90001',
    weight=1000,
    declared_value=5000
)

print(f"Quote Price: ${response['price']}")

Quote Request (qr)

Quote requests create a job and return a job ID:

# Create a quote request
job_id = quoter.qr(
    customer_id='CUST123',
    origin_address={
        'street': '123 Main St',
        'city': 'New York',
        'state': 'NY',
        'zip': '10001'
    },
    destination_address={
        'street': '456 Oak Ave',
        'city': 'Los Angeles',
        'state': 'CA',
        'zip': '90001'
    },
    items=[
        {'description': 'Box 1', 'weight': 50},
        {'description': 'Box 2', 'weight': 75}
    ]
)

print(f"Job Created: {job_id}")

Auto-Booking

The Quoter supports automatic booking after quote creation:

# Quote with auto-booking
job_id = quoter.qr(
    customer_id='CUST123',
    # ... other parameters
    auto_book=True
)

Integration with Builder

The Quoter uses the Builder module internally for request construction:

# The Quoter automatically uses Builder for request formatting
# You can also manually build requests if needed
from ABConnect.Builder import APIRequestBuilder

builder = APIRequestBuilder()
request_data = builder.build(**quote_params)

# Then use with Quoter
response = quoter._send_request(request_data)

Error Handling

from ABConnect.exceptions import ABConnectError

try:
    response = quoter.qq(invalid_params)
except ABConnectError as e:
    print(f"Quote failed: {e}")

Environment Configuration

The Quoter supports both staging and production environments:

# Staging environment (default)
quoter_staging = Quoter(env='staging')

# Production environment
quoter_prod = Quoter(env='production')