(serviceGroups())
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.
- list - List all service groups
- create - Create a new service group
- update - Update an existing service group
- delete - Delete a service group
Returns a list of service group objects.
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
}
}
}
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 |
ListServiceGroupsResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Creates a new service group.
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
}
}
}
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 |
|
CreateServiceGroupResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Updates an existing service group object.
The object_id cannot be updated as it is the unique identifier for the object.
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
}
}
}
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 |
|
UpdateServiceGroupResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Deletes an existing service group using an object ID.
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
}
}
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 |
DeleteServiceGroupResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |