Skip to content

Latest commit

 

History

History
389 lines (257 loc) · 11.3 KB

CustomersApi.md

File metadata and controls

389 lines (257 loc) · 11.3 KB

SquareConnect::CustomersApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
create_customer POST /v2/customers CreateCustomer
create_customer_card POST /v2/customers/{customer_id}/cards CreateCustomerCard
delete_customer DELETE /v2/customers/{customer_id} DeleteCustomer
delete_customer_card DELETE /v2/customers/{customer_id}/cards/{card_id} DeleteCustomerCard
list_customers GET /v2/customers ListCustomers
retrieve_customer GET /v2/customers/{customer_id} RetrieveCustomer
update_customer PUT /v2/customers/{customer_id} UpdateCustomer

create_customer

CreateCustomerResponse create_customer(body)

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 This endpoint does not accept an idempotency key. If you accidentally create a duplicate customer, you can delete it with the DeleteCustomer endpoint.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

body = SquareConnect::CreateCustomerRequest.new # CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.


begin
  #CreateCustomer
  result = api_instance.create_customer(body)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->create_customer: #{e}"
end

Parameters

Name Type Description Notes
body CreateCustomerRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateCustomerResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

create_customer_card

CreateCustomerCardResponse create_customer_card(customer_id, body)

CreateCustomerCard

Adds a card on file to an existing customer. In the United States Square takes care of automatically updating any cards on file that might have expired since you first attached them to a 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.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

customer_id = "customer_id_example" # String | The ID of the customer to link the card on file to.

body = SquareConnect::CreateCustomerCardRequest.new # CreateCustomerCardRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.


begin
  #CreateCustomerCard
  result = api_instance.create_customer_card(customer_id, body)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->create_customer_card: #{e}"
end

Parameters

Name Type Description Notes
customer_id String The ID of the customer to link the card on file to.
body CreateCustomerCardRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

CreateCustomerCardResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

delete_customer

DeleteCustomerResponse delete_customer(customer_id)

DeleteCustomer

Deletes a customer from a business, along with any linked cards on file.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

customer_id = "customer_id_example" # String | The ID of the customer to delete.


begin
  #DeleteCustomer
  result = api_instance.delete_customer(customer_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->delete_customer: #{e}"
end

Parameters

Name Type Description Notes
customer_id String The ID of the customer to delete.

Return type

DeleteCustomerResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

delete_customer_card

DeleteCustomerCardResponse delete_customer_card(customer_id, card_id)

DeleteCustomerCard

Removes a card on file from a customer.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

customer_id = "customer_id_example" # String | The ID of the customer that the card on file belongs to.

card_id = "card_id_example" # String | The ID of the card on file to delete.


begin
  #DeleteCustomerCard
  result = api_instance.delete_customer_card(customer_id, card_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->delete_customer_card: #{e}"
end

Parameters

Name Type Description Notes
customer_id String The ID of the customer that the card on file belongs to.
card_id String The ID of the card on file to delete.

Return type

DeleteCustomerCardResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

list_customers

ListCustomersResponse list_customers(opts)

ListCustomers

Lists a business's customers.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

opts = { 
  cursor: "cursor_example" # String | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query.  See [Paginating results](#paginatingresults) for more information.
}

begin
  #ListCustomers
  result = api_instance.list_customers(opts)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->list_customers: #{e}"
end

Parameters

Name Type Description Notes
cursor String A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See Paginating results for more information. [optional]

Return type

ListCustomersResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

retrieve_customer

RetrieveCustomerResponse retrieve_customer(customer_id)

RetrieveCustomer

Returns details for a single customer.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

customer_id = "customer_id_example" # String | The ID of the customer to retrieve.


begin
  #RetrieveCustomer
  result = api_instance.retrieve_customer(customer_id)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->retrieve_customer: #{e}"
end

Parameters

Name Type Description Notes
customer_id String The ID of the customer to retrieve.

Return type

RetrieveCustomerResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

update_customer

UpdateCustomerResponse update_customer(customer_id, body)

UpdateCustomer

Updates the details of an existing customer. The ID of the customer may change if the customer has been merged into another customer. 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, then create a new one with the CreateCustomerCard endpoint.

Example

# load the gem
require 'square_connect'
# setup authorization
SquareConnect.configure do |config|
  # Configure OAuth2 access token for authorization: oauth2
  config.access_token = 'YOUR ACCESS TOKEN'
end

api_instance = SquareConnect::CustomersApi.new

customer_id = "customer_id_example" # String | The ID of the customer to update.

body = SquareConnect::UpdateCustomerRequest.new # UpdateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.


begin
  #UpdateCustomer
  result = api_instance.update_customer(customer_id, body)
  p result
rescue SquareConnect::ApiError => e
  puts "Exception when calling CustomersApi->update_customer: #{e}"
end

Parameters

Name Type Description Notes
customer_id String The ID of the customer to update.
body UpdateCustomerRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateCustomerResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json