Skip to content

Commit c298f29

Browse files
committed
Forward request_options to API requests
Add request_options to Square::Internal::JSON::Request calls in lib/square/inventory/client.rb and lib/square/transfer_orders/client.rb so per-request options (e.g. base_url, headers) are properly forwarded. Updated request constructors for various GET/POST/PUT/DELETE endpoints to include request_options and adjusted argument formatting; no other business logic changes.
1 parent 1869c5a commit c298f29

File tree

2 files changed

+42
-21
lines changed

2 files changed

+42
-21
lines changed

lib/square/inventory/client.rb

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ def deprecated_get_adjustment(request_options: {}, **params)
1616
_request = Square::Internal::JSON::Request.new(
1717
base_url: request_options[:base_url],
1818
method: "GET",
19-
path: "v2/inventory/adjustment/#{params[:adjustment_id]}"
19+
path: "v2/inventory/adjustment/#{params[:adjustment_id]}",
20+
request_options: request_options
2021
)
2122
begin
2223
_response = @client.send(_request)
@@ -40,7 +41,8 @@ def get_adjustment(request_options: {}, **params)
4041
_request = Square::Internal::JSON::Request.new(
4142
base_url: request_options[:base_url],
4243
method: "GET",
43-
path: "v2/inventory/adjustments/#{params[:adjustment_id]}"
44+
path: "v2/inventory/adjustments/#{params[:adjustment_id]}",
45+
request_options: request_options
4446
)
4547
begin
4648
_response = @client.send(_request)
@@ -65,7 +67,8 @@ def deprecated_batch_change(request_options: {}, **params)
6567
base_url: request_options[:base_url],
6668
method: "POST",
6769
path: "v2/inventory/batch-change",
68-
body: Square::Types::BatchChangeInventoryRequest.new(params).to_h
70+
body: Square::Types::BatchChangeInventoryRequest.new(params).to_h,
71+
request_options: request_options
6972
)
7073
begin
7174
_response = @client.send(_request)
@@ -90,7 +93,8 @@ def deprecated_batch_get_changes(request_options: {}, **params)
9093
base_url: request_options[:base_url],
9194
method: "POST",
9295
path: "v2/inventory/batch-retrieve-changes",
93-
body: Square::Types::BatchRetrieveInventoryChangesRequest.new(params).to_h
96+
body: Square::Types::BatchRetrieveInventoryChangesRequest.new(params).to_h,
97+
request_options: request_options
9498
)
9599
begin
96100
_response = @client.send(_request)
@@ -115,7 +119,8 @@ def deprecated_batch_get_counts(request_options: {}, **params)
115119
base_url: request_options[:base_url],
116120
method: "POST",
117121
path: "v2/inventory/batch-retrieve-counts",
118-
body: Square::Types::BatchGetInventoryCountsRequest.new(params).to_h
122+
body: Square::Types::BatchGetInventoryCountsRequest.new(params).to_h,
123+
request_options: request_options
119124
)
120125
begin
121126
_response = @client.send(_request)
@@ -143,7 +148,8 @@ def batch_create_changes(request_options: {}, **params)
143148
base_url: request_options[:base_url],
144149
method: "POST",
145150
path: "v2/inventory/changes/batch-create",
146-
body: Square::Types::BatchChangeInventoryRequest.new(params).to_h
151+
body: Square::Types::BatchChangeInventoryRequest.new(params).to_h,
152+
request_options: request_options
147153
)
148154
begin
149155
_response = @client.send(_request)
@@ -180,7 +186,8 @@ def batch_get_changes(request_options: {}, **params)
180186
base_url: request_options[:base_url],
181187
method: "POST",
182188
path: "v2/inventory/changes/batch-retrieve",
183-
body: Square::Types::BatchRetrieveInventoryChangesRequest.new(params).to_h
189+
body: Square::Types::BatchRetrieveInventoryChangesRequest.new(params).to_h,
190+
request_options: request_options
184191
)
185192
begin
186193
_response = @client.send(_request)
@@ -221,7 +228,8 @@ def batch_get_counts(request_options: {}, **params)
221228
base_url: request_options[:base_url],
222229
method: "POST",
223230
path: "v2/inventory/counts/batch-retrieve",
224-
body: Square::Types::BatchGetInventoryCountsRequest.new(params).to_h
231+
body: Square::Types::BatchGetInventoryCountsRequest.new(params).to_h,
232+
request_options: request_options
225233
)
226234
begin
227235
_response = @client.send(_request)
@@ -246,7 +254,8 @@ def deprecated_get_physical_count(request_options: {}, **params)
246254
_request = Square::Internal::JSON::Request.new(
247255
base_url: request_options[:base_url],
248256
method: "GET",
249-
path: "v2/inventory/physical-count/#{params[:physical_count_id]}"
257+
path: "v2/inventory/physical-count/#{params[:physical_count_id]}",
258+
request_options: request_options
250259
)
251260
begin
252261
_response = @client.send(_request)
@@ -270,7 +279,8 @@ def get_physical_count(request_options: {}, **params)
270279
_request = Square::Internal::JSON::Request.new(
271280
base_url: request_options[:base_url],
272281
method: "GET",
273-
path: "v2/inventory/physical-counts/#{params[:physical_count_id]}"
282+
path: "v2/inventory/physical-counts/#{params[:physical_count_id]}",
283+
request_options: request_options
274284
)
275285
begin
276286
_response = @client.send(_request)
@@ -294,7 +304,8 @@ def get_transfer(request_options: {}, **params)
294304
_request = Square::Internal::JSON::Request.new(
295305
base_url: request_options[:base_url],
296306
method: "GET",
297-
path: "v2/inventory/transfers/#{params[:transfer_id]}"
307+
path: "v2/inventory/transfers/#{params[:transfer_id]}",
308+
request_options: request_options
298309
)
299310
begin
300311
_response = @client.send(_request)
@@ -332,7 +343,8 @@ def get(request_options: {}, **params)
332343
base_url: request_options[:base_url],
333344
method: "GET",
334345
path: "v2/inventory/#{params[:catalog_object_id]}",
335-
query: _query
346+
query: _query,
347+
request_options: request_options
336348
)
337349
begin
338350
_response = @client.send(_request)
@@ -380,7 +392,8 @@ def changes(request_options: {}, **params)
380392
base_url: request_options[:base_url],
381393
method: "GET",
382394
path: "v2/inventory/#{params[:catalog_object_id]}/changes",
383-
query: _query
395+
query: _query,
396+
request_options: request_options
384397
)
385398
begin
386399
_response = @client.send(_request)

