square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
@@ -1,282 +1,282 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# PaymentsApi
|
8
|
-
class PaymentsApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Retrieves a list of payments taken by the account making the request.
|
14
|
-
# Max results per page: 100
|
15
|
-
# @param [String] begin_time Optional parameter: Timestamp for the beginning
|
16
|
-
# of the reporting period, in RFC 3339 format. Inclusive. Default: The
|
17
|
-
# current time minus one year.
|
18
|
-
# @param [String] end_time Optional parameter: Timestamp for the end of the
|
19
|
-
# requested reporting period, in RFC 3339 format. Default: The current
|
20
|
-
# time.
|
21
|
-
# @param [String] sort_order Optional parameter: The order in which results
|
22
|
-
# are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
|
23
|
-
# (default).
|
24
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
26
|
-
# results for the original query. See
|
27
|
-
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
28
|
-
# for more information.
|
29
|
-
# @param [String] location_id Optional parameter: ID of location associated
|
30
|
-
# with payment
|
31
|
-
# @param [Long] total Optional parameter: The exact amount in the
|
32
|
-
# total_money for a `Payment`.
|
33
|
-
# @param [String] last_4 Optional parameter: The last 4 digits of `Payment`
|
34
|
-
# card.
|
35
|
-
# @param [String] card_brand Optional parameter: The brand of `Payment`
|
36
|
-
# card. For example, `VISA`
|
37
|
-
# @return [ListPaymentsResponse Hash] response from the API call
|
38
|
-
def list_payments(begin_time: nil,
|
39
|
-
end_time: nil,
|
40
|
-
sort_order: nil,
|
41
|
-
cursor: nil,
|
42
|
-
location_id: nil,
|
43
|
-
total: nil,
|
44
|
-
last_4: nil,
|
45
|
-
card_brand: nil)
|
46
|
-
# Prepare query url.
|
47
|
-
_query_builder = config.get_base_uri
|
48
|
-
_query_builder << '/v2/payments'
|
49
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
50
|
-
_query_builder,
|
51
|
-
'begin_time' => begin_time,
|
52
|
-
'end_time' => end_time,
|
53
|
-
'sort_order' => sort_order,
|
54
|
-
'cursor' => cursor,
|
55
|
-
'location_id' => location_id,
|
56
|
-
'total' => total,
|
57
|
-
'last_4' => last_4,
|
58
|
-
'card_brand' => card_brand
|
59
|
-
)
|
60
|
-
_query_url = APIHelper.clean_url _query_builder
|
61
|
-
|
62
|
-
# Prepare headers.
|
63
|
-
_headers = {
|
64
|
-
'accept' => 'application/json'
|
65
|
-
}
|
66
|
-
|
67
|
-
# Prepare and execute HttpRequest.
|
68
|
-
_request = config.http_client.get(
|
69
|
-
_query_url,
|
70
|
-
headers: _headers
|
71
|
-
)
|
72
|
-
OAuth2.apply(config, _request)
|
73
|
-
_response = execute_request(_request)
|
74
|
-
|
75
|
-
# Return appropriate response type.
|
76
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
77
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
78
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
79
|
-
end
|
80
|
-
|
81
|
-
# Charges a payment source, for example, a card
|
82
|
-
# represented by customer's card on file or a card nonce. In addition
|
83
|
-
# to the payment source, the request must also include the
|
84
|
-
# amount to accept for the payment.
|
85
|
-
# There are several optional parameters that you can include in the request.
|
86
|
-
# For example, tip money, whether to autocomplete the payment, or a
|
87
|
-
# reference ID
|
88
|
-
# to correlate this payment with another system.
|
89
|
-
# For more information about these
|
90
|
-
# payment options, see [Take
|
91
|
-
# Payments](https://developer.squareup.com/docs/payments-api/take-payments).
|
92
|
-
# The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
|
93
|
-
# to enable application fees.
|
94
|
-
# @param [CreatePaymentRequest] body Required parameter: An object
|
95
|
-
# containing the fields to POST for the request. See the corresponding
|
96
|
-
# object definition for field details.
|
97
|
-
# @return [CreatePaymentResponse Hash] response from the API call
|
98
|
-
def create_payment(body:)
|
99
|
-
# Prepare query url.
|
100
|
-
_query_builder = config.get_base_uri
|
101
|
-
_query_builder << '/v2/payments'
|
102
|
-
_query_url = APIHelper.clean_url _query_builder
|
103
|
-
|
104
|
-
# Prepare headers.
|
105
|
-
_headers = {
|
106
|
-
'accept' => 'application/json',
|
107
|
-
'content-type' => 'application/json; charset=utf-8'
|
108
|
-
}
|
109
|
-
|
110
|
-
# Prepare and execute HttpRequest.
|
111
|
-
_request = config.http_client.post(
|
112
|
-
_query_url,
|
113
|
-
headers: _headers,
|
114
|
-
parameters: body.to_json
|
115
|
-
)
|
116
|
-
OAuth2.apply(config, _request)
|
117
|
-
_response = execute_request(_request)
|
118
|
-
|
119
|
-
# Return appropriate response type.
|
120
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
121
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
122
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
123
|
-
end
|
124
|
-
|
125
|
-
# Cancels a payment identified by the
|
126
|
-
# request.
|
127
|
-
# Use this method when status of a CreatePayment request is unknown.
|
128
|
-
# For example, after you send a CreatePayment
|
129
|
-
# request a network error occurs and you don't get a response. In this case,
|
130
|
-
# you can direct
|
131
|
-
# Square to cancel the payment using this endpoint. In the request, you
|
132
|
-
# provide the same idempotency
|
133
|
-
# key that you provided in your CreatePayment request you want to cancel.
|
134
|
-
# After cancelling the
|
135
|
-
# payment, you can submit your CreatePayment request again.
|
136
|
-
# Note that if no payment with the specified idempotency key is found, no
|
137
|
-
# action is taken, the end
|
138
|
-
# point returns successfully.
|
139
|
-
# @param [CancelPaymentByIdempotencyKeyRequest] body Required parameter: An
|
140
|
-
# object containing the fields to POST for the request. See the
|
141
|
-
# corresponding object definition for field details.
|
142
|
-
# @return [CancelPaymentByIdempotencyKeyResponse Hash] response from the API call
|
143
|
-
def cancel_payment_by_idempotency_key(body:)
|
144
|
-
# Prepare query url.
|
145
|
-
_query_builder = config.get_base_uri
|
146
|
-
_query_builder << '/v2/payments/cancel'
|
147
|
-
_query_url = APIHelper.clean_url _query_builder
|
148
|
-
|
149
|
-
# Prepare headers.
|
150
|
-
_headers = {
|
151
|
-
'accept' => 'application/json',
|
152
|
-
'content-type' => 'application/json; charset=utf-8'
|
153
|
-
}
|
154
|
-
|
155
|
-
# Prepare and execute HttpRequest.
|
156
|
-
_request = config.http_client.post(
|
157
|
-
_query_url,
|
158
|
-
headers: _headers,
|
159
|
-
parameters: body.to_json
|
160
|
-
)
|
161
|
-
OAuth2.apply(config, _request)
|
162
|
-
_response = execute_request(_request)
|
163
|
-
|
164
|
-
# Return appropriate response type.
|
165
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
166
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
167
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
168
|
-
end
|
169
|
-
|
170
|
-
# Retrieves details for a specific Payment.
|
171
|
-
# @param [String] payment_id Required parameter: Unique ID for the desired
|
172
|
-
# `Payment`.
|
173
|
-
# @return [GetPaymentResponse Hash] response from the API call
|
174
|
-
def get_payment(payment_id:)
|
175
|
-
# Prepare query url.
|
176
|
-
_query_builder = config.get_base_uri
|
177
|
-
_query_builder << '/v2/payments/{payment_id}'
|
178
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
179
|
-
_query_builder,
|
180
|
-
'payment_id' => payment_id
|
181
|
-
)
|
182
|
-
_query_url = APIHelper.clean_url _query_builder
|
183
|
-
|
184
|
-
# Prepare headers.
|
185
|
-
_headers = {
|
186
|
-
'accept' => 'application/json'
|
187
|
-
}
|
188
|
-
|
189
|
-
# Prepare and execute HttpRequest.
|
190
|
-
_request = config.http_client.get(
|
191
|
-
_query_url,
|
192
|
-
headers: _headers
|
193
|
-
)
|
194
|
-
OAuth2.apply(config, _request)
|
195
|
-
_response = execute_request(_request)
|
196
|
-
|
197
|
-
# Return appropriate response type.
|
198
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
199
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
200
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
201
|
-
end
|
202
|
-
|
203
|
-
# Cancels a payment. If you set `autocomplete` to false when
|
204
|
-
# payment,
|
205
|
-
# you can cancel the payment using this endpoint. For more information, see
|
206
|
-
# [Delayed
|
207
|
-
# Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
|
208
|
-
# elayed-payments).
|
209
|
-
# @param [String] payment_id Required parameter: `payment_id` identifying
|
210
|
-
# the payment to be canceled.
|
211
|
-
# @return [CancelPaymentResponse Hash] response from the API call
|
212
|
-
def cancel_payment(payment_id:)
|
213
|
-
# Prepare query url.
|
214
|
-
_query_builder = config.get_base_uri
|
215
|
-
_query_builder << '/v2/payments/{payment_id}/cancel'
|
216
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
217
|
-
_query_builder,
|
218
|
-
'payment_id' => payment_id
|
219
|
-
)
|
220
|
-
_query_url = APIHelper.clean_url _query_builder
|
221
|
-
|
222
|
-
# Prepare headers.
|
223
|
-
_headers = {
|
224
|
-
'accept' => 'application/json'
|
225
|
-
}
|
226
|
-
|
227
|
-
# Prepare and execute HttpRequest.
|
228
|
-
_request = config.http_client.post(
|
229
|
-
_query_url,
|
230
|
-
headers: _headers
|
231
|
-
)
|
232
|
-
OAuth2.apply(config, _request)
|
233
|
-
_response = execute_request(_request)
|
234
|
-
|
235
|
-
# Return appropriate response type.
|
236
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
237
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
238
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
239
|
-
end
|
240
|
-
|
241
|
-
# Completes a payment.
|
242
|
-
# By default, payments are set to complete immediately after they are
|
243
|
-
# created.
|
244
|
-
# If you set autocomplete to false when creating a payment,
|
245
|
-
#
|
246
|
-
# see
|
247
|
-
# [Delayed
|
248
|
-
# Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
|
249
|
-
# elayed-payments).
|
250
|
-
# @param [String] payment_id Required parameter: Unique ID identifying the
|
251
|
-
# payment to be completed.
|
252
|
-
# @return [CompletePaymentResponse Hash] response from the API call
|
253
|
-
def complete_payment(payment_id:)
|
254
|
-
# Prepare query url.
|
255
|
-
_query_builder = config.get_base_uri
|
256
|
-
_query_builder << '/v2/payments/{payment_id}/complete'
|
257
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
258
|
-
_query_builder,
|
259
|
-
'payment_id' => payment_id
|
260
|
-
)
|
261
|
-
_query_url = APIHelper.clean_url _query_builder
|
262
|
-
|
263
|
-
# Prepare headers.
|
264
|
-
_headers = {
|
265
|
-
'accept' => 'application/json'
|
266
|
-
}
|
267
|
-
|
268
|
-
# Prepare and execute HttpRequest.
|
269
|
-
_request = config.http_client.post(
|
270
|
-
_query_url,
|
271
|
-
headers: _headers
|
272
|
-
)
|
273
|
-
OAuth2.apply(config, _request)
|
274
|
-
_response = execute_request(_request)
|
275
|
-
|
276
|
-
# Return appropriate response type.
|
277
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
278
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
279
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# PaymentsApi
|
8
|
+
class PaymentsApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieves a list of payments taken by the account making the request.
|
14
|
+
# Max results per page: 100
|
15
|
+
# @param [String] begin_time Optional parameter: Timestamp for the beginning
|
16
|
+
# of the reporting period, in RFC 3339 format. Inclusive. Default: The
|
17
|
+
# current time minus one year.
|
18
|
+
# @param [String] end_time Optional parameter: Timestamp for the end of the
|
19
|
+
# requested reporting period, in RFC 3339 format. Default: The current
|
20
|
+
# time.
|
21
|
+
# @param [String] sort_order Optional parameter: The order in which results
|
22
|
+
# are listed. - `ASC` - oldest to newest - `DESC` - newest to oldest
|
23
|
+
# (default).
|
24
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
26
|
+
# results for the original query. See
|
27
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
28
|
+
# for more information.
|
29
|
+
# @param [String] location_id Optional parameter: ID of location associated
|
30
|
+
# with payment
|
31
|
+
# @param [Long] total Optional parameter: The exact amount in the
|
32
|
+
# total_money for a `Payment`.
|
33
|
+
# @param [String] last_4 Optional parameter: The last 4 digits of `Payment`
|
34
|
+
# card.
|
35
|
+
# @param [String] card_brand Optional parameter: The brand of `Payment`
|
36
|
+
# card. For example, `VISA`
|
37
|
+
# @return [ListPaymentsResponse Hash] response from the API call
|
38
|
+
def list_payments(begin_time: nil,
|
39
|
+
end_time: nil,
|
40
|
+
sort_order: nil,
|
41
|
+
cursor: nil,
|
42
|
+
location_id: nil,
|
43
|
+
total: nil,
|
44
|
+
last_4: nil,
|
45
|
+
card_brand: nil)
|
46
|
+
# Prepare query url.
|
47
|
+
_query_builder = config.get_base_uri
|
48
|
+
_query_builder << '/v2/payments'
|
49
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
50
|
+
_query_builder,
|
51
|
+
'begin_time' => begin_time,
|
52
|
+
'end_time' => end_time,
|
53
|
+
'sort_order' => sort_order,
|
54
|
+
'cursor' => cursor,
|
55
|
+
'location_id' => location_id,
|
56
|
+
'total' => total,
|
57
|
+
'last_4' => last_4,
|
58
|
+
'card_brand' => card_brand
|
59
|
+
)
|
60
|
+
_query_url = APIHelper.clean_url _query_builder
|
61
|
+
|
62
|
+
# Prepare headers.
|
63
|
+
_headers = {
|
64
|
+
'accept' => 'application/json'
|
65
|
+
}
|
66
|
+
|
67
|
+
# Prepare and execute HttpRequest.
|
68
|
+
_request = config.http_client.get(
|
69
|
+
_query_url,
|
70
|
+
headers: _headers
|
71
|
+
)
|
72
|
+
OAuth2.apply(config, _request)
|
73
|
+
_response = execute_request(_request)
|
74
|
+
|
75
|
+
# Return appropriate response type.
|
76
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
77
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
78
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Charges a payment source, for example, a card
|
82
|
+
# represented by customer's card on file or a card nonce. In addition
|
83
|
+
# to the payment source, the request must also include the
|
84
|
+
# amount to accept for the payment.
|
85
|
+
# There are several optional parameters that you can include in the request.
|
86
|
+
# For example, tip money, whether to autocomplete the payment, or a
|
87
|
+
# reference ID
|
88
|
+
# to correlate this payment with another system.
|
89
|
+
# For more information about these
|
90
|
+
# payment options, see [Take
|
91
|
+
# Payments](https://developer.squareup.com/docs/payments-api/take-payments).
|
92
|
+
# The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
|
93
|
+
# to enable application fees.
|
94
|
+
# @param [CreatePaymentRequest] body Required parameter: An object
|
95
|
+
# containing the fields to POST for the request. See the corresponding
|
96
|
+
# object definition for field details.
|
97
|
+
# @return [CreatePaymentResponse Hash] response from the API call
|
98
|
+
def create_payment(body:)
|
99
|
+
# Prepare query url.
|
100
|
+
_query_builder = config.get_base_uri
|
101
|
+
_query_builder << '/v2/payments'
|
102
|
+
_query_url = APIHelper.clean_url _query_builder
|
103
|
+
|
104
|
+
# Prepare headers.
|
105
|
+
_headers = {
|
106
|
+
'accept' => 'application/json',
|
107
|
+
'content-type' => 'application/json; charset=utf-8'
|
108
|
+
}
|
109
|
+
|
110
|
+
# Prepare and execute HttpRequest.
|
111
|
+
_request = config.http_client.post(
|
112
|
+
_query_url,
|
113
|
+
headers: _headers,
|
114
|
+
parameters: body.to_json
|
115
|
+
)
|
116
|
+
OAuth2.apply(config, _request)
|
117
|
+
_response = execute_request(_request)
|
118
|
+
|
119
|
+
# Return appropriate response type.
|
120
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
121
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
122
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
123
|
+
end
|
124
|
+
|
125
|
+
# Cancels (voids) a payment identified by the idempotency key that is
|
126
|
+
# specified in the request.
|
127
|
+
# Use this method when status of a CreatePayment request is unknown.
|
128
|
+
# For example, after you send a CreatePayment
|
129
|
+
# request a network error occurs and you don't get a response. In this case,
|
130
|
+
# you can direct
|
131
|
+
# Square to cancel the payment using this endpoint. In the request, you
|
132
|
+
# provide the same idempotency
|
133
|
+
# key that you provided in your CreatePayment request you want to cancel.
|
134
|
+
# After cancelling the
|
135
|
+
# payment, you can submit your CreatePayment request again.
|
136
|
+
# Note that if no payment with the specified idempotency key is found, no
|
137
|
+
# action is taken, the end
|
138
|
+
# point returns successfully.
|
139
|
+
# @param [CancelPaymentByIdempotencyKeyRequest] body Required parameter: An
|
140
|
+
# object containing the fields to POST for the request. See the
|
141
|
+
# corresponding object definition for field details.
|
142
|
+
# @return [CancelPaymentByIdempotencyKeyResponse Hash] response from the API call
|
143
|
+
def cancel_payment_by_idempotency_key(body:)
|
144
|
+
# Prepare query url.
|
145
|
+
_query_builder = config.get_base_uri
|
146
|
+
_query_builder << '/v2/payments/cancel'
|
147
|
+
_query_url = APIHelper.clean_url _query_builder
|
148
|
+
|
149
|
+
# Prepare headers.
|
150
|
+
_headers = {
|
151
|
+
'accept' => 'application/json',
|
152
|
+
'content-type' => 'application/json; charset=utf-8'
|
153
|
+
}
|
154
|
+
|
155
|
+
# Prepare and execute HttpRequest.
|
156
|
+
_request = config.http_client.post(
|
157
|
+
_query_url,
|
158
|
+
headers: _headers,
|
159
|
+
parameters: body.to_json
|
160
|
+
)
|
161
|
+
OAuth2.apply(config, _request)
|
162
|
+
_response = execute_request(_request)
|
163
|
+
|
164
|
+
# Return appropriate response type.
|
165
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
166
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
167
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Retrieves details for a specific Payment.
|
171
|
+
# @param [String] payment_id Required parameter: Unique ID for the desired
|
172
|
+
# `Payment`.
|
173
|
+
# @return [GetPaymentResponse Hash] response from the API call
|
174
|
+
def get_payment(payment_id:)
|
175
|
+
# Prepare query url.
|
176
|
+
_query_builder = config.get_base_uri
|
177
|
+
_query_builder << '/v2/payments/{payment_id}'
|
178
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
179
|
+
_query_builder,
|
180
|
+
'payment_id' => payment_id
|
181
|
+
)
|
182
|
+
_query_url = APIHelper.clean_url _query_builder
|
183
|
+
|
184
|
+
# Prepare headers.
|
185
|
+
_headers = {
|
186
|
+
'accept' => 'application/json'
|
187
|
+
}
|
188
|
+
|
189
|
+
# Prepare and execute HttpRequest.
|
190
|
+
_request = config.http_client.get(
|
191
|
+
_query_url,
|
192
|
+
headers: _headers
|
193
|
+
)
|
194
|
+
OAuth2.apply(config, _request)
|
195
|
+
_response = execute_request(_request)
|
196
|
+
|
197
|
+
# Return appropriate response type.
|
198
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
199
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
200
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Cancels (voids) a payment. If you set `autocomplete` to false when
|
204
|
+
# creating a payment,
|
205
|
+
# you can cancel the payment using this endpoint. For more information, see
|
206
|
+
# [Delayed
|
207
|
+
# Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
|
208
|
+
# elayed-payments).
|
209
|
+
# @param [String] payment_id Required parameter: `payment_id` identifying
|
210
|
+
# the payment to be canceled.
|
211
|
+
# @return [CancelPaymentResponse Hash] response from the API call
|
212
|
+
def cancel_payment(payment_id:)
|
213
|
+
# Prepare query url.
|
214
|
+
_query_builder = config.get_base_uri
|
215
|
+
_query_builder << '/v2/payments/{payment_id}/cancel'
|
216
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
217
|
+
_query_builder,
|
218
|
+
'payment_id' => payment_id
|
219
|
+
)
|
220
|
+
_query_url = APIHelper.clean_url _query_builder
|
221
|
+
|
222
|
+
# Prepare headers.
|
223
|
+
_headers = {
|
224
|
+
'accept' => 'application/json'
|
225
|
+
}
|
226
|
+
|
227
|
+
# Prepare and execute HttpRequest.
|
228
|
+
_request = config.http_client.post(
|
229
|
+
_query_url,
|
230
|
+
headers: _headers
|
231
|
+
)
|
232
|
+
OAuth2.apply(config, _request)
|
233
|
+
_response = execute_request(_request)
|
234
|
+
|
235
|
+
# Return appropriate response type.
|
236
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
237
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
238
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Completes (captures) a payment.
|
242
|
+
# By default, payments are set to complete immediately after they are
|
243
|
+
# created.
|
244
|
+
# If you set autocomplete to false when creating a payment, you can complete
|
245
|
+
# (capture)
|
246
|
+
# the payment using this endpoint. For more information, see
|
247
|
+
# [Delayed
|
248
|
+
# Payments](https://developer.squareup.com/docs/payments-api/take-payments#d
|
249
|
+
# elayed-payments).
|
250
|
+
# @param [String] payment_id Required parameter: Unique ID identifying the
|
251
|
+
# payment to be completed.
|
252
|
+
# @return [CompletePaymentResponse Hash] response from the API call
|
253
|
+
def complete_payment(payment_id:)
|
254
|
+
# Prepare query url.
|
255
|
+
_query_builder = config.get_base_uri
|
256
|
+
_query_builder << '/v2/payments/{payment_id}/complete'
|
257
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
258
|
+
_query_builder,
|
259
|
+
'payment_id' => payment_id
|
260
|
+
)
|
261
|
+
_query_url = APIHelper.clean_url _query_builder
|
262
|
+
|
263
|
+
# Prepare headers.
|
264
|
+
_headers = {
|
265
|
+
'accept' => 'application/json'
|
266
|
+
}
|
267
|
+
|
268
|
+
# Prepare and execute HttpRequest.
|
269
|
+
_request = config.http_client.post(
|
270
|
+
_query_url,
|
271
|
+
headers: _headers
|
272
|
+
)
|
273
|
+
OAuth2.apply(config, _request)
|
274
|
+
_response = execute_request(_request)
|
275
|
+
|
276
|
+
# Return appropriate response type.
|
277
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
278
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
279
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|