Class: SquareLegacy::CustomerGroupsApi
- Defined in:
- lib/square_legacy/api/customer_groups_api.rb
Overview
CustomerGroupsApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#create_customer_group(body:) ⇒ ApiResponse
Creates a new customer group for a business.
-
#delete_customer_group(group_id:) ⇒ ApiResponse
Deletes a customer group as identified by the
group_idvalue. -
#list_customer_groups(cursor: nil, limit: nil) ⇒ ApiResponse
Retrieves the list of customer groups of a business.
-
#retrieve_customer_group(group_id:) ⇒ ApiResponse
Retrieves a specific customer group as identified by the
group_idvalue. -
#update_customer_group(group_id:, body:) ⇒ ApiResponse
Updates a customer group as identified by the
group_idvalue.
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 SquareLegacy::BaseApi
Instance Method Details
#create_customer_group(body:) ⇒ ApiResponse
Creates a new customer group for a business.
The request must include the name value of the group.
containing the fields to POST for the request. See the corresponding
object definition for field details.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/square_legacy/api/customer_groups_api.rb', line 41 def create_customer_group(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/customers/groups', 'default') .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |
#delete_customer_group(group_id:) ⇒ ApiResponse
Deletes a customer group as identified by the group_id value.
to delete.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/square_legacy/api/customer_groups_api.rb', line 62 def delete_customer_group(group_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/v2/customers/groups/{group_id}', 'default') .template_param(new_parameter(group_id, key: 'group_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 |
#list_customer_groups(cursor: nil, limit: nil) ⇒ ApiResponse
Retrieves the list of customer groups of a business.
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](https://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 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](https://developer.squareup.com/docs/build-basics/common-api-p
atterns/pagination).
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/square_legacy/api/customer_groups_api.rb', line 18 def list_customer_groups(cursor: nil, limit: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/groups', '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_group(group_id:) ⇒ ApiResponse
Retrieves a specific customer group as identified by the group_id value.
to retrieve.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/square_legacy/api/customer_groups_api.rb', line 82 def retrieve_customer_group(group_id:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/groups/{group_id}', 'default') .template_param(new_parameter(group_id, key: 'group_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 |
#update_customer_group(group_id:, body:) ⇒ ApiResponse
Updates a customer group as identified by the group_id value.
to update.
containing the fields to POST for the request. See the corresponding
object definition for field details.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/square_legacy/api/customer_groups_api.rb', line 105 def update_customer_group(group_id:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/v2/customers/groups/{group_id}', 'default') .template_param(new_parameter(group_id, key: 'group_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('global'))) .response(new_response_handler .deserializer(APIHelper.method(:json_deserialize)) .is_api_response(true) .convertor(ApiResponse.method(:create))) .execute end |