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