square.rb 26.0.0.20221214 → 26.2.0.20230315
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/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +419 -0
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +82 -46
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +7 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +12 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# VendorsApi
|
3
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
4
|
# Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to
|
9
5
|
# a seller.
|
10
6
|
# @param [BulkCreateVendorsRequest] body Required parameter: An object
|
@@ -12,32 +8,20 @@ module Square
|
|
12
8
|
# object definition for field details.
|
13
9
|
# @return [BulkCreateVendorsResponse Hash] response from the API call
|
14
10
|
def bulk_create_vendors(body:)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
)
|
11
|
+
new_api_call_builder
|
12
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
13
|
+
'/v2/vendors/bulk-create',
|
14
|
+
'default')
|
15
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
16
|
+
.body_param(new_parameter(body))
|
17
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
18
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
19
|
+
.auth(Single.new('global')))
|
20
|
+
.response(new_response_handler
|
21
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
22
|
+
.is_api_response(true)
|
23
|
+
.convertor(ApiResponse.method(:create)))
|
24
|
+
.execute
|
41
25
|
end
|
42
26
|
|
43
27
|
# Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
|
@@ -46,32 +30,20 @@ module Square
|
|
46
30
|
# object definition for field details.
|
47
31
|
# @return [BulkRetrieveVendorsResponse Hash] response from the API call
|
48
32
|
def bulk_retrieve_vendors(body:)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
)
|
33
|
+
new_api_call_builder
|
34
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
35
|
+
'/v2/vendors/bulk-retrieve',
|
36
|
+
'default')
|
37
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
38
|
+
.body_param(new_parameter(body))
|
39
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
40
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
41
|
+
.auth(Single.new('global')))
|
42
|
+
.response(new_response_handler
|
43
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
44
|
+
.is_api_response(true)
|
45
|
+
.convertor(ApiResponse.method(:create)))
|
46
|
+
.execute
|
75
47
|
end
|
76
48
|
|
77
49
|
# Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers
|
@@ -81,32 +53,20 @@ module Square
|
|
81
53
|
# object definition for field details.
|
82
54
|
# @return [BulkUpdateVendorsResponse Hash] response from the API call
|
83
55
|
def bulk_update_vendors(body:)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
-
)
|
56
|
+
new_api_call_builder
|
57
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
58
|
+
'/v2/vendors/bulk-update',
|
59
|
+
'default')
|
60
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
61
|
+
.body_param(new_parameter(body))
|
62
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
63
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
64
|
+
.auth(Single.new('global')))
|
65
|
+
.response(new_response_handler
|
66
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
67
|
+
.is_api_response(true)
|
68
|
+
.convertor(ApiResponse.method(:create)))
|
69
|
+
.execute
|
110
70
|
end
|
111
71
|
|
112
72
|
# Creates a single [Vendor]($m/Vendor) object to represent a supplier to a
|
@@ -116,32 +76,20 @@ module Square
|
|
116
76
|
# definition for field details.
|
117
77
|
# @return [CreateVendorResponse Hash] response from the API call
|
118
78
|
def create_vendor(body:)
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
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
|
-
)
|
79
|
+
new_api_call_builder
|
80
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
81
|
+
'/v2/vendors/create',
|
82
|
+
'default')
|
83
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
84
|
+
.body_param(new_parameter(body))
|
85
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
86
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
87
|
+
.auth(Single.new('global')))
|
88
|
+
.response(new_response_handler
|
89
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
90
|
+
.is_api_response(true)
|
91
|
+
.convertor(ApiResponse.method(:create)))
|
92
|
+
.execute
|
145
93
|
end
|
146
94
|
|
147
95
|
# Searches for vendors using a filter against supported [Vendor]($m/Vendor)
|
@@ -151,32 +99,20 @@ module Square
|
|
151
99
|
# object definition for field details.
|
152
100
|
# @return [SearchVendorsResponse Hash] response from the API call
|
153
101
|
def search_vendors(body:)
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
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
|
-
)
|
102
|
+
new_api_call_builder
|
103
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
104
|
+
'/v2/vendors/search',
|
105
|
+
'default')
|
106
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
107
|
+
.body_param(new_parameter(body))
|
108
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
109
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
110
|
+
.auth(Single.new('global')))
|
111
|
+
.response(new_response_handler
|
112
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
113
|
+
.is_api_response(true)
|
114
|
+
.convertor(ApiResponse.method(:create)))
|
115
|
+
.execute
|
180
116
|
end
|
181
117
|
|
182
118
|
# Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
|
@@ -184,34 +120,19 @@ module Square
|
|
184
120
|
# [Vendor]($m/Vendor) to retrieve.
|
185
121
|
# @return [RetrieveVendorResponse Hash] response from the API call
|
186
122
|
def retrieve_vendor(vendor_id:)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
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
|
-
)
|
123
|
+
new_api_call_builder
|
124
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
125
|
+
'/v2/vendors/{vendor_id}',
|
126
|
+
'default')
|
127
|
+
.template_param(new_parameter(vendor_id, key: 'vendor_id')
|
128
|
+
.should_encode(true))
|
129
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
130
|
+
.auth(Single.new('global')))
|
131
|
+
.response(new_response_handler
|
132
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
133
|
+
.is_api_response(true)
|
134
|
+
.convertor(ApiResponse.method(:create)))
|
135
|
+
.execute
|
215
136
|
end
|
216
137
|
|
217
138
|
# Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
|
@@ -222,36 +143,22 @@ module Square
|
|
222
143
|
# @return [UpdateVendorResponse Hash] response from the API call
|
223
144
|
def update_vendor(body:,
|
224
145
|
vendor_id:)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
-
)
|
146
|
+
new_api_call_builder
|
147
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
148
|
+
'/v2/vendors/{vendor_id}',
|
149
|
+
'default')
|
150
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
151
|
+
.body_param(new_parameter(body))
|
152
|
+
.template_param(new_parameter(vendor_id, key: 'vendor_id')
|
153
|
+
.should_encode(true))
|
154
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
155
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
156
|
+
.auth(Single.new('global')))
|
157
|
+
.response(new_response_handler
|
158
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
159
|
+
.is_api_response(true)
|
160
|
+
.convertor(ApiResponse.method(:create)))
|
161
|
+
.execute
|
255
162
|
end
|
256
163
|
end
|
257
164
|
end
|