square.rb 8.0.0.20201216 → 26.1.0.20230119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -5,91 +5,10 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Provides non-confidential details for all of a location's associated bank
|
9
|
-
# accounts. This endpoint does not provide full bank account numbers, and
|
10
|
-
# there is no way to obtain a full bank account number with the Connect API.
|
11
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
12
|
-
# list bank accounts for.
|
13
|
-
# @return [List of V1BankAccount Hash] response from the API call
|
14
|
-
def list_bank_accounts(location_id:)
|
15
|
-
warn 'Endpoint list_bank_accounts in V1TransactionsApi is deprecated'
|
16
|
-
# Prepare query url.
|
17
|
-
_query_builder = config.get_base_uri
|
18
|
-
_query_builder << '/v1/{location_id}/bank-accounts'
|
19
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
20
|
-
_query_builder,
|
21
|
-
'location_id' => { 'value' => location_id, 'encode' => true }
|
22
|
-
)
|
23
|
-
_query_url = APIHelper.clean_url _query_builder
|
24
|
-
|
25
|
-
# Prepare headers.
|
26
|
-
_headers = {
|
27
|
-
'accept' => 'application/json'
|
28
|
-
}
|
29
|
-
|
30
|
-
# Prepare and execute HttpRequest.
|
31
|
-
_request = config.http_client.get(
|
32
|
-
_query_url,
|
33
|
-
headers: _headers
|
34
|
-
)
|
35
|
-
OAuth2.apply(config, _request)
|
36
|
-
_response = execute_request(_request)
|
37
|
-
|
38
|
-
# Return appropriate response type.
|
39
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
-
ApiResponse.new(
|
42
|
-
_response, data: decoded, errors: _errors
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Provides non-confidential details for a merchant's associated bank
|
47
|
-
# account. This endpoint does not provide full bank account numbers, and
|
48
|
-
# there is no way to obtain a full bank account number with the Connect API.
|
49
|
-
# @param [String] location_id Required parameter: The ID of the bank
|
50
|
-
# account's associated location.
|
51
|
-
# @param [String] bank_account_id Required parameter: The bank account's
|
52
|
-
# Square-issued ID. You obtain this value from Settlement objects
|
53
|
-
# returned.
|
54
|
-
# @return [V1BankAccount Hash] response from the API call
|
55
|
-
def retrieve_bank_account(location_id:,
|
56
|
-
bank_account_id:)
|
57
|
-
warn 'Endpoint retrieve_bank_account in V1TransactionsApi is deprecated'
|
58
|
-
# Prepare query url.
|
59
|
-
_query_builder = config.get_base_uri
|
60
|
-
_query_builder << '/v1/{location_id}/bank-accounts/{bank_account_id}'
|
61
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
62
|
-
_query_builder,
|
63
|
-
'location_id' => { 'value' => location_id, 'encode' => true },
|
64
|
-
'bank_account_id' => { 'value' => bank_account_id, 'encode' => true }
|
65
|
-
)
|
66
|
-
_query_url = APIHelper.clean_url _query_builder
|
67
|
-
|
68
|
-
# Prepare headers.
|
69
|
-
_headers = {
|
70
|
-
'accept' => 'application/json'
|
71
|
-
}
|
72
|
-
|
73
|
-
# Prepare and execute HttpRequest.
|
74
|
-
_request = config.http_client.get(
|
75
|
-
_query_url,
|
76
|
-
headers: _headers
|
77
|
-
)
|
78
|
-
OAuth2.apply(config, _request)
|
79
|
-
_response = execute_request(_request)
|
80
|
-
|
81
|
-
# Return appropriate response type.
|
82
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
83
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
84
|
-
ApiResponse.new(
|
85
|
-
_response, data: decoded, errors: _errors
|
86
|
-
)
|
87
|
-
end
|
88
|
-
|
89
8
|
# Provides summary information for a merchant's online store orders.
|
90
9
|
# @param [String] location_id Required parameter: The ID of the location to
|
91
10
|
# list online store orders for.
|
92
|
-
# @param [SortOrder] order Optional parameter:
|
11
|
+
# @param [SortOrder] order Optional parameter: The order in which payments
|
93
12
|
# are listed in the response.
|
94
13
|
# @param [Integer] limit Optional parameter: The maximum number of payments
|
95
14
|
# to return in a single response. This value cannot exceed 200.
|
@@ -97,10 +16,11 @@ module Square
|
|
97
16
|
# retrieve the next set of results for your original query to the
|
98
17
|
# endpoint.
|
99
18
|
# @return [List of V1Order Hash] response from the API call
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
|
19
|
+
def v1_list_orders(location_id:,
|
20
|
+
order: nil,
|
21
|
+
limit: nil,
|
22
|
+
batch_token: nil)
|
23
|
+
warn 'Endpoint v1_list_orders in V1TransactionsApi is deprecated'
|
104
24
|
# Prepare query url.
|
105
25
|
_query_builder = config.get_base_uri
|
106
26
|
_query_builder << '/v1/{location_id}/orders'
|
@@ -145,8 +65,9 @@ module Square
|
|
145
65
|
# You obtain this value from Order objects returned by the List Orders
|
146
66
|
# endpoint
|
147
67
|
# @return [V1Order Hash] response from the API call
|
148
|
-
def
|
149
|
-
|
68
|
+
def v1_retrieve_order(location_id:,
|
69
|
+
order_id:)
|
70
|
+
warn 'Endpoint v1_retrieve_order in V1TransactionsApi is deprecated'
|
150
71
|
# Prepare query url.
|
151
72
|
_query_builder = config.get_base_uri
|
152
73
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -189,9 +110,10 @@ module Square
|
|
189
110
|
# containing the fields to POST for the request. See the corresponding
|
190
111
|
# object definition for field details.
|
191
112
|
# @return [V1Order Hash] response from the API call
|
192
|
-
def
|
193
|
-
|
194
|
-
|
113
|
+
def v1_update_order(location_id:,
|
114
|
+
order_id:,
|
115
|
+
body:)
|
116
|
+
warn 'Endpoint v1_update_order in V1TransactionsApi is deprecated'
|
195
117
|
# Prepare query url.
|
196
118
|
_query_builder = config.get_base_uri
|
197
119
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -205,7 +127,7 @@ module Square
|
|
205
127
|
# Prepare headers.
|
206
128
|
_headers = {
|
207
129
|
'accept' => 'application/json',
|
208
|
-
'
|
130
|
+
'Content-Type' => 'application/json'
|
209
131
|
}
|
210
132
|
|
211
133
|
# Prepare and execute HttpRequest.
|
@@ -253,18 +175,19 @@ module Square
|
|
253
175
|
# @param [String] batch_token Optional parameter: A pagination cursor to
|
254
176
|
# retrieve the next set of results for your original query to the
|
255
177
|
# endpoint.
|
256
|
-
# @param [
|
257
|
-
# not to include partial payments in the response.
|
258
|
-
# have the tenders collected so far, but the
|
259
|
-
# until the payment is completed.
|
178
|
+
# @param [TrueClass|FalseClass] include_partial Optional parameter:
|
179
|
+
# Indicates whether or not to include partial payments in the response.
|
180
|
+
# Partial payments will have the tenders collected so far, but the
|
181
|
+
# itemizations will be empty until the payment is completed.
|
260
182
|
# @return [List of V1Payment Hash] response from the API call
|
261
|
-
def
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
183
|
+
def v1_list_payments(location_id:,
|
184
|
+
order: nil,
|
185
|
+
begin_time: nil,
|
186
|
+
end_time: nil,
|
187
|
+
limit: nil,
|
188
|
+
batch_token: nil,
|
189
|
+
include_partial: false)
|
190
|
+
warn 'Endpoint v1_list_payments in V1TransactionsApi is deprecated'
|
268
191
|
# Prepare query url.
|
269
192
|
_query_builder = config.get_base_uri
|
270
193
|
_query_builder << '/v1/{location_id}/payments'
|
@@ -312,8 +235,9 @@ module Square
|
|
312
235
|
# endpoint, Settlement objects returned by the List Settlements endpoint, or
|
313
236
|
# Refund objects returned by the List Refunds endpoint.
|
314
237
|
# @return [V1Payment Hash] response from the API call
|
315
|
-
def
|
316
|
-
|
238
|
+
def v1_retrieve_payment(location_id:,
|
239
|
+
payment_id:)
|
240
|
+
warn 'Endpoint v1_retrieve_payment in V1TransactionsApi is deprecated'
|
317
241
|
# Prepare query url.
|
318
242
|
_query_builder = config.get_base_uri
|
319
243
|
_query_builder << '/v1/{location_id}/payments/{payment_id}'
|
@@ -350,7 +274,7 @@ module Square
|
|
350
274
|
# year in length.
|
351
275
|
# @param [String] location_id Required parameter: The ID of the location to
|
352
276
|
# list refunds for.
|
353
|
-
# @param [SortOrder] order Optional parameter:
|
277
|
+
# @param [SortOrder] order Optional parameter: The order in which payments
|
354
278
|
# are listed in the response.
|
355
279
|
# @param [String] begin_time Optional parameter: The beginning of the
|
356
280
|
# requested reporting period, in ISO 8601 format. If this value is before
|
@@ -369,12 +293,13 @@ module Square
|
|
369
293
|
# retrieve the next set of results for your original query to the
|
370
294
|
# endpoint.
|
371
295
|
# @return [List of V1Refund Hash] response from the API call
|
372
|
-
def
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
296
|
+
def v1_list_refunds(location_id:,
|
297
|
+
order: nil,
|
298
|
+
begin_time: nil,
|
299
|
+
end_time: nil,
|
300
|
+
limit: nil,
|
301
|
+
batch_token: nil)
|
302
|
+
warn 'Endpoint v1_list_refunds in V1TransactionsApi is deprecated'
|
378
303
|
# Prepare query url.
|
379
304
|
_query_builder = config.get_base_uri
|
380
305
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -429,8 +354,9 @@ module Square
|
|
429
354
|
# containing the fields to POST for the request. See the corresponding
|
430
355
|
# object definition for field details.
|
431
356
|
# @return [V1Refund Hash] response from the API call
|
432
|
-
def
|
433
|
-
|
357
|
+
def v1_create_refund(location_id:,
|
358
|
+
body:)
|
359
|
+
warn 'Endpoint v1_create_refund in V1TransactionsApi is deprecated'
|
434
360
|
# Prepare query url.
|
435
361
|
_query_builder = config.get_base_uri
|
436
362
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -443,7 +369,7 @@ module Square
|
|
443
369
|
# Prepare headers.
|
444
370
|
_headers = {
|
445
371
|
'accept' => 'application/json',
|
446
|
-
'
|
372
|
+
'Content-Type' => 'application/json'
|
447
373
|
}
|
448
374
|
|
449
375
|
# Prepare and execute HttpRequest.
|
@@ -491,13 +417,14 @@ module Square
|
|
491
417
|
# retrieve the next set of results for your original query to the
|
492
418
|
# endpoint.
|
493
419
|
# @return [List of V1Settlement Hash] response from the API call
|
494
|
-
def
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
420
|
+
def v1_list_settlements(location_id:,
|
421
|
+
order: nil,
|
422
|
+
begin_time: nil,
|
423
|
+
end_time: nil,
|
424
|
+
limit: nil,
|
425
|
+
status: nil,
|
426
|
+
batch_token: nil)
|
427
|
+
warn 'Endpoint v1_list_settlements in V1TransactionsApi is deprecated'
|
501
428
|
# Prepare query url.
|
502
429
|
_query_builder = config.get_base_uri
|
503
430
|
_query_builder << '/v1/{location_id}/settlements'
|
@@ -558,8 +485,9 @@ module Square
|
|
558
485
|
# Square-issued ID. You obtain this value from Settlement objects returned
|
559
486
|
# by the List Settlements endpoint.
|
560
487
|
# @return [V1Settlement Hash] response from the API call
|
561
|
-
def
|
562
|
-
|
488
|
+
def v1_retrieve_settlement(location_id:,
|
489
|
+
settlement_id:)
|
490
|
+
warn 'Endpoint v1_retrieve_settlement in V1TransactionsApi is deprecated'
|
563
491
|
# Prepare query url.
|
564
492
|
_query_builder = config.get_base_uri
|
565
493
|
_query_builder << '/v1/{location_id}/settlements/{settlement_id}'
|
@@ -0,0 +1,257 @@
|
|
1
|
+
module Square
|
2
|
+
# VendorsApi
|
3
|
+
class VendorsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to
|
9
|
+
# a seller.
|
10
|
+
# @param [BulkCreateVendorsRequest] body Required parameter: An object
|
11
|
+
# containing the fields to POST for the request. See the corresponding
|
12
|
+
# object definition for field details.
|
13
|
+
# @return [BulkCreateVendorsResponse Hash] response from the API call
|
14
|
+
def bulk_create_vendors(body:)
|
15
|
+
# Prepare query url.
|
16
|
+
_query_builder = config.get_base_uri
|
17
|
+
_query_builder << '/v2/vendors/bulk-create'
|
18
|
+
_query_url = APIHelper.clean_url _query_builder
|
19
|
+
|
20
|
+
# Prepare headers.
|
21
|
+
_headers = {
|
22
|
+
'accept' => 'application/json',
|
23
|
+
'Content-Type' => 'application/json'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Prepare and execute HttpRequest.
|
27
|
+
_request = config.http_client.post(
|
28
|
+
_query_url,
|
29
|
+
headers: _headers,
|
30
|
+
parameters: body.to_json
|
31
|
+
)
|
32
|
+
OAuth2.apply(config, _request)
|
33
|
+
_response = execute_request(_request)
|
34
|
+
|
35
|
+
# Return appropriate response type.
|
36
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
37
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
38
|
+
ApiResponse.new(
|
39
|
+
_response, data: decoded, errors: _errors
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
|
44
|
+
# @param [BulkRetrieveVendorsRequest] body Required parameter: An object
|
45
|
+
# containing the fields to POST for the request. See the corresponding
|
46
|
+
# object definition for field details.
|
47
|
+
# @return [BulkRetrieveVendorsResponse Hash] response from the API call
|
48
|
+
def bulk_retrieve_vendors(body:)
|
49
|
+
# Prepare query url.
|
50
|
+
_query_builder = config.get_base_uri
|
51
|
+
_query_builder << '/v2/vendors/bulk-retrieve'
|
52
|
+
_query_url = APIHelper.clean_url _query_builder
|
53
|
+
|
54
|
+
# Prepare headers.
|
55
|
+
_headers = {
|
56
|
+
'accept' => 'application/json',
|
57
|
+
'Content-Type' => 'application/json'
|
58
|
+
}
|
59
|
+
|
60
|
+
# Prepare and execute HttpRequest.
|
61
|
+
_request = config.http_client.post(
|
62
|
+
_query_url,
|
63
|
+
headers: _headers,
|
64
|
+
parameters: body.to_json
|
65
|
+
)
|
66
|
+
OAuth2.apply(config, _request)
|
67
|
+
_response = execute_request(_request)
|
68
|
+
|
69
|
+
# Return appropriate response type.
|
70
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
71
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
72
|
+
ApiResponse.new(
|
73
|
+
_response, data: decoded, errors: _errors
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers
|
78
|
+
# to a seller.
|
79
|
+
# @param [BulkUpdateVendorsRequest] body Required parameter: An object
|
80
|
+
# containing the fields to POST for the request. See the corresponding
|
81
|
+
# object definition for field details.
|
82
|
+
# @return [BulkUpdateVendorsResponse Hash] response from the API call
|
83
|
+
def bulk_update_vendors(body:)
|
84
|
+
# Prepare query url.
|
85
|
+
_query_builder = config.get_base_uri
|
86
|
+
_query_builder << '/v2/vendors/bulk-update'
|
87
|
+
_query_url = APIHelper.clean_url _query_builder
|
88
|
+
|
89
|
+
# Prepare headers.
|
90
|
+
_headers = {
|
91
|
+
'accept' => 'application/json',
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
}
|
94
|
+
|
95
|
+
# Prepare and execute HttpRequest.
|
96
|
+
_request = config.http_client.put(
|
97
|
+
_query_url,
|
98
|
+
headers: _headers,
|
99
|
+
parameters: body.to_json
|
100
|
+
)
|
101
|
+
OAuth2.apply(config, _request)
|
102
|
+
_response = execute_request(_request)
|
103
|
+
|
104
|
+
# Return appropriate response type.
|
105
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
106
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
107
|
+
ApiResponse.new(
|
108
|
+
_response, data: decoded, errors: _errors
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates a single [Vendor]($m/Vendor) object to represent a supplier to a
|
113
|
+
# seller.
|
114
|
+
# @param [CreateVendorRequest] body Required parameter: An object containing
|
115
|
+
# the fields to POST for the request. See the corresponding object
|
116
|
+
# definition for field details.
|
117
|
+
# @return [CreateVendorResponse Hash] response from the API call
|
118
|
+
def create_vendor(body:)
|
119
|
+
# Prepare query url.
|
120
|
+
_query_builder = config.get_base_uri
|
121
|
+
_query_builder << '/v2/vendors/create'
|
122
|
+
_query_url = APIHelper.clean_url _query_builder
|
123
|
+
|
124
|
+
# Prepare headers.
|
125
|
+
_headers = {
|
126
|
+
'accept' => 'application/json',
|
127
|
+
'Content-Type' => 'application/json'
|
128
|
+
}
|
129
|
+
|
130
|
+
# Prepare and execute HttpRequest.
|
131
|
+
_request = config.http_client.post(
|
132
|
+
_query_url,
|
133
|
+
headers: _headers,
|
134
|
+
parameters: body.to_json
|
135
|
+
)
|
136
|
+
OAuth2.apply(config, _request)
|
137
|
+
_response = execute_request(_request)
|
138
|
+
|
139
|
+
# Return appropriate response type.
|
140
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
141
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
142
|
+
ApiResponse.new(
|
143
|
+
_response, data: decoded, errors: _errors
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Searches for vendors using a filter against supported [Vendor]($m/Vendor)
|
148
|
+
# properties and a supported sorter.
|
149
|
+
# @param [SearchVendorsRequest] body Required parameter: An object
|
150
|
+
# containing the fields to POST for the request. See the corresponding
|
151
|
+
# object definition for field details.
|
152
|
+
# @return [SearchVendorsResponse Hash] response from the API call
|
153
|
+
def search_vendors(body:)
|
154
|
+
# Prepare query url.
|
155
|
+
_query_builder = config.get_base_uri
|
156
|
+
_query_builder << '/v2/vendors/search'
|
157
|
+
_query_url = APIHelper.clean_url _query_builder
|
158
|
+
|
159
|
+
# Prepare headers.
|
160
|
+
_headers = {
|
161
|
+
'accept' => 'application/json',
|
162
|
+
'Content-Type' => 'application/json'
|
163
|
+
}
|
164
|
+
|
165
|
+
# Prepare and execute HttpRequest.
|
166
|
+
_request = config.http_client.post(
|
167
|
+
_query_url,
|
168
|
+
headers: _headers,
|
169
|
+
parameters: body.to_json
|
170
|
+
)
|
171
|
+
OAuth2.apply(config, _request)
|
172
|
+
_response = execute_request(_request)
|
173
|
+
|
174
|
+
# Return appropriate response type.
|
175
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
176
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
177
|
+
ApiResponse.new(
|
178
|
+
_response, data: decoded, errors: _errors
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
|
183
|
+
# @param [String] vendor_id Required parameter: ID of the
|
184
|
+
# [Vendor]($m/Vendor) to retrieve.
|
185
|
+
# @return [RetrieveVendorResponse Hash] response from the API call
|
186
|
+
def retrieve_vendor(vendor_id:)
|
187
|
+
# Prepare query url.
|
188
|
+
_query_builder = config.get_base_uri
|
189
|
+
_query_builder << '/v2/vendors/{vendor_id}'
|
190
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
191
|
+
_query_builder,
|
192
|
+
'vendor_id' => { 'value' => vendor_id, 'encode' => true }
|
193
|
+
)
|
194
|
+
_query_url = APIHelper.clean_url _query_builder
|
195
|
+
|
196
|
+
# Prepare headers.
|
197
|
+
_headers = {
|
198
|
+
'accept' => 'application/json'
|
199
|
+
}
|
200
|
+
|
201
|
+
# Prepare and execute HttpRequest.
|
202
|
+
_request = config.http_client.get(
|
203
|
+
_query_url,
|
204
|
+
headers: _headers
|
205
|
+
)
|
206
|
+
OAuth2.apply(config, _request)
|
207
|
+
_response = execute_request(_request)
|
208
|
+
|
209
|
+
# Return appropriate response type.
|
210
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
211
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
212
|
+
ApiResponse.new(
|
213
|
+
_response, data: decoded, errors: _errors
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
|
218
|
+
# @param [UpdateVendorRequest] body Required parameter: An object containing
|
219
|
+
# the fields to POST for the request. See the corresponding object
|
220
|
+
# definition for field details.
|
221
|
+
# @param [String] vendor_id Required parameter: Example:
|
222
|
+
# @return [UpdateVendorResponse Hash] response from the API call
|
223
|
+
def update_vendor(body:,
|
224
|
+
vendor_id:)
|
225
|
+
# Prepare query url.
|
226
|
+
_query_builder = config.get_base_uri
|
227
|
+
_query_builder << '/v2/vendors/{vendor_id}'
|
228
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
229
|
+
_query_builder,
|
230
|
+
'vendor_id' => { 'value' => vendor_id, 'encode' => true }
|
231
|
+
)
|
232
|
+
_query_url = APIHelper.clean_url _query_builder
|
233
|
+
|
234
|
+
# Prepare headers.
|
235
|
+
_headers = {
|
236
|
+
'accept' => 'application/json',
|
237
|
+
'Content-Type' => 'application/json'
|
238
|
+
}
|
239
|
+
|
240
|
+
# Prepare and execute HttpRequest.
|
241
|
+
_request = config.http_client.put(
|
242
|
+
_query_url,
|
243
|
+
headers: _headers,
|
244
|
+
parameters: body.to_json
|
245
|
+
)
|
246
|
+
OAuth2.apply(config, _request)
|
247
|
+
_response = execute_request(_request)
|
248
|
+
|
249
|
+
# Return appropriate response type.
|
250
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
251
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
252
|
+
ApiResponse.new(
|
253
|
+
_response, data: decoded, errors: _errors
|
254
|
+
)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|