square.rb 5.2.2.20200422 → 6.3.0.20200826

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cb76727d70686f42bfdb4822a48a4e94f9266c706eace4beee4ae31665f651a
4
- data.tar.gz: cf8261b678b0f8c9c0f5016f8f679d56969f7c4b23598580d3fbb055c4211ce1
3
+ metadata.gz: 973136d2e4f8177385869ee692c78d893fc79df5a5cb27512a57a24318027cfe
4
+ data.tar.gz: 8b502686044b15c7a047abc2c2a6dfa44cd7741406892b7bfb1f42e5a8af9190
5
5
  SHA512:
6
- metadata.gz: 8848dab1cc5f701fe8f3cf49ae510c7f016b9422af39bb63e7b24aa16bc9559a8fd4c135eb57d94d6d9d9ec520311df3376f929bae4677e99dfb3f54560a9de0
7
- data.tar.gz: 0e33550b5db4f37e88d7341abdad8c515be1f2f1963e4b479d99bd115091f6f21f75684afbc66d1b70ad6e0e63aefd33f40557ea21bf4a05a1976a67e58bae3c
6
+ metadata.gz: 1138a5aeefa0e9f4a1c7fbb8d9275b7f9519bcd3092f7ee694818e00077c661893fa5c1c200d75b587bf8f6a4752b874c32f00a7f089036304302c880e5d2fc9
7
+ data.tar.gz: 669ef667f74ed01898f5fabcde7be3c92835878cc7a0fbded426b44906478a7c37dc72d1d3bd730c9d6b4701754592b24414cd33ca30402741664997907d403b
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2019 Square, Inc.
1
+ Copyright 2020 Square, Inc.
2
2
  Licensed under the Apache License, Version 2.0 (the "License");
3
3
  you may not use this file except in compliance with the License.
4
4
  You may obtain a copy of the License at
data/README.md CHANGED
@@ -1,285 +1,317 @@
1
- ![Square logo]
2
-
3
- # Square Ruby SDK
4
-
5
- [![Travis status](https://travis-ci.org/square/square-ruby-sdk.svg?branch=master)](https://travis-ci.org/square/square-ruby-sdk)
6
- [![Gem version](https://badge.fury.io/rb/square.rb.svg?new)](https://badge.fury.io/rb/square.rb)
7
- [![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
8
-
9
- Use this gem to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
10
-
11
- ## Installation
12
-
13
- Install the gem from the command line:
14
-
15
- ```ruby
16
- gem install square.rb
17
- ```
18
-
19
- Or add the gem to your Gemfile and `bundle`:
20
-
21
- ```ruby
22
- gem 'square.rb'
23
- ```
24
-
25
- ## API documentation
26
-
27
- ### API Client
28
- * [Client]
29
-
30
- ### Take Payments
31
-
32
- * [Payments]
33
- * [Checkout]
34
-
35
- ### More Square APIs
36
-
37
- * [Catalog]
38
- * [Customers]
39
- * [Employees]
40
- * [Inventory]
41
- * [Labor]
42
- * [Locations]
43
- * [Merchants]
44
- * [Orders]
45
- * [Apple Pay]
46
- * [Refunds]
47
- * [Reporting]
48
-
49
- ### Authorization APIs
50
-
51
- * [Mobile Authorization]
52
- * [O Auth]
53
-
54
- ### Deprecated APIs
55
-
56
- * [V1 Locations]
57
- * [V1 Employees]
58
- * [V1 Transactions]
59
- * [V1 Items]
60
- * [Transactions]
61
-
62
- ## Usage
63
-
64
- First time using Square? Here’s how to get started:
65
-
66
- 1. **Create a Square account.** If you don’t have one already, [sign up for a developer account].
67
- 1. **Create an application.** Go to your [Developer Dashboard] and create your first application. All you need to do is give it a name. When you’re doing this for your production application, enter the name as you would want a customer to see it.
68
- 1. **Make your first API call.** Almost all Square API calls require a location ID. You’ll make your first call to #list_locations, which happens to be one of the API calls that don’t require a location ID. For more information about locations, see the [Locations] API documentation.
69
-
70
- Now let’s call your first Square API. Open your favorite text editor, create a new file called `locations.rb`, and copy the following code into that file:
71
-
72
- ```ruby
73
- require 'square'
74
-
75
- # Create an instance of the API Client and initialize it with the credentials
76
- # for the Square account whose assets you want to manage.
77
-
78
- client = Square::Client.new(
79
- access_token: 'YOUR SANDBOX ACCESS TOKEN HERE',
80
- environment: 'sandbox'
81
- )
82
-
83
- # Call list_locations method to get all locations in this Square account
84
- result = client.locations.list_locations
85
-
86
- # Call the #success? method to see if the call succeeded
87
- if result.success?
88
- # The #data Struct contains a list of locations
89
- locations = result.data.locations
90
-
91
- # Iterate over the list
92
- locations.each do |location|
93
- # Each location is represented as a Hash
94
- location.each do |key, value|
95
- puts "#{key}: #{value}"
96
- end
97
- end
98
- else
99
- # Handle the case that the result is an error.
100
- warn 'Error calling LocationsApi.listlocations ...'
101
-
102
- # The #errors method returns an Array of error Hashes
103
- result.errors.each do |key, value|
104
- warn "#{key}: #{value}"
105
- end
106
- end
107
- ```
108
-
109
- Next, get an access token and reference it in your code. Go back to your application in the Developer Dashboard, in the Sandbox section click Show in the Sandbox Access Token box, copy that access token, and replace `'YOUR SANDBOX ACCESS TOKEN HERE'` with that token.
110
-
111
- **Important** When you eventually switch from trying things out on sandbox to actually working with your real production resources, you should not embed the access token in your code. Make sure you store and access your production access tokens securely.
112
-
113
- Now save `locations.rb` and run it:
114
-
115
- ```sh
116
- ruby locations.rb
117
- ```
118
-
119
- If your call is successful, you’ll get a response that looks like this:
120
-
121
- ```
122
- address : {'address_line_1': '1455 Market Street', 'administrative_district_level_1': 'CA', 'country': 'US', 'locality': 'San Francisco', 'postal_code': '94103'}
123
- # ...
124
- ```
125
-
126
- Yay! You successfully made your first call. If you didn’t, you would see an error message that looks something like this:
127
-
128
- ```
129
- Error calling LocationsApi.listlocations
130
- category : AUTHENTICATION_ERROR
131
- code : UNAUTHORIZED
132
- detail : This request could not be authorized.
133
- ```
134
-
135
- This error was returned when an invalid token was used to call the API.
136
-
137
- After you’ve tried out the Square APIs and tested your application using sandbox, you will want to switch to your production credentials so that you can manage real Square resources. Don't forget to switch your access token from sandbox to production for real data.
138
-
139
- ## SDK patterns
140
- If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones:
141
-
142
- ### Get an access token
143
-
144
- To use the Square API to manage the resources (such as payments, orders, customers, etc.) of a Square account, you need to create an application (or use an existing one) in the Developer Dashboard and get an access token.
145
-
146
- When you call a Square API, you call it using an access key. An access key has specific permissions to resources in a specific Square account that can be accessed by a specific application in a specific developer account.
147
- Use an access token that is appropriate for your use case. There are two options:
148
-
149
- - To manage the resources for your own Square account, use the Personal Access Token for the application created in your Square account.
150
- - To manage resources for other Square accounts, use OAuth to ask owners of the accounts you want to manage so that you can work on their behalf. When you implement OAuth, you ask the Square account holder for permission to manage resources in their account (you can define the specific resources to access) and get an OAuth access token and refresh token for their account.
151
-
152
- **Important** For both use cases, make sure you store and access the tokens securely.
153
-
154
- ### Import and Instantiate the Client Class
155
-
156
- To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how:
157
-
158
- - Instantiate a `Square::Client` object with the access token for the Square account whose resources you want to manage. To access sandbox resources, initialize the `Square::Client` with environment set to sandbox:
159
-
160
- ```ruby
161
- client = Square::Client.new(
162
- access_token: 'SANDBOX ACCESS TOKEN HERE',
163
- environment: 'sandbox'
164
- )
165
- ```
166
-
167
- - To access production resources, set environment to production:
168
-
169
- ```ruby
170
- client = Square::Client.new(
171
- access_token: 'ACCESS TOKEN HERE',
172
- environment: 'production'
173
- )
174
- ```
175
-
176
- ### Get an Instance of an API object and call its methods
177
-
178
- Each API is implemented as a class. The Client object instantiates every API class and exposes them as properties so you can easily start using any Square API. You work with an API by calling methods on an instance of an API class. Here’s how:
179
-
180
- - Work with an API by calling the methods on the API object. For example, you would call list_customers to get a list of all customers in the Square account:
181
-
182
- ```ruby
183
- result = client.customers.list_customers
184
- ```
185
-
186
- See the SDK documentation for the list of methods for each API class.
187
-
188
- Pass complex parameters (such as create, update, search, etc.) as a Hash. For example, you would pass a Hash containing the values used to create a new customer using create_customer:
189
-
190
- ```ruby
191
- # Create a unique key for this creation operation so you don't accidentally
192
- # create the customer multiple times if you need to retry this operation.
193
- require 'securerandom'
194
-
195
- idempotency_key = SecureRandom.uuid
196
-
197
- # To create a customer, you'll need to specify at least a few required fields.
198
- request_body = {idempotency_key: idempotency_key, given_name: 'Amelia', family_name: 'Earhardt'}
199
-
200
- # Call create_customer method to create a new customer in this Square account
201
- result = client.customers.create_customer(request_body)
202
- ```
203
-
204
- If your call succeeds, you’ll see a response that looks like this:
205
- ```
206
- {'customer': {'created_at': '2019-06-28T21:23:05.126Z', 'creation_source': 'THIRD_PARTY', 'family_name': 'Earhardt', 'given_name': 'Amelia', 'id': 'CBASEDwl3El91nohQ2FLEk4aBfcgAQ', 'preferences': {'email_unsubscribed': False}, 'updated_at': '2019-06-28T21:23:05.126Z'}}
207
- ```
208
-
209
- - Use idempotency for create, update, or other calls that you want to avoid calling twice. To make an idempotent API call, you add the idempotency_key with a unique value in the Hash for the API call’s request.
210
- - Specify a location ID for APIs such as Transactions, Orders, and Checkout that deal with payments. When a payment or order is created in Square, it is always associated with a location.
211
-
212
- ### Handle the response
213
-
214
- API calls return a response object that contains properties that describe both the request (headers and request) and the response (status_code, reason_phrase, text, errors, body, and cursor). The response also has #success? and #error? helper methods so you can easily determine the success or failure of a call:
215
-
216
- ```ruby
217
- if result.success?
218
- p result.data
219
- elsif result.error?
220
- warn result.errors.inspect
221
- end
222
- ```
223
-
224
- - Read the response payload. The response payload is returned as a Struct from the #data method. For retrieve calls, a Struct containing a single item is returned with a key name that is the name of the object (for example, customer). For list calls, a Struct containing a Array of objects is returned with a key name that is the plural of the object name (for example, customers).
225
- - Make sure you get all items returned in a list call by checking the cursor value returned in the API response. When you call a list API the first time, set the cursor to an empty String or omit it from the API request. If the API response contains a cursor with a value, you call the API again to get the next page of items and continue to call that API again until the cursor is an empty String.
226
-
227
- ## Tests
228
-
229
- First, clone the gem locally and `cd` into the directory.
230
-
231
- ```sh
232
- git clone https://github.com/square/square-ruby-sdk.git
233
- cd square-ruby-sdk
234
- ```
235
-
236
- Next, make sure Bundler is installed and install the development dependencies.
237
-
238
- ```sh
239
- gem install bundler
240
- bundle
241
- ```
242
-
243
- Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_SANDBOX_TOKEN` environment variable.
244
-
245
- ```sh
246
- export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX TOKEN HERE"
247
- ```
248
-
249
- And run the tests.
250
-
251
- ```sh
252
- rake
253
- ```
254
-
255
- ## Learn more
256
-
257
- The Square Platform is built on the [Square API]. Square has a number of other SDKs that enable you to securely handle credit card information on both mobile and web so that you can process payments via the Square API.
258
-
259
- You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register).
260
-
261
- [Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
262
- [Developer Dashboard]: https://developer.squareup.com/apps
263
- [Square API]: https://squareup.com/developers
264
- [sign up for a developer account]: https://squareup.com/signup?v=developers
265
- [Client]: doc/client.md
266
- [Payments]: doc/payments.md
267
- [Checkout]: doc/checkout.md
268
- [Catalog]: doc/catalog.md
269
- [Customers]: doc/customers.md
270
- [Employees]: doc/employees.md
271
- [Inventory]: doc/inventory.md
272
- [Labor]: doc/labor.md
273
- [Locations]: doc/locations.md
274
- [Merchants]: doc/merchants.md
275
- [Orders]: doc/orders.md
276
- [Apple Pay]: doc/apple-pay.md
277
- [Refunds]: doc/refunds.md
278
- [Reporting]: doc/reporting.md
279
- [Mobile Authorization]: doc/mobile-authorization.md
280
- [O Auth]: doc/o-auth.md
281
- [V1 Locations]: doc/v1-locations.md
282
- [V1 Employees]: doc/v1-employees.md
283
- [V1 Transactions]: doc/v1-transactions.md
284
- [V1 Items]: doc/v1-items.md
285
- [Transactions]: doc/transactions.md
1
+ ![Square logo]
2
+
3
+ # Square Ruby SDK
4
+
5
+ [![Travis status](https://travis-ci.org/square/square-ruby-sdk.svg?branch=master)](https://travis-ci.org/square/square-ruby-sdk)
6
+ [![Gem version](https://badge.fury.io/rb/square.rb.svg?new)](https://badge.fury.io/rb/square.rb)
7
+ [![Apache-2 license](https://img.shields.io/badge/license-Apache2-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0)
8
+
9
+ Use this gem to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
10
+
11
+ ## Installation
12
+
13
+ Install the gem from the command line:
14
+
15
+ ```ruby
16
+ gem install square.rb
17
+ ```
18
+
19
+ Or add the gem to your Gemfile and `bundle`:
20
+
21
+ ```ruby
22
+ gem 'square.rb'
23
+ ```
24
+
25
+ ### API Client
26
+ * [Client]
27
+
28
+ ## API documentation
29
+
30
+ ### Payments
31
+ * [Payments]
32
+ * [Refunds]
33
+ * [Disputes]
34
+ * [Checkout]
35
+ * [Apple Pay]
36
+ * [Terminal]
37
+
38
+ ### Orders
39
+ * [Orders]
40
+
41
+ ### Subscriptions
42
+ * [Subscriptions]
43
+
44
+ ### Invoices
45
+ * [Invoices]
46
+
47
+ ### Items
48
+ * [Catalog]
49
+ * [Inventory]
50
+
51
+ ### Customers
52
+ * [Customers]
53
+ * [Customer Groups]
54
+ * [Customer Segments]
55
+
56
+ ### Loyalty
57
+ * [Loyalty]
58
+
59
+ ### Business
60
+ * [Merchants]
61
+ * [Locations]
62
+ * [Devices]
63
+
64
+ ### Team
65
+ * [Team]
66
+ * [Employees]
67
+ * [Labor]
68
+ * [Cash Drawers]
69
+
70
+ ### Financials
71
+ * [Bank Accounts]
72
+
73
+ ### Authorization APIs
74
+ * [Mobile Authorization]
75
+ * [O Auth]
76
+
77
+ ### Deprecated APIs
78
+ * [V1 Locations]
79
+ * [V1 Employees]
80
+ * [V1 Transactions]
81
+ * [V1 Items]
82
+ * [Transactions]
83
+
84
+ ## Usage
85
+
86
+ First time using Square? Here’s how to get started:
87
+
88
+ 1. **Create a Square account.** If you don’t have one already, [sign up for a developer account].
89
+ 1. **Create an application.** Go to your [Developer Dashboard] and create your first application. All you need to do is give it a name. When you’re doing this for your production application, enter the name as you would want a customer to see it.
90
+ 1. **Make your first API call.** Almost all Square API calls require a location ID. You’ll make your first call to #list_locations, which happens to be one of the API calls that don’t require a location ID. For more information about locations, see the [Locations] API documentation.
91
+
92
+ Now let’s call your first Square API. Open your favorite text editor, create a new file called `locations.rb`, and copy the following code into that file:
93
+
94
+ ```ruby
95
+ require 'square'
96
+
97
+ # Create an instance of the API Client and initialize it with the credentials
98
+ # for the Square account whose assets you want to manage.
99
+
100
+ client = Square::Client.new(
101
+ access_token: 'YOUR SANDBOX ACCESS TOKEN HERE',
102
+ environment: 'sandbox'
103
+ )
104
+
105
+ # Call list_locations method to get all locations in this Square account
106
+ result = client.locations.list_locations
107
+
108
+ # Call the #success? method to see if the call succeeded
109
+ if result.success?
110
+ # The #data Struct contains a list of locations
111
+ locations = result.data.locations
112
+
113
+ # Iterate over the list
114
+ locations.each do |location|
115
+ # Each location is represented as a Hash
116
+ location.each do |key, value|
117
+ puts "#{key}: #{value}"
118
+ end
119
+ end
120
+ else
121
+ # Handle the case that the result is an error.
122
+ warn 'Error calling LocationsApi.listlocations ...'
123
+
124
+ # The #errors method returns an Array of error Hashes
125
+ result.errors.each do |key, value|
126
+ warn "#{key}: #{value}"
127
+ end
128
+ end
129
+ ```
130
+
131
+ Next, get an access token and reference it in your code. Go back to your application in the Developer Dashboard, in the Sandbox section click Show in the Sandbox Access Token box, copy that access token, and replace `'YOUR SANDBOX ACCESS TOKEN HERE'` with that token.
132
+
133
+ **Important** When you eventually switch from trying things out on sandbox to actually working with your real production resources, you should not embed the access token in your code. Make sure you store and access your production access tokens securely.
134
+
135
+ Now save `locations.rb` and run it:
136
+
137
+ ```sh
138
+ ruby locations.rb
139
+ ```
140
+
141
+ If your call is successful, you’ll get a response that looks like this:
142
+
143
+ ```
144
+ address : {'address_line_1': '1455 Market Street', 'administrative_district_level_1': 'CA', 'country': 'US', 'locality': 'San Francisco', 'postal_code': '94103'}
145
+ # ...
146
+ ```
147
+
148
+ Yay! You successfully made your first call. If you didn’t, you would see an error message that looks something like this:
149
+
150
+ ```
151
+ Error calling LocationsApi.listlocations
152
+ category : AUTHENTICATION_ERROR
153
+ code : UNAUTHORIZED
154
+ detail : This request could not be authorized.
155
+ ```
156
+
157
+ This error was returned when an invalid token was used to call the API.
158
+
159
+ After you’ve tried out the Square APIs and tested your application using sandbox, you will want to switch to your production credentials so that you can manage real Square resources. Don't forget to switch your access token from sandbox to production for real data.
160
+
161
+ ## SDK patterns
162
+ If you know a few patterns, you’ll be able to call any API in the SDK. Here are some important ones:
163
+
164
+ ### Get an access token
165
+
166
+ To use the Square API to manage the resources (such as payments, orders, customers, etc.) of a Square account, you need to create an application (or use an existing one) in the Developer Dashboard and get an access token.
167
+
168
+ When you call a Square API, you call it using an access key. An access key has specific permissions to resources in a specific Square account that can be accessed by a specific application in a specific developer account.
169
+ Use an access token that is appropriate for your use case. There are two options:
170
+
171
+ - To manage the resources for your own Square account, use the Personal Access Token for the application created in your Square account.
172
+ - To manage resources for other Square accounts, use OAuth to ask owners of the accounts you want to manage so that you can work on their behalf. When you implement OAuth, you ask the Square account holder for permission to manage resources in their account (you can define the specific resources to access) and get an OAuth access token and refresh token for their account.
173
+
174
+ **Important** For both use cases, make sure you store and access the tokens securely.
175
+
176
+ ### Import and Instantiate the Client Class
177
+
178
+ To use the Square API, you import the Client class, instantiate a Client object, and initialize it with the appropriate access token. Here’s how:
179
+
180
+ - Instantiate a `Square::Client` object with the access token for the Square account whose resources you want to manage. To access sandbox resources, initialize the `Square::Client` with environment set to sandbox:
181
+
182
+ ```ruby
183
+ client = Square::Client.new(
184
+ access_token: 'SANDBOX ACCESS TOKEN HERE',
185
+ environment: 'sandbox'
186
+ )
187
+ ```
188
+
189
+ - To access production resources, set environment to production:
190
+
191
+ ```ruby
192
+ client = Square::Client.new(
193
+ access_token: 'ACCESS TOKEN HERE',
194
+ environment: 'production'
195
+ )
196
+ ```
197
+
198
+ ### Get an Instance of an API object and call its methods
199
+
200
+ Each API is implemented as a class. The Client object instantiates every API class and exposes them as properties so you can easily start using any Square API. You work with an API by calling methods on an instance of an API class. Here’s how:
201
+
202
+ - Work with an API by calling the methods on the API object. For example, you would call list_customers to get a list of all customers in the Square account:
203
+
204
+ ```ruby
205
+ result = client.customers.list_customers
206
+ ```
207
+
208
+ See the SDK documentation for the list of methods for each API class.
209
+
210
+ Pass complex parameters (such as create, update, search, etc.) as a Hash. For example, you would pass a Hash containing the values used to create a new customer using create_customer:
211
+
212
+ ```ruby
213
+ # Create a unique key for this creation operation so you don't accidentally
214
+ # create the customer multiple times if you need to retry this operation.
215
+ require 'securerandom'
216
+
217
+ idempotency_key = SecureRandom.uuid
218
+
219
+ # To create a customer, you'll need to specify at least a few required fields.
220
+ request_body = {idempotency_key: idempotency_key, given_name: 'Amelia', family_name: 'Earhardt'}
221
+
222
+ # Call create_customer method to create a new customer in this Square account
223
+ result = client.customers.create_customer(request_body)
224
+ ```
225
+
226
+ If your call succeeds, you’ll see a response that looks like this:
227
+ ```
228
+ {'customer': {'created_at': '2019-06-28T21:23:05.126Z', 'creation_source': 'THIRD_PARTY', 'family_name': 'Earhardt', 'given_name': 'Amelia', 'id': 'CBASEDwl3El91nohQ2FLEk4aBfcgAQ', 'preferences': {'email_unsubscribed': False}, 'updated_at': '2019-06-28T21:23:05.126Z'}}
229
+ ```
230
+
231
+ - Use idempotency for create, update, or other calls that you want to avoid calling twice. To make an idempotent API call, you add the idempotency_key with a unique value in the Hash for the API call’s request.
232
+ - Specify a location ID for APIs such as Transactions, Orders, and Checkout that deal with payments. When a payment or order is created in Square, it is always associated with a location.
233
+
234
+ ### Handle the response
235
+
236
+ API calls return a response object that contains properties that describe both the request (headers and request) and the response (status_code, reason_phrase, text, errors, body, and cursor). The response also has #success? and #error? helper methods so you can easily determine the success or failure of a call:
237
+
238
+ ```ruby
239
+ if result.success?
240
+ p result.data
241
+ elsif result.error?
242
+ warn result.errors.inspect
243
+ end
244
+ ```
245
+
246
+ - Read the response payload. The response payload is returned as a Struct from the #data method. For retrieve calls, a Struct containing a single item is returned with a key name that is the name of the object (for example, customer). For list calls, a Struct containing a Array of objects is returned with a key name that is the plural of the object name (for example, customers).
247
+ - Make sure you get all items returned in a list call by checking the cursor value returned in the API response. When you call a list API the first time, set the cursor to an empty String or omit it from the API request. If the API response contains a cursor with a value, you call the API again to get the next page of items and continue to call that API again until the cursor is an empty String.
248
+
249
+ ## Tests
250
+
251
+ First, clone the gem locally and `cd` into the directory.
252
+
253
+ ```sh
254
+ git clone https://github.com/square/square-ruby-sdk.git
255
+ cd square-ruby-sdk
256
+ ```
257
+
258
+ Next, make sure Bundler is installed and install the development dependencies.
259
+
260
+ ```sh
261
+ gem install bundler
262
+ bundle
263
+ ```
264
+
265
+ Before running the tests, find a sandbox token in your [Developer Dashboard] and set a `SQUARE_SANDBOX_TOKEN` environment variable.
266
+
267
+ ```sh
268
+ export SQUARE_SANDBOX_TOKEN="YOUR SANDBOX TOKEN HERE"
269
+ ```
270
+
271
+ And run the tests.
272
+
273
+ ```sh
274
+ rake
275
+ ```
276
+
277
+ ## Learn more
278
+
279
+ The Square Platform is built on the [Square API]. Square has a number of other SDKs that enable you to securely handle credit card information on both mobile and web so that you can process payments via the Square API.
280
+
281
+ You can also use the Square API to create applications or services that work with payments, orders, inventory, etc. that have been created and managed in Square’s in-person hardware products (Square Point of Sale and Square Register).
282
+
283
+ [Square Logo]: https://docs.connect.squareup.com/images/github/github-square-logo.svg
284
+ [Developer Dashboard]: https://developer.squareup.com/apps
285
+ [Square API]: https://squareup.com/developers
286
+ [sign up for a developer account]: https://squareup.com/signup?v=developers
287
+ [Client]: doc/client.md
288
+ [Devices]: doc/devices.md
289
+ [Disputes]: doc/disputes.md
290
+ [Terminal]: doc/terminal.md
291
+ [Team]: doc/team.md
292
+ [Cash Drawers]: doc/cash-drawers.md
293
+ [Customer Groups]: doc/customer-groups.md
294
+ [Customer Segments]: doc/customer-segments.md
295
+ [Bank Accounts]: doc/bank-accounts
296
+ [Payments]: doc/payments.md
297
+ [Checkout]: doc/checkout.md
298
+ [Catalog]: doc/catalog.md
299
+ [Customers]: doc/customers.md
300
+ [Employees]: doc/employees.md
301
+ [Inventory]: doc/inventory.md
302
+ [Labor]: doc/labor.md
303
+ [Loyalty]: doc/loyalty.md
304
+ [Locations]: doc/locations.md
305
+ [Merchants]: doc/merchants.md
306
+ [Orders]: doc/orders.md
307
+ [Invoices]: doc/invoices.md
308
+ [Apple Pay]: doc/apple-pay.md
309
+ [Refunds]: doc/refunds.md
310
+ [Mobile Authorization]: doc/mobile-authorization.md
311
+ [O Auth]: doc/o-auth.md
312
+ [V1 Locations]: doc/v1-locations.md
313
+ [V1 Employees]: doc/v1-employees.md
314
+ [V1 Transactions]: doc/v1-transactions.md
315
+ [V1 Items]: doc/v1-items.md
316
+ [Transactions]: doc/transactions.md
317
+ [Subscriptions]: doc/subscriptions.md