Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
518 lines (340 loc) · 18.5 KB

CustomersApi.md

File metadata and controls

518 lines (340 loc) · 18.5 KB

SquareConnect.CustomersApi

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

Method HTTP request Description
addGroupToCustomer PUT /v2/customers/{customer_id}/groups/{group_id} AddGroupToCustomer
createCustomer POST /v2/customers CreateCustomer
createCustomerCard POST /v2/customers/{customer_id}/cards CreateCustomerCard
deleteCustomer DELETE /v2/customers/{customer_id} DeleteCustomer
deleteCustomerCard DELETE /v2/customers/{customer_id}/cards/{card_id} DeleteCustomerCard
listCustomers GET /v2/customers ListCustomers
removeGroupFromCustomer DELETE /v2/customers/{customer_id}/groups/{group_id} RemoveGroupFromCustomer
retrieveCustomer GET /v2/customers/{customer_id} RetrieveCustomer
searchCustomers POST /v2/customers/search SearchCustomers
updateCustomer PUT /v2/customers/{customer_id} UpdateCustomer

addGroupToCustomer

AddGroupToCustomerResponse addGroupToCustomer(customerId, groupId)

AddGroupToCustomer

Adds a group membership to a customer. The customer is identified by the `customer_id` value and the customer group is identified by the `group_id` value.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer to add to a group.

var groupId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer group to add the customer to.

apiInstance.addGroupToCustomer(customerId, groupId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
customerId String The ID of the customer to add to a group.
groupId String The ID of the customer group to add the customer to.

Return type

AddGroupToCustomerResponse

Authorization

oauth2

HTTP request headers

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

createCustomer

CreateCustomerResponse createCustomer(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`

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var body = SquareConnect.CustomersApi.constructFromObject({}); // CreateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createCustomer(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

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

createCustomerCard

CreateCustomerCardResponse createCustomerCard(customerId, body)

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The Square ID of the customer profile the card is linked to.

var body = SquareConnect.CustomersApi.constructFromObject({}); // CreateCustomerCardRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.createCustomerCard(customerId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
customerId String The Square ID of the customer profile the card is linked 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

deleteCustomer

DeleteCustomerResponse deleteCustomer(customerId)

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer to delete.

apiInstance.deleteCustomer(customerId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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

Return type

DeleteCustomerResponse

Authorization

oauth2

HTTP request headers

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

deleteCustomerCard

DeleteCustomerCardResponse deleteCustomerCard(customerId, cardId)

DeleteCustomerCard

Removes a card on file from a customer.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer that the card on file belongs to.

var cardId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the card on file to delete.

apiInstance.deleteCustomerCard(customerId, cardId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
customerId String The ID of the customer that the card on file belongs to.
cardId 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

listCustomers

ListCustomersResponse listCustomers(opts)

ListCustomers

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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var opts = { 
  'cursor': SquareConnect.CustomersApi.constructFromObject({});, // 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 the [Pagination guide](https://developer.squareup.com/docs/working-with-apis/pagination) for more information.
  'sortField': SquareConnect.CustomersApi.constructFromObject({});, // String | Indicates how Customers should be sorted.  Default: `DEFAULT`.
  'sortOrder': SquareConnect.CustomersApi.constructFromObject({}); // String | Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order.  Default: `ASC`.
};
apiInstance.listCustomers(opts).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

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 the Pagination guide for more information. [optional]
sortField String Indicates how Customers should be sorted. Default: `DEFAULT`. [optional]
sortOrder String Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`. [optional]

Return type

ListCustomersResponse

Authorization

oauth2

HTTP request headers

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

removeGroupFromCustomer

RemoveGroupFromCustomerResponse removeGroupFromCustomer(customerId, groupId)

RemoveGroupFromCustomer

Removes a group membership from a customer. The customer is identified by the `customer_id` value and the customer group is identified by the `group_id` value.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer to remove from the group.

var groupId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer group to remove the customer from.

apiInstance.removeGroupFromCustomer(customerId, groupId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
customerId String The ID of the customer to remove from the group.
groupId String The ID of the customer group to remove the customer from.

Return type

RemoveGroupFromCustomerResponse

Authorization

oauth2

HTTP request headers

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

retrieveCustomer

RetrieveCustomerResponse retrieveCustomer(customerId)

RetrieveCustomer

Returns details for a single customer.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer to retrieve.

apiInstance.retrieveCustomer(customerId).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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

Return type

RetrieveCustomerResponse

Authorization

oauth2

HTTP request headers

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

searchCustomers

SearchCustomersResponse searchCustomers(body)

SearchCustomers

Searches the customer profiles associated with a Square account using a supported query filter. 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.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var body = SquareConnect.CustomersApi.constructFromObject({}); // SearchCustomersRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.searchCustomers(body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

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

Return type

SearchCustomersResponse

Authorization

oauth2

HTTP request headers

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

updateCustomer

UpdateCustomerResponse updateCustomer(customerId, body)

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, then create a new one with the CreateCustomerCard endpoint.

Example

var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = 'YOUR ACCESS TOKEN';

var apiInstance = new SquareConnect.CustomersApi();

var customerId = SquareConnect.CustomersApi.constructFromObject({}); // String | The ID of the customer to update.

var body = SquareConnect.CustomersApi.constructFromObject({}); // UpdateCustomerRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.

apiInstance.updateCustomer(customerId, body).then(function(data) {
  console.log('API called successfully. Returned data: ' + data);
}, function(error) {
  console.error(error);
});

Parameters

Name Type Description Notes
customerId 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