lib/square/transfer_orders/client.rb

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def create(request_options: {}, **params)
3535
base_url: request_options[:base_url],
3636
method: "POST",
3737
path: "v2/transfer-orders",
38-
body: params
38+
body: params,
39+
request_options: request_options
3940
)
4041
begin
4142
_response = @client.send(_request)
@@ -71,7 +72,8 @@ def search(request_options: {}, **params)
7172
base_url: request_options[:base_url],
7273
method: "POST",
7374
path: "v2/transfer-orders/search",
74-
body: params
75+
body: params,
76+
request_options: request_options
7577
)
7678
begin
7779
_response = @client.send(_request)
@@ -101,7 +103,8 @@ def get(request_options: {}, **params)
101103
_request = Square::Internal::JSON::Request.new(
102104
base_url: request_options[:base_url],
103105
method: "GET",
104-
path: "v2/transfer-orders/#{params[:transfer_order_id]}"
106+
path: "v2/transfer-orders/#{params[:transfer_order_id]}",
107+
request_options: request_options
105108
)
106109
begin
107110
_response = @client.send(_request)
@@ -130,7 +133,8 @@ def update(request_options: {}, **params)
130133
base_url: request_options[:base_url],
131134
method: "PUT",
132135
path: "v2/transfer-orders/#{params[:transfer_order_id]}",
133-
body: params.except(*_path_param_names)
136+
body: params.except(*_path_param_names),
137+
request_options: request_options
134138
)
135139
begin
136140
_response = @client.send(_request)
@@ -163,7 +167,8 @@ def delete(request_options: {}, **params)
163167
base_url: request_options[:base_url],
164168
method: "DELETE",
165169
path: "v2/transfer-orders/#{params[:transfer_order_id]}",
166-
query: _query
170+
query: _query,
171+
request_options: request_options
167172
)
168173
begin
169174
_response = @client.send(_request)
@@ -198,7 +203,8 @@ def cancel(request_options: {}, **params)
198203
base_url: request_options[:base_url],
199204
method: "POST",
200205
path: "v2/transfer-orders/#{params[:transfer_order_id]}/cancel",
201-
body: params.except(*_path_param_names)
206+
body: params.except(*_path_param_names),
207+
request_options: request_options
202208
)
203209
begin
204210
_response = @client.send(_request)
@@ -239,7 +245,8 @@ def receive(request_options: {}, **params)
239245
base_url: request_options[:base_url],
240246
method: "POST",
241247
path: "v2/transfer-orders/#{params[:transfer_order_id]}/receive",
242-
body: params.except(*_path_param_names)
248+
body: params.except(*_path_param_names),
249+
request_options: request_options
243250
)
244251
begin
245252
_response = @client.send(_request)
@@ -272,7 +279,8 @@ def start(request_options: {}, **params)
272279
base_url: request_options[:base_url],
273280
method: "POST",
274281
path: "v2/transfer-orders/#{params[:transfer_order_id]}/start",
275-
body: params.except(*_path_param_names)
282+
body: params.except(*_path_param_names),
283+
request_options: request_options
276284
)
277285
begin
278286
_response = @client.send(_request)

0 commit comments

Comments
 (0)