Class: SquareLegacy::CustomerCustomAttributesApi
- Defined in:
- lib/square_legacy/api/customer_custom_attributes_api.rb
Overview
CustomerCustomAttributesApi
Instance Attribute Summary
Attributes inherited from BaseApi
Instance Method Summary collapse
-
#bulk_upsert_customer_custom_attributes(body:) ⇒ ApiResponse
Creates or updates custom attributes for customer profiles as a bulk operation.
-
#create_customer_custom_attribute_definition(body:) ⇒ ApiResponse
Creates a customer-related custom attribute definition for a Square seller account.
-
#delete_customer_custom_attribute(customer_id:, key:) ⇒ ApiResponse
Deletes a custom attribute associated with a customer profile.
-
#delete_customer_custom_attribute_definition(key:) ⇒ ApiResponse
Deletes a customer-related custom attribute definition from a Square seller account.
-
#list_customer_custom_attribute_definitions(limit: nil, cursor: nil) ⇒ ApiResponse
Lists the customer-related custom attribute definitions that belong to a Square seller account.
-
#list_customer_custom_attributes(customer_id:, limit: nil, cursor: nil, with_definitions: false) ⇒ ApiResponse
Lists the custom attributes associated with a customer profile.
-
#retrieve_customer_custom_attribute(customer_id:, key:, with_definition: false, version: nil) ⇒ ApiResponse
Retrieves a custom attribute associated with a customer profile.
-
#retrieve_customer_custom_attribute_definition(key:, version: nil) ⇒ ApiResponse
Retrieves a customer-related custom attribute definition from a Square seller account.
-
#update_customer_custom_attribute_definition(key:, body:) ⇒ ApiResponse
Updates a customer-related custom attribute definition for a Square seller account.
-
#upsert_customer_custom_attribute(customer_id:, key:, body:) ⇒ ApiResponse
Creates or updates a custom attribute for a customer profile.
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
#bulk_upsert_customer_custom_attributes(body:) ⇒ ApiResponse
Creates or updates custom attributes for customer
profiles as a bulk operation.
Use this endpoint to set the value of one or more custom attributes for
one or more customer profiles.
A custom attribute is based on a custom attribute definition in a Square
seller account, which is
created using the
[CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
teCustomerCustomAttributeDefinition) endpoint.
This BulkUpsertCustomerCustomAttributes endpoint accepts a map of 1 to
25 individual upsert
requests and returns a map of individual upsert responses. Each upsert
request has a unique ID
and provides a customer ID and custom attribute. Each upsert response is
returned with the ID
of the corresponding request.
To create or update a custom attribute owned by another application, the
visibility setting
must be VISIBILITY_READ_WRITE_VALUES. Note that seller-defined custom
attributes
(also known as custom fields) are always set to
VISIBILITY_READ_WRITE_VALUES.
parameter: An object containing the fields to POST for the request. See
the corresponding object definition for field details.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 204 def bulk_upsert_customer_custom_attributes(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/customers/custom-attributes/bulk-upsert', '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 |
#create_customer_custom_attribute_definition(body:) ⇒ ApiResponse
Creates a customer-related custom attribute
definition for a Square seller account.
Use this endpoint to define a custom attribute that can be associated with
customer profiles.
A custom attribute definition specifies the key, visibility, schema,
and other properties
for a custom attribute. After the definition is created, you can call
[UpsertCustomerCustomAttribute]($e/CustomerCustomAttributes/UpsertCustomer
CustomAttribute) or
[BulkUpsertCustomerCustomAttributes]($e/CustomerCustomAttributes/BulkUpser
tCustomerCustomAttributes)
to set the custom attribute for customer profiles in the seller's Customer
Directory.
Sellers can view all custom attributes in exported customer data,
including those set to
VISIBILITY_HIDDEN.
parameter: An object containing the fields to POST for the request. See
the corresponding object definition for field details.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 65 def create_customer_custom_attribute_definition(body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/customers/custom-attribute-definitions', '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_custom_attribute(customer_id:, key:) ⇒ ApiResponse
Deletes a custom attribute associated with a
customer profile.
To delete a custom attribute owned by another application, the
visibility setting must be
VISIBILITY_READ_WRITE_VALUES. Note that seller-defined custom attributes
(also known as custom fields) are always set to
VISIBILITY_READ_WRITE_VALUES.
customer profile.
delete. This key must match the key of a custom attribute definition in
the Square seller account. If the requesting application is not the
definition owner, you must use the qualified key.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 288 def delete_customer_custom_attribute(customer_id:, key:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/v2/customers/{customer_id}/custom-attributes/{key}', 'default') .template_param(new_parameter(customer_id, key: 'customer_id') .should_encode(true)) .template_param(new_parameter(key, key: 'key') .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 |
#delete_customer_custom_attribute_definition(key:) ⇒ ApiResponse
Deletes a customer-related custom attribute definition from a Square seller account. Deleting a custom attribute definition also deletes the corresponding custom attribute from all customer profiles in the seller's Customer Directory. Only the definition owner can delete a custom attribute definition. definition to delete.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 91 def delete_customer_custom_attribute_definition(key:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::DELETE, '/v2/customers/custom-attribute-definitions/{key}', 'default') .template_param(new_parameter(key, key: 'key') .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_custom_attribute_definitions(limit: nil, cursor: nil) ⇒ ApiResponse
Lists the customer-related custom attribute
definitions that belong to a Square seller
account.
When all response pages are retrieved, the results include all custom
attribute definitions
that are visible to the requesting application, including those that are
created by other
applications and set to VISIBILITY_READ_ONLY or
VISIBILITY_READ_WRITE_VALUES. Note that
seller-defined custom attributes (also known as custom fields) are always
set to VISIBILITY_READ_WRITE_VALUES.
to return in a single paged response. This limit is advisory. The response
might contain more or fewer results. The minimum value is 1 and the
maximum value is 100. The default value is 20. For more information, see
[Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
atterns/pagination).
paged response from the previous call to this endpoint. Provide this
cursor to retrieve the next page of results for your original request. For
more information, see
[Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
atterns/pagination).
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 28 def list_customer_custom_attribute_definitions(limit: nil, cursor: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/custom-attribute-definitions', 'default') .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .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_custom_attributes(customer_id:, limit: nil, cursor: nil, with_definitions: false) ⇒ ApiResponse
Lists the custom attributes associated with a
customer profile.
You can use the with_definitions query parameter to also retrieve custom
attribute definitions
in the same call.
When all response pages are retrieved, the results include all custom
attributes that are
visible to the requesting application, including those that are owned by
other applications
and set to VISIBILITY_READ_ONLY or VISIBILITY_READ_WRITE_VALUES.
customer profile.
to return in a single paged response. This limit is advisory. The response
might contain more or fewer results. The minimum value is 1 and the
maximum value is 100. The default value is 20. For more information, see
[Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
atterns/pagination).
paged response from the previous call to this endpoint. Provide this
cursor to retrieve the next page of results for your original request. For
more information, see
[Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
atterns/pagination).
Indicates whether to return the custom attribute
definition in the definition field of
each custom attribute. Set this parameter to true to get the name and
description of each custom attribute, information about the data type, or
other definition details. The default value is false.
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 252 def list_customer_custom_attributes(customer_id:, limit: nil, cursor: nil, with_definitions: false) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/{customer_id}/custom-attributes', 'default') .template_param(new_parameter(customer_id, key: 'customer_id') .should_encode(true)) .query_param(new_parameter(limit, key: 'limit')) .query_param(new_parameter(cursor, key: 'cursor')) .query_param(new_parameter(with_definitions, key: 'with_definitions')) .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_custom_attribute(customer_id:, key:, with_definition: false, version: nil) ⇒ ApiResponse
Retrieves a custom attribute associated with a
customer profile.
You can use the with_definition query parameter to also retrieve the
custom attribute definition
in the same call.
To retrieve a custom attribute owned by another application, the
visibility setting must be
VISIBILITY_READ_ONLY or VISIBILITY_READ_WRITE_VALUES. Note that
seller-defined custom attributes
(also known as custom fields) are always set to
VISIBILITY_READ_WRITE_VALUES.
customer profile.
retrieve. This key must match the key of a custom attribute definition
in the Square seller account. If the requesting application is not the
definition owner, you must use the qualified key.
Indicates whether to return the custom attribute
definition in the definition field of
the custom attribute. Set this parameter to true to get the name and
description of the custom attribute, information about the data type, or
other definition details. The default value is false.
custom attribute, which is used for strongly consistent reads to guarantee
that you receive the most up-to-date data. When included in the request,
Square returns the specified version or a higher version if one exists. If
the specified version is higher than the current version, Square returns a
BAD_REQUEST error.
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 337 def retrieve_customer_custom_attribute(customer_id:, key:, with_definition: false, version: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/{customer_id}/custom-attributes/{key}', 'default') .template_param(new_parameter(customer_id, key: 'customer_id') .should_encode(true)) .template_param(new_parameter(key, key: 'key') .should_encode(true)) .query_param(new_parameter(with_definition, key: 'with_definition')) .query_param(new_parameter(version, key: 'version')) .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_custom_attribute_definition(key:, version: nil) ⇒ ApiResponse
Retrieves a customer-related custom attribute
definition from a Square seller account.
To retrieve a custom attribute definition created by another application,
the visibility
setting must be VISIBILITY_READ_ONLY or VISIBILITY_READ_WRITE_VALUES.
Note that seller-defined custom attributes
(also known as custom fields) are always set to
VISIBILITY_READ_WRITE_VALUES.
definition to retrieve. If the requesting application is not the
definition owner, you must use the qualified key.
custom attribute definition, which is used for strongly consistent reads
to guarantee that you receive the most up-to-date data. When included in
the request, Square returns the specified version or a higher version if
one exists. If the specified version is higher than the current version,
Square returns a BAD_REQUEST error.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 125 def retrieve_customer_custom_attribute_definition(key:, version: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/v2/customers/custom-attribute-definitions/{key}', 'default') .template_param(new_parameter(key, key: 'key') .should_encode(true)) .query_param(new_parameter(version, key: 'version')) .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_custom_attribute_definition(key:, body:) ⇒ ApiResponse
Updates a customer-related custom attribute
definition for a Square seller account.
Use this endpoint to update the following fields: name, description,
visibility, or the
schema for a Selection data type.
Only the definition owner can update a custom attribute definition. Note
that sellers can view
all custom attributes in exported customer data, including those set to
VISIBILITY_HIDDEN.
definition to update.
parameter: An object containing the fields to POST for the request. See
the corresponding object definition for field details.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 158 def update_customer_custom_attribute_definition(key:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/v2/customers/custom-attribute-definitions/{key}', 'default') .template_param(new_parameter(key, key: 'key') .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 |
#upsert_customer_custom_attribute(customer_id:, key:, body:) ⇒ ApiResponse
Creates or updates a custom attribute for a customer
profile.
Use this endpoint to set the value of a custom attribute for a specified
customer profile.
A custom attribute is based on a custom attribute definition in a Square
seller account, which
is created using the
[CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
teCustomerCustomAttributeDefinition) endpoint.
To create or update a custom attribute owned by another application, the
visibility setting
must be VISIBILITY_READ_WRITE_VALUES. Note that seller-defined custom
attributes
(also known as custom fields) are always set to
VISIBILITY_READ_WRITE_VALUES.
customer profile.
create or update. This key must match the key of a custom attribute
definition in the Square seller account. If the requesting application is
not the definition owner, you must use the qualified key.
object containing the fields to POST for the request. See the
corresponding object definition for field details.
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/square_legacy/api/customer_custom_attributes_api.rb', line 385 def upsert_customer_custom_attribute(customer_id:, key:, body:) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/v2/customers/{customer_id}/custom-attributes/{key}', 'default') .template_param(new_parameter(customer_id, key: 'customer_id') .should_encode(true)) .template_param(new_parameter(key, key: 'key') .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 |