Skip to content

Latest commit

 

History

History
210 lines (149 loc) · 6.07 KB

customer-groups.md

File metadata and controls

210 lines (149 loc) · 6.07 KB

Customer Groups

CustomerGroupsApi customerGroupsApi = client.getCustomerGroupsApi();

Class Name

CustomerGroupsApi

Methods

List Customer Groups

Retrieves the list of customer groups of a business.

CompletableFuture<ListCustomerGroupsResponse> listCustomerGroupsAsync(
    final String cursor,
    final Integer limit)

Parameters

Parameter Type Tags Description
cursor String Query, Optional A pagination cursor returned by a previous call to this endpoint.
Provide this cursor to retrieve the next set of results for your original query.

For more information, see Pagination.
limit Integer Query, Optional The maximum number of results to return in a single page. This limit is advisory. The response might contain more or fewer results.
If the limit is less than 1 or greater than 50, Square returns a 400 VALUE_TOO_LOW or 400 VALUE_TOO_HIGH error. The default value is 50.

For more information, see Pagination.

Response Type

ListCustomerGroupsResponse

Example Usage

customerGroupsApi.listCustomerGroupsAsync(null, null).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Create Customer Group

Creates a new customer group for a business.

The request must include the name value of the group.

CompletableFuture<CreateCustomerGroupResponse> createCustomerGroupAsync(
    final CreateCustomerGroupRequest body)

Parameters

Parameter Type Tags Description
body CreateCustomerGroupRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

CreateCustomerGroupResponse

Example Usage

CreateCustomerGroupRequest body = new CreateCustomerGroupRequest.Builder(
    new CustomerGroup.Builder(
        "Loyal Customers"
    )
    .build()
)
.build();

customerGroupsApi.createCustomerGroupAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Delete Customer Group

Deletes a customer group as identified by the group_id value.

CompletableFuture<DeleteCustomerGroupResponse> deleteCustomerGroupAsync(
    final String groupId)

Parameters

Parameter Type Tags Description
groupId String Template, Required The ID of the customer group to delete.

Response Type

DeleteCustomerGroupResponse

Example Usage

String groupId = "group_id0";

customerGroupsApi.deleteCustomerGroupAsync(groupId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Retrieve Customer Group

Retrieves a specific customer group as identified by the group_id value.

CompletableFuture<RetrieveCustomerGroupResponse> retrieveCustomerGroupAsync(
    final String groupId)

Parameters

Parameter Type Tags Description
groupId String Template, Required The ID of the customer group to retrieve.

Response Type

RetrieveCustomerGroupResponse

Example Usage

String groupId = "group_id0";

customerGroupsApi.retrieveCustomerGroupAsync(groupId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Update Customer Group

Updates a customer group as identified by the group_id value.

CompletableFuture<UpdateCustomerGroupResponse> updateCustomerGroupAsync(
    final String groupId,
    final UpdateCustomerGroupRequest body)

Parameters

Parameter Type Tags Description
groupId String Template, Required The ID of the customer group to update.
body UpdateCustomerGroupRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

UpdateCustomerGroupResponse

Example Usage

String groupId = "group_id0";
UpdateCustomerGroupRequest body = new UpdateCustomerGroupRequest.Builder(
    new CustomerGroup.Builder(
        "Loyal Customers"
    )
    .build()
)
.build();

customerGroupsApi.updateCustomerGroupAsync(groupId, body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});