square.rb 26.0.0.20221214 → 26.2.0.20230315
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/LICENSE +1 -1
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +419 -0
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +82 -46
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +7 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +12 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# CheckoutApi
|
3
3
|
class CheckoutApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Links a `checkoutId` to a `checkout_page_url` that customers are
|
9
5
|
# directed to in order to provide their payment information using a
|
10
6
|
# payment processing workflow hosted on connect.squareup.com.
|
@@ -24,36 +20,22 @@ module Square
|
|
24
20
|
def create_checkout(location_id:,
|
25
21
|
body:)
|
26
22
|
warn 'Endpoint create_checkout in CheckoutApi is deprecated'
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
_request = config.http_client.post(
|
44
|
-
_query_url,
|
45
|
-
headers: _headers,
|
46
|
-
parameters: body.to_json
|
47
|
-
)
|
48
|
-
OAuth2.apply(config, _request)
|
49
|
-
_response = execute_request(_request)
|
50
|
-
|
51
|
-
# Return appropriate response type.
|
52
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
53
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
54
|
-
ApiResponse.new(
|
55
|
-
_response, data: decoded, errors: _errors
|
56
|
-
)
|
23
|
+
new_api_call_builder
|
24
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
25
|
+
'/v2/locations/{location_id}/checkouts',
|
26
|
+
'default')
|
27
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
28
|
+
.should_encode(true))
|
29
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
30
|
+
.body_param(new_parameter(body))
|
31
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
32
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
33
|
+
.auth(Single.new('global')))
|
34
|
+
.response(new_response_handler
|
35
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
36
|
+
.is_api_response(true)
|
37
|
+
.convertor(ApiResponse.method(:create)))
|
38
|
+
.execute
|
57
39
|
end
|
58
40
|
|
59
41
|
# Lists all payment links.
|
@@ -71,35 +53,19 @@ module Square
|
|
71
53
|
# @return [ListPaymentLinksResponse Hash] response from the API call
|
72
54
|
def list_payment_links(cursor: nil,
|
73
55
|
limit: nil)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
-
)
|
56
|
+
new_api_call_builder
|
57
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
58
|
+
'/v2/online-checkout/payment-links',
|
59
|
+
'default')
|
60
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
61
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
62
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
63
|
+
.auth(Single.new('global')))
|
64
|
+
.response(new_response_handler
|
65
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
66
|
+
.is_api_response(true)
|
67
|
+
.convertor(ApiResponse.method(:create)))
|
68
|
+
.execute
|
103
69
|
end
|
104
70
|
|
105
71
|
# Creates a Square-hosted checkout page. Applications can share the
|
@@ -109,32 +75,20 @@ module Square
|
|
109
75
|
# object definition for field details.
|
110
76
|
# @return [CreatePaymentLinkResponse Hash] response from the API call
|
111
77
|
def create_payment_link(body:)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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
|
-
)
|
78
|
+
new_api_call_builder
|
79
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
80
|
+
'/v2/online-checkout/payment-links',
|
81
|
+
'default')
|
82
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
83
|
+
.body_param(new_parameter(body))
|
84
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
85
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
86
|
+
.auth(Single.new('global')))
|
87
|
+
.response(new_response_handler
|
88
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
89
|
+
.is_api_response(true)
|
90
|
+
.convertor(ApiResponse.method(:create)))
|
91
|
+
.execute
|
138
92
|
end
|
139
93
|
|
140
94
|
# Deletes a payment link.
|
@@ -142,68 +96,38 @@ module Square
|
|
142
96
|
# delete.
|
143
97
|
# @return [DeletePaymentLinkResponse Hash] response from the API call
|
144
98
|
def delete_payment_link(id:)
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
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
|
-
)
|
99
|
+
new_api_call_builder
|
100
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
101
|
+
'/v2/online-checkout/payment-links/{id}',
|
102
|
+
'default')
|
103
|
+
.template_param(new_parameter(id, key: 'id')
|
104
|
+
.should_encode(true))
|
105
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
106
|
+
.auth(Single.new('global')))
|
107
|
+
.response(new_response_handler
|
108
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
109
|
+
.is_api_response(true)
|
110
|
+
.convertor(ApiResponse.method(:create)))
|
111
|
+
.execute
|
173
112
|
end
|
174
113
|
|
175
114
|
# Retrieves a payment link.
|
176
115
|
# @param [String] id Required parameter: The ID of link to retrieve.
|
177
116
|
# @return [RetrievePaymentLinkResponse Hash] response from the API call
|
178
117
|
def retrieve_payment_link(id:)
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
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
|
-
)
|
118
|
+
new_api_call_builder
|
119
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
120
|
+
'/v2/online-checkout/payment-links/{id}',
|
121
|
+
'default')
|
122
|
+
.template_param(new_parameter(id, key: 'id')
|
123
|
+
.should_encode(true))
|
124
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
125
|
+
.auth(Single.new('global')))
|
126
|
+
.response(new_response_handler
|
127
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
128
|
+
.is_api_response(true)
|
129
|
+
.convertor(ApiResponse.method(:create)))
|
130
|
+
.execute
|
207
131
|
end
|
208
132
|
|
209
133
|
# Updates a payment link. You can update the `payment_link` fields such as
|
@@ -218,36 +142,22 @@ module Square
|
|
218
142
|
# @return [UpdatePaymentLinkResponse Hash] response from the API call
|
219
143
|
def update_payment_link(id:,
|
220
144
|
body:)
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
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
|
-
)
|
145
|
+
new_api_call_builder
|
146
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
147
|
+
'/v2/online-checkout/payment-links/{id}',
|
148
|
+
'default')
|
149
|
+
.template_param(new_parameter(id, key: 'id')
|
150
|
+
.should_encode(true))
|
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
|
251
161
|
end
|
252
162
|
end
|
253
163
|
end
|