square.rb 33.0.0.20231018 → 36.1.0.20240320
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/square/api/base_api.rb +2 -1
- data/lib/square/api/bookings_api.rb +1 -1
- data/lib/square/api/catalog_api.rb +11 -1
- data/lib/square/api/checkout_api.rb +87 -2
- data/lib/square/api/customers_api.rb +104 -14
- data/lib/square/api/invoices_api.rb +70 -1
- data/lib/square/api/labor_api.rb +17 -16
- data/lib/square/api/locations_api.rb +2 -1
- data/lib/square/api/terminal_api.rb +43 -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/api_response.rb +1 -1
- 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: 6ca5ac550267d6ef5f80789ac3b8e8e2034af630f0ef9ad50d9c57b62b7505c4
|
4
|
+
data.tar.gz: f9c1d0f6d335ca88a5b7854a9cd64172ffe322aac6d50be06cc84988be0c6d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64df0c00f641647f66e9dc4186eac0a80952607c42304e4332599396c31e8fb3078d405bc29d0dc22b68848bc36965e959a5a682aa50ef9c9144ad42c2880334
|
7
|
+
data.tar.gz: 5e51a74b742960cfa8019bb54aa8081c0906ad258b70368a312388221694875308dfeb0ccaf5f0ba122d0ccce238474dc1e5d3684df694a1662bc42bec821cce
|
data/LICENSE
CHANGED
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.1.0.20240320 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
8
9
|
end
|
9
10
|
|
10
11
|
def self.user_agent_parameters
|
@@ -58,7 +58,7 @@ module Square
|
|
58
58
|
# The required input must include the following:
|
59
59
|
# - `Booking.location_id`
|
60
60
|
# - `Booking.start_at`
|
61
|
-
# - `Booking.team_member_id`
|
61
|
+
# - `Booking.AppointmentSegment.team_member_id`
|
62
62
|
# - `Booking.AppointmentSegment.service_variation_id`
|
63
63
|
# - `Booking.AppointmentSegment.service_variation_version`
|
64
64
|
# To call this endpoint with buyer-level permissions, set
|
@@ -328,10 +328,19 @@ module Square
|
|
328
328
|
# of an object can be found in the version field of
|
329
329
|
# [CatalogObject]($m/CatalogObject)s. If not included, results will be from
|
330
330
|
# the current version of the catalog.
|
331
|
+
# @param [TrueClass | FalseClass] include_category_path_to_root Optional
|
332
|
+
# parameter: Specifies whether or not to include the `path_to_root` list for
|
333
|
+
# each returned category instance. The `path_to_root` list consists of
|
334
|
+
# `CategoryPathToRootNode` objects and specifies the path that starts with
|
335
|
+
# the immediate parent category of the returned category and ends with its
|
336
|
+
# root category. If the returned category is a top-level category, the
|
337
|
+
# `path_to_root` list is empty and is not returned in the response
|
338
|
+
# payload.
|
331
339
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
332
340
|
def retrieve_catalog_object(object_id:,
|
333
341
|
include_related_objects: false,
|
334
|
-
catalog_version: nil
|
342
|
+
catalog_version: nil,
|
343
|
+
include_category_path_to_root: false)
|
335
344
|
new_api_call_builder
|
336
345
|
.request(new_request_builder(HttpMethodEnum::GET,
|
337
346
|
'/v2/catalog/object/{object_id}',
|
@@ -340,6 +349,7 @@ module Square
|
|
340
349
|
.should_encode(true))
|
341
350
|
.query_param(new_parameter(include_related_objects, key: 'include_related_objects'))
|
342
351
|
.query_param(new_parameter(catalog_version, key: 'catalog_version'))
|
352
|
+
.query_param(new_parameter(include_category_path_to_root, key: 'include_category_path_to_root'))
|
343
353
|
.header_param(new_parameter('application/json', key: 'accept'))
|
344
354
|
.auth(Single.new('global')))
|
345
355
|
.response(new_response_handler
|
@@ -35,13 +35,98 @@ module Square
|
|
35
35
|
.execute
|
36
36
|
end
|
37
37
|
|
38
|
+
# Retrieves the location-level settings for a Square-hosted checkout page.
|
39
|
+
# @param [String] location_id Required parameter: The ID of the location for
|
40
|
+
# which to retrieve settings.
|
41
|
+
# @return [RetrieveLocationSettingsResponse Hash] response from the API call
|
42
|
+
def retrieve_location_settings(location_id:)
|
43
|
+
new_api_call_builder
|
44
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
45
|
+
'/v2/online-checkout/location-settings/{location_id}',
|
46
|
+
'default')
|
47
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
48
|
+
.should_encode(true))
|
49
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
50
|
+
.auth(Single.new('global')))
|
51
|
+
.response(new_response_handler
|
52
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
53
|
+
.is_api_response(true)
|
54
|
+
.convertor(ApiResponse.method(:create)))
|
55
|
+
.execute
|
56
|
+
end
|
57
|
+
|
58
|
+
# Updates the location-level settings for a Square-hosted checkout page.
|
59
|
+
# @param [String] location_id Required parameter: The ID of the location for
|
60
|
+
# which to retrieve settings.
|
61
|
+
# @param [UpdateLocationSettingsRequest] body Required parameter: An object
|
62
|
+
# containing the fields to POST for the request. See the corresponding
|
63
|
+
# object definition for field details.
|
64
|
+
# @return [UpdateLocationSettingsResponse Hash] response from the API call
|
65
|
+
def update_location_settings(location_id:,
|
66
|
+
body:)
|
67
|
+
new_api_call_builder
|
68
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
69
|
+
'/v2/online-checkout/location-settings/{location_id}',
|
70
|
+
'default')
|
71
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
72
|
+
.should_encode(true))
|
73
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
74
|
+
.body_param(new_parameter(body))
|
75
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
76
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
77
|
+
.auth(Single.new('global')))
|
78
|
+
.response(new_response_handler
|
79
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
80
|
+
.is_api_response(true)
|
81
|
+
.convertor(ApiResponse.method(:create)))
|
82
|
+
.execute
|
83
|
+
end
|
84
|
+
|
85
|
+
# Retrieves the merchant-level settings for a Square-hosted checkout page.
|
86
|
+
# @return [RetrieveMerchantSettingsResponse Hash] response from the API call
|
87
|
+
def retrieve_merchant_settings
|
88
|
+
new_api_call_builder
|
89
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
90
|
+
'/v2/online-checkout/merchant-settings',
|
91
|
+
'default')
|
92
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
93
|
+
.auth(Single.new('global')))
|
94
|
+
.response(new_response_handler
|
95
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
96
|
+
.is_api_response(true)
|
97
|
+
.convertor(ApiResponse.method(:create)))
|
98
|
+
.execute
|
99
|
+
end
|
100
|
+
|
101
|
+
# Updates the merchant-level settings for a Square-hosted checkout page.
|
102
|
+
# @param [UpdateMerchantSettingsRequest] body Required parameter: An object
|
103
|
+
# containing the fields to POST for the request. See the corresponding
|
104
|
+
# object definition for field details.
|
105
|
+
# @return [UpdateMerchantSettingsResponse Hash] response from the API call
|
106
|
+
def update_merchant_settings(body:)
|
107
|
+
new_api_call_builder
|
108
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
109
|
+
'/v2/online-checkout/merchant-settings',
|
110
|
+
'default')
|
111
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
112
|
+
.body_param(new_parameter(body))
|
113
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
114
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
115
|
+
.auth(Single.new('global')))
|
116
|
+
.response(new_response_handler
|
117
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
118
|
+
.is_api_response(true)
|
119
|
+
.convertor(ApiResponse.method(:create)))
|
120
|
+
.execute
|
121
|
+
end
|
122
|
+
|
38
123
|
# Lists all payment links.
|
39
124
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
40
125
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
41
126
|
# set of results for the original query. If a cursor is not provided, the
|
42
127
|
# endpoint returns the first page of the results. For more information, see
|
43
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
44
|
-
# .
|
128
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
129
|
+
# atterns/pagination).
|
45
130
|
# @param [Integer] limit Optional parameter: A limit on the number of
|
46
131
|
# results to return per page. The limit is advisory and the implementation
|
47
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
|
@@ -171,6 +171,71 @@ module Square
|
|
171
171
|
.execute
|
172
172
|
end
|
173
173
|
|
174
|
+
# Uploads a file and attaches it to an invoice. This endpoint accepts HTTP
|
175
|
+
# multipart/form-data file uploads
|
176
|
+
# with a JSON `request` part and a `file` part. The `file` part must be a
|
177
|
+
# `readable stream` that contains a file
|
178
|
+
# in a supported format: GIF, JPEG, PNG, TIFF, BMP, or PDF.
|
179
|
+
# Invoices can have up to 10 attachments with a total file size of 25 MB.
|
180
|
+
# Attachments can be added only to invoices
|
181
|
+
# in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state.
|
182
|
+
# @param [String] invoice_id Required parameter: The ID of the
|
183
|
+
# [invoice](entity:Invoice) to attach the file to.
|
184
|
+
# @param [CreateInvoiceAttachmentRequest] request Optional parameter:
|
185
|
+
# Represents a
|
186
|
+
# [CreateInvoiceAttachment]($e/Invoices/CreateInvoiceAttachment) request.
|
187
|
+
# @param [File | UploadIO] image_file Optional parameter: Example:
|
188
|
+
# @return [CreateInvoiceAttachmentResponse Hash] response from the API call
|
189
|
+
def create_invoice_attachment(invoice_id:,
|
190
|
+
request: nil,
|
191
|
+
image_file: nil)
|
192
|
+
new_api_call_builder
|
193
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
194
|
+
'/v2/invoices/{invoice_id}/attachments',
|
195
|
+
'default')
|
196
|
+
.template_param(new_parameter(invoice_id, key: 'invoice_id')
|
197
|
+
.should_encode(true))
|
198
|
+
.multipart_param(new_parameter(StringIO.new(request.to_json), key: 'request')
|
199
|
+
.default_content_type('application/json; charset=utf-8'))
|
200
|
+
.multipart_param(new_parameter(image_file, key: 'image_file')
|
201
|
+
.default_content_type('image/jpeg'))
|
202
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
203
|
+
.auth(Single.new('global')))
|
204
|
+
.response(new_response_handler
|
205
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
206
|
+
.is_api_response(true)
|
207
|
+
.convertor(ApiResponse.method(:create)))
|
208
|
+
.execute
|
209
|
+
end
|
210
|
+
|
211
|
+
# Removes an attachment from an invoice and permanently deletes the file.
|
212
|
+
# Attachments can be removed only
|
213
|
+
# from invoices in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID`
|
214
|
+
# state.
|
215
|
+
# @param [String] invoice_id Required parameter: The ID of the
|
216
|
+
# [invoice](entity:Invoice) to delete the attachment from.
|
217
|
+
# @param [String] attachment_id Required parameter: The ID of the
|
218
|
+
# [attachment](entity:InvoiceAttachment) to delete.
|
219
|
+
# @return [DeleteInvoiceAttachmentResponse Hash] response from the API call
|
220
|
+
def delete_invoice_attachment(invoice_id:,
|
221
|
+
attachment_id:)
|
222
|
+
new_api_call_builder
|
223
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
224
|
+
'/v2/invoices/{invoice_id}/attachments/{attachment_id}',
|
225
|
+
'default')
|
226
|
+
.template_param(new_parameter(invoice_id, key: 'invoice_id')
|
227
|
+
.should_encode(true))
|
228
|
+
.template_param(new_parameter(attachment_id, key: 'attachment_id')
|
229
|
+
.should_encode(true))
|
230
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
231
|
+
.auth(Single.new('global')))
|
232
|
+
.response(new_response_handler
|
233
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
234
|
+
.is_api_response(true)
|
235
|
+
.convertor(ApiResponse.method(:create)))
|
236
|
+
.execute
|
237
|
+
end
|
238
|
+
|
174
239
|
# Cancels an invoice. The seller cannot collect payments for
|
175
240
|
# the canceled invoice.
|
176
241
|
# You cannot cancel an invoice in the `DRAFT` state or in a terminal state:
|
@@ -211,9 +276,13 @@ module Square
|
|
211
276
|
# The invoice `status` also changes from `DRAFT` to a status
|
212
277
|
# based on the invoice configuration. For example, the status changes to
|
213
278
|
# `UNPAID` if
|
214
|
-
# Square emails the invoice or `PARTIALLY_PAID` if Square
|
279
|
+
# Square emails the invoice or `PARTIALLY_PAID` if Square charges a card on
|
215
280
|
# file for a portion of the
|
216
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.
|
217
286
|
# @param [String] invoice_id Required parameter: The ID of the invoice to
|
218
287
|
# publish.
|
219
288
|
# @param [PublishInvoiceRequest] body Required parameter: An object
|
data/lib/square/api/labor_api.rb
CHANGED
@@ -183,19 +183,20 @@ module Square
|
|
183
183
|
end
|
184
184
|
|
185
185
|
# Creates a new `Shift`.
|
186
|
-
# A `Shift` represents a complete workday for a single
|
186
|
+
# A `Shift` represents a complete workday for a single team member.
|
187
187
|
# You must provide the following values in your request to this
|
188
188
|
# endpoint:
|
189
189
|
# - `location_id`
|
190
|
-
# - `
|
190
|
+
# - `team_member_id`
|
191
191
|
# - `start_at`
|
192
192
|
# An attempt to create a new `Shift` can result in a `BAD_REQUEST` error
|
193
193
|
# when:
|
194
|
-
# - The `status` of the new `Shift` is `OPEN` and the
|
194
|
+
# - The `status` of the new `Shift` is `OPEN` and the team member has
|
195
|
+
# another
|
195
196
|
# shift with an `OPEN` status.
|
196
197
|
# - The `start_at` date is in the future.
|
197
|
-
# - The `start_at` or `end_at` date overlaps another shift for the same
|
198
|
-
#
|
198
|
+
# - The `start_at` or `end_at` date overlaps another shift for the same team
|
199
|
+
# member.
|
199
200
|
# - The `Break` instances are set in the request and a break `start_at`
|
200
201
|
# is before the `Shift.start_at`, a break `end_at` is after
|
201
202
|
# the `Shift.end_at`, or both.
|
@@ -222,17 +223,17 @@ module Square
|
|
222
223
|
|
223
224
|
# Returns a paginated list of `Shift` records for a business.
|
224
225
|
# The list to be returned can be filtered by:
|
225
|
-
# - Location IDs
|
226
|
-
# -
|
227
|
-
# - Shift status (`OPEN`
|
228
|
-
# - Shift start
|
229
|
-
# - Shift end
|
230
|
-
# - Workday details
|
226
|
+
# - Location IDs
|
227
|
+
# - Team member IDs
|
228
|
+
# - Shift status (`OPEN` or `CLOSED`)
|
229
|
+
# - Shift start
|
230
|
+
# - Shift end
|
231
|
+
# - Workday details
|
231
232
|
# The list can be sorted by:
|
232
|
-
# - `
|
233
|
-
# - `
|
234
|
-
# - `
|
235
|
-
# - `
|
233
|
+
# - `START_AT`
|
234
|
+
# - `END_AT`
|
235
|
+
# - `CREATED_AT`
|
236
|
+
# - `UPDATED_AT`
|
236
237
|
# @param [SearchShiftsRequest] body Required parameter: An object containing
|
237
238
|
# the fields to POST for the request. See the corresponding object
|
238
239
|
# definition for field details.
|
@@ -355,7 +356,7 @@ module Square
|
|
355
356
|
.execute
|
356
357
|
end
|
357
358
|
|
358
|
-
# Returns a single `TeamMemberWage` specified by `id
|
359
|
+
# Returns a single `TeamMemberWage` specified by `id`.
|
359
360
|
# @param [String] id Required parameter: The UUID for the `TeamMemberWage`
|
360
361
|
# being retrieved.
|
361
362
|
# @return [GetTeamMemberWageResponse Hash] response from the API call
|
@@ -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
|
@@ -94,7 +94,7 @@ module Square
|
|
94
94
|
# Actions](https://developer.squareup.com/docs/terminal-api/advanced-feature
|
95
95
|
# s/custom-workflows/link-and-dismiss-actions) for more details.
|
96
96
|
# @param [String] action_id Required parameter: Unique ID for the
|
97
|
-
# `TerminalAction` associated with the
|
97
|
+
# `TerminalAction` associated with the action to be dismissed.
|
98
98
|
# @return [DismissTerminalActionResponse Hash] response from the API call
|
99
99
|
def dismiss_terminal_action(action_id:)
|
100
100
|
new_api_call_builder
|
@@ -203,6 +203,27 @@ module Square
|
|
203
203
|
.execute
|
204
204
|
end
|
205
205
|
|
206
|
+
# Dismisses a Terminal checkout request if the status and type of the
|
207
|
+
# request permits it.
|
208
|
+
# @param [String] checkout_id Required parameter: Unique ID for the
|
209
|
+
# `TerminalCheckout` associated with the checkout to be dismissed.
|
210
|
+
# @return [DismissTerminalCheckoutResponse Hash] response from the API call
|
211
|
+
def dismiss_terminal_checkout(checkout_id:)
|
212
|
+
new_api_call_builder
|
213
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
214
|
+
'/v2/terminals/checkouts/{checkout_id}/dismiss',
|
215
|
+
'default')
|
216
|
+
.template_param(new_parameter(checkout_id, key: 'checkout_id')
|
217
|
+
.should_encode(true))
|
218
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
219
|
+
.auth(Single.new('global')))
|
220
|
+
.response(new_response_handler
|
221
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
222
|
+
.is_api_response(true)
|
223
|
+
.convertor(ApiResponse.method(:create)))
|
224
|
+
.execute
|
225
|
+
end
|
226
|
+
|
206
227
|
# Creates a request to refund an Interac payment completed on a Square
|
207
228
|
# Terminal. Refunds for Interac payments on a Square Terminal are supported
|
208
229
|
# only for Interac debit cards in Canada. Other refunds for Terminal
|
@@ -294,5 +315,26 @@ module Square
|
|
294
315
|
.convertor(ApiResponse.method(:create)))
|
295
316
|
.execute
|
296
317
|
end
|
318
|
+
|
319
|
+
# Dismisses a Terminal refund request if the status and type of the request
|
320
|
+
# permits it.
|
321
|
+
# @param [String] terminal_refund_id Required parameter: Unique ID for the
|
322
|
+
# `TerminalRefund` associated with the refund to be dismissed.
|
323
|
+
# @return [DismissTerminalRefundResponse Hash] response from the API call
|
324
|
+
def dismiss_terminal_refund(terminal_refund_id:)
|
325
|
+
new_api_call_builder
|
326
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
327
|
+
'/v2/terminals/refunds/{terminal_refund_id}/dismiss',
|
328
|
+
'default')
|
329
|
+
.template_param(new_parameter(terminal_refund_id, key: 'terminal_refund_id')
|
330
|
+
.should_encode(true))
|
331
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
332
|
+
.auth(Single.new('global')))
|
333
|
+
.response(new_response_handler
|
334
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
335
|
+
.is_api_response(true)
|
336
|
+
.convertor(ApiResponse.method(:create)))
|
337
|
+
.execute
|
338
|
+
end
|
297
339
|
end
|
298
340
|
end
|
@@ -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.1.0.20240320'
|
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-03-20',
|
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-03-20',
|
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' => {
|
@@ -20,7 +20,7 @@ module Square
|
|
20
20
|
|
21
21
|
@cursor = data.fetch(:cursor, nil)
|
22
22
|
data.reject! { |k| %i[cursor errors].include?(k) }
|
23
|
-
@data = Struct.new(*data.keys).new(*data.values)
|
23
|
+
@data = data.keys.any? ? Struct.new(*data.keys).new(*data.values) : nil
|
24
24
|
else
|
25
25
|
@data = data
|
26
26
|
@body = data
|
@@ -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.1.0.20240320
|
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:
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: apimatic_core_interfaces
|