Class: SquareConnect::CustomersApi
- Inherits:
-
Object
- Object
- SquareConnect::CustomersApi
- Defined in:
- lib/square_connect/api/customers_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_customer(body, opts = {}) ⇒ CreateCustomerResponse
CreateCustomer Creates a new customer for a business, which can have associated cards on file.
-
#create_customer_card(customer_id, body, opts = {}) ⇒ CreateCustomerCardResponse
CreateCustomerCard Adds a card on file to an existing customer.
-
#create_customer_card_with_http_info(customer_id, body, opts = {}) ⇒ Array<(CreateCustomerCardResponse, Fixnum, Hash)>
CreateCustomerCard Adds a card on file to an existing customer.
-
#create_customer_with_http_info(body, opts = {}) ⇒ Array<(CreateCustomerResponse, Fixnum, Hash)>
CreateCustomer Creates a new customer for a business, which can have associated cards on file.
-
#delete_customer(customer_id, opts = {}) ⇒ DeleteCustomerResponse
DeleteCustomer Deletes a customer from a business, along with any linked cards on file.
-
#delete_customer_card(customer_id, card_id, opts = {}) ⇒ DeleteCustomerCardResponse
DeleteCustomerCard Removes a card on file from a customer.
-
#delete_customer_card_with_http_info(customer_id, card_id, opts = {}) ⇒ Array<(DeleteCustomerCardResponse, Fixnum, Hash)>
DeleteCustomerCard Removes a card on file from a customer.
-
#delete_customer_with_http_info(customer_id, opts = {}) ⇒ Array<(DeleteCustomerResponse, Fixnum, Hash)>
DeleteCustomer Deletes a customer from a business, along with any linked cards on file.
-
#initialize(api_client = ApiClient.default) ⇒ CustomersApi
constructor
A new instance of CustomersApi.
-
#list_customers(opts = {}) ⇒ ListCustomersResponse
ListCustomers Lists a business’s customers.
-
#list_customers_with_http_info(opts = {}) ⇒ Array<(ListCustomersResponse, Fixnum, Hash)>
ListCustomers Lists a business's customers.
-
#retrieve_customer(customer_id, opts = {}) ⇒ RetrieveCustomerResponse
RetrieveCustomer Returns details for a single customer.
-
#retrieve_customer_with_http_info(customer_id, opts = {}) ⇒ Array<(RetrieveCustomerResponse, Fixnum, Hash)>
RetrieveCustomer Returns details for a single customer.
-
#search_customers(body, opts = {}) ⇒ SearchCustomersResponse
SearchCustomers Searches the customer profiles associated with a Square account.
-
#search_customers_with_http_info(body, opts = {}) ⇒ Array<(SearchCustomersResponse, Fixnum, Hash)>
SearchCustomers Searches the customer profiles associated with a Square account.
-
#update_customer(customer_id, body, opts = {}) ⇒ UpdateCustomerResponse
UpdateCustomer Updates the details of an existing customer.
-
#update_customer_with_http_info(customer_id, body, opts = {}) ⇒ Array<(UpdateCustomerResponse, Fixnum, Hash)>
UpdateCustomer Updates the details of an existing customer.
Constructor Details
#initialize(api_client = ApiClient.default) ⇒ CustomersApi
Returns a new instance of CustomersApi.
16 17 18 |
# File 'lib/square_connect/api/customers_api.rb', line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end |
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
14 15 16 |
# File 'lib/square_connect/api/customers_api.rb', line 14 def api_client @api_client end |
Instance Method Details
#create_customer(body, opts = {}) ⇒ CreateCustomerResponse
CreateCustomer Creates a new customer for a business, which can have associated cards on file. 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`
25 26 27 28 |
# File 'lib/square_connect/api/customers_api.rb', line 25 def create_customer(body, opts = {}) data, _status_code, _headers = create_customer_with_http_info(body, opts) return data end |
#create_customer_card(customer_id, body, opts = {}) ⇒ CreateCustomerCardResponse
CreateCustomerCard Adds a card on file to an existing customer. As with charges, calls to ‘CreateCustomerCard` are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the first call.
81 82 83 84 |
# File 'lib/square_connect/api/customers_api.rb', line 81 def create_customer_card(customer_id, body, opts = {}) data, _status_code, _headers = create_customer_card_with_http_info(customer_id, body, opts) return data end |
#create_customer_card_with_http_info(customer_id, body, opts = {}) ⇒ Array<(CreateCustomerCardResponse, Fixnum, Hash)>
CreateCustomerCard Adds a card on file to an existing customer. As with charges, calls to `CreateCustomerCard` are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the first call.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/square_connect/api/customers_api.rb', line 92 def create_customer_card_with_http_info(customer_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.create_customer_card ..." end # verify the required parameter 'customer_id' is set fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.create_customer_card" if customer_id.nil? # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling CustomersApi.create_customer_card" if body.nil? # resource path local_var_path = "/v2/customers/{customer_id}/cards".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'CreateCustomerCardResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#create_customer_card\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_customer_with_http_info(body, opts = {}) ⇒ Array<(CreateCustomerResponse, Fixnum, Hash)>
CreateCustomer Creates a new customer for a business, which can have associated cards on file. 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`
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/square_connect/api/customers_api.rb', line 35 def create_customer_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.create_customer ..." end # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling CustomersApi.create_customer" if body.nil? # resource path local_var_path = "/v2/customers".sub('{format}','json') # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'CreateCustomerResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#create_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#delete_customer(customer_id, opts = {}) ⇒ DeleteCustomerResponse
DeleteCustomer Deletes a customer from a business, along with any linked cards on file. When two profiles are merged into a single profile, that profile is assigned a new ‘customer_id`. You must use the new `customer_id` to delete merged profiles.
139 140 141 142 |
# File 'lib/square_connect/api/customers_api.rb', line 139 def delete_customer(customer_id, opts = {}) data, _status_code, _headers = delete_customer_with_http_info(customer_id, opts) return data end |
#delete_customer_card(customer_id, card_id, opts = {}) ⇒ DeleteCustomerCardResponse
DeleteCustomerCard Removes a card on file from a customer.
195 196 197 198 |
# File 'lib/square_connect/api/customers_api.rb', line 195 def delete_customer_card(customer_id, card_id, opts = {}) data, _status_code, _headers = delete_customer_card_with_http_info(customer_id, card_id, opts) return data end |
#delete_customer_card_with_http_info(customer_id, card_id, opts = {}) ⇒ Array<(DeleteCustomerCardResponse, Fixnum, Hash)>
DeleteCustomerCard Removes a card on file from a customer.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/square_connect/api/customers_api.rb', line 206 def delete_customer_card_with_http_info(customer_id, card_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.delete_customer_card ..." end # verify the required parameter 'customer_id' is set fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.delete_customer_card" if customer_id.nil? # verify the required parameter 'card_id' is set fail ArgumentError, "Missing the required parameter 'card_id' when calling CustomersApi.delete_customer_card" if card_id.nil? # resource path local_var_path = "/v2/customers/{customer_id}/cards/{card_id}".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s).sub('{' + 'card_id' + '}', card_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeleteCustomerCardResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#delete_customer_card\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#delete_customer_with_http_info(customer_id, opts = {}) ⇒ Array<(DeleteCustomerResponse, Fixnum, Hash)>
DeleteCustomer Deletes a customer from a business, along with any linked cards on file. When two profiles are merged into a single profile, that profile is assigned a new `customer_id`. You must use the new `customer_id` to delete merged profiles.
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/square_connect/api/customers_api.rb', line 149 def delete_customer_with_http_info(customer_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.delete_customer ..." end # verify the required parameter 'customer_id' is set fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.delete_customer" if customer_id.nil? # resource path local_var_path = "/v2/customers/{customer_id}".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DeleteCustomerResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#delete_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#list_customers(opts = {}) ⇒ ListCustomersResponse
ListCustomers Lists a business’s customers.
255 256 257 258 |
# File 'lib/square_connect/api/customers_api.rb', line 255 def list_customers(opts = {}) data, _status_code, _headers = list_customers_with_http_info(opts) return data end |
#list_customers_with_http_info(opts = {}) ⇒ Array<(ListCustomersResponse, Fixnum, Hash)>
ListCustomers Lists a business's customers.
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/square_connect/api/customers_api.rb', line 267 def list_customers_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.list_customers ..." end if opts[:'sort_field'] && !['DEFAULT', 'CREATED_AT'].include?(opts[:'sort_field']) fail ArgumentError, 'invalid value for "sort_field", must be one of DEFAULT, CREATED_AT' end if opts[:'sort_order'] && !['DESC', 'ASC'].include?(opts[:'sort_order']) fail ArgumentError, 'invalid value for "sort_order", must be one of DESC, ASC' end # resource path local_var_path = "/v2/customers".sub('{format}','json') # query parameters query_params = {} query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil? query_params[:'sort_field'] = opts[:'sort_field'] if !opts[:'sort_field'].nil? query_params[:'sort_order'] = opts[:'sort_order'] if !opts[:'sort_order'].nil? # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'ListCustomersResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#list_customers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#retrieve_customer(customer_id, opts = {}) ⇒ RetrieveCustomerResponse
RetrieveCustomer Returns details for a single customer.
319 320 321 322 |
# File 'lib/square_connect/api/customers_api.rb', line 319 def retrieve_customer(customer_id, opts = {}) data, _status_code, _headers = retrieve_customer_with_http_info(customer_id, opts) return data end |
#retrieve_customer_with_http_info(customer_id, opts = {}) ⇒ Array<(RetrieveCustomerResponse, Fixnum, Hash)>
RetrieveCustomer Returns details for a single customer.
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
# File 'lib/square_connect/api/customers_api.rb', line 329 def retrieve_customer_with_http_info(customer_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.retrieve_customer ..." end # verify the required parameter 'customer_id' is set fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.retrieve_customer" if customer_id.nil? # resource path local_var_path = "/v2/customers/{customer_id}".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'RetrieveCustomerResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#retrieve_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#search_customers(body, opts = {}) ⇒ SearchCustomersResponse
SearchCustomers Searches the customer profiles associated with a Square account. Calling SearchCustomers without an explicit query parameter returns all customer profiles ordered alphabetically based on ‘given_name` and `family_name`.
374 375 376 377 |
# File 'lib/square_connect/api/customers_api.rb', line 374 def search_customers(body, opts = {}) data, _status_code, _headers = search_customers_with_http_info(body, opts) return data end |
#search_customers_with_http_info(body, opts = {}) ⇒ Array<(SearchCustomersResponse, Fixnum, Hash)>
SearchCustomers Searches the customer profiles associated with a Square account. Calling SearchCustomers without an explicit query parameter returns all customer profiles ordered alphabetically based on `given_name` and `family_name`.
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/square_connect/api/customers_api.rb', line 384 def search_customers_with_http_info(body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.search_customers ..." end # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling CustomersApi.search_customers" if body.nil? # resource path local_var_path = "/v2/customers/search".sub('{format}','json') # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'SearchCustomersResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#search_customers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#update_customer(customer_id, body, opts = {}) ⇒ UpdateCustomerResponse
UpdateCustomer Updates the details of an existing customer. When two profiles are merged into a single profile, that profile is assigned a new ‘customer_id`. You must use the new `customer_id` to update merged profiles. You cannot edit a customer’s cards on file with this endpoint. To make changes to a card on file, you must delete the existing card on file with the [DeleteCustomerCard](#endpoint-deletecustomercard) endpoint, then create a new one with the [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
430 431 432 433 |
# File 'lib/square_connect/api/customers_api.rb', line 430 def update_customer(customer_id, body, opts = {}) data, _status_code, _headers = update_customer_with_http_info(customer_id, body, opts) return data end |
#update_customer_with_http_info(customer_id, body, opts = {}) ⇒ Array<(UpdateCustomerResponse, Fixnum, Hash)>
UpdateCustomer Updates the details of an existing customer. When two profiles are merged into a single profile, that profile is assigned a new `customer_id`. You must use the new `customer_id` to update merged profiles. You cannot edit a customer's cards on file with this endpoint. To make changes to a card on file, you must delete the existing card on file with the [DeleteCustomerCard](#endpoint-deletecustomercard) endpoint, then create a new one with the [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/square_connect/api/customers_api.rb', line 441 def update_customer_with_http_info(customer_id, body, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug "Calling API: CustomersApi.update_customer ..." end # verify the required parameter 'customer_id' is set fail ArgumentError, "Missing the required parameter 'customer_id' when calling CustomersApi.update_customer" if customer_id.nil? # verify the required parameter 'body' is set fail ArgumentError, "Missing the required parameter 'body' when calling CustomersApi.update_customer" if body.nil? # resource path local_var_path = "/v2/customers/{customer_id}".sub('{format}','json').sub('{' + 'customer_id' + '}', customer_id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) header_params['Square-Version'] = "2019-02-13" # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(body) auth_names = ['oauth2'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'UpdateCustomerResponse') if @api_client.config.debugging @api_client.config.logger.debug "API called: CustomersApi#update_customer\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |