Skip to content

Commit a3de184

Browse files
authored
Fix the generator for optional body parameters (#69)
* Try again * Change * Whatever * Generate the right way
1 parent cce7fbb commit a3de184

13 files changed

+68
-304
lines changed

Diff for: Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
patch_ruby (1.24.0)
4+
patch_ruby (1.24.1)
55
typhoeus (~> 1.0, >= 1.0.1)
66

77
GEM

Diff for: lib/patch_ruby.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
require 'patch_ruby/models/estimate_response'
3838
require 'patch_ruby/models/highlight'
3939
require 'patch_ruby/models/inventory'
40-
require 'patch_ruby/models/issued_to'
4140
require 'patch_ruby/models/meta_index_object'
4241
require 'patch_ruby/models/order'
4342
require 'patch_ruby/models/order_inventory'
4443
require 'patch_ruby/models/order_inventory_project'
44+
require 'patch_ruby/models/order_issued_to'
4545
require 'patch_ruby/models/order_list_response'
4646
require 'patch_ruby/models/order_response'
4747
require 'patch_ruby/models/parent_technology_type'
@@ -54,7 +54,6 @@
5454
require 'patch_ruby/models/standard'
5555
require 'patch_ruby/models/technology_type'
5656
require 'patch_ruby/models/technology_type_list_response'
57-
require 'patch_ruby/models/v1_orders_issued_to'
5857

5958
# APIs
6059
require 'patch_ruby/api/estimates_api'

Diff for: lib/patch_ruby/api/estimates_api.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts
4747
end
4848

4949
# Creates a GLEC air shipping estimate given freight mass and logistics
50-
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
50+
# Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
5151
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
5252
# @param [Hash] opts the optional parameters
5353
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -116,7 +116,7 @@ def create_bitcoin_estimate(create_bitcoin_estimate_request = {}, opts = {})
116116
end
117117

118118
# Create a bitcoin estimate given a timestamp and transaction value
119-
# Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
119+
# Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
120120
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
121121
# @param [Hash] opts the optional parameters
122122
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -185,7 +185,7 @@ def create_ethereum_estimate(create_ethereum_estimate_request = {}, opts = {})
185185
end
186186

187187
# Create an ethereum estimate
188-
# Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
188+
# Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
189189
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
190190
# @param [Hash] opts the optional parameters
191191
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -254,7 +254,7 @@ def create_flight_estimate(create_flight_estimate_request = {}, opts = {})
254254
end
255255

256256
# Create a flight estimate given the distance traveled in meters
257-
# Creates a flight estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
257+
# Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
258258
# @param create_flight_estimate_request [CreateFlightEstimateRequest]
259259
# @param [Hash] opts the optional parameters
260260
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -323,7 +323,7 @@ def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
323323
end
324324

325325
# Create a hotel estimate.
326-
# Creates a hotel estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters.
326+
# Creates a hotel estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
327327
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
328328
# @param [Hash] opts the optional parameters
329329
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -392,7 +392,7 @@ def create_mass_estimate(create_mass_estimate_request = {}, opts = {})
392392
end
393393

394394
# Create an estimate based on mass of CO2
395-
# Creates an estimate for the mass of CO2 to be compensated. An order in the &#x60;draft&#x60; state will also be created, linked to the estimate.
395+
# Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate.
396396
# @param create_mass_estimate_request [CreateMassEstimateRequest]
397397
# @param [Hash] opts the optional parameters
398398
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -461,7 +461,7 @@ def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, op
461461
end
462462

463463
# Creates a GLEC rail shipping estimate given freight mass and logistics
464-
# Creates a GLEC rail shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
464+
# Creates a GLEC rail shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
465465
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
466466
# @param [Hash] opts the optional parameters
467467
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -530,7 +530,7 @@ def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, op
530530
end
531531

532532
# Creates a GLEC road shipping estimate given freight mass and logistics
533-
# Creates a GLEC road shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
533+
# Creates a GLEC road shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
534534
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
535535
# @param [Hash] opts the optional parameters
536536
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -599,7 +599,7 @@ def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts
599599
end
600600

601601
# Creates a GLEC sea shipping estimate given freight mass and logistics
602-
# Creates a GLEC sea shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
602+
# Creates a GLEC sea shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate.
603603
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
604604
# @param [Hash] opts the optional parameters
605605
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -668,7 +668,7 @@ def create_shipping_estimate(create_shipping_estimate_request = {}, opts = {})
668668
end
669669

670670
# Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
671-
# Creates a shipping estimate for the amount of CO2 to be compensated. An order in the &#x60;draft&#x60; state may be created based on the parameters.
671+
# Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters.
672672
# @param create_shipping_estimate_request [CreateShippingEstimateRequest]
673673
# @param [Hash] opts the optional parameters
674674
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
@@ -737,7 +737,7 @@ def create_vehicle_estimate(create_vehicle_estimate_request = {}, opts = {})
737737
end
738738

739739
# Create a vehicle estimate given the distance traveled in meters and the type of vehicle
740-
# Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the &#x60;draft&#x60; state may be created based on the parameters, linked to the estimate.
740+
# Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate.
741741
# @param create_vehicle_estimate_request [CreateVehicleEstimateRequest]
742742
# @param [Hash] opts the optional parameters
743743
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers

Diff for: lib/patch_ruby/api/orders_api.rb

+36-34
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,19 @@ def initialize(api_client = ApiClient.default)
2828
@api_client = api_client
2929
end
3030
# Cancel an order
31-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
32-
# @param id [String]
31+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
32+
# @param id [String]
3333
# @param [Hash] opts the optional parameters
3434
# @return [OrderResponse]
3535
def cancel_order(id, opts = {})
36+
3637
data, _status_code, _headers = cancel_order_with_http_info(id, opts)
3738
data
3839
end
3940

4041
# Cancel an order
41-
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the &#x60;draft&#x60; or &#x60;placed&#x60; state can be cancelled.
42-
# @param id [String]
42+
# Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled.
43+
# @param id [String]
4344
# @param [Hash] opts the optional parameters
4445
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
4546
def cancel_order_with_http_info(id, opts = {})
@@ -91,19 +92,19 @@ def cancel_order_with_http_info(id, opts = {})
9192
end
9293

9394
# Creates an order
94-
# Creates an order in the `placed` or `draft` state.
95-
# @param create_order_request [CreateOrderRequest]
95+
# Creates an order in the `placed` or `draft` state.
96+
# @param create_order_request [CreateOrderRequest]
9697
# @param [Hash] opts the optional parameters
9798
# @return [OrderResponse]
9899
def create_order(create_order_request = {}, opts = {})
99-
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
100+
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
100101
data, _status_code, _headers = create_order_with_http_info(_create_order_request, opts)
101102
data
102103
end
103104

104105
# Creates an order
105-
# Creates an order in the &#x60;placed&#x60; or &#x60;draft&#x60; state.
106-
# @param create_order_request [CreateOrderRequest]
106+
# Creates an order in the `placed` or `draft` state.
107+
# @param create_order_request [CreateOrderRequest]
107108
# @param [Hash] opts the optional parameters
108109
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
109110
def create_order_with_http_info(create_order_request, opts = {})
@@ -160,23 +161,22 @@ def create_order_with_http_info(create_order_request, opts = {})
160161
end
161162

162163
# Place an order
163-
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
164-
# @param id [String]
164+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
165+
# @param id [String]
165166
# @param [Hash] opts the optional parameters
166-
# @option opts [PlaceOrderRequest] :place_order_request
167+
# @option opts [PlaceOrderRequest] :place_order_request
167168
# @return [OrderResponse]
168-
def place_order(order_id, opts = {})
169-
place_order_request = Patch::PlaceOrderRequest.new(opts)
170-
opts[:place_order_request] = place_order_request
171-
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
169+
def place_order(id, opts = {})
170+
171+
data, _status_code, _headers = place_order_with_http_info(id, opts)
172172
data
173173
end
174174

175175
# Place an order
176-
# Placing an order confirms an order&#39;s allocation of offsets. Only orders that are in the &#x60;draft&#x60; state can be placed
177-
# @param id [String]
176+
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
177+
# @param id [String]
178178
# @param [Hash] opts the optional parameters
179-
# @option opts [PlaceOrderRequest] :place_order_request
179+
# @option opts [PlaceOrderRequest] :place_order_request
180180
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
181181
def place_order_with_http_info(id, opts = {})
182182
if @api_client.config.debugging
@@ -206,7 +206,7 @@ def place_order_with_http_info(id, opts = {})
206206
form_params = opts[:form_params] || {}
207207

208208
# http body (model)
209-
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'place_order_request'])
209+
post_body = opts[:debug_body] || @api_client.object_to_http_body(opts)
210210

211211
# return_type
212212
return_type = opts[:debug_return_type] || 'OrderResponse'
@@ -232,18 +232,19 @@ def place_order_with_http_info(id, opts = {})
232232
end
233233

234234
# Retrieves an order
235-
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
236-
# @param id [String]
235+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
236+
# @param id [String]
237237
# @param [Hash] opts the optional parameters
238238
# @return [OrderResponse]
239239
def retrieve_order(id, opts = {})
240+
240241
data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
241242
data
242243
end
243244

244245
# Retrieves an order
245-
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
246-
# @param id [String]
246+
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
247+
# @param id [String]
247248
# @param [Hash] opts the optional parameters
248249
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
249250
def retrieve_order_with_http_info(id, opts = {})
@@ -295,25 +296,26 @@ def retrieve_order_with_http_info(id, opts = {})
295296
end
296297

297298
# Retrieves a list of orders
298-
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
299+
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
299300
# @param [Hash] opts the optional parameters
300-
# @option opts [Integer] :page
301-
# @option opts [String] :metadata
302-
# @option opts [String] :metadata_example1
303-
# @option opts [String] :metadata_example2
301+
# @option opts [Integer] :page
302+
# @option opts [String] :metadata
303+
# @option opts [String] :metadata_example1
304+
# @option opts [String] :metadata_example2
304305
# @return [OrderListResponse]
305306
def retrieve_orders(opts = {})
307+
306308
data, _status_code, _headers = retrieve_orders_with_http_info(opts)
307309
data
308310
end
309311

310312
# Retrieves a list of orders
311-
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
313+
# Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
312314
# @param [Hash] opts the optional parameters
313-
# @option opts [Integer] :page
314-
# @option opts [String] :metadata
315-
# @option opts [String] :metadata_example1
316-
# @option opts [String] :metadata_example2
315+
# @option opts [Integer] :page
316+
# @option opts [String] :metadata
317+
# @option opts [String] :metadata_example1
318+
# @option opts [String] :metadata_example2
317319
# @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers
318320
def retrieve_orders_with_http_info(opts = {})
319321
if @api_client.config.debugging

Diff for: lib/patch_ruby/api/projects_api.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def retrieve_project(id, opts = {})
3737
end
3838

3939
# Retrieves a project
40-
# Retrieves a project available on Patch&#39;s platform.
40+
# Retrieves a project available on Patch's platform.
4141
# @param id [String]
4242
# @param [Hash] opts the optional parameters
4343
# @option opts [String] :accept_language
@@ -107,7 +107,7 @@ def retrieve_projects(opts = {})
107107
end
108108

109109
# Retrieves a list of projects
110-
# Retrieves a list of projects available for purchase on Patch&#39;s platform.
110+
# Retrieves a list of projects available for purchase on Patch's platform.
111111
# @param [Hash] opts the optional parameters
112112
# @option opts [Integer] :page
113113
# @option opts [String] :country

Diff for: lib/patch_ruby/api_client.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ApiClient
3131
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
3232
def initialize(config = Configuration.default)
3333
@config = config
34-
@user_agent = "patch-ruby/1.24.0"
34+
@user_agent = "patch-ruby/1.24.1"
3535
@default_headers = {
3636
'Content-Type' => 'application/json',
3737
'User-Agent' => @user_agent

Diff for: lib/patch_ruby/models/create_order_request.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def self.openapi_types
9494
:'currency' => :'String',
9595
:'amount' => :'Integer',
9696
:'unit' => :'String',
97-
:'issued_to' => :'V1OrdersIssuedTo'
97+
:'issued_to' => :'OrderIssuedTo'
9898
}
9999
end
100100

@@ -111,7 +111,6 @@ def self.openapi_nullable
111111
:'currency',
112112
:'amount',
113113
:'unit',
114-
:'issued_to'
115114
])
116115
end
117116

Diff for: lib/patch_ruby/models/order.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class Order
6666
# An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price.
6767
attr_accessor :inventory
6868

69+
# An object containing the name & email of the party the inventory will be issued to.
6970
attr_accessor :issued_to
7071

7172
class EnumAttributeValidator
@@ -139,7 +140,7 @@ def self.openapi_types
139140
:'registry_url' => :'String',
140141
:'metadata' => :'Object',
141142
:'inventory' => :'Array<OrderInventory>',
142-
:'issued_to' => :'IssuedTo'
143+
:'issued_to' => :'OrderIssuedTo'
143144
}
144145
end
145146

@@ -251,6 +252,9 @@ def initialize(attributes = {})
251252
end
252253

253254
if attributes.key?(:'issued_to')
255+
if (value = attributes[:'issued_to']).is_a?(Hash)
256+
self.issued_to = value
257+
end
254258
self.issued_to = attributes[:'issued_to']
255259
end
256260
end

0 commit comments

Comments
 (0)