square.rb 35.0.0.20240118 → 36.0.0.20240222
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/square/api/base_api.rb +2 -1
- data/lib/square/api/checkout_api.rb +2 -2
- data/lib/square/api/customers_api.rb +104 -14
- data/lib/square/api/invoices_api.rb +5 -1
- data/lib/square/api/locations_api.rb +2 -1
- data/lib/square/api/v1_transactions_api.rb +0 -279
- data/lib/square/client.rb +26 -24
- data/lib/square/configuration.rb +43 -15
- data/lib/square/http/auth/o_auth2.rb +21 -2
- data/lib/square.rb +0 -3
- data/test/api/api_test_base.rb +1 -1
- data/test/api/test_locations_api.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea20e3c2ee0ef503bef9ebb50a42a318ac2bfd2a38cd0462550e6590be2b8750
|
4
|
+
data.tar.gz: 7da667a65f84a3ac563d9422ad550b0654f2fb6083ea636f3ba1030d22743335
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f0441c199381f05274e0e2afc4a5f2620773a9f72ba1a8b6eb76e137ee7c6129d076bba6cfe779dd20c7aa00238db283d9e3e2b06c8682dfa88a7d85aa1e164
|
7
|
+
data.tar.gz: f5bb1c5f90feb1af56ee67027606145a36672a7c69a1fe0e0e81049f07c7eb9dbe04384538b09565130c951cf005d61cd3919aaf61889be70018f45780a3dd07
|
data/lib/square/api/base_api.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Square
|
2
2
|
# BaseApi.
|
3
3
|
class BaseApi
|
4
|
+
include CoreLibrary
|
4
5
|
attr_accessor :config, :http_call_back
|
5
6
|
|
6
7
|
def self.user_agent
|
7
|
-
'Square-Ruby-SDK/
|
8
|
+
'Square-Ruby-SDK/36.0.0.20240222 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.user_agent_parameters
|
@@ -125,8 +125,8 @@ module Square
|
|
125
125
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
126
126
|
# set of results for the original query. If a cursor is not provided, the
|
127
127
|
# endpoint returns the first page of the results. For more information, see
|
128
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
129
|
-
# .
|
128
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
129
|
+
# atterns/pagination).
|
130
130
|
# @param [Integer] limit Optional parameter: A limit on the number of
|
131
131
|
# results to return per page. The limit is advisory and the implementation
|
132
132
|
# might return more or less results. If the supplied limit is negative,
|
@@ -83,6 +83,109 @@ module Square
|
|
83
83
|
.execute
|
84
84
|
end
|
85
85
|
|
86
|
+
# Creates multiple [customer profiles]($m/Customer) for a business.
|
87
|
+
# This endpoint takes a map of individual create requests and returns a map
|
88
|
+
# of responses.
|
89
|
+
# You must provide at least one of the following values in each create
|
90
|
+
# request:
|
91
|
+
# - `given_name`
|
92
|
+
# - `family_name`
|
93
|
+
# - `company_name`
|
94
|
+
# - `email_address`
|
95
|
+
# - `phone_number`
|
96
|
+
# @param [BulkCreateCustomersRequest] body Required parameter: An object
|
97
|
+
# containing the fields to POST for the request. See the corresponding
|
98
|
+
# object definition for field details.
|
99
|
+
# @return [BulkCreateCustomersResponse Hash] response from the API call
|
100
|
+
def bulk_create_customers(body:)
|
101
|
+
new_api_call_builder
|
102
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
103
|
+
'/v2/customers/bulk-create',
|
104
|
+
'default')
|
105
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
106
|
+
.body_param(new_parameter(body))
|
107
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
108
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
109
|
+
.auth(Single.new('global')))
|
110
|
+
.response(new_response_handler
|
111
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
112
|
+
.is_api_response(true)
|
113
|
+
.convertor(ApiResponse.method(:create)))
|
114
|
+
.execute
|
115
|
+
end
|
116
|
+
|
117
|
+
# Deletes multiple customer profiles.
|
118
|
+
# The endpoint takes a list of customer IDs and returns a map of responses.
|
119
|
+
# @param [BulkDeleteCustomersRequest] body Required parameter: An object
|
120
|
+
# containing the fields to POST for the request. See the corresponding
|
121
|
+
# object definition for field details.
|
122
|
+
# @return [BulkDeleteCustomersResponse Hash] response from the API call
|
123
|
+
def bulk_delete_customers(body:)
|
124
|
+
new_api_call_builder
|
125
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
126
|
+
'/v2/customers/bulk-delete',
|
127
|
+
'default')
|
128
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
129
|
+
.body_param(new_parameter(body))
|
130
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
131
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
132
|
+
.auth(Single.new('global')))
|
133
|
+
.response(new_response_handler
|
134
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
135
|
+
.is_api_response(true)
|
136
|
+
.convertor(ApiResponse.method(:create)))
|
137
|
+
.execute
|
138
|
+
end
|
139
|
+
|
140
|
+
# Retrieves multiple customer profiles.
|
141
|
+
# This endpoint takes a list of customer IDs and returns a map of responses.
|
142
|
+
# @param [BulkRetrieveCustomersRequest] body Required parameter: An object
|
143
|
+
# containing the fields to POST for the request. See the corresponding
|
144
|
+
# object definition for field details.
|
145
|
+
# @return [BulkRetrieveCustomersResponse Hash] response from the API call
|
146
|
+
def bulk_retrieve_customers(body:)
|
147
|
+
new_api_call_builder
|
148
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
149
|
+
'/v2/customers/bulk-retrieve',
|
150
|
+
'default')
|
151
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
152
|
+
.body_param(new_parameter(body))
|
153
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
154
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
155
|
+
.auth(Single.new('global')))
|
156
|
+
.response(new_response_handler
|
157
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
158
|
+
.is_api_response(true)
|
159
|
+
.convertor(ApiResponse.method(:create)))
|
160
|
+
.execute
|
161
|
+
end
|
162
|
+
|
163
|
+
# Updates multiple customer profiles.
|
164
|
+
# This endpoint takes a map of individual update requests and returns a map
|
165
|
+
# of responses.
|
166
|
+
# You cannot use this endpoint to change cards on file. To make changes, use
|
167
|
+
# the [Cards API]($e/Cards) or [Gift Cards API]($e/GiftCards).
|
168
|
+
# @param [BulkUpdateCustomersRequest] body Required parameter: An object
|
169
|
+
# containing the fields to POST for the request. See the corresponding
|
170
|
+
# object definition for field details.
|
171
|
+
# @return [BulkUpdateCustomersResponse Hash] response from the API call
|
172
|
+
def bulk_update_customers(body:)
|
173
|
+
new_api_call_builder
|
174
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
175
|
+
'/v2/customers/bulk-update',
|
176
|
+
'default')
|
177
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
178
|
+
.body_param(new_parameter(body))
|
179
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
180
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
181
|
+
.auth(Single.new('global')))
|
182
|
+
.response(new_response_handler
|
183
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
184
|
+
.is_api_response(true)
|
185
|
+
.convertor(ApiResponse.method(:create)))
|
186
|
+
.execute
|
187
|
+
end
|
188
|
+
|
86
189
|
# Searches the customer profiles associated with a Square account using one
|
87
190
|
# or more supported query filters.
|
88
191
|
# Calling `SearchCustomers` without any explicit query filter returns all
|
@@ -117,12 +220,6 @@ module Square
|
|
117
220
|
|
118
221
|
# Deletes a customer profile from a business. This operation also unlinks
|
119
222
|
# any associated cards on file.
|
120
|
-
# As a best practice, include the `version` field in the request to enable
|
121
|
-
# [optimistic
|
122
|
-
# concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
|
123
|
-
# atterns/optimistic-concurrency) control.
|
124
|
-
# If included, the value must be set to the current version of the customer
|
125
|
-
# profile.
|
126
223
|
# To delete a customer profile that was created by merging existing
|
127
224
|
# profiles, you must use the ID of the newly created profile.
|
128
225
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
@@ -177,14 +274,7 @@ module Square
|
|
177
274
|
# Updates a customer profile. This endpoint supports sparse updates, so only
|
178
275
|
# new or changed fields are required in the request.
|
179
276
|
# To add or update a field, specify the new value. To remove a field,
|
180
|
-
# specify `null
|
181
|
-
# (recommended) or specify an empty string (string fields only).
|
182
|
-
# As a best practice, include the `version` field in the request to enable
|
183
|
-
# [optimistic
|
184
|
-
# concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
|
185
|
-
# atterns/optimistic-concurrency) control.
|
186
|
-
# If included, the value must be set to the current version of the customer
|
187
|
-
# profile.
|
277
|
+
# specify `null`.
|
188
278
|
# To update a customer profile that was created by merging existing
|
189
279
|
# profiles, you must use the ID of the newly created profile.
|
190
280
|
# You cannot use this endpoint to change cards on file. To make changes, use
|
@@ -276,9 +276,13 @@ module Square
|
|
276
276
|
# The invoice `status` also changes from `DRAFT` to a status
|
277
277
|
# based on the invoice configuration. For example, the status changes to
|
278
278
|
# `UNPAID` if
|
279
|
-
# Square emails the invoice or `PARTIALLY_PAID` if Square
|
279
|
+
# Square emails the invoice or `PARTIALLY_PAID` if Square charges a card on
|
280
280
|
# file for a portion of the
|
281
281
|
# invoice amount.
|
282
|
+
# In addition to the required `ORDERS_WRITE` and `INVOICES_WRITE`
|
283
|
+
# permissions, `CUSTOMERS_READ`
|
284
|
+
# and `PAYMENTS_WRITE` are required when publishing invoices configured for
|
285
|
+
# card-on-file payments.
|
282
286
|
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
283
287
|
# publish.
|
284
288
|
# @param [PublishInvoiceRequest] body Required parameter: An object
|
@@ -3,7 +3,8 @@ module Square
|
|
3
3
|
class LocationsApi < BaseApi
|
4
4
|
# Provides details about all of the seller's
|
5
5
|
# [locations](https://developer.squareup.com/docs/locations-api),
|
6
|
-
# including those with an inactive status.
|
6
|
+
# including those with an inactive status. Locations are listed
|
7
|
+
# alphabetically by `name`.
|
7
8
|
# @return [ListLocationsResponse Hash] response from the API call
|
8
9
|
def list_locations
|
9
10
|
new_api_call_builder
|
@@ -98,284 +98,5 @@ module Square
|
|
98
98
|
.convertor(ApiResponse.method(:create)))
|
99
99
|
.execute
|
100
100
|
end
|
101
|
-
|
102
|
-
# Provides summary information for all payments taken for a given
|
103
|
-
# Square account during a date range. Date ranges cannot exceed 1 year in
|
104
|
-
# length. See Date ranges for details of inclusive and exclusive dates.
|
105
|
-
# *Note**: Details for payments processed with Square Point of Sale while
|
106
|
-
# in offline mode may not be transmitted to Square for up to 72 hours.
|
107
|
-
# Offline payments have a `created_at` value that reflects the time the
|
108
|
-
# payment was originally processed, not the time it was subsequently
|
109
|
-
# transmitted to Square. Consequently, the ListPayments endpoint might
|
110
|
-
# list an offline payment chronologically between online payments that
|
111
|
-
# were seen in a previous request.
|
112
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
113
|
-
# list payments for. If you specify me, this endpoint returns payments
|
114
|
-
# aggregated from all of the business's locations.
|
115
|
-
# @param [SortOrder] order Optional parameter: The order in which payments
|
116
|
-
# are listed in the response.
|
117
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
118
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
119
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
120
|
-
# Default value: The current time minus one year.
|
121
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
122
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
123
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
124
|
-
# The current time.
|
125
|
-
# @param [Integer] limit Optional parameter: The maximum number of payments
|
126
|
-
# to return in a single response. This value cannot exceed 200.
|
127
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
128
|
-
# retrieve the next set of results for your original query to the
|
129
|
-
# endpoint.
|
130
|
-
# @param [TrueClass | FalseClass] include_partial Optional parameter:
|
131
|
-
# Indicates whether or not to include partial payments in the response.
|
132
|
-
# Partial payments will have the tenders collected so far, but the
|
133
|
-
# itemizations will be empty until the payment is completed.
|
134
|
-
# @return [Array[V1Payment] Hash] response from the API call
|
135
|
-
def v1_list_payments(location_id:,
|
136
|
-
order: nil,
|
137
|
-
begin_time: nil,
|
138
|
-
end_time: nil,
|
139
|
-
limit: nil,
|
140
|
-
batch_token: nil,
|
141
|
-
include_partial: false)
|
142
|
-
warn 'Endpoint v1_list_payments in V1TransactionsApi is deprecated'
|
143
|
-
new_api_call_builder
|
144
|
-
.request(new_request_builder(HttpMethodEnum::GET,
|
145
|
-
'/v1/{location_id}/payments',
|
146
|
-
'default')
|
147
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
148
|
-
.should_encode(true))
|
149
|
-
.query_param(new_parameter(order, key: 'order'))
|
150
|
-
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
151
|
-
.query_param(new_parameter(end_time, key: 'end_time'))
|
152
|
-
.query_param(new_parameter(limit, key: 'limit'))
|
153
|
-
.query_param(new_parameter(batch_token, key: 'batch_token'))
|
154
|
-
.query_param(new_parameter(include_partial, key: 'include_partial'))
|
155
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
156
|
-
.auth(Single.new('global')))
|
157
|
-
.response(new_response_handler
|
158
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
159
|
-
.is_api_response(true)
|
160
|
-
.convertor(ApiResponse.method(:create))
|
161
|
-
.is_response_array(true))
|
162
|
-
.execute
|
163
|
-
end
|
164
|
-
|
165
|
-
# Provides comprehensive information for a single payment.
|
166
|
-
# @param [String] location_id Required parameter: The ID of the payment's
|
167
|
-
# associated location.
|
168
|
-
# @param [String] payment_id Required parameter: The Square-issued payment
|
169
|
-
# ID. payment_id comes from Payment objects returned by the List Payments
|
170
|
-
# endpoint, Settlement objects returned by the List Settlements endpoint, or
|
171
|
-
# Refund objects returned by the List Refunds endpoint.
|
172
|
-
# @return [V1Payment Hash] response from the API call
|
173
|
-
def v1_retrieve_payment(location_id:,
|
174
|
-
payment_id:)
|
175
|
-
warn 'Endpoint v1_retrieve_payment in V1TransactionsApi is deprecated'
|
176
|
-
new_api_call_builder
|
177
|
-
.request(new_request_builder(HttpMethodEnum::GET,
|
178
|
-
'/v1/{location_id}/payments/{payment_id}',
|
179
|
-
'default')
|
180
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
181
|
-
.should_encode(true))
|
182
|
-
.template_param(new_parameter(payment_id, key: 'payment_id')
|
183
|
-
.should_encode(true))
|
184
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
185
|
-
.auth(Single.new('global')))
|
186
|
-
.response(new_response_handler
|
187
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
188
|
-
.is_api_response(true)
|
189
|
-
.convertor(ApiResponse.method(:create)))
|
190
|
-
.execute
|
191
|
-
end
|
192
|
-
|
193
|
-
# Provides the details for all refunds initiated by a merchant or any of the
|
194
|
-
# merchant's mobile staff during a date range. Date ranges cannot exceed one
|
195
|
-
# year in length.
|
196
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
197
|
-
# list refunds for.
|
198
|
-
# @param [SortOrder] order Optional parameter: The order in which payments
|
199
|
-
# are listed in the response.
|
200
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
201
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
202
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
203
|
-
# Default value: The current time minus one year.
|
204
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
205
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
206
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
207
|
-
# The current time.
|
208
|
-
# @param [Integer] limit Optional parameter: The approximate number of
|
209
|
-
# refunds to return in a single response. Default: 100. Max: 200. Response
|
210
|
-
# may contain more results than the prescribed limit when refunds are made
|
211
|
-
# simultaneously to multiple tenders in a payment or when refunds are
|
212
|
-
# generated in an exchange to account for the value of returned goods.
|
213
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
214
|
-
# retrieve the next set of results for your original query to the
|
215
|
-
# endpoint.
|
216
|
-
# @return [Array[V1Refund] Hash] response from the API call
|
217
|
-
def v1_list_refunds(location_id:,
|
218
|
-
order: nil,
|
219
|
-
begin_time: nil,
|
220
|
-
end_time: nil,
|
221
|
-
limit: nil,
|
222
|
-
batch_token: nil)
|
223
|
-
warn 'Endpoint v1_list_refunds in V1TransactionsApi is deprecated'
|
224
|
-
new_api_call_builder
|
225
|
-
.request(new_request_builder(HttpMethodEnum::GET,
|
226
|
-
'/v1/{location_id}/refunds',
|
227
|
-
'default')
|
228
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
229
|
-
.should_encode(true))
|
230
|
-
.query_param(new_parameter(order, key: 'order'))
|
231
|
-
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
232
|
-
.query_param(new_parameter(end_time, key: 'end_time'))
|
233
|
-
.query_param(new_parameter(limit, key: 'limit'))
|
234
|
-
.query_param(new_parameter(batch_token, key: 'batch_token'))
|
235
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
236
|
-
.auth(Single.new('global')))
|
237
|
-
.response(new_response_handler
|
238
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
239
|
-
.is_api_response(true)
|
240
|
-
.convertor(ApiResponse.method(:create))
|
241
|
-
.is_response_array(true))
|
242
|
-
.execute
|
243
|
-
end
|
244
|
-
|
245
|
-
# Issues a refund for a previously processed payment. You must issue
|
246
|
-
# a refund within 60 days of the associated payment.
|
247
|
-
# You cannot issue a partial refund for a split tender payment. You must
|
248
|
-
# instead issue a full or partial refund for a particular tender, by
|
249
|
-
# providing the applicable tender id to the V1CreateRefund endpoint.
|
250
|
-
# Issuing a full refund for a split tender payment refunds all tenders
|
251
|
-
# associated with the payment.
|
252
|
-
# Issuing a refund for a card payment is not reversible. For development
|
253
|
-
# purposes, you can create fake cash payments in Square Point of Sale and
|
254
|
-
# refund them.
|
255
|
-
# @param [String] location_id Required parameter: The ID of the original
|
256
|
-
# payment's associated location.
|
257
|
-
# @param [V1CreateRefundRequest] body Required parameter: An object
|
258
|
-
# containing the fields to POST for the request. See the corresponding
|
259
|
-
# object definition for field details.
|
260
|
-
# @return [V1Refund Hash] response from the API call
|
261
|
-
def v1_create_refund(location_id:,
|
262
|
-
body:)
|
263
|
-
warn 'Endpoint v1_create_refund in V1TransactionsApi is deprecated'
|
264
|
-
new_api_call_builder
|
265
|
-
.request(new_request_builder(HttpMethodEnum::POST,
|
266
|
-
'/v1/{location_id}/refunds',
|
267
|
-
'default')
|
268
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
269
|
-
.should_encode(true))
|
270
|
-
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
271
|
-
.body_param(new_parameter(body))
|
272
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
273
|
-
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
274
|
-
.auth(Single.new('global')))
|
275
|
-
.response(new_response_handler
|
276
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
277
|
-
.is_api_response(true)
|
278
|
-
.convertor(ApiResponse.method(:create)))
|
279
|
-
.execute
|
280
|
-
end
|
281
|
-
|
282
|
-
# Provides summary information for all deposits and withdrawals
|
283
|
-
# initiated by Square to a linked bank account during a date range. Date
|
284
|
-
# ranges cannot exceed one year in length.
|
285
|
-
# *Note**: the ListSettlements endpoint does not provide entry
|
286
|
-
# information.
|
287
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
288
|
-
# list settlements for. If you specify me, this endpoint returns settlements
|
289
|
-
# aggregated from all of the business's locations.
|
290
|
-
# @param [SortOrder] order Optional parameter: The order in which
|
291
|
-
# settlements are listed in the response.
|
292
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
293
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
294
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
295
|
-
# Default value: The current time minus one year.
|
296
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
297
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
298
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
299
|
-
# The current time.
|
300
|
-
# @param [Integer] limit Optional parameter: The maximum number of
|
301
|
-
# settlements to return in a single response. This value cannot exceed
|
302
|
-
# 200.
|
303
|
-
# @param [V1ListSettlementsRequestStatus] status Optional parameter: Provide
|
304
|
-
# this parameter to retrieve only settlements with a particular status (SENT
|
305
|
-
# or FAILED).
|
306
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
307
|
-
# retrieve the next set of results for your original query to the
|
308
|
-
# endpoint.
|
309
|
-
# @return [Array[V1Settlement] Hash] response from the API call
|
310
|
-
def v1_list_settlements(location_id:,
|
311
|
-
order: nil,
|
312
|
-
begin_time: nil,
|
313
|
-
end_time: nil,
|
314
|
-
limit: nil,
|
315
|
-
status: nil,
|
316
|
-
batch_token: nil)
|
317
|
-
warn 'Endpoint v1_list_settlements in V1TransactionsApi is deprecated'
|
318
|
-
new_api_call_builder
|
319
|
-
.request(new_request_builder(HttpMethodEnum::GET,
|
320
|
-
'/v1/{location_id}/settlements',
|
321
|
-
'default')
|
322
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
323
|
-
.should_encode(true))
|
324
|
-
.query_param(new_parameter(order, key: 'order'))
|
325
|
-
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
326
|
-
.query_param(new_parameter(end_time, key: 'end_time'))
|
327
|
-
.query_param(new_parameter(limit, key: 'limit'))
|
328
|
-
.query_param(new_parameter(status, key: 'status'))
|
329
|
-
.query_param(new_parameter(batch_token, key: 'batch_token'))
|
330
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
331
|
-
.auth(Single.new('global')))
|
332
|
-
.response(new_response_handler
|
333
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
334
|
-
.is_api_response(true)
|
335
|
-
.convertor(ApiResponse.method(:create))
|
336
|
-
.is_response_array(true))
|
337
|
-
.execute
|
338
|
-
end
|
339
|
-
|
340
|
-
# Provides comprehensive information for a single settlement.
|
341
|
-
# The returned `Settlement` objects include an `entries` field that lists
|
342
|
-
# the transactions that contribute to the settlement total. Most
|
343
|
-
# settlement entries correspond to a payment payout, but settlement
|
344
|
-
# entries are also generated for less common events, like refunds, manual
|
345
|
-
# adjustments, or chargeback holds.
|
346
|
-
# Square initiates its regular deposits as indicated in the
|
347
|
-
# [Deposit Options with
|
348
|
-
# Square](https://squareup.com/help/us/en/article/3807)
|
349
|
-
# help article. Details for a regular deposit are usually not available
|
350
|
-
# from Connect API endpoints before 10 p.m. PST the same day.
|
351
|
-
# Square does not know when an initiated settlement **completes**, only
|
352
|
-
# whether it has failed. A completed settlement is typically reflected in
|
353
|
-
# a bank account within 3 business days, but in exceptional cases it may
|
354
|
-
# take longer.
|
355
|
-
# @param [String] location_id Required parameter: The ID of the
|
356
|
-
# settlements's associated location.
|
357
|
-
# @param [String] settlement_id Required parameter: The settlement's
|
358
|
-
# Square-issued ID. You obtain this value from Settlement objects returned
|
359
|
-
# by the List Settlements endpoint.
|
360
|
-
# @return [V1Settlement Hash] response from the API call
|
361
|
-
def v1_retrieve_settlement(location_id:,
|
362
|
-
settlement_id:)
|
363
|
-
warn 'Endpoint v1_retrieve_settlement in V1TransactionsApi is deprecated'
|
364
|
-
new_api_call_builder
|
365
|
-
.request(new_request_builder(HttpMethodEnum::GET,
|
366
|
-
'/v1/{location_id}/settlements/{settlement_id}',
|
367
|
-
'default')
|
368
|
-
.template_param(new_parameter(location_id, key: 'location_id')
|
369
|
-
.should_encode(true))
|
370
|
-
.template_param(new_parameter(settlement_id, key: 'settlement_id')
|
371
|
-
.should_encode(true))
|
372
|
-
.header_param(new_parameter('application/json', key: 'accept'))
|
373
|
-
.auth(Single.new('global')))
|
374
|
-
.response(new_response_handler
|
375
|
-
.deserializer(APIHelper.method(:json_deserialize))
|
376
|
-
.is_api_response(true)
|
377
|
-
.convertor(ApiResponse.method(:create)))
|
378
|
-
.execute
|
379
|
-
end
|
380
101
|
end
|
381
102
|
end
|
data/lib/square/client.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Square
|
2
2
|
# square client class.
|
3
3
|
class Client
|
4
|
+
include CoreLibrary
|
4
5
|
attr_reader :config, :auth_managers
|
5
6
|
|
6
7
|
def sdk_version
|
7
|
-
'
|
8
|
+
'36.0.0.20240222'
|
8
9
|
end
|
9
10
|
|
10
11
|
def square_version
|
@@ -261,28 +262,29 @@ module Square
|
|
261
262
|
@webhook_subscriptions ||= WebhookSubscriptionsApi.new @global_configuration
|
262
263
|
end
|
263
264
|
|
264
|
-
def initialize(
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
265
|
+
def initialize(
|
266
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
267
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
268
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
269
|
+
retry_methods: %i[get put], http_callback: nil, environment: 'production',
|
270
|
+
custom_url: 'https://connect.squareup.com', access_token: nil,
|
271
|
+
bearer_auth_credentials: nil, square_version: '2024-02-22',
|
272
|
+
user_agent_detail: '', additional_headers: {}, config: nil
|
273
|
+
)
|
272
274
|
@config = if config.nil?
|
273
|
-
Configuration.new(
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
275
|
+
Configuration.new(
|
276
|
+
connection: connection, adapter: adapter, timeout: timeout,
|
277
|
+
max_retries: max_retries, retry_interval: retry_interval,
|
278
|
+
backoff_factor: backoff_factor,
|
279
|
+
retry_statuses: retry_statuses,
|
280
|
+
retry_methods: retry_methods, http_callback: http_callback,
|
281
|
+
environment: environment, custom_url: custom_url,
|
282
|
+
access_token: access_token,
|
283
|
+
bearer_auth_credentials: bearer_auth_credentials,
|
284
|
+
square_version: square_version,
|
285
|
+
user_agent_detail: user_agent_detail,
|
286
|
+
additional_headers: additional_headers
|
287
|
+
)
|
286
288
|
else
|
287
289
|
config
|
288
290
|
end
|
@@ -311,8 +313,8 @@ module Square
|
|
311
313
|
def initialize_auth_managers(global_config)
|
312
314
|
@auth_managers = {}
|
313
315
|
http_client_config = global_config.client_configuration
|
314
|
-
[
|
315
|
-
@auth_managers['global'] = OAuth2.new(http_client_config.
|
316
|
+
%w[global].each { |auth| @auth_managers[auth] = nil }
|
317
|
+
@auth_managers['global'] = OAuth2.new(http_client_config.bearer_auth_credentials)
|
316
318
|
end
|
317
319
|
end
|
318
320
|
end
|
data/lib/square/configuration.rb
CHANGED
@@ -2,8 +2,13 @@ module Square
|
|
2
2
|
# All configuration including auth info and base URI for the API access
|
3
3
|
# are configured in this class.
|
4
4
|
class Configuration < CoreLibrary::HttpClientConfiguration
|
5
|
+
def access_token
|
6
|
+
@bearer_auth_credentials.access_token
|
7
|
+
end
|
8
|
+
|
5
9
|
# The attribute readers for properties.
|
6
|
-
attr_reader :environment, :custom_url, :
|
10
|
+
attr_reader :environment, :custom_url, :bearer_auth_credentials, :square_version,
|
11
|
+
:user_agent_detail
|
7
12
|
|
8
13
|
def additional_headers
|
9
14
|
@additional_headers.clone
|
@@ -13,14 +18,15 @@ module Square
|
|
13
18
|
attr_reader :environments
|
14
19
|
end
|
15
20
|
|
16
|
-
def initialize(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
def initialize(
|
22
|
+
connection: nil, adapter: :net_http_persistent, timeout: 60,
|
23
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
24
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
25
|
+
retry_methods: %i[get put], http_callback: nil, environment: 'production',
|
26
|
+
custom_url: 'https://connect.squareup.com', access_token: nil,
|
27
|
+
bearer_auth_credentials: nil, square_version: '2024-02-22',
|
28
|
+
user_agent_detail: '', additional_headers: {}
|
29
|
+
)
|
24
30
|
|
25
31
|
super connection: connection, adapter: adapter, timeout: timeout,
|
26
32
|
max_retries: max_retries, retry_interval: retry_interval,
|
@@ -42,6 +48,11 @@ module Square
|
|
42
48
|
# Additional headers to add to each API request
|
43
49
|
@additional_headers = additional_headers.clone
|
44
50
|
|
51
|
+
# Initializing OAuth 2 Bearer token credentials with the provided auth parameters
|
52
|
+
@bearer_auth_credentials = create_auth_credentials_object(
|
53
|
+
access_token, bearer_auth_credentials
|
54
|
+
)
|
55
|
+
|
45
56
|
# The Http Client to use for making requests.
|
46
57
|
set_http_client CoreLibrary::FaradayClient.new(self)
|
47
58
|
|
@@ -53,8 +64,8 @@ module Square
|
|
53
64
|
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
54
65
|
retry_statuses: nil, retry_methods: nil, http_callback: nil,
|
55
66
|
environment: nil, custom_url: nil, access_token: nil,
|
56
|
-
|
57
|
-
additional_headers: nil)
|
67
|
+
bearer_auth_credentials: nil, square_version: nil,
|
68
|
+
user_agent_detail: nil, additional_headers: nil)
|
58
69
|
connection ||= self.connection
|
59
70
|
adapter ||= self.adapter
|
60
71
|
timeout ||= self.timeout
|
@@ -66,10 +77,12 @@ module Square
|
|
66
77
|
http_callback ||= self.http_callback
|
67
78
|
environment ||= self.environment
|
68
79
|
custom_url ||= self.custom_url
|
69
|
-
access_token ||= self.access_token
|
70
80
|
square_version ||= self.square_version
|
71
81
|
user_agent_detail ||= self.user_agent_detail
|
72
82
|
additional_headers ||= self.additional_headers
|
83
|
+
bearer_auth_credentials = create_auth_credentials_object(
|
84
|
+
access_token, bearer_auth_credentials || self.bearer_auth_credentials
|
85
|
+
)
|
73
86
|
|
74
87
|
Configuration.new(connection: connection, adapter: adapter,
|
75
88
|
timeout: timeout, max_retries: max_retries,
|
@@ -78,10 +91,10 @@ module Square
|
|
78
91
|
retry_statuses: retry_statuses,
|
79
92
|
retry_methods: retry_methods,
|
80
93
|
http_callback: http_callback, environment: environment,
|
81
|
-
custom_url: custom_url,
|
82
|
-
square_version: square_version,
|
94
|
+
custom_url: custom_url, square_version: square_version,
|
83
95
|
user_agent_detail: user_agent_detail,
|
84
|
-
additional_headers: additional_headers
|
96
|
+
additional_headers: additional_headers,
|
97
|
+
bearer_auth_credentials: bearer_auth_credentials)
|
85
98
|
end
|
86
99
|
|
87
100
|
def get_user_agent(user_agent_detail)
|
@@ -91,6 +104,21 @@ module Square
|
|
91
104
|
user_agent_detail
|
92
105
|
end
|
93
106
|
|
107
|
+
def create_auth_credentials_object(access_token, bearer_auth_credentials)
|
108
|
+
return bearer_auth_credentials if access_token.nil?
|
109
|
+
|
110
|
+
warn('The \'access_token\' params are deprecated. Use \'bearer_auth_cred'\
|
111
|
+
'entials\' param instead.')
|
112
|
+
|
113
|
+
unless bearer_auth_credentials.nil?
|
114
|
+
return bearer_auth_credentials.clone_with(
|
115
|
+
access_token: access_token
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
BearerAuthCredentials.new(access_token: access_token)
|
120
|
+
end
|
121
|
+
|
94
122
|
# All the environments the SDK can run in.
|
95
123
|
ENVIRONMENTS = {
|
96
124
|
'production' => {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Square
|
2
2
|
# Utility class for OAuth 2 authorization and token management.
|
3
3
|
class OAuth2 < CoreLibrary::HeaderAuth
|
4
|
+
include CoreLibrary
|
4
5
|
# Display error message on occurrence of authentication failure.
|
5
6
|
# @returns [String] The oAuth error message.
|
6
7
|
def error_message
|
@@ -8,12 +9,30 @@ module Square
|
|
8
9
|
end
|
9
10
|
|
10
11
|
# Initialization constructor.
|
11
|
-
def initialize(
|
12
|
+
def initialize(bearer_auth_credentials)
|
12
13
|
auth_params = {}
|
13
|
-
@_access_token = access_token
|
14
|
+
@_access_token = bearer_auth_credentials.access_token unless
|
15
|
+
bearer_auth_credentials.nil? || bearer_auth_credentials.access_token.nil?
|
14
16
|
auth_params['Authorization'] = "Bearer #{@_access_token}" unless @_access_token.nil?
|
15
17
|
|
16
18
|
super auth_params
|
17
19
|
end
|
18
20
|
end
|
21
|
+
|
22
|
+
# Data class for BearerAuthCredentials.
|
23
|
+
class BearerAuthCredentials
|
24
|
+
attr_reader :access_token
|
25
|
+
|
26
|
+
def initialize(access_token:)
|
27
|
+
raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
|
28
|
+
|
29
|
+
@access_token = access_token
|
30
|
+
end
|
31
|
+
|
32
|
+
def clone_with(access_token: nil)
|
33
|
+
access_token ||= self.access_token
|
34
|
+
|
35
|
+
BearerAuthCredentials.new(access_token: access_token)
|
36
|
+
end
|
37
|
+
end
|
19
38
|
end
|
data/lib/square.rb
CHANGED
@@ -3,9 +3,6 @@ require 'json'
|
|
3
3
|
require 'apimatic_core_interfaces'
|
4
4
|
require 'apimatic_core'
|
5
5
|
require 'apimatic_faraday_client_adapter'
|
6
|
-
# rubocop:disable Style/MixinUsage
|
7
|
-
include CoreLibrary
|
8
|
-
# rubocop:enable Style/MixinUsage
|
9
6
|
|
10
7
|
require_relative 'square/api_helper'
|
11
8
|
require_relative 'square/client'
|
data/test/api/api_test_base.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative '../http_response_catcher'
|
|
9
9
|
class ApiTestBase < Minitest::Test
|
10
10
|
parallelize_me!
|
11
11
|
include Square
|
12
|
+
include CoreLibrary
|
12
13
|
|
13
14
|
# Create configuration and set any test parameters
|
14
15
|
def create_configuration
|
@@ -22,6 +23,5 @@ class ApiTestBase < Minitest::Test
|
|
22
23
|
def setup_class
|
23
24
|
_config = create_configuration
|
24
25
|
@client = Client.new(config: _config)
|
25
|
-
_auth_managers = @client.auth_managers
|
26
26
|
end
|
27
27
|
end
|
@@ -9,7 +9,7 @@ class LocationsApiTests < ApiTestBase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# Provides details about all of the seller's [locations](https://developer.squareup.com/docs/locations-api),
|
12
|
-
#including those with an inactive status.
|
12
|
+
#including those with an inactive status. Locations are listed alphabetically by `name`.
|
13
13
|
def test_list_locations
|
14
14
|
|
15
15
|
# Perform the API call through the SDK function
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 36.0.0.20240222
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Square Developer Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apimatic_core_interfaces
|