square.rb 19.0.0.20220420 → 20.0.0.20220512
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/README.md +6 -0
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +9 -0
- data/lib/square/api/checkout_api.rb +202 -0
- data/lib/square/api/customer_custom_attributes_api.rb +540 -0
- data/lib/square/api/gift_card_activities_api.rb +5 -6
- data/lib/square/api/gift_cards_api.rb +6 -6
- data/lib/square/api/terminal_api.rb +143 -0
- data/lib/square/client.rb +8 -2
- data/lib/square/configuration.rb +1 -1
- data/lib/square.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1907488e99eddc840ad5c67c38ac3feaacf9b6440359b6085add2d248388ab7a
|
4
|
+
data.tar.gz: e6647691aec85fd628b47ac329248f9171a33570bf0eb37871391f7e246a8014
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b0d5825af20339f09f49466d34a46825bc25c995eba52108174d1e78ed58083cc1c5b280fecefe4f1edbf94a8ca45aba427c0c01feafac02b6e0b076224f749
|
7
|
+
data.tar.gz: 572efdbd9f3ebb6915ab82e2c2b554e5b2e53d764f6a64f05c4cfd5373118e73f97b9076ad0ce8d0dc70c3c5a540d29db5fb101ceb4bde7da8638e0edc4eb448
|
data/README.md
CHANGED
@@ -62,6 +62,7 @@ rake
|
|
62
62
|
* [Checkout]
|
63
63
|
* [Apple Pay]
|
64
64
|
* [Cards]
|
65
|
+
* [Payouts]
|
65
66
|
|
66
67
|
### Terminal
|
67
68
|
* [Terminal]
|
@@ -81,6 +82,7 @@ rake
|
|
81
82
|
|
82
83
|
### Customers
|
83
84
|
* [Customers]
|
85
|
+
* [Customer Custom Attributes]
|
84
86
|
* [Customer Groups]
|
85
87
|
* [Customer Segments]
|
86
88
|
|
@@ -99,6 +101,7 @@ rake
|
|
99
101
|
* [Locations]
|
100
102
|
* [Devices]
|
101
103
|
* [Cash Drawers]
|
104
|
+
* [Vendors]
|
102
105
|
|
103
106
|
### Team
|
104
107
|
* [Team]
|
@@ -134,6 +137,7 @@ rake
|
|
134
137
|
[Terminal]: doc/api/terminal.md
|
135
138
|
[Team]: doc/api/team.md
|
136
139
|
[Cash Drawers]: doc/api/cash-drawers.md
|
140
|
+
[Vendors]: doc/api/vendors.md
|
137
141
|
[Customer Groups]: doc/api/customer-groups.md
|
138
142
|
[Customer Segments]: doc/api/customer-segments.md
|
139
143
|
[Bank Accounts]: doc/api/bank-accounts.md
|
@@ -141,6 +145,7 @@ rake
|
|
141
145
|
[Checkout]: doc/api/checkout.md
|
142
146
|
[Catalog]: doc/api/catalog.md
|
143
147
|
[Customers]: doc/api/customers.md
|
148
|
+
[Customer Custom Attributes]: doc/api/customer-custom-attributes.md
|
144
149
|
[Employees]: doc/api/employees.md
|
145
150
|
[Inventory]: doc/api/inventory.md
|
146
151
|
[Labor]: doc/api/labor.md
|
@@ -162,5 +167,6 @@ rake
|
|
162
167
|
[Sites]: doc/api/sites.md
|
163
168
|
[Snippets]: doc/api/snippets.md
|
164
169
|
[Cards]: doc/api/cards.md
|
170
|
+
[Payouts]: doc/api/payouts.md
|
165
171
|
[Gift Cards]: doc/api/gift-cards.md
|
166
172
|
[Gift Card Activities]: doc/api/gift-card-activities.md
|
data/lib/square/api/base_api.rb
CHANGED
@@ -38,7 +38,7 @@ module Square
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def get_user_agent
|
41
|
-
user_agent = 'Square-Ruby-SDK/
|
41
|
+
user_agent = 'Square-Ruby-SDK/20.0.0.20220512 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
42
42
|
user_agent['{engine}'] = RUBY_ENGINE
|
43
43
|
user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
|
44
44
|
user_agent['{os-info}'] = RUBY_PLATFORM
|
@@ -74,6 +74,9 @@ module Square
|
|
74
74
|
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
75
75
|
# To call this endpoint with seller-level permissions, set
|
76
76
|
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
77
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
78
|
+
# seller must have subscribed to *Appointments Plus*
|
79
|
+
# or *Appointments Premium*.
|
77
80
|
# @param [CreateBookingRequest] body Required parameter: An object
|
78
81
|
# containing the fields to POST for the request. See the corresponding
|
79
82
|
# object definition for field details.
|
@@ -303,6 +306,9 @@ module Square
|
|
303
306
|
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
304
307
|
# To call this endpoint with seller-level permissions, set
|
305
308
|
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
309
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
310
|
+
# seller must have subscribed to *Appointments Plus*
|
311
|
+
# or *Appointments Premium*.
|
306
312
|
# @param [String] booking_id Required parameter: The ID of the
|
307
313
|
# [Booking]($m/Booking) object representing the to-be-updated booking.
|
308
314
|
# @param [UpdateBookingRequest] body Required parameter: An object
|
@@ -348,6 +354,9 @@ module Square
|
|
348
354
|
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
349
355
|
# To call this endpoint with seller-level permissions, set
|
350
356
|
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
357
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
358
|
+
# seller must have subscribed to *Appointments Plus*
|
359
|
+
# or *Appointments Premium*.
|
351
360
|
# @param [String] booking_id Required parameter: The ID of the
|
352
361
|
# [Booking]($m/Booking) object representing the to-be-cancelled booking.
|
353
362
|
# @param [CancelBookingRequest] body Required parameter: An object
|
@@ -8,6 +8,13 @@ module Square
|
|
8
8
|
# Links a `checkoutId` to a `checkout_page_url` that customers are
|
9
9
|
# directed to in order to provide their payment information using a
|
10
10
|
# payment processing workflow hosted on connect.squareup.com.
|
11
|
+
# NOTE: The Checkout API has been updated with new features.
|
12
|
+
# For more information, see [Checkout API
|
13
|
+
# highlights](https://developer.squareup.com/docs/checkout-api#checkout-api-
|
14
|
+
# highlights).
|
15
|
+
# We recommend that you use the
|
16
|
+
# new [CreatePaymentLink]($e/Checkout/CreatePaymentLink)
|
17
|
+
# endpoint in place of this previously released endpoint.
|
11
18
|
# @param [String] location_id Required parameter: The ID of the business
|
12
19
|
# location to associate the checkout with.
|
13
20
|
# @param [CreateCheckoutRequest] body Required parameter: An object
|
@@ -47,5 +54,200 @@ module Square
|
|
47
54
|
_response, data: decoded, errors: _errors
|
48
55
|
)
|
49
56
|
end
|
57
|
+
|
58
|
+
# Lists all payment links.
|
59
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
60
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the
|
61
|
+
# next set of results for the original query. If a cursor is not provided,
|
62
|
+
# the endpoint returns the first page of the results. For more
|
63
|
+
# information, see
|
64
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
65
|
+
# .
|
66
|
+
# @param [Integer] limit Optional parameter: A limit on the number of
|
67
|
+
# results to return per page. The limit is advisory and the implementation
|
68
|
+
# might return more or less results. If the supplied limit is negative,
|
69
|
+
# zero, or greater than the maximum limit of 1000, it is ignored. Default
|
70
|
+
# value: `100`
|
71
|
+
# @return [ListPaymentLinksResponse Hash] response from the API call
|
72
|
+
def list_payment_links(cursor: nil,
|
73
|
+
limit: nil)
|
74
|
+
# Prepare query url.
|
75
|
+
_query_builder = config.get_base_uri
|
76
|
+
_query_builder << '/v2/online-checkout/payment-links'
|
77
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
78
|
+
_query_builder,
|
79
|
+
'cursor' => cursor,
|
80
|
+
'limit' => limit
|
81
|
+
)
|
82
|
+
_query_url = APIHelper.clean_url _query_builder
|
83
|
+
|
84
|
+
# Prepare headers.
|
85
|
+
_headers = {
|
86
|
+
'accept' => 'application/json'
|
87
|
+
}
|
88
|
+
|
89
|
+
# Prepare and execute HttpRequest.
|
90
|
+
_request = config.http_client.get(
|
91
|
+
_query_url,
|
92
|
+
headers: _headers
|
93
|
+
)
|
94
|
+
OAuth2.apply(config, _request)
|
95
|
+
_response = execute_request(_request)
|
96
|
+
|
97
|
+
# Return appropriate response type.
|
98
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
99
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
100
|
+
ApiResponse.new(
|
101
|
+
_response, data: decoded, errors: _errors
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Creates a Square-hosted checkout page. Applications can share the
|
106
|
+
# resulting payment link with their buyer to pay for goods and services.
|
107
|
+
# @param [CreatePaymentLinkRequest] body Required parameter: An object
|
108
|
+
# containing the fields to POST for the request. See the corresponding
|
109
|
+
# object definition for field details.
|
110
|
+
# @return [CreatePaymentLinkResponse Hash] response from the API call
|
111
|
+
def create_payment_link(body:)
|
112
|
+
# Prepare query url.
|
113
|
+
_query_builder = config.get_base_uri
|
114
|
+
_query_builder << '/v2/online-checkout/payment-links'
|
115
|
+
_query_url = APIHelper.clean_url _query_builder
|
116
|
+
|
117
|
+
# Prepare headers.
|
118
|
+
_headers = {
|
119
|
+
'accept' => 'application/json',
|
120
|
+
'Content-Type' => 'application/json'
|
121
|
+
}
|
122
|
+
|
123
|
+
# Prepare and execute HttpRequest.
|
124
|
+
_request = config.http_client.post(
|
125
|
+
_query_url,
|
126
|
+
headers: _headers,
|
127
|
+
parameters: body.to_json
|
128
|
+
)
|
129
|
+
OAuth2.apply(config, _request)
|
130
|
+
_response = execute_request(_request)
|
131
|
+
|
132
|
+
# Return appropriate response type.
|
133
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
134
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
135
|
+
ApiResponse.new(
|
136
|
+
_response, data: decoded, errors: _errors
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Deletes a payment link.
|
141
|
+
# @param [String] id Required parameter: The ID of the payment link to
|
142
|
+
# delete.
|
143
|
+
# @return [DeletePaymentLinkResponse Hash] response from the API call
|
144
|
+
def delete_payment_link(id:)
|
145
|
+
# Prepare query url.
|
146
|
+
_query_builder = config.get_base_uri
|
147
|
+
_query_builder << '/v2/online-checkout/payment-links/{id}'
|
148
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
149
|
+
_query_builder,
|
150
|
+
'id' => { 'value' => id, 'encode' => true }
|
151
|
+
)
|
152
|
+
_query_url = APIHelper.clean_url _query_builder
|
153
|
+
|
154
|
+
# Prepare headers.
|
155
|
+
_headers = {
|
156
|
+
'accept' => 'application/json'
|
157
|
+
}
|
158
|
+
|
159
|
+
# Prepare and execute HttpRequest.
|
160
|
+
_request = config.http_client.delete(
|
161
|
+
_query_url,
|
162
|
+
headers: _headers
|
163
|
+
)
|
164
|
+
OAuth2.apply(config, _request)
|
165
|
+
_response = execute_request(_request)
|
166
|
+
|
167
|
+
# Return appropriate response type.
|
168
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
169
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
170
|
+
ApiResponse.new(
|
171
|
+
_response, data: decoded, errors: _errors
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Retrieves a payment link.
|
176
|
+
# @param [String] id Required parameter: The ID of link to retrieve.
|
177
|
+
# @return [RetrievePaymentLinkResponse Hash] response from the API call
|
178
|
+
def retrieve_payment_link(id:)
|
179
|
+
# Prepare query url.
|
180
|
+
_query_builder = config.get_base_uri
|
181
|
+
_query_builder << '/v2/online-checkout/payment-links/{id}'
|
182
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
183
|
+
_query_builder,
|
184
|
+
'id' => { 'value' => id, 'encode' => true }
|
185
|
+
)
|
186
|
+
_query_url = APIHelper.clean_url _query_builder
|
187
|
+
|
188
|
+
# Prepare headers.
|
189
|
+
_headers = {
|
190
|
+
'accept' => 'application/json'
|
191
|
+
}
|
192
|
+
|
193
|
+
# Prepare and execute HttpRequest.
|
194
|
+
_request = config.http_client.get(
|
195
|
+
_query_url,
|
196
|
+
headers: _headers
|
197
|
+
)
|
198
|
+
OAuth2.apply(config, _request)
|
199
|
+
_response = execute_request(_request)
|
200
|
+
|
201
|
+
# Return appropriate response type.
|
202
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
203
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
204
|
+
ApiResponse.new(
|
205
|
+
_response, data: decoded, errors: _errors
|
206
|
+
)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Updates a payment link. You can update the `payment_link` fields such as
|
210
|
+
# `description`, `checkout_options`, and `pre_populated_data`.
|
211
|
+
# You cannot update other fields such as the `order_id`, `version`, `URL`,
|
212
|
+
# or `timestamp` field.
|
213
|
+
# @param [String] id Required parameter: The ID of the payment link to
|
214
|
+
# update.
|
215
|
+
# @param [UpdatePaymentLinkRequest] body Required parameter: An object
|
216
|
+
# containing the fields to POST for the request. See the corresponding
|
217
|
+
# object definition for field details.
|
218
|
+
# @return [UpdatePaymentLinkResponse Hash] response from the API call
|
219
|
+
def update_payment_link(id:,
|
220
|
+
body:)
|
221
|
+
# Prepare query url.
|
222
|
+
_query_builder = config.get_base_uri
|
223
|
+
_query_builder << '/v2/online-checkout/payment-links/{id}'
|
224
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
225
|
+
_query_builder,
|
226
|
+
'id' => { 'value' => id, 'encode' => true }
|
227
|
+
)
|
228
|
+
_query_url = APIHelper.clean_url _query_builder
|
229
|
+
|
230
|
+
# Prepare headers.
|
231
|
+
_headers = {
|
232
|
+
'accept' => 'application/json',
|
233
|
+
'Content-Type' => 'application/json'
|
234
|
+
}
|
235
|
+
|
236
|
+
# Prepare and execute HttpRequest.
|
237
|
+
_request = config.http_client.put(
|
238
|
+
_query_url,
|
239
|
+
headers: _headers,
|
240
|
+
parameters: body.to_json
|
241
|
+
)
|
242
|
+
OAuth2.apply(config, _request)
|
243
|
+
_response = execute_request(_request)
|
244
|
+
|
245
|
+
# Return appropriate response type.
|
246
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
247
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
248
|
+
ApiResponse.new(
|
249
|
+
_response, data: decoded, errors: _errors
|
250
|
+
)
|
251
|
+
end
|
50
252
|
end
|
51
253
|
end
|
@@ -0,0 +1,540 @@
|
|
1
|
+
module Square
|
2
|
+
# CustomerCustomAttributesApi
|
3
|
+
class CustomerCustomAttributesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists the customer-related custom attribute definitions that belong to a
|
9
|
+
# Square seller account.
|
10
|
+
# When all response pages are retrieved, the results include all custom
|
11
|
+
# attribute definitions
|
12
|
+
# that are visible to the requesting application, including those that are
|
13
|
+
# created by other
|
14
|
+
# applications and set to `VISIBILITY_READ_ONLY` or
|
15
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
16
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
17
|
+
# to return in a single paged response. This limit is advisory. The response
|
18
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
19
|
+
# maximum value is 100. The default value is 20. For more information, see
|
20
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
21
|
+
# atterns/pagination).
|
22
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
23
|
+
# paged response from the previous call to this endpoint. Provide this
|
24
|
+
# cursor to retrieve the next page of results for your original request. For
|
25
|
+
# more information, see
|
26
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
27
|
+
# atterns/pagination).
|
28
|
+
# @return [ListCustomerCustomAttributeDefinitionsResponse Hash] response from the API call
|
29
|
+
def list_customer_custom_attribute_definitions(limit: nil,
|
30
|
+
cursor: nil)
|
31
|
+
# Prepare query url.
|
32
|
+
_query_builder = config.get_base_uri
|
33
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
34
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
35
|
+
_query_builder,
|
36
|
+
'limit' => limit,
|
37
|
+
'cursor' => cursor
|
38
|
+
)
|
39
|
+
_query_url = APIHelper.clean_url _query_builder
|
40
|
+
|
41
|
+
# Prepare headers.
|
42
|
+
_headers = {
|
43
|
+
'accept' => 'application/json'
|
44
|
+
}
|
45
|
+
|
46
|
+
# Prepare and execute HttpRequest.
|
47
|
+
_request = config.http_client.get(
|
48
|
+
_query_url,
|
49
|
+
headers: _headers
|
50
|
+
)
|
51
|
+
OAuth2.apply(config, _request)
|
52
|
+
_response = execute_request(_request)
|
53
|
+
|
54
|
+
# Return appropriate response type.
|
55
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
56
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
57
|
+
ApiResponse.new(
|
58
|
+
_response, data: decoded, errors: _errors
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Creates a customer-related custom attribute definition for a Square seller
|
63
|
+
# account. Use this
|
64
|
+
# endpoint to define a custom attribute that can be associated with customer
|
65
|
+
# profiles.
|
66
|
+
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
67
|
+
# and other properties
|
68
|
+
# for a custom attribute. After the definition is created, you can call
|
69
|
+
# [UpsertCustomerCustomAttribute]($e/CustomerCustomAttributes/UpsertCustomer
|
70
|
+
# CustomAttribute) or
|
71
|
+
# [BulkUpsertCustomerCustomAttributes]($e/CustomerCustomAttributes/BulkUpser
|
72
|
+
# tCustomerCustomAttributes)
|
73
|
+
# to set the custom attribute for customer profiles in the seller's Customer
|
74
|
+
# Directory.
|
75
|
+
# Sellers can view all custom attributes in exported customer data,
|
76
|
+
# including those set to
|
77
|
+
# `VISIBILITY_HIDDEN`.
|
78
|
+
# @param [CreateCustomerCustomAttributeDefinitionRequest] body Required
|
79
|
+
# parameter: An object containing the fields to POST for the request. See
|
80
|
+
# the corresponding object definition for field details.
|
81
|
+
# @return [CreateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
82
|
+
def create_customer_custom_attribute_definition(body:)
|
83
|
+
# Prepare query url.
|
84
|
+
_query_builder = config.get_base_uri
|
85
|
+
_query_builder << '/v2/customers/custom-attribute-definitions'
|
86
|
+
_query_url = APIHelper.clean_url _query_builder
|
87
|
+
|
88
|
+
# Prepare headers.
|
89
|
+
_headers = {
|
90
|
+
'accept' => 'application/json',
|
91
|
+
'Content-Type' => 'application/json'
|
92
|
+
}
|
93
|
+
|
94
|
+
# Prepare and execute HttpRequest.
|
95
|
+
_request = config.http_client.post(
|
96
|
+
_query_url,
|
97
|
+
headers: _headers,
|
98
|
+
parameters: body.to_json
|
99
|
+
)
|
100
|
+
OAuth2.apply(config, _request)
|
101
|
+
_response = execute_request(_request)
|
102
|
+
|
103
|
+
# Return appropriate response type.
|
104
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
105
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
106
|
+
ApiResponse.new(
|
107
|
+
_response, data: decoded, errors: _errors
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Deletes a customer-related custom attribute definition from a Square
|
112
|
+
# seller account.
|
113
|
+
# Deleting a custom attribute definition also deletes the corresponding
|
114
|
+
# custom attribute from
|
115
|
+
# all customer profiles in the seller's Customer Directory.
|
116
|
+
# Only the definition owner can delete a custom attribute definition.
|
117
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
118
|
+
# definition to delete.
|
119
|
+
# @return [DeleteCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
120
|
+
def delete_customer_custom_attribute_definition(key:)
|
121
|
+
# Prepare query url.
|
122
|
+
_query_builder = config.get_base_uri
|
123
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
124
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
125
|
+
_query_builder,
|
126
|
+
'key' => { 'value' => key, 'encode' => true }
|
127
|
+
)
|
128
|
+
_query_url = APIHelper.clean_url _query_builder
|
129
|
+
|
130
|
+
# Prepare headers.
|
131
|
+
_headers = {
|
132
|
+
'accept' => 'application/json'
|
133
|
+
}
|
134
|
+
|
135
|
+
# Prepare and execute HttpRequest.
|
136
|
+
_request = config.http_client.delete(
|
137
|
+
_query_url,
|
138
|
+
headers: _headers
|
139
|
+
)
|
140
|
+
OAuth2.apply(config, _request)
|
141
|
+
_response = execute_request(_request)
|
142
|
+
|
143
|
+
# Return appropriate response type.
|
144
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
145
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
146
|
+
ApiResponse.new(
|
147
|
+
_response, data: decoded, errors: _errors
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
151
|
+
# Retrieves a customer-related custom attribute definition from a Square
|
152
|
+
# seller account.
|
153
|
+
# To retrieve a custom attribute definition created by another application,
|
154
|
+
# the `visibility`
|
155
|
+
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
156
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
157
|
+
# definition to retrieve. If the requesting application is not the
|
158
|
+
# definition owner, you must use the qualified key.
|
159
|
+
# @param [Integer] version Optional parameter: The current version of the
|
160
|
+
# custom attribute definition, which is used for strongly consistent reads
|
161
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
162
|
+
# the request, Square returns the specified version or a higher version if
|
163
|
+
# one exists. If the specified version is higher than the current version,
|
164
|
+
# Square returns a `BAD_REQUEST` error.
|
165
|
+
# @return [RetrieveCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
166
|
+
def retrieve_customer_custom_attribute_definition(key:,
|
167
|
+
version: nil)
|
168
|
+
# Prepare query url.
|
169
|
+
_query_builder = config.get_base_uri
|
170
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
171
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
172
|
+
_query_builder,
|
173
|
+
'key' => { 'value' => key, 'encode' => true }
|
174
|
+
)
|
175
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'version' => version
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json'
|
184
|
+
}
|
185
|
+
|
186
|
+
# Prepare and execute HttpRequest.
|
187
|
+
_request = config.http_client.get(
|
188
|
+
_query_url,
|
189
|
+
headers: _headers
|
190
|
+
)
|
191
|
+
OAuth2.apply(config, _request)
|
192
|
+
_response = execute_request(_request)
|
193
|
+
|
194
|
+
# Return appropriate response type.
|
195
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
196
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
197
|
+
ApiResponse.new(
|
198
|
+
_response, data: decoded, errors: _errors
|
199
|
+
)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Updates a customer-related custom attribute definition for a Square seller
|
203
|
+
# account.
|
204
|
+
# Use this endpoint to update the following fields: `name`, `description`,
|
205
|
+
# `visibility`, or the
|
206
|
+
# `schema` for a `Selection` data type.
|
207
|
+
# Only the definition owner can update a custom attribute definition. Note
|
208
|
+
# that sellers can view
|
209
|
+
# all custom attributes in exported customer data, including those set to
|
210
|
+
# `VISIBILITY_HIDDEN`.
|
211
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
212
|
+
# definition to update.
|
213
|
+
# @param [UpdateCustomerCustomAttributeDefinitionRequest] body Required
|
214
|
+
# parameter: An object containing the fields to POST for the request. See
|
215
|
+
# the corresponding object definition for field details.
|
216
|
+
# @return [UpdateCustomerCustomAttributeDefinitionResponse Hash] response from the API call
|
217
|
+
def update_customer_custom_attribute_definition(key:,
|
218
|
+
body:)
|
219
|
+
# Prepare query url.
|
220
|
+
_query_builder = config.get_base_uri
|
221
|
+
_query_builder << '/v2/customers/custom-attribute-definitions/{key}'
|
222
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
223
|
+
_query_builder,
|
224
|
+
'key' => { 'value' => key, 'encode' => true }
|
225
|
+
)
|
226
|
+
_query_url = APIHelper.clean_url _query_builder
|
227
|
+
|
228
|
+
# Prepare headers.
|
229
|
+
_headers = {
|
230
|
+
'accept' => 'application/json',
|
231
|
+
'Content-Type' => 'application/json'
|
232
|
+
}
|
233
|
+
|
234
|
+
# Prepare and execute HttpRequest.
|
235
|
+
_request = config.http_client.put(
|
236
|
+
_query_url,
|
237
|
+
headers: _headers,
|
238
|
+
parameters: body.to_json
|
239
|
+
)
|
240
|
+
OAuth2.apply(config, _request)
|
241
|
+
_response = execute_request(_request)
|
242
|
+
|
243
|
+
# Return appropriate response type.
|
244
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
245
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
246
|
+
ApiResponse.new(
|
247
|
+
_response, data: decoded, errors: _errors
|
248
|
+
)
|
249
|
+
end
|
250
|
+
|
251
|
+
# Creates or updates custom attributes for customer profiles as a bulk
|
252
|
+
# operation.
|
253
|
+
# Use this endpoint to set the value of one or more custom attributes for
|
254
|
+
# one or more customer profiles.
|
255
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
256
|
+
# seller account, which is
|
257
|
+
# created using the
|
258
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
259
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
260
|
+
# This `BulkUpsertCustomerCustomAttributes` endpoint accepts a map of 1 to
|
261
|
+
# 25 individual upsert
|
262
|
+
# requests and returns a map of individual upsert responses. Each upsert
|
263
|
+
# request has a unique ID
|
264
|
+
# and provides a customer ID and custom attribute. Each upsert response is
|
265
|
+
# returned with the ID
|
266
|
+
# of the corresponding request.
|
267
|
+
# To create or update a custom attribute owned by another application, the
|
268
|
+
# `visibility` setting
|
269
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
270
|
+
# @param [BulkUpsertCustomerCustomAttributesRequest] body Required
|
271
|
+
# parameter: An object containing the fields to POST for the request. See
|
272
|
+
# the corresponding object definition for field details.
|
273
|
+
# @return [BulkUpsertCustomerCustomAttributesResponse Hash] response from the API call
|
274
|
+
def bulk_upsert_customer_custom_attributes(body:)
|
275
|
+
# Prepare query url.
|
276
|
+
_query_builder = config.get_base_uri
|
277
|
+
_query_builder << '/v2/customers/custom-attributes/bulk-upsert'
|
278
|
+
_query_url = APIHelper.clean_url _query_builder
|
279
|
+
|
280
|
+
# Prepare headers.
|
281
|
+
_headers = {
|
282
|
+
'accept' => 'application/json',
|
283
|
+
'Content-Type' => 'application/json'
|
284
|
+
}
|
285
|
+
|
286
|
+
# Prepare and execute HttpRequest.
|
287
|
+
_request = config.http_client.post(
|
288
|
+
_query_url,
|
289
|
+
headers: _headers,
|
290
|
+
parameters: body.to_json
|
291
|
+
)
|
292
|
+
OAuth2.apply(config, _request)
|
293
|
+
_response = execute_request(_request)
|
294
|
+
|
295
|
+
# Return appropriate response type.
|
296
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
297
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
298
|
+
ApiResponse.new(
|
299
|
+
_response, data: decoded, errors: _errors
|
300
|
+
)
|
301
|
+
end
|
302
|
+
|
303
|
+
# Lists the custom attributes associated with a customer profile.
|
304
|
+
# You can use the `with_definitions` query parameter to also retrieve custom
|
305
|
+
# attribute definitions
|
306
|
+
# in the same call.
|
307
|
+
# When all response pages are retrieved, the results include all custom
|
308
|
+
# attributes that are
|
309
|
+
# visible to the requesting application, including those that are owned by
|
310
|
+
# other applications
|
311
|
+
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
312
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
313
|
+
# [customer profile]($m/Customer).
|
314
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
315
|
+
# to return in a single paged response. This limit is advisory. The response
|
316
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
317
|
+
# maximum value is 100. The default value is 20. For more information, see
|
318
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
319
|
+
# atterns/pagination).
|
320
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
321
|
+
# paged response from the previous call to this endpoint. Provide this
|
322
|
+
# cursor to retrieve the next page of results for your original request. For
|
323
|
+
# more information, see
|
324
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
325
|
+
# atterns/pagination).
|
326
|
+
# @param [Boolean] with_definitions Optional parameter: Indicates whether to
|
327
|
+
# return the [custom attribute definition]($m/CustomAttributeDefinition) in
|
328
|
+
# the `definition` field of each custom attribute. Set this parameter to
|
329
|
+
# `true` to get the name and description of each custom attribute,
|
330
|
+
# information about the data type, or other definition details. The default
|
331
|
+
# value is `false`.
|
332
|
+
# @return [ListCustomerCustomAttributesResponse Hash] response from the API call
|
333
|
+
def list_customer_custom_attributes(customer_id:,
|
334
|
+
limit: nil,
|
335
|
+
cursor: nil,
|
336
|
+
with_definitions: false)
|
337
|
+
# Prepare query url.
|
338
|
+
_query_builder = config.get_base_uri
|
339
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes'
|
340
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
|
+
_query_builder,
|
342
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true }
|
343
|
+
)
|
344
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
|
+
_query_builder,
|
346
|
+
'limit' => limit,
|
347
|
+
'cursor' => cursor,
|
348
|
+
'with_definitions' => with_definitions
|
349
|
+
)
|
350
|
+
_query_url = APIHelper.clean_url _query_builder
|
351
|
+
|
352
|
+
# Prepare headers.
|
353
|
+
_headers = {
|
354
|
+
'accept' => 'application/json'
|
355
|
+
}
|
356
|
+
|
357
|
+
# Prepare and execute HttpRequest.
|
358
|
+
_request = config.http_client.get(
|
359
|
+
_query_url,
|
360
|
+
headers: _headers
|
361
|
+
)
|
362
|
+
OAuth2.apply(config, _request)
|
363
|
+
_response = execute_request(_request)
|
364
|
+
|
365
|
+
# Return appropriate response type.
|
366
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
367
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
368
|
+
ApiResponse.new(
|
369
|
+
_response, data: decoded, errors: _errors
|
370
|
+
)
|
371
|
+
end
|
372
|
+
|
373
|
+
# Deletes a custom attribute associated with a customer profile.
|
374
|
+
# To delete a custom attribute owned by another application, the
|
375
|
+
# `visibility` setting must be
|
376
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
377
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
378
|
+
# [customer profile]($m/Customer).
|
379
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
380
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
381
|
+
# the Square seller account. If the requesting application is not the
|
382
|
+
# definition owner, you must use the qualified key.
|
383
|
+
# @return [DeleteCustomerCustomAttributeResponse Hash] response from the API call
|
384
|
+
def delete_customer_custom_attribute(customer_id:,
|
385
|
+
key:)
|
386
|
+
# Prepare query url.
|
387
|
+
_query_builder = config.get_base_uri
|
388
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
389
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
390
|
+
_query_builder,
|
391
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
392
|
+
'key' => { 'value' => key, 'encode' => true }
|
393
|
+
)
|
394
|
+
_query_url = APIHelper.clean_url _query_builder
|
395
|
+
|
396
|
+
# Prepare headers.
|
397
|
+
_headers = {
|
398
|
+
'accept' => 'application/json'
|
399
|
+
}
|
400
|
+
|
401
|
+
# Prepare and execute HttpRequest.
|
402
|
+
_request = config.http_client.delete(
|
403
|
+
_query_url,
|
404
|
+
headers: _headers
|
405
|
+
)
|
406
|
+
OAuth2.apply(config, _request)
|
407
|
+
_response = execute_request(_request)
|
408
|
+
|
409
|
+
# Return appropriate response type.
|
410
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
411
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
412
|
+
ApiResponse.new(
|
413
|
+
_response, data: decoded, errors: _errors
|
414
|
+
)
|
415
|
+
end
|
416
|
+
|
417
|
+
# Retrieves a custom attribute associated with a customer profile.
|
418
|
+
# You can use the `with_definition` query parameter to also retrieve the
|
419
|
+
# custom attribute definition
|
420
|
+
# in the same call.
|
421
|
+
# To retrieve a custom attribute owned by another application, the
|
422
|
+
# `visibility` setting must be
|
423
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
424
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
425
|
+
# [customer profile]($m/Customer).
|
426
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
427
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
428
|
+
# in the Square seller account. If the requesting application is not the
|
429
|
+
# definition owner, you must use the qualified key.
|
430
|
+
# @param [Boolean] with_definition Optional parameter: Indicates whether to
|
431
|
+
# return the [custom attribute definition]($m/CustomAttributeDefinition) in
|
432
|
+
# the `definition` field of the custom attribute. Set this parameter to
|
433
|
+
# `true` to get the name and description of the custom attribute,
|
434
|
+
# information about the data type, or other definition details. The default
|
435
|
+
# value is `false`.
|
436
|
+
# @param [Integer] version Optional parameter: The current version of the
|
437
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
438
|
+
# that you receive the most up-to-date data. When included in the request,
|
439
|
+
# Square returns the specified version or a higher version if one exists. If
|
440
|
+
# the specified version is higher than the current version, Square returns a
|
441
|
+
# `BAD_REQUEST` error.
|
442
|
+
# @return [RetrieveCustomerCustomAttributeResponse Hash] response from the API call
|
443
|
+
def retrieve_customer_custom_attribute(customer_id:,
|
444
|
+
key:,
|
445
|
+
with_definition: false,
|
446
|
+
version: nil)
|
447
|
+
# Prepare query url.
|
448
|
+
_query_builder = config.get_base_uri
|
449
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
450
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
451
|
+
_query_builder,
|
452
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
453
|
+
'key' => { 'value' => key, 'encode' => true }
|
454
|
+
)
|
455
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
456
|
+
_query_builder,
|
457
|
+
'with_definition' => with_definition,
|
458
|
+
'version' => version
|
459
|
+
)
|
460
|
+
_query_url = APIHelper.clean_url _query_builder
|
461
|
+
|
462
|
+
# Prepare headers.
|
463
|
+
_headers = {
|
464
|
+
'accept' => 'application/json'
|
465
|
+
}
|
466
|
+
|
467
|
+
# Prepare and execute HttpRequest.
|
468
|
+
_request = config.http_client.get(
|
469
|
+
_query_url,
|
470
|
+
headers: _headers
|
471
|
+
)
|
472
|
+
OAuth2.apply(config, _request)
|
473
|
+
_response = execute_request(_request)
|
474
|
+
|
475
|
+
# Return appropriate response type.
|
476
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
477
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
478
|
+
ApiResponse.new(
|
479
|
+
_response, data: decoded, errors: _errors
|
480
|
+
)
|
481
|
+
end
|
482
|
+
|
483
|
+
# Creates or updates a custom attribute for a customer profile.
|
484
|
+
# Use this endpoint to set the value of a custom attribute for a specified
|
485
|
+
# customer profile.
|
486
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
487
|
+
# seller account, which
|
488
|
+
# is created using the
|
489
|
+
# [CreateCustomerCustomAttributeDefinition]($e/CustomerCustomAttributes/Crea
|
490
|
+
# teCustomerCustomAttributeDefinition) endpoint.
|
491
|
+
# To create or update a custom attribute owned by another application, the
|
492
|
+
# `visibility` setting
|
493
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
494
|
+
# @param [String] customer_id Required parameter: The ID of the target
|
495
|
+
# [customer profile]($m/Customer).
|
496
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
497
|
+
# create or update. This key must match the `key` of a custom attribute
|
498
|
+
# definition in the Square seller account. If the requesting application is
|
499
|
+
# not the definition owner, you must use the qualified key.
|
500
|
+
# @param [UpsertCustomerCustomAttributeRequest] body Required parameter: An
|
501
|
+
# object containing the fields to POST for the request. See the
|
502
|
+
# corresponding object definition for field details.
|
503
|
+
# @return [UpsertCustomerCustomAttributeResponse Hash] response from the API call
|
504
|
+
def upsert_customer_custom_attribute(customer_id:,
|
505
|
+
key:,
|
506
|
+
body:)
|
507
|
+
# Prepare query url.
|
508
|
+
_query_builder = config.get_base_uri
|
509
|
+
_query_builder << '/v2/customers/{customer_id}/custom-attributes/{key}'
|
510
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
511
|
+
_query_builder,
|
512
|
+
'customer_id' => { 'value' => customer_id, 'encode' => true },
|
513
|
+
'key' => { 'value' => key, 'encode' => true }
|
514
|
+
)
|
515
|
+
_query_url = APIHelper.clean_url _query_builder
|
516
|
+
|
517
|
+
# Prepare headers.
|
518
|
+
_headers = {
|
519
|
+
'accept' => 'application/json',
|
520
|
+
'Content-Type' => 'application/json'
|
521
|
+
}
|
522
|
+
|
523
|
+
# Prepare and execute HttpRequest.
|
524
|
+
_request = config.http_client.post(
|
525
|
+
_query_url,
|
526
|
+
headers: _headers,
|
527
|
+
parameters: body.to_json
|
528
|
+
)
|
529
|
+
OAuth2.apply(config, _request)
|
530
|
+
_response = execute_request(_request)
|
531
|
+
|
532
|
+
# Return appropriate response type.
|
533
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
534
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
535
|
+
ApiResponse.new(
|
536
|
+
_response, data: decoded, errors: _errors
|
537
|
+
)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
end
|
@@ -91,12 +91,11 @@ module Square
|
|
91
91
|
)
|
92
92
|
end
|
93
93
|
|
94
|
-
# Creates a gift card activity
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
# #using-activated-gift-cards).
|
94
|
+
# Creates a gift card activity to manage the balance or state of a [gift
|
95
|
+
# card]($m/GiftCard).
|
96
|
+
# For example, you create an `ACTIVATE` activity to activate a gift card
|
97
|
+
# with an initial balance
|
98
|
+
# before the gift card can be used.
|
100
99
|
# @param [CreateGiftCardActivityRequest] body Required parameter: An object
|
101
100
|
# containing the fields to POST for the request. See the corresponding
|
102
101
|
# object definition for field details.
|
@@ -68,11 +68,11 @@ module Square
|
|
68
68
|
end
|
69
69
|
|
70
70
|
# Creates a digital gift card or registers a physical (plastic) gift card.
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# [
|
74
|
-
#
|
75
|
-
#
|
71
|
+
# After the gift card
|
72
|
+
# is created, you must call
|
73
|
+
# [CreateGiftCardActivity]($e/GiftCardActivities/CreateGiftCardActivity)
|
74
|
+
# to activate the card with an initial balance before it can be used for
|
75
|
+
# payment.
|
76
76
|
# @param [CreateGiftCardRequest] body Required parameter: An object
|
77
77
|
# containing the fields to POST for the request. See the corresponding
|
78
78
|
# object definition for field details.
|
@@ -259,7 +259,7 @@ module Square
|
|
259
259
|
)
|
260
260
|
end
|
261
261
|
|
262
|
-
# Retrieves a gift card using
|
262
|
+
# Retrieves a gift card using the gift card ID.
|
263
263
|
# @param [String] id Required parameter: The ID of the gift card to
|
264
264
|
# retrieve.
|
265
265
|
# @return [RetrieveGiftCardResponse Hash] response from the API call
|
@@ -5,6 +5,149 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
+
# Creates a Terminal action request and sends it to the specified device to
|
9
|
+
# take a payment
|
10
|
+
# for the requested amount.
|
11
|
+
# @param [CreateTerminalActionRequest] body Required parameter: An object
|
12
|
+
# containing the fields to POST for the request. See the corresponding
|
13
|
+
# object definition for field details.
|
14
|
+
# @return [CreateTerminalActionResponse Hash] response from the API call
|
15
|
+
def create_terminal_action(body:)
|
16
|
+
# Prepare query url.
|
17
|
+
_query_builder = config.get_base_uri
|
18
|
+
_query_builder << '/v2/terminals/actions'
|
19
|
+
_query_url = APIHelper.clean_url _query_builder
|
20
|
+
|
21
|
+
# Prepare headers.
|
22
|
+
_headers = {
|
23
|
+
'accept' => 'application/json',
|
24
|
+
'Content-Type' => 'application/json'
|
25
|
+
}
|
26
|
+
|
27
|
+
# Prepare and execute HttpRequest.
|
28
|
+
_request = config.http_client.post(
|
29
|
+
_query_url,
|
30
|
+
headers: _headers,
|
31
|
+
parameters: body.to_json
|
32
|
+
)
|
33
|
+
OAuth2.apply(config, _request)
|
34
|
+
_response = execute_request(_request)
|
35
|
+
|
36
|
+
# Return appropriate response type.
|
37
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
38
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
39
|
+
ApiResponse.new(
|
40
|
+
_response, data: decoded, errors: _errors
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Retrieves a filtered list of Terminal action requests created by the
|
45
|
+
# account making the request. Terminal action requests are available for 30
|
46
|
+
# days.
|
47
|
+
# @param [SearchTerminalActionsRequest] body Required parameter: An object
|
48
|
+
# containing the fields to POST for the request. See the corresponding
|
49
|
+
# object definition for field details.
|
50
|
+
# @return [SearchTerminalActionsResponse Hash] response from the API call
|
51
|
+
def search_terminal_actions(body:)
|
52
|
+
# Prepare query url.
|
53
|
+
_query_builder = config.get_base_uri
|
54
|
+
_query_builder << '/v2/terminals/actions/search'
|
55
|
+
_query_url = APIHelper.clean_url _query_builder
|
56
|
+
|
57
|
+
# Prepare headers.
|
58
|
+
_headers = {
|
59
|
+
'accept' => 'application/json',
|
60
|
+
'Content-Type' => 'application/json'
|
61
|
+
}
|
62
|
+
|
63
|
+
# Prepare and execute HttpRequest.
|
64
|
+
_request = config.http_client.post(
|
65
|
+
_query_url,
|
66
|
+
headers: _headers,
|
67
|
+
parameters: body.to_json
|
68
|
+
)
|
69
|
+
OAuth2.apply(config, _request)
|
70
|
+
_response = execute_request(_request)
|
71
|
+
|
72
|
+
# Return appropriate response type.
|
73
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
74
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
75
|
+
ApiResponse.new(
|
76
|
+
_response, data: decoded, errors: _errors
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Retrieves a Terminal action request by `action_id`. Terminal action
|
81
|
+
# requests are available for 30 days.
|
82
|
+
# @param [String] action_id Required parameter: Unique ID for the desired
|
83
|
+
# `TerminalAction`
|
84
|
+
# @return [GetTerminalActionResponse Hash] response from the API call
|
85
|
+
def get_terminal_action(action_id:)
|
86
|
+
# Prepare query url.
|
87
|
+
_query_builder = config.get_base_uri
|
88
|
+
_query_builder << '/v2/terminals/actions/{action_id}'
|
89
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
90
|
+
_query_builder,
|
91
|
+
'action_id' => { 'value' => action_id, 'encode' => true }
|
92
|
+
)
|
93
|
+
_query_url = APIHelper.clean_url _query_builder
|
94
|
+
|
95
|
+
# Prepare headers.
|
96
|
+
_headers = {
|
97
|
+
'accept' => 'application/json'
|
98
|
+
}
|
99
|
+
|
100
|
+
# Prepare and execute HttpRequest.
|
101
|
+
_request = config.http_client.get(
|
102
|
+
_query_url,
|
103
|
+
headers: _headers
|
104
|
+
)
|
105
|
+
OAuth2.apply(config, _request)
|
106
|
+
_response = execute_request(_request)
|
107
|
+
|
108
|
+
# Return appropriate response type.
|
109
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
110
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
111
|
+
ApiResponse.new(
|
112
|
+
_response, data: decoded, errors: _errors
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
# Cancels a Terminal action request if the status of the request permits it.
|
117
|
+
# @param [String] action_id Required parameter: Unique ID for the desired
|
118
|
+
# `TerminalAction`
|
119
|
+
# @return [CancelTerminalActionResponse Hash] response from the API call
|
120
|
+
def cancel_terminal_action(action_id:)
|
121
|
+
# Prepare query url.
|
122
|
+
_query_builder = config.get_base_uri
|
123
|
+
_query_builder << '/v2/terminals/actions/{action_id}/cancel'
|
124
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
125
|
+
_query_builder,
|
126
|
+
'action_id' => { 'value' => action_id, 'encode' => true }
|
127
|
+
)
|
128
|
+
_query_url = APIHelper.clean_url _query_builder
|
129
|
+
|
130
|
+
# Prepare headers.
|
131
|
+
_headers = {
|
132
|
+
'accept' => 'application/json'
|
133
|
+
}
|
134
|
+
|
135
|
+
# Prepare and execute HttpRequest.
|
136
|
+
_request = config.http_client.post(
|
137
|
+
_query_url,
|
138
|
+
headers: _headers
|
139
|
+
)
|
140
|
+
OAuth2.apply(config, _request)
|
141
|
+
_response = execute_request(_request)
|
142
|
+
|
143
|
+
# Return appropriate response type.
|
144
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
145
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
146
|
+
ApiResponse.new(
|
147
|
+
_response, data: decoded, errors: _errors
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
8
151
|
# Creates a Terminal checkout request and sends it to the specified device
|
9
152
|
# to take a payment
|
10
153
|
# for the requested amount.
|
data/lib/square/client.rb
CHANGED
@@ -4,7 +4,7 @@ module Square
|
|
4
4
|
attr_reader :config
|
5
5
|
|
6
6
|
def sdk_version
|
7
|
-
'
|
7
|
+
'20.0.0.20220512'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -75,6 +75,12 @@ module Square
|
|
75
75
|
@customers ||= CustomersApi.new config
|
76
76
|
end
|
77
77
|
|
78
|
+
# Access to customer_custom_attributes controller.
|
79
|
+
# @return [CustomerCustomAttributesApi] Returns the controller instance.
|
80
|
+
def customer_custom_attributes
|
81
|
+
@customer_custom_attributes ||= CustomerCustomAttributesApi.new config
|
82
|
+
end
|
83
|
+
|
78
84
|
# Access to customer_groups controller.
|
79
85
|
# @return [CustomerGroupsApi] Returns the controller instance.
|
80
86
|
def customer_groups
|
@@ -230,7 +236,7 @@ module Square
|
|
230
236
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
231
237
|
retry_methods: %i[get put], environment: 'production',
|
232
238
|
custom_url: 'https://connect.squareup.com',
|
233
|
-
square_version: '2022-
|
239
|
+
square_version: '2022-05-12', access_token: '',
|
234
240
|
user_agent_detail: '', additional_headers: {}, config: nil)
|
235
241
|
@config = if config.nil?
|
236
242
|
Configuration.new(connection: connection, timeout: timeout,
|
data/lib/square/configuration.rb
CHANGED
@@ -20,7 +20,7 @@ module Square
|
|
20
20
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
21
|
retry_methods: %i[get put], environment: 'production',
|
22
22
|
custom_url: 'https://connect.squareup.com',
|
23
|
-
square_version: '2022-
|
23
|
+
square_version: '2022-05-12', access_token: '',
|
24
24
|
user_agent_detail: '', additional_headers: {})
|
25
25
|
# The Faraday connection object passed by the SDK user for making requests
|
26
26
|
@connection = connection
|
data/lib/square.rb
CHANGED
@@ -40,6 +40,7 @@ require_relative 'square/api/cards_api'
|
|
40
40
|
require_relative 'square/api/cash_drawers_api'
|
41
41
|
require_relative 'square/api/catalog_api'
|
42
42
|
require_relative 'square/api/customers_api'
|
43
|
+
require_relative 'square/api/customer_custom_attributes_api'
|
43
44
|
require_relative 'square/api/customer_groups_api'
|
44
45
|
require_relative 'square/api/customer_segments_api'
|
45
46
|
require_relative 'square/api/devices_api'
|
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: 20.0.0.20220512
|
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: 2022-
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -31,6 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 2.0.1
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +41,9 @@ dependencies:
|
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '2.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 2.0.1
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: faraday-follow_redirects
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,6 +186,7 @@ files:
|
|
180
186
|
- lib/square/api/cash_drawers_api.rb
|
181
187
|
- lib/square/api/catalog_api.rb
|
182
188
|
- lib/square/api/checkout_api.rb
|
189
|
+
- lib/square/api/customer_custom_attributes_api.rb
|
183
190
|
- lib/square/api/customer_groups_api.rb
|
184
191
|
- lib/square/api/customer_segments_api.rb
|
185
192
|
- lib/square/api/customers_api.rb
|