Skip to content

Latest commit

 

History

History
253 lines (185 loc) · 19.2 KB

README.md

File metadata and controls

253 lines (185 loc) · 19.2 KB

ServiceGroups

(serviceGroups())

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

package hello.world;

import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.ListServiceGroupsResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Shippo sdk = Shippo.builder()
                .apiKeyHeader("<YOUR_API_KEY_HERE>")
                .shippoApiVersion("2018-02-08")
            .build();

        ListServiceGroupsResponse res = sdk.serviceGroups().list()
                .shippoApiVersion("2018-02-08")
                .call();

        if (res.serviceGroupListResponse().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
shippoApiVersion Optional<String> Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

ListServiceGroupsResponse

Errors

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

create

Creates a new service group.

Example Usage

package hello.world;

import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.ServiceGroupAccountAndServiceLevel;
import com.goshippo.shippo_sdk.models.components.ServiceGroupCreateRequest;
import com.goshippo.shippo_sdk.models.components.ServiceGroupTypeEnum;
import com.goshippo.shippo_sdk.models.operations.CreateServiceGroupResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Shippo sdk = Shippo.builder()
                .apiKeyHeader("<YOUR_API_KEY_HERE>")
                .shippoApiVersion("2018-02-08")
            .build();

        CreateServiceGroupResponse res = sdk.serviceGroups().create()
                .shippoApiVersion("2018-02-08")
                .serviceGroupCreateRequest(ServiceGroupCreateRequest.builder()
                    .description("USPS shipping options")
                    .name("USPS Shipping")
                    .type(ServiceGroupTypeEnum.FLAT_RATE)
                    .serviceLevels(List.of(
                        ServiceGroupAccountAndServiceLevel.builder()
                            .accountObjectId("80feb1633d4a43c898f0058506cfd82d")
                            .serviceLevelToken("ups_next_day_air_saver")
                            .build()))
                    .flatRate("5")
                    .flatRateCurrency("USD")
                    .freeShippingThresholdCurrency("USD")
                    .freeShippingThresholdMin("5")
                    .rateAdjustment(15L)
                    .build())
                .call();

        if (res.serviceGroup().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
shippoApiVersion Optional<String> Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08
serviceGroupCreateRequest ServiceGroupCreateRequest ✔️ N/A

Response

CreateServiceGroupResponse

Errors

Error Type Status Code Content Type
models/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

package hello.world;

import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.ServiceGroupAccountAndServiceLevel;
import com.goshippo.shippo_sdk.models.components.ServiceGroupTypeEnum;
import com.goshippo.shippo_sdk.models.components.ServiceGroupUpdateRequest;
import com.goshippo.shippo_sdk.models.operations.UpdateServiceGroupResponse;
import java.lang.Exception;
import java.util.List;

public class Application {

    public static void main(String[] args) throws Exception {

        Shippo sdk = Shippo.builder()
                .apiKeyHeader("<YOUR_API_KEY_HERE>")
                .shippoApiVersion("2018-02-08")
            .build();

        UpdateServiceGroupResponse res = sdk.serviceGroups().update()
                .shippoApiVersion("2018-02-08")
                .serviceGroupUpdateRequest(ServiceGroupUpdateRequest.builder()
                    .description("USPS shipping options")
                    .name("USPS Shipping")
                    .type(ServiceGroupTypeEnum.FLAT_RATE)
                    .objectId("80feb1633d4a43c898f005850")
                    .isActive(true)
                    .serviceLevels(List.of(
                        ServiceGroupAccountAndServiceLevel.builder()
                            .accountObjectId("80feb1633d4a43c898f0058506cfd82d")
                            .serviceLevelToken("ups_next_day_air_saver")
                            .build()))
                    .flatRate("5")
                    .flatRateCurrency("USD")
                    .freeShippingThresholdCurrency("USD")
                    .freeShippingThresholdMin("5")
                    .rateAdjustment(15L)
                    .build())
                .call();

        if (res.serviceGroup().isPresent()) {
            // handle response
        }
    }
}

Parameters

Parameter Type Required Description Example
shippoApiVersion Optional<String> Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08
serviceGroupUpdateRequest Optional<ServiceGroupUpdateRequest> N/A

Response

UpdateServiceGroupResponse

Errors

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

delete

Deletes an existing service group using an object ID.

Example Usage

package hello.world;

import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.DeleteServiceGroupResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        Shippo sdk = Shippo.builder()
                .apiKeyHeader("<YOUR_API_KEY_HERE>")
                .shippoApiVersion("2018-02-08")
            .build();

        DeleteServiceGroupResponse res = sdk.serviceGroups().delete()
                .serviceGroupId("<id>")
                .shippoApiVersion("2018-02-08")
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description Example
serviceGroupId String ✔️ Object ID of the service group
shippoApiVersion Optional<String> Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

DeleteServiceGroupResponse

Errors

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