Skip to content

Latest commit

 

History

History
216 lines (157 loc) · 5.46 KB

customer-groups.md

File metadata and controls

216 lines (157 loc) · 5.46 KB

Customer Groups

ICustomerGroupsApi customerGroupsApi = client.CustomerGroupsApi;

Class Name

CustomerGroupsApi

Methods

List Customer Groups

Retrieves the list of customer groups of a business.

ListCustomerGroupsAsync(
    string cursor = null,
    int? limit = null)

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 int? 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

Task<Models.ListCustomerGroupsResponse>

Example Usage

try
{
    ListCustomerGroupsResponse result = await customerGroupsApi.ListCustomerGroupsAsync();
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Create Customer Group

Creates a new customer group for a business.

The request must include the name value of the group.

CreateCustomerGroupAsync(
    Models.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

Task<Models.CreateCustomerGroupResponse>

Example Usage

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

try
{
    CreateCustomerGroupResponse result = await customerGroupsApi.CreateCustomerGroupAsync(body);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Delete Customer Group

Deletes a customer group as identified by the group_id value.

DeleteCustomerGroupAsync(
    string groupId)

Parameters

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

Response Type

Task<Models.DeleteCustomerGroupResponse>

Example Usage

string groupId = "group_id0";
try
{
    DeleteCustomerGroupResponse result = await customerGroupsApi.DeleteCustomerGroupAsync(groupId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Retrieve Customer Group

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

RetrieveCustomerGroupAsync(
    string groupId)

Parameters

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

Response Type

Task<Models.RetrieveCustomerGroupResponse>

Example Usage

string groupId = "group_id0";
try
{
    RetrieveCustomerGroupResponse result = await customerGroupsApi.RetrieveCustomerGroupAsync(groupId);
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}

Update Customer Group

Updates a customer group as identified by the group_id value.

UpdateCustomerGroupAsync(
    string groupId,
    Models.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

Task<Models.UpdateCustomerGroupResponse>

Example Usage

string groupId = "group_id0";
UpdateCustomerGroupRequest body = new UpdateCustomerGroupRequest.Builder(
    new CustomerGroup.Builder(
        "Loyal Customers"
    )
    .Build()
)
.Build();

try
{
    UpdateCustomerGroupResponse result = await customerGroupsApi.UpdateCustomerGroupAsync(
        groupId,
        body
    );
}
catch (ApiException e)
{
    // TODO: Handle exception here
    Console.WriteLine(e.Message);
}