square.rb 18.0.0.20220216 → 20.0.0.20220512
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -221
- 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/customer_groups_api.rb +7 -6
- data/lib/square/api/customer_segments_api.rb +7 -6
- data/lib/square/api/customers_api.rb +11 -8
- 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/locations_api.rb +3 -4
- data/lib/square/api/loyalty_api.rb +4 -3
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/subscriptions_api.rb +0 -3
- data/lib/square/api/terminal_api.rb +157 -6
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/client.rb +20 -2
- data/lib/square/configuration.rb +1 -1
- data/lib/square/http/faraday_client.rb +15 -5
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square.rb +3 -0
- metadata +53 -8
@@ -40,12 +40,11 @@ module Square
|
|
40
40
|
# Creating new locations allows for separate configuration of receipt
|
41
41
|
# layouts, item prices,
|
42
42
|
# and sales reports. Developers can use locations to separate sales activity
|
43
|
-
#
|
43
|
+
# through applications
|
44
44
|
# that integrate with Square from sales activity elsewhere in a seller's
|
45
45
|
# account.
|
46
|
-
# Locations created programmatically with the Locations API
|
47
|
-
#
|
48
|
-
# are visible to the seller for their own management, so ensure that
|
46
|
+
# Locations created programmatically with the Locations API last forever and
|
47
|
+
# are visible to the seller for their own management. Therefore, ensure that
|
49
48
|
# each location has a sensible and unique name.
|
50
49
|
# @param [CreateLocationRequest] body Required parameter: An object
|
51
50
|
# containing the fields to POST for the request. See the corresponding
|
@@ -424,9 +424,10 @@ module Square
|
|
424
424
|
)
|
425
425
|
end
|
426
426
|
|
427
|
-
# Searches for loyalty rewards
|
428
|
-
#
|
429
|
-
# `
|
427
|
+
# Searches for loyalty rewards. This endpoint accepts a request with no
|
428
|
+
# query filters and returns results for all loyalty accounts.
|
429
|
+
# If you include a `query` object, `loyalty_account_id` is required and
|
430
|
+
# `status` is optional.
|
430
431
|
# If you know a reward ID, use the
|
431
432
|
# [RetrieveLoyaltyReward]($e/Loyalty/RetrieveLoyaltyReward) endpoint.
|
432
433
|
# Search results are sorted by `updated_at` in descending order.
|
@@ -311,8 +311,8 @@ module Square
|
|
311
311
|
# the
|
312
312
|
# `payment_ids` is canceled.
|
313
313
|
# - Be approved with [delayed
|
314
|
-
# capture](https://developer.squareup.com/docs/payments-api/take-payments
|
315
|
-
#
|
314
|
+
# capture](https://developer.squareup.com/docs/payments-api/take-payments/ca
|
315
|
+
# rd-payments/delayed-capture).
|
316
316
|
# Using a delayed capture payment with `PayOrder` completes the approved
|
317
317
|
# payment.
|
318
318
|
# @param [String] order_id Required parameter: The ID of the order being
|
@@ -0,0 +1,173 @@
|
|
1
|
+
module Square
|
2
|
+
# PayoutsApi
|
3
|
+
class PayoutsApi < 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 all payouts for the default location.
|
9
|
+
# You can filter payouts by location ID, status, time range, and order them
|
10
|
+
# in ascending or descending order.
|
11
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
12
|
+
# @param [String] location_id Optional parameter: The ID of the location for
|
13
|
+
# which to list the payouts. By default, payouts are returned for the
|
14
|
+
# default (main) location associated with the seller.
|
15
|
+
# @param [PayoutStatus] status Optional parameter: If provided, only payouts
|
16
|
+
# with the given status are returned.
|
17
|
+
# @param [String] begin_time Optional parameter: The timestamp for the
|
18
|
+
# beginning of the payout creation time, in RFC 3339 format. Inclusive.
|
19
|
+
# Default: The current time minus one year.
|
20
|
+
# @param [String] end_time Optional parameter: The timestamp for the end of
|
21
|
+
# the payout creation time, in RFC 3339 format. Default: The current time.
|
22
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
23
|
+
# payouts are listed.
|
24
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
26
|
+
# set of results for the original query. For more information, see
|
27
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
28
|
+
# . If request parameters change between requests, subsequent results may
|
29
|
+
# contain duplicates or missing records.
|
30
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
31
|
+
# to be returned in a single page. It is possible to receive fewer results
|
32
|
+
# than the specified limit on a given page. The default value of 100 is also
|
33
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
34
|
+
# is ignored and the default value is used instead. Default: `100`
|
35
|
+
# @return [ListPayoutsResponse Hash] response from the API call
|
36
|
+
def list_payouts(location_id: nil,
|
37
|
+
status: nil,
|
38
|
+
begin_time: nil,
|
39
|
+
end_time: nil,
|
40
|
+
sort_order: nil,
|
41
|
+
cursor: nil,
|
42
|
+
limit: nil)
|
43
|
+
# Prepare query url.
|
44
|
+
_query_builder = config.get_base_uri
|
45
|
+
_query_builder << '/v2/payouts'
|
46
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
47
|
+
_query_builder,
|
48
|
+
'location_id' => location_id,
|
49
|
+
'status' => status,
|
50
|
+
'begin_time' => begin_time,
|
51
|
+
'end_time' => end_time,
|
52
|
+
'sort_order' => sort_order,
|
53
|
+
'cursor' => cursor,
|
54
|
+
'limit' => limit
|
55
|
+
)
|
56
|
+
_query_url = APIHelper.clean_url _query_builder
|
57
|
+
|
58
|
+
# Prepare headers.
|
59
|
+
_headers = {
|
60
|
+
'accept' => 'application/json'
|
61
|
+
}
|
62
|
+
|
63
|
+
# Prepare and execute HttpRequest.
|
64
|
+
_request = config.http_client.get(
|
65
|
+
_query_url,
|
66
|
+
headers: _headers
|
67
|
+
)
|
68
|
+
OAuth2.apply(config, _request)
|
69
|
+
_response = execute_request(_request)
|
70
|
+
|
71
|
+
# Return appropriate response type.
|
72
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
73
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
74
|
+
ApiResponse.new(
|
75
|
+
_response, data: decoded, errors: _errors
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Retrieves details of a specific payout identified by a payout ID.
|
80
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
81
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
82
|
+
# retrieve the information for.
|
83
|
+
# @return [GetPayoutResponse Hash] response from the API call
|
84
|
+
def get_payout(payout_id:)
|
85
|
+
# Prepare query url.
|
86
|
+
_query_builder = config.get_base_uri
|
87
|
+
_query_builder << '/v2/payouts/{payout_id}'
|
88
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
89
|
+
_query_builder,
|
90
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
91
|
+
)
|
92
|
+
_query_url = APIHelper.clean_url _query_builder
|
93
|
+
|
94
|
+
# Prepare headers.
|
95
|
+
_headers = {
|
96
|
+
'accept' => 'application/json'
|
97
|
+
}
|
98
|
+
|
99
|
+
# Prepare and execute HttpRequest.
|
100
|
+
_request = config.http_client.get(
|
101
|
+
_query_url,
|
102
|
+
headers: _headers
|
103
|
+
)
|
104
|
+
OAuth2.apply(config, _request)
|
105
|
+
_response = execute_request(_request)
|
106
|
+
|
107
|
+
# Return appropriate response type.
|
108
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
109
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
110
|
+
ApiResponse.new(
|
111
|
+
_response, data: decoded, errors: _errors
|
112
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Retrieves a list of all payout entries for a specific payout.
|
116
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
117
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
118
|
+
# retrieve the information for.
|
119
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
120
|
+
# payout entries are listed.
|
121
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
122
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
123
|
+
# set of results for the original query. For more information, see
|
124
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
125
|
+
# . If request parameters change between requests, subsequent results may
|
126
|
+
# contain duplicates or missing records.
|
127
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
128
|
+
# to be returned in a single page. It is possible to receive fewer results
|
129
|
+
# than the specified limit on a given page. The default value of 100 is also
|
130
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
131
|
+
# is ignored and the default value is used instead. Default: `100`
|
132
|
+
# @return [ListPayoutEntriesResponse Hash] response from the API call
|
133
|
+
def list_payout_entries(payout_id:,
|
134
|
+
sort_order: nil,
|
135
|
+
cursor: nil,
|
136
|
+
limit: nil)
|
137
|
+
# Prepare query url.
|
138
|
+
_query_builder = config.get_base_uri
|
139
|
+
_query_builder << '/v2/payouts/{payout_id}/payout-entries'
|
140
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
141
|
+
_query_builder,
|
142
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
143
|
+
)
|
144
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
145
|
+
_query_builder,
|
146
|
+
'sort_order' => sort_order,
|
147
|
+
'cursor' => cursor,
|
148
|
+
'limit' => limit
|
149
|
+
)
|
150
|
+
_query_url = APIHelper.clean_url _query_builder
|
151
|
+
|
152
|
+
# Prepare headers.
|
153
|
+
_headers = {
|
154
|
+
'accept' => 'application/json'
|
155
|
+
}
|
156
|
+
|
157
|
+
# Prepare and execute HttpRequest.
|
158
|
+
_request = config.http_client.get(
|
159
|
+
_query_url,
|
160
|
+
headers: _headers
|
161
|
+
)
|
162
|
+
OAuth2.apply(config, _request)
|
163
|
+
_response = execute_request(_request)
|
164
|
+
|
165
|
+
# Return appropriate response type.
|
166
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
167
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
168
|
+
ApiResponse.new(
|
169
|
+
_response, data: decoded, errors: _errors
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -260,9 +260,6 @@ module Square
|
|
260
260
|
end
|
261
261
|
|
262
262
|
# Lists all events for a specific subscription.
|
263
|
-
# In the current implementation, only `START_SUBSCRIPTION` and
|
264
|
-
# `STOP_SUBSCRIPTION` (when the subscription was canceled) events are
|
265
|
-
# returned.
|
266
263
|
# @param [String] subscription_id Required parameter: The ID of the
|
267
264
|
# subscription to retrieve the events for.
|
268
265
|
# @param [String] cursor Optional parameter: When the total number of
|
@@ -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.
|
@@ -41,8 +184,10 @@ module Square
|
|
41
184
|
)
|
42
185
|
end
|
43
186
|
|
44
|
-
#
|
45
|
-
#
|
187
|
+
# Returns a filtered list of Terminal checkout requests created by the
|
188
|
+
# application making the request. Only Terminal checkout requests created
|
189
|
+
# for the merchant scoped to the OAuth token are returned. Terminal checkout
|
190
|
+
# requests are available for 30 days.
|
46
191
|
# @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
|
47
192
|
# containing the fields to POST for the request. See the corresponding
|
48
193
|
# object definition for field details.
|
@@ -76,7 +221,8 @@ module Square
|
|
76
221
|
)
|
77
222
|
end
|
78
223
|
|
79
|
-
# Retrieves a Terminal checkout request by `checkout_id`.
|
224
|
+
# Retrieves a Terminal checkout request by `checkout_id`. Terminal checkout
|
225
|
+
# requests are available for 30 days.
|
80
226
|
# @param [String] checkout_id Required parameter: The unique ID for the
|
81
227
|
# desired `TerminalCheckout`.
|
82
228
|
# @return [GetTerminalCheckoutResponse Hash] response from the API call
|
@@ -148,7 +294,10 @@ module Square
|
|
148
294
|
end
|
149
295
|
|
150
296
|
# Creates a request to refund an Interac payment completed on a Square
|
151
|
-
# Terminal.
|
297
|
+
# Terminal. Refunds for Interac payments on a Square Terminal are supported
|
298
|
+
# only for Interac debit cards in Canada. Other refunds for Terminal
|
299
|
+
# payments should use the Refunds API. For more information, see [Refunds
|
300
|
+
# API]($e/Refunds).
|
152
301
|
# @param [CreateTerminalRefundRequest] body Required parameter: An object
|
153
302
|
# containing the fields to POST for the request. See the corresponding
|
154
303
|
# object definition for field details.
|
@@ -183,7 +332,8 @@ module Square
|
|
183
332
|
end
|
184
333
|
|
185
334
|
# Retrieves a filtered list of Interac Terminal refund requests created by
|
186
|
-
# the seller making the request.
|
335
|
+
# the seller making the request. Terminal refund requests are available for
|
336
|
+
# 30 days.
|
187
337
|
# @param [SearchTerminalRefundsRequest] body Required parameter: An object
|
188
338
|
# containing the fields to POST for the request. See the corresponding
|
189
339
|
# object definition for field details.
|
@@ -217,7 +367,8 @@ module Square
|
|
217
367
|
)
|
218
368
|
end
|
219
369
|
|
220
|
-
# Retrieves an Interac Terminal refund object by ID.
|
370
|
+
# Retrieves an Interac Terminal refund object by ID. Terminal refund objects
|
371
|
+
# are available for 30 days.
|
221
372
|
# @param [String] terminal_refund_id Required parameter: The unique ID for
|
222
373
|
# the desired `TerminalRefund`.
|
223
374
|
# @return [GetTerminalRefundResponse Hash] response from the API call
|
@@ -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
|