Skip to content

Latest commit

 

History

History
214 lines (149 loc) · 9.97 KB

File metadata and controls

214 lines (149 loc) · 9.97 KB

ServiceGroups

(service_groups)

Overview

A service group is a set of service levels grouped together. Rates at checkout uses services groups to present available shipping options to customers in their shopping basket.

Available Operations

  • list - List all service groups
  • create - Create a new service group
  • update - Update an existing service group
  • delete - Delete a service group

list

Returns a list of service group objects.

Example Usage

from shippo import Shippo


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.service_groups.list(request={})

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request operations.ListServiceGroupsRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

List[components.ServiceGroup]

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

create

Creates a new service group.

Example Usage

from shippo import Shippo
from shippo.models import components


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.service_groups.create(request={
        "description": "USPS shipping options",
        "name": "USPS Shipping",
        "type": components.ServiceGroupTypeEnum.FLAT_RATE,
        "service_levels": [
            {
                "account_object_id": "80feb1633d4a43c898f0058506cfd82d",
                "service_level_token": "ups_next_day_air_saver",
            },
        ],
        "flat_rate": "5",
        "flat_rate_currency": "USD",
        "free_shipping_threshold_currency": "USD",
        "free_shipping_threshold_min": "5",
        "rate_adjustment": 15,
    })

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request components.ServiceGroupCreateRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.ServiceGroup

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

update

Updates an existing service group object.
The object_id cannot be updated as it is the unique identifier for the object.

Example Usage

from shippo import Shippo
from shippo.models import components


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    res = s_client.service_groups.update(request={
        "description": "USPS shipping options",
        "name": "USPS Shipping",
        "type": components.ServiceGroupTypeEnum.FLAT_RATE,
        "object_id": "80feb1633d4a43c898f005850",
        "is_active": True,
        "service_levels": [
            {
                "account_object_id": "80feb1633d4a43c898f0058506cfd82d",
                "service_level_token": "ups_next_day_air_saver",
            },
            {
                "account_object_id": "80feb1633d4a43c898f0058506cfd82d",
                "service_level_token": "ups_next_day_air_saver",
            },
            {
                "account_object_id": "80feb1633d4a43c898f0058506cfd82d",
                "service_level_token": "ups_next_day_air_saver",
            },
        ],
        "flat_rate": "5",
        "flat_rate_currency": "USD",
        "free_shipping_threshold_currency": "USD",
        "free_shipping_threshold_min": "5",
        "rate_adjustment": 15,
    })

    assert res is not None

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request components.ServiceGroupUpdateRequest ✔️ The request object to use for the request.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

components.ServiceGroup

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*

delete

Deletes an existing service group using an object ID.

Example Usage

from shippo import Shippo


with Shippo(
    api_key_header="<YOUR_API_KEY_HERE>",
    shippo_api_version="2018-02-08",
) as s_client:

    s_client.service_groups.delete(service_group_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
service_group_id str ✔️ Object ID of the service group
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
errors.SDKError 4XX, 5XX */*