Class: Square::Customers::Client
- Inherits:
-
Object
- Object
- Square::Customers::Client
- Defined in:
- lib/square/customers/client.rb
Instance Method Summary collapse
-
#batch_create(request_options: {}, **params) ⇒ Square::Types::BulkCreateCustomersResponse
Creates multiple [customer profiles](entity:Customer) for a business.
-
#bulk_delete_customers(request_options: {}, **params) ⇒ Square::Types::BulkDeleteCustomersResponse
Deletes multiple customer profiles.
-
#bulk_retrieve_customers(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveCustomersResponse
Retrieves multiple customer profiles.
-
#bulk_update_customers(request_options: {}, **params) ⇒ Square::Types::BulkUpdateCustomersResponse
Updates multiple customer profiles.
- #cards ⇒ Square::Cards::Client
-
#create(request_options: {}, **params) ⇒ Square::Types::CreateCustomerResponse
Creates a new customer for a business.
- #custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
- #custom_attributes ⇒ Square::CustomAttributes::Client
-
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCustomerResponse
Deletes a customer profile from a business.
-
#get(request_options: {}, **params) ⇒ Square::Types::GetCustomerResponse
Returns details for a single customer.
- #groups ⇒ Square::Groups::Client
- #initialize(client:) ⇒ Square::Customers::Client constructor
-
#list(request_options: {}, **params) ⇒ Square::Types::ListCustomersResponse
Lists customer profiles associated with a Square account.
-
#search(request_options: {}, **params) ⇒ Square::Types::SearchCustomersResponse
Searches the customer profiles associated with a Square account using one or more supported query filters.
- #segments ⇒ Square::Segments::Client
-
#update(request_options: {}, **params) ⇒ Square::Types::UpdateCustomerResponse
Updates a customer profile.
Constructor Details
#initialize(client:) ⇒ Square::Customers::Client
7 8 9 |
# File 'lib/square/customers/client.rb', line 7 def initialize(client:) @client = client end |
Instance Method Details
#batch_create(request_options: {}, **params) ⇒ Square::Types::BulkCreateCustomersResponse
Creates multiple [customer profiles](entity:Customer) for a business.
This endpoint takes a map of individual create requests and returns a map of responses.
You must provide at least one of the following values in each create request:
-
‘given_name`
-
‘family_name`
-
‘company_name`
-
‘email_address`
-
‘phone_number`
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/square/customers/client.rb', line 77 def batch_create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/bulk-create", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkCreateCustomersResponse.load(_response.body) end raise _response.body end |
#bulk_delete_customers(request_options: {}, **params) ⇒ Square::Types::BulkDeleteCustomersResponse
Deletes multiple customer profiles.
The endpoint takes a list of customer IDs and returns a map of responses.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/square/customers/client.rb', line 97 def bulk_delete_customers(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/bulk-delete", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkDeleteCustomersResponse.load(_response.body) end raise _response.body end |
#bulk_retrieve_customers(request_options: {}, **params) ⇒ Square::Types::BulkRetrieveCustomersResponse
Retrieves multiple customer profiles.
This endpoint takes a list of customer IDs and returns a map of responses.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/square/customers/client.rb', line 117 def bulk_retrieve_customers(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/bulk-retrieve", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkRetrieveCustomersResponse.load(_response.body) end raise _response.body end |
#bulk_update_customers(request_options: {}, **params) ⇒ Square::Types::BulkUpdateCustomersResponse
Updates multiple customer profiles.
This endpoint takes a map of individual update requests and returns a map of responses.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/square/customers/client.rb', line 137 def bulk_update_customers(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/bulk-update", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::BulkUpdateCustomersResponse.load(_response.body) end raise _response.body end |
#cards ⇒ Square::Cards::Client
258 259 260 |
# File 'lib/square/customers/client.rb', line 258 def cards @cards ||= Square::Customers::Cards::Client.new(client: @client) end |
#create(request_options: {}, **params) ⇒ Square::Types::CreateCustomerResponse
Creates a new customer for a business.
You must provide at least one of the following values in your request to this endpoint:
-
‘given_name`
-
‘family_name`
-
‘company_name`
-
‘email_address`
-
‘phone_number`
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/square/customers/client.rb', line 49 def create(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::CreateCustomerResponse.load(_response.body) end raise _response.body end |
#custom_attribute_definitions ⇒ Square::CustomAttributeDefinitions::Client
243 244 245 |
# File 'lib/square/customers/client.rb', line 243 def custom_attribute_definitions @custom_attribute_definitions ||= Square::Customers::CustomAttributeDefinitions::Client.new(client: @client) end |
#custom_attributes ⇒ Square::CustomAttributes::Client
263 264 265 |
# File 'lib/square/customers/client.rb', line 263 def custom_attributes @custom_attributes ||= Square::Customers::CustomAttributes::Client.new(client: @client) end |
#delete(request_options: {}, **params) ⇒ Square::Types::DeleteCustomerResponse
Deletes a customer profile from a business.
To delete a customer profile that was created by merging existing profiles, you must use the ID of the newly created profile.
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/square/customers/client.rb', line 223 def delete(request_options: {}, **params) _query_param_names = ["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: "DELETE", path: "v2/customers/#{params[:customer_id]}", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::DeleteCustomerResponse.load(_response.body) end raise _response.body end |
#get(request_options: {}, **params) ⇒ Square::Types::GetCustomerResponse
Returns details for a single customer.
181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/square/customers/client.rb', line 181 def get(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/customers/#{params[:customer_id]}" ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::GetCustomerResponse.load(_response.body) end raise _response.body end |
#groups ⇒ Square::Groups::Client
248 249 250 |
# File 'lib/square/customers/client.rb', line 248 def groups @groups ||= Square::Customers::Groups::Client.new(client: @client) end |
#list(request_options: {}, **params) ⇒ Square::Types::ListCustomersResponse
Lists customer profiles associated with a Square account.
Under normal operating conditions, newly created or updated customer profiles become available for the listing operation in well under 30 seconds. Occasionally, propagation of the new or updated profiles can take closer to one minute or longer, especially during network incidents and outages.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/square/customers/client.rb', line 18 def list(request_options: {}, **params) _query_param_names = %w[cursor limit sort_field sort_order count] _query = params.slice(*_query_param_names) params.except(*_query_param_names) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "GET", path: "v2/customers", query: _query ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::ListCustomersResponse.load(_response.body) end raise _response.body end |
#search(request_options: {}, **params) ⇒ Square::Types::SearchCustomersResponse
Searches the customer profiles associated with a Square account using one or more supported query filters.
Calling ‘SearchCustomers` without any explicit query filter returns all customer profiles ordered alphabetically based on `given_name` and `family_name`.
Under normal operating conditions, newly created or updated customer profiles become available for the search operation in well under 30 seconds. Occasionally, propagation of the new or updated profiles can take closer to one minute or longer, especially during network incidents and outages.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/square/customers/client.rb', line 163 def search(request_options: {}, **params) _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "POST", path: "v2/customers/search", body: params ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::SearchCustomersResponse.load(_response.body) end raise _response.body end |
#segments ⇒ Square::Segments::Client
253 254 255 |
# File 'lib/square/customers/client.rb', line 253 def segments @segments ||= Square::Customers::Segments::Client.new(client: @client) end |
#update(request_options: {}, **params) ⇒ Square::Types::UpdateCustomerResponse
Updates a customer profile. This endpoint supports sparse updates, so only new or changed fields are required in the request. To add or update a field, specify the new value. To remove a field, specify ‘null`.
To update a customer profile that was created by merging existing profiles, you must use the ID of the newly created profile.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/square/customers/client.rb', line 201 def update(request_options: {}, **params) _path_param_names = ["customer_id"] _request = Square::Internal::JSON::Request.new( base_url: [:base_url] || Square::Environment::SANDBOX, method: "PUT", path: "v2/customers/#{params[:customer_id]}", body: params.except(*_path_param_names) ) _response = @client.send(_request) if _response.code >= "200" && _response.code < "300" return Square::Types::UpdateCustomerResponse.load(_response.body) end raise _response.body end |