Skip to content

Commit

Permalink
Fix the generator for optional body parameters (#69)
Browse files Browse the repository at this point in the history
* Try again

* Change

* Whatever

* Generate the right way
  • Loading branch information
pcothenet authored Jul 29, 2022
1 parent cce7fbb commit a3de184
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 304 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
patch_ruby (1.24.0)
patch_ruby (1.24.1)
typhoeus (~> 1.0, >= 1.0.1)

GEM
Expand Down
3 changes: 1 addition & 2 deletions lib/patch_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
require 'patch_ruby/models/estimate_response'
require 'patch_ruby/models/highlight'
require 'patch_ruby/models/inventory'
require 'patch_ruby/models/issued_to'
require 'patch_ruby/models/meta_index_object'
require 'patch_ruby/models/order'
require 'patch_ruby/models/order_inventory'
require 'patch_ruby/models/order_inventory_project'
require 'patch_ruby/models/order_issued_to'
require 'patch_ruby/models/order_list_response'
require 'patch_ruby/models/order_response'
require 'patch_ruby/models/parent_technology_type'
Expand All @@ -54,7 +54,6 @@
require 'patch_ruby/models/standard'
require 'patch_ruby/models/technology_type'
require 'patch_ruby/models/technology_type_list_response'
require 'patch_ruby/models/v1_orders_issued_to'

# APIs
require 'patch_ruby/api/estimates_api'
Expand Down
22 changes: 11 additions & 11 deletions lib/patch_ruby/api/estimates_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts
end

# Creates a GLEC air shipping estimate given freight mass and logistics
# 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.
# 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.
# @param create_air_shipping_estimate_request [CreateAirShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -116,7 +116,7 @@ def create_bitcoin_estimate(create_bitcoin_estimate_request = {}, opts = {})
end

# Create a bitcoin estimate given a timestamp and transaction value
# 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.
# 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.
# @param create_bitcoin_estimate_request [CreateBitcoinEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -185,7 +185,7 @@ def create_ethereum_estimate(create_ethereum_estimate_request = {}, opts = {})
end

# Create an ethereum estimate
# 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.
# 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.
# @param create_ethereum_estimate_request [CreateEthereumEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -254,7 +254,7 @@ def create_flight_estimate(create_flight_estimate_request = {}, opts = {})
end

# Create a flight estimate given the distance traveled in meters
# 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.
# 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.
# @param create_flight_estimate_request [CreateFlightEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -323,7 +323,7 @@ def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {})
end

# Create a hotel estimate.
# 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.
# 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.
# @param create_hotel_estimate_request [CreateHotelEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -392,7 +392,7 @@ def create_mass_estimate(create_mass_estimate_request = {}, opts = {})
end

# Create an estimate based on mass of CO2
# 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.
# 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.
# @param create_mass_estimate_request [CreateMassEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -461,7 +461,7 @@ def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, op
end

# Creates a GLEC rail shipping estimate given freight mass and logistics
# 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.
# 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.
# @param create_rail_shipping_estimate_request [CreateRailShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -530,7 +530,7 @@ def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, op
end

# Creates a GLEC road shipping estimate given freight mass and logistics
# 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.
# 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.
# @param create_road_shipping_estimate_request [CreateRoadShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -599,7 +599,7 @@ def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts
end

# Creates a GLEC sea shipping estimate given freight mass and logistics
# 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.
# 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.
# @param create_sea_shipping_estimate_request [CreateSeaShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -668,7 +668,7 @@ def create_shipping_estimate(create_shipping_estimate_request = {}, opts = {})
end

# Create a shipping estimate given the distance traveled in meters, package weight, and transportation method.
# 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.
# 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.
# @param create_shipping_estimate_request [CreateShippingEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down Expand Up @@ -737,7 +737,7 @@ def create_vehicle_estimate(create_vehicle_estimate_request = {}, opts = {})
end

# Create a vehicle estimate given the distance traveled in meters and the type of vehicle
# 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.
# 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.
# @param create_vehicle_estimate_request [CreateVehicleEstimateRequest]
# @param [Hash] opts the optional parameters
# @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers
Expand Down
70 changes: 36 additions & 34 deletions lib/patch_ruby/api/orders_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Cancel an order
# 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.
# @param id [String]
# 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.
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [OrderResponse]
def cancel_order(id, opts = {})

data, _status_code, _headers = cancel_order_with_http_info(id, opts)
data
end

# Cancel an order
# 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.
# @param id [String]
# 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.
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers
def cancel_order_with_http_info(id, opts = {})
Expand Down Expand Up @@ -91,19 +92,19 @@ def cancel_order_with_http_info(id, opts = {})
end

# Creates an order
# Creates an order in the `placed` or `draft` state.
# @param create_order_request [CreateOrderRequest]
# Creates an order in the `placed` or `draft` state.
# @param create_order_request [CreateOrderRequest]
# @param [Hash] opts the optional parameters
# @return [OrderResponse]
def create_order(create_order_request = {}, opts = {})
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
_create_order_request = Patch::CreateOrderRequest.new(create_order_request)
data, _status_code, _headers = create_order_with_http_info(_create_order_request, opts)
data
end

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

# Place an order
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
# @param id [String]
# Placing an order confirms an order's allocation of offsets. Only orders that are in the `draft` state can be placed
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [PlaceOrderRequest] :place_order_request
# @option opts [PlaceOrderRequest] :place_order_request
# @return [OrderResponse]
def place_order(order_id, opts = {})
place_order_request = Patch::PlaceOrderRequest.new(opts)
opts[:place_order_request] = place_order_request
data, _status_code, _headers = place_order_with_http_info(order_id, opts)
def place_order(id, opts = {})

data, _status_code, _headers = place_order_with_http_info(id, opts)
data
end

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

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

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

# Retrieves an order
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
# @param id [String]
# Retrieves a given order and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for.
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [OrderResponse]
def retrieve_order(id, opts = {})

data, _status_code, _headers = retrieve_order_with_http_info(id, opts)
data
end

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

# Retrieves a list of orders
# 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.
# 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.
# @param [Hash] opts the optional parameters
# @option opts [Integer] :page
# @option opts [String] :metadata
# @option opts [String] :metadata_example1
# @option opts [String] :metadata_example2
# @option opts [Integer] :page
# @option opts [String] :metadata
# @option opts [String] :metadata_example1
# @option opts [String] :metadata_example2
# @return [OrderListResponse]
def retrieve_orders(opts = {})

data, _status_code, _headers = retrieve_orders_with_http_info(opts)
data
end

# Retrieves a list of orders
# 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.
# 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.
# @param [Hash] opts the optional parameters
# @option opts [Integer] :page
# @option opts [String] :metadata
# @option opts [String] :metadata_example1
# @option opts [String] :metadata_example2
# @option opts [Integer] :page
# @option opts [String] :metadata
# @option opts [String] :metadata_example1
# @option opts [String] :metadata_example2
# @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers
def retrieve_orders_with_http_info(opts = {})
if @api_client.config.debugging
Expand Down
4 changes: 2 additions & 2 deletions lib/patch_ruby/api/projects_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def retrieve_project(id, opts = {})
end

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

# Retrieves a list of projects
# Retrieves a list of projects available for purchase on Patch&#39;s platform.
# Retrieves a list of projects available for purchase on Patch's platform.
# @param [Hash] opts the optional parameters
# @option opts [Integer] :page
# @option opts [String] :country
Expand Down
2 changes: 1 addition & 1 deletion lib/patch_ruby/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ApiClient
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
@user_agent = "patch-ruby/1.24.0"
@user_agent = "patch-ruby/1.24.1"
@default_headers = {
'Content-Type' => 'application/json',
'User-Agent' => @user_agent
Expand Down
3 changes: 1 addition & 2 deletions lib/patch_ruby/models/create_order_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def self.openapi_types
:'currency' => :'String',
:'amount' => :'Integer',
:'unit' => :'String',
:'issued_to' => :'V1OrdersIssuedTo'
:'issued_to' => :'OrderIssuedTo'
}
end

Expand All @@ -111,7 +111,6 @@ def self.openapi_nullable
:'currency',
:'amount',
:'unit',
:'issued_to'
])
end

Expand Down
6 changes: 5 additions & 1 deletion lib/patch_ruby/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Order
# An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price.
attr_accessor :inventory

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

class EnumAttributeValidator
Expand Down Expand Up @@ -139,7 +140,7 @@ def self.openapi_types
:'registry_url' => :'String',
:'metadata' => :'Object',
:'inventory' => :'Array<OrderInventory>',
:'issued_to' => :'IssuedTo'
:'issued_to' => :'OrderIssuedTo'
}
end

Expand Down Expand Up @@ -251,6 +252,9 @@ def initialize(attributes = {})
end

if attributes.key?(:'issued_to')
if (value = attributes[:'issued_to']).is_a?(Hash)
self.issued_to = value
end
self.issued_to = attributes[:'issued_to']
end
end
Expand Down
Loading

0 comments on commit a3de184

Please sign in to comment.