Skip to content

Latest commit

 

History

History
88 lines (57 loc) · 2.92 KB

customer-segments.md

File metadata and controls

88 lines (57 loc) · 2.92 KB

Customer Segments

$customerSegmentsApi = $client->getCustomerSegmentsApi();

Class Name

CustomerSegmentsApi

Methods

List Customer Segments

Retrieves the list of customer segments of a business.

function listCustomerSegments(?string $cursor = null, ?int $limit = null): ApiResponse

Parameters

Parameter Type Tags Description
cursor ?string Query, Optional A pagination cursor returned by previous calls to ListCustomerSegments.
This cursor is used to retrieve the next set of query results.

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 specified 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

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type ListCustomerSegmentsResponse.

Example Usage

$apiResponse = $customerSegmentsApi->listCustomerSegments();

if ($apiResponse->isSuccess()) {
    $listCustomerSegmentsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Retrieve Customer Segment

Retrieves a specific customer segment as identified by the segment_id value.

function retrieveCustomerSegment(string $segmentId): ApiResponse

Parameters

Parameter Type Tags Description
segmentId string Template, Required The Square-issued ID of the customer segment.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveCustomerSegmentResponse.

Example Usage

$segmentId = 'segment_id4';

$apiResponse = $customerSegmentsApi->retrieveCustomerSegment($segmentId);

if ($apiResponse->isSuccess()) {
    $retrieveCustomerSegmentResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());