Class: Square::Customers::CustomAttributes::Client
- Inherits:
-
Object
- Object
- Square::Customers::CustomAttributes::Client
- Defined in:
- lib/square/customers/custom_attributes/client.rb
Instance Method Summary collapse
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCustomerCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) associated with a customer profile.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetCustomerCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) associated with a customer profile.
- #initialize(client:) ⇒ Square::Customers::CustomAttributes::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListCustomerCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) associated with a customer profile.
-
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertCustomerCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) for a customer profile.
Constructor Details
#initialize(client:) ⇒ Square::Customers::CustomAttributes::Client
8 9 10 |
# File 'lib/square/customers/custom_attributes/client.rb', line 8 def initialize(client:) @client = client end |
Instance Method Details
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCustomerCustomAttributeResponse
Deletes a [custom attribute](entity:CustomAttribute) 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`.
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/square/customers/custom_attributes/client.rb', line 105 def delete(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "DELETE", path: "v2/customers/#{params[:customer_id]}/custom-attributes/#{params[:key]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteCustomerCustomAttributeResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetCustomerCustomAttributeResponse
Retrieves a [custom attribute](entity:CustomAttribute) 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`.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/square/customers/custom_attributes/client.rb', line 51 def get(request_options: {}, **params) _query_param_names = %w[with_definition version] _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/customers/#{params[:customer_id]}/custom-attributes/#{params[:key]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetCustomerCustomAttributeResponse.load(_response.body) end raise _response.body end |
#list(request_options: {}, **params) ⇒ Square::Types::ListCustomerCustomAttributesResponse
Lists the [custom attributes](entity:CustomAttribute) 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`.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/square/customers/custom_attributes/client.rb', line 22 def list(request_options: {}, **params) _query_param_names = %w[limit cursor with_definitions] _query = params.slice(*_query_param_names) params = params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/customers/#{params[:customer_id]}/custom-attributes", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListCustomerCustomAttributesResponse.load(_response.body) end raise _response.body end |
#upsert(request_options: {}, **params) ⇒ Square::Types::UpsertCustomerCustomAttributeResponse
Creates or updates a [custom attribute](entity:CustomAttribute) 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](api-endpoint:CustomerCustomAttributes-CreateCustomerCustomAttributeDefinition) 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`.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/square/customers/custom_attributes/client.rb', line 81 def upsert(request_options: {}, **params) _path_param_names = %w[customer_id key] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/#{params[:customer_id]}/custom-attributes/#{params[:key]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpsertCustomerCustomAttributeResponse.load(_response.body) end raise _response.body end |