Class: Square::CustomerSegmentsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/customer_segments_api.rb

Overview

CustomerSegmentsApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#list_customer_segments(cursor: nil, limit: nil) ⇒ ApiResponse

Retrieves the list of customer segments of a business. previous calls to ‘ListCustomerSegments`. This cursor is used to retrieve the next set of query results. For more information, see [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination). 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](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination).

Parameters:

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

  • limit (Integer) (defaults to: nil)

    Optional parameter: The maximum number of results

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/square/api/customer_segments_api.rb', line 18

def list_customer_segments(cursor: nil,
                           limit: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/customers/segments',
                                 'default')
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(limit, key: 'limit'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_customer_segment(segment_id:) ⇒ ApiResponse

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

Parameters:

  • segment_id (String)

    Required parameter: The Square-issued ID of the

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/square/api/customer_segments_api.rb', line 40

def retrieve_customer_segment(segment_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/customers/segments/{segment_id}',
                                 'default')
               .template_param(new_parameter(segment_id, key: 'segment_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize))
                .is_api_response(true)
                .convertor(ApiResponse.method(:create)))
    .execute
end