From 564d89781172657bc9cf393904013312c0779e1f Mon Sep 17 00:00:00 2001 From: Jeremy Oustrich Date: Thu, 13 Oct 2022 12:21:54 -0400 Subject: [PATCH] API version 2. See https://docs.patch.io/#/changelog for changes (#72) --- .github/workflows/test.yml | 2 +- Gemfile.lock | 2 +- lib/patch_ruby.rb | 15 +- lib/patch_ruby/api/estimates_api.rb | 74 +++- lib/patch_ruby/api/order_line_items_api.rb | 269 +++++++++++++ lib/patch_ruby/api/orders_api.rb | 103 ++++- lib/patch_ruby/api/projects_api.rb | 14 +- lib/patch_ruby/api/technology_types_api.rb | 9 +- lib/patch_ruby/api_client.rb | 6 +- lib/patch_ruby/api_error.rb | 4 +- lib/patch_ruby/configuration.rb | 4 +- .../create_air_shipping_estimate_request.rb | 4 +- .../models/create_bitcoin_estimate_request.rb | 4 +- .../create_ecommerce_estimate_request.rb | 4 +- .../create_ethereum_estimate_request.rb | 4 +- .../models/create_flight_estimate_request.rb | 4 +- .../models/create_hotel_estimate_request.rb | 4 +- .../models/create_mass_estimate_request.rb | 4 +- .../models/create_order_line_item_request.rb | 375 ++++++++++++++++++ lib/patch_ruby/models/create_order_request.rb | 75 +--- .../create_rail_shipping_estimate_request.rb | 4 +- .../create_road_shipping_estimate_request.rb | 4 +- .../create_sea_shipping_estimate_request.rb | 4 +- .../create_shipping_estimate_request.rb | 4 +- .../models/create_success_response.rb | 4 +- .../models/create_vehicle_estimate_request.rb | 4 +- .../models/delete_order_line_item_response.rb | 257 ++++++++++++ .../models/delete_order_response.rb | 257 ++++++++++++ lib/patch_ruby/models/error_response.rb | 4 +- lib/patch_ruby/models/estimate.rb | 4 +- .../models/estimate_list_response.rb | 4 +- lib/patch_ruby/models/estimate_response.rb | 4 +- lib/patch_ruby/models/highlight.rb | 4 +- lib/patch_ruby/models/inventory.rb | 4 +- lib/patch_ruby/models/meta_index_object.rb | 4 +- lib/patch_ruby/models/order.rb | 126 +----- lib/patch_ruby/models/order_issued_to.rb | 4 +- ...{order_inventory.rb => order_line_item.rb} | 28 +- ..._project.rb => order_line_item_project.rb} | 14 +- ...ocation.rb => order_line_item_response.rb} | 73 ++-- lib/patch_ruby/models/order_list_response.rb | 4 +- lib/patch_ruby/models/order_response.rb | 4 +- .../models/parent_technology_type.rb | 4 +- lib/patch_ruby/models/photo.rb | 4 +- lib/patch_ruby/models/place_order_request.rb | 4 +- lib/patch_ruby/models/project.rb | 66 +-- .../models/project_list_response.rb | 4 +- lib/patch_ruby/models/project_response.rb | 4 +- lib/patch_ruby/models/sdg.rb | 4 +- lib/patch_ruby/models/standard.rb | 4 +- lib/patch_ruby/models/technology_type.rb | 4 +- .../models/technology_type_list_response.rb | 4 +- .../models/update_order_line_item_request.rb | 366 +++++++++++++++++ lib/patch_ruby/version.rb | 6 +- patch_ruby.gemspec | 4 +- spec/api/order_line_items_api_spec.rb | 78 ++++ spec/api_client_spec.rb | 4 +- spec/configuration_spec.rb | 4 +- spec/factories/allocations.rb | 7 - spec/factories/create_order_requests.rb | 6 +- spec/factories/orders.rb | 9 +- spec/factories/projects.rb | 5 +- spec/integration/orders_spec.rb | 129 ++++-- spec/integration/projects_spec.rb | 6 +- spec/models/allocation_spec.rb | 59 --- spec/models/create_order_request_spec.rb | 13 +- spec/models/order_spec.rb | 31 +- spec/models/project_spec.rb | 5 +- spec/spec_helper.rb | 4 +- 69 files changed, 2093 insertions(+), 544 deletions(-) create mode 100644 lib/patch_ruby/api/order_line_items_api.rb create mode 100644 lib/patch_ruby/models/create_order_line_item_request.rb create mode 100644 lib/patch_ruby/models/delete_order_line_item_response.rb create mode 100644 lib/patch_ruby/models/delete_order_response.rb rename lib/patch_ruby/models/{order_inventory.rb => order_line_item.rb} (92%) rename lib/patch_ruby/models/{order_inventory_project.rb => order_line_item_project.rb} (93%) rename lib/patch_ruby/models/{allocation.rb => order_line_item_response.rb} (78%) create mode 100644 lib/patch_ruby/models/update_order_line_item_request.rb create mode 100644 spec/api/order_line_items_api_spec.rb delete mode 100644 spec/factories/allocations.rb delete mode 100644 spec/models/allocation_spec.rb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c45bc73..1c50bda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: - ruby-version: [3.0.2, 2.7.4, 2.6.8] + ruby-version: [3.1.2, 3.0.2, 2.7.4] max-parallel: 1 steps: diff --git a/Gemfile.lock b/Gemfile.lock index 296fb4a..13e5439 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.24.2) + patch_ruby (2.0.0) typhoeus (~> 1.0, >= 1.0.1) GEM diff --git a/lib/patch_ruby.rb b/lib/patch_ruby.rb index 4832994..2e1bdfd 100644 --- a/lib/patch_ruby.rb +++ b/lib/patch_ruby.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -17,7 +17,6 @@ require 'patch_ruby/configuration' # Models -require 'patch_ruby/models/allocation' require 'patch_ruby/models/create_air_shipping_estimate_request' require 'patch_ruby/models/create_bitcoin_estimate_request' require 'patch_ruby/models/create_ecommerce_estimate_request' @@ -25,6 +24,7 @@ require 'patch_ruby/models/create_flight_estimate_request' require 'patch_ruby/models/create_hotel_estimate_request' require 'patch_ruby/models/create_mass_estimate_request' +require 'patch_ruby/models/create_order_line_item_request' require 'patch_ruby/models/create_order_request' require 'patch_ruby/models/create_rail_shipping_estimate_request' require 'patch_ruby/models/create_road_shipping_estimate_request' @@ -32,6 +32,8 @@ require 'patch_ruby/models/create_shipping_estimate_request' require 'patch_ruby/models/create_success_response' require 'patch_ruby/models/create_vehicle_estimate_request' +require 'patch_ruby/models/delete_order_line_item_response' +require 'patch_ruby/models/delete_order_response' require 'patch_ruby/models/error_response' require 'patch_ruby/models/estimate' require 'patch_ruby/models/estimate_list_response' @@ -40,9 +42,10 @@ require 'patch_ruby/models/inventory' 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_line_item' +require 'patch_ruby/models/order_line_item_project' +require 'patch_ruby/models/order_line_item_response' require 'patch_ruby/models/order_list_response' require 'patch_ruby/models/order_response' require 'patch_ruby/models/parent_technology_type' @@ -55,9 +58,11 @@ require 'patch_ruby/models/standard' require 'patch_ruby/models/technology_type' require 'patch_ruby/models/technology_type_list_response' +require 'patch_ruby/models/update_order_line_item_request' # APIs require 'patch_ruby/api/estimates_api' +require 'patch_ruby/api/order_line_items_api' require 'patch_ruby/api/orders_api' require 'patch_ruby/api/projects_api' require 'patch_ruby/api/technology_types_api' diff --git a/lib/patch_ruby/api/estimates_api.rb b/lib/patch_ruby/api/estimates_api.rb index 270e562..8e90be9 100644 --- a/lib/patch_ruby/api/estimates_api.rb +++ b/lib/patch_ruby/api/estimates_api.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -40,6 +40,7 @@ def initialize(api_client = ApiClient.default) # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts = {}) _create_air_shipping_estimate_request = Patch::CreateAirShippingEstimateRequest.new(create_air_shipping_estimate_request) @@ -51,6 +52,7 @@ def create_air_shipping_estimate(create_air_shipping_estimate_request = {}, opts # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_request, opts = {}) if @api_client.config.debugging @@ -68,6 +70,7 @@ def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_req # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -75,6 +78,8 @@ def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_req if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -109,6 +114,7 @@ def create_air_shipping_estimate_with_http_info(create_air_shipping_estimate_req # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_bitcoin_estimate(create_bitcoin_estimate_request = {}, opts = {}) _create_bitcoin_estimate_request = Patch::CreateBitcoinEstimateRequest.new(create_bitcoin_estimate_request) @@ -120,6 +126,7 @@ def create_bitcoin_estimate(create_bitcoin_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts = {}) if @api_client.config.debugging @@ -137,6 +144,7 @@ def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -144,6 +152,8 @@ def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -178,6 +188,7 @@ def create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, opts # Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # @param create_ecommerce_estimate_request [CreateEcommerceEstimateRequest] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_ecommerce_estimate(create_ecommerce_estimate_request = {}, opts = {}) _create_ecommerce_estimate_request = Patch::CreateEcommerceEstimateRequest.new(create_ecommerce_estimate_request) @@ -189,6 +200,7 @@ def create_ecommerce_estimate(create_ecommerce_estimate_request = {}, opts = {}) # Creates a e-commerce estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # @param create_ecommerce_estimate_request [CreateEcommerceEstimateRequest] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, opts = {}) if @api_client.config.debugging @@ -206,6 +218,7 @@ def create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -213,6 +226,8 @@ def create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -247,6 +262,7 @@ def create_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_ethereum_estimate(create_ethereum_estimate_request = {}, opts = {}) _create_ethereum_estimate_request = Patch::CreateEthereumEstimateRequest.new(create_ethereum_estimate_request) @@ -258,6 +274,7 @@ def create_ethereum_estimate(create_ethereum_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, opts = {}) if @api_client.config.debugging @@ -275,6 +292,7 @@ def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, op # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -282,6 +300,8 @@ def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, op if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -316,6 +336,7 @@ def create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, op # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_flight_estimate(create_flight_estimate_request = {}, opts = {}) _create_flight_estimate_request = Patch::CreateFlightEstimateRequest.new(create_flight_estimate_request) @@ -327,6 +348,7 @@ def create_flight_estimate(create_flight_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = {}) if @api_client.config.debugging @@ -344,6 +366,7 @@ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -351,6 +374,8 @@ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -385,6 +410,7 @@ def create_flight_estimate_with_http_info(create_flight_estimate_request, opts = # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {}) _create_hotel_estimate_request = Patch::CreateHotelEstimateRequest.new(create_hotel_estimate_request) @@ -396,6 +422,7 @@ def create_hotel_estimate(create_hotel_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = {}) if @api_client.config.debugging @@ -413,6 +440,7 @@ def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = { # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -420,6 +448,8 @@ def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = { if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -454,6 +484,7 @@ def create_hotel_estimate_with_http_info(create_hotel_estimate_request, opts = { # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_mass_estimate(create_mass_estimate_request = {}, opts = {}) _create_mass_estimate_request = Patch::CreateMassEstimateRequest.new(create_mass_estimate_request) @@ -465,6 +496,7 @@ def create_mass_estimate(create_mass_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) if @api_client.config.debugging @@ -482,6 +514,7 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -489,6 +522,8 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -523,6 +558,7 @@ def create_mass_estimate_with_http_info(create_mass_estimate_request, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, opts = {}) _create_rail_shipping_estimate_request = Patch::CreateRailShippingEstimateRequest.new(create_rail_shipping_estimate_request) @@ -534,6 +570,7 @@ def create_rail_shipping_estimate(create_rail_shipping_estimate_request = {}, op # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_request, opts = {}) if @api_client.config.debugging @@ -551,6 +588,7 @@ def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_r # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -558,6 +596,8 @@ def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_r if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -592,6 +632,7 @@ def create_rail_shipping_estimate_with_http_info(create_rail_shipping_estimate_r # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, opts = {}) _create_road_shipping_estimate_request = Patch::CreateRoadShippingEstimateRequest.new(create_road_shipping_estimate_request) @@ -603,6 +644,7 @@ def create_road_shipping_estimate(create_road_shipping_estimate_request = {}, op # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_request, opts = {}) if @api_client.config.debugging @@ -620,6 +662,7 @@ def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_r # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -627,6 +670,8 @@ def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_r if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -661,6 +706,7 @@ def create_road_shipping_estimate_with_http_info(create_road_shipping_estimate_r # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts = {}) _create_sea_shipping_estimate_request = Patch::CreateSeaShippingEstimateRequest.new(create_sea_shipping_estimate_request) @@ -672,6 +718,7 @@ def create_sea_shipping_estimate(create_sea_shipping_estimate_request = {}, opts # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_request, opts = {}) if @api_client.config.debugging @@ -689,6 +736,7 @@ def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_req # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -696,6 +744,8 @@ def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_req if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -730,6 +780,7 @@ def create_sea_shipping_estimate_with_http_info(create_sea_shipping_estimate_req # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_shipping_estimate(create_shipping_estimate_request = {}, opts = {}) _create_shipping_estimate_request = Patch::CreateShippingEstimateRequest.new(create_shipping_estimate_request) @@ -741,6 +792,7 @@ def create_shipping_estimate(create_shipping_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_shipping_estimate_with_http_info(create_shipping_estimate_request, opts = {}) if @api_client.config.debugging @@ -758,6 +810,7 @@ def create_shipping_estimate_with_http_info(create_shipping_estimate_request, op # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -765,6 +818,8 @@ def create_shipping_estimate_with_http_info(create_shipping_estimate_request, op if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -799,6 +854,7 @@ def create_shipping_estimate_with_http_info(create_shipping_estimate_request, op # 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 + # @option opts [Integer] :patch_version # @return [EstimateResponse] def create_vehicle_estimate(create_vehicle_estimate_request = {}, opts = {}) _create_vehicle_estimate_request = Patch::CreateVehicleEstimateRequest.new(create_vehicle_estimate_request) @@ -810,6 +866,7 @@ def create_vehicle_estimate(create_vehicle_estimate_request = {}, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts = {}) if @api_client.config.debugging @@ -827,6 +884,7 @@ def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -834,6 +892,8 @@ def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -868,6 +928,7 @@ def create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, opts # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # @param id [String] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [EstimateResponse] def retrieve_estimate(id, opts = {}) @@ -879,6 +940,7 @@ def retrieve_estimate(id, opts = {}) # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # @param id [String] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [Array<(EstimateResponse, Integer, Hash)>] EstimateResponse data, response status code and response headers def retrieve_estimate_with_http_info(id, opts = {}) if @api_client.config.debugging @@ -896,8 +958,11 @@ def retrieve_estimate_with_http_info(id, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -932,6 +997,7 @@ def retrieve_estimate_with_http_info(id, opts = {}) # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [Integer] :patch_version # @return [EstimateListResponse] def retrieve_estimates(opts = {}) @@ -943,6 +1009,7 @@ def retrieve_estimates(opts = {}) # Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [Integer] :patch_version # @return [Array<(EstimateListResponse, Integer, Hash)>] EstimateListResponse data, response status code and response headers def retrieve_estimates_with_http_info(opts = {}) if @api_client.config.debugging @@ -957,8 +1024,11 @@ def retrieve_estimates_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} diff --git a/lib/patch_ruby/api/order_line_items_api.rb b/lib/patch_ruby/api/order_line_items_api.rb new file mode 100644 index 0000000..1bba60b --- /dev/null +++ b/lib/patch_ruby/api/order_line_items_api.rb @@ -0,0 +1,269 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'cgi' + +module Patch + class OrderLineItemsApi + OPERATIONS = [ + :create_order_line_item, + :delete_order_line_item, + :update_order_line_item, + ] + + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Creates an order line item + # Creates a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param create_order_line_item_request [CreateOrderLineItemRequest] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [OrderLineItemResponse] + def create_order_line_item(order_id, create_order_line_item_request = {}, opts = {}) + _create_order_line_item_request = Patch::CreateOrderLineItemRequest.new(create_order_line_item_request) + data, _status_code, _headers = create_order_line_item_with_http_info(order_id, _create_order_line_item_request, opts) + data + end + + # Creates an order line item + # Creates a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param create_order_line_item_request [CreateOrderLineItemRequest] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [Array<(OrderLineItemResponse, Integer, Hash)>] OrderLineItemResponse data, response status code and response headers + def create_order_line_item_with_http_info(order_id, create_order_line_item_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.create_order_line_item ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.create_order_line_item" + end + # verify the required parameter 'create_order_line_item_request' is set + if @api_client.config.client_side_validation && create_order_line_item_request.nil? + fail ArgumentError, "Missing the required parameter 'create_order_line_item_request' when calling OrderLineItemsApi.create_order_line_item" + end + # resource path + local_var_path = '/v1/orders/{order_id}/line_items'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_order_line_item_request) + + # return_type + return_type = opts[:debug_return_type] || 'OrderLineItemResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer_auth'] + + new_options = opts.merge( + :operation => :"OrderLineItemsApi.create_order_line_item", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrderLineItemsApi#create_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Deletes an order line item + # Deletes a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param serial_number [String] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [DeleteOrderLineItemResponse] + def delete_order_line_item(order_id, serial_number, opts = {}) + + data, _status_code, _headers = delete_order_line_item_with_http_info(order_id, serial_number, opts) + data + end + + # Deletes an order line item + # Deletes a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param serial_number [String] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [Array<(DeleteOrderLineItemResponse, Integer, Hash)>] DeleteOrderLineItemResponse data, response status code and response headers + def delete_order_line_item_with_http_info(order_id, serial_number, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.delete_order_line_item ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.delete_order_line_item" + end + # verify the required parameter 'serial_number' is set + if @api_client.config.client_side_validation && serial_number.nil? + fail ArgumentError, "Missing the required parameter 'serial_number' when calling OrderLineItemsApi.delete_order_line_item" + end + # resource path + local_var_path = '/v1/orders/{order_id}/line_items/{serial_number}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)).sub('{' + 'serial_number' + '}', CGI.escape(serial_number.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DeleteOrderLineItemResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer_auth'] + + new_options = opts.merge( + :operation => :"OrderLineItemsApi.delete_order_line_item", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrderLineItemsApi#delete_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Updates an order line item + # Updates a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param serial_number [String] + # @param update_order_line_item_request [UpdateOrderLineItemRequest] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [OrderLineItemResponse] + def update_order_line_item(order_id, serial_number, update_order_line_item_request = {}, opts = {}) + _update_order_line_item_request = Patch::UpdateOrderLineItemRequest.new(update_order_line_item_request) + data, _status_code, _headers = update_order_line_item_with_http_info(order_id, serial_number, _update_order_line_item_request, opts) + data + end + + # Updates an order line item + # Updates a line item on an order that is in the `draft` state. + # @param order_id [String] + # @param serial_number [String] + # @param update_order_line_item_request [UpdateOrderLineItemRequest] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [Array<(OrderLineItemResponse, Integer, Hash)>] OrderLineItemResponse data, response status code and response headers + def update_order_line_item_with_http_info(order_id, serial_number, update_order_line_item_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrderLineItemsApi.update_order_line_item ...' + end + # verify the required parameter 'order_id' is set + if @api_client.config.client_side_validation && order_id.nil? + fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderLineItemsApi.update_order_line_item" + end + # verify the required parameter 'serial_number' is set + if @api_client.config.client_side_validation && serial_number.nil? + fail ArgumentError, "Missing the required parameter 'serial_number' when calling OrderLineItemsApi.update_order_line_item" + end + # verify the required parameter 'update_order_line_item_request' is set + if @api_client.config.client_side_validation && update_order_line_item_request.nil? + fail ArgumentError, "Missing the required parameter 'update_order_line_item_request' when calling OrderLineItemsApi.update_order_line_item" + end + # resource path + local_var_path = '/v1/orders/{order_id}/line_items/{serial_number}'.sub('{' + 'order_id' + '}', CGI.escape(order_id.to_s)).sub('{' + 'serial_number' + '}', CGI.escape(serial_number.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_order_line_item_request) + + # return_type + return_type = opts[:debug_return_type] || 'OrderLineItemResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer_auth'] + + new_options = opts.merge( + :operation => :"OrderLineItemsApi.update_order_line_item", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrderLineItemsApi#update_order_line_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index 233f033..6d0a64a 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -17,6 +17,7 @@ class OrdersApi OPERATIONS = [ :cancel_order, :create_order, + :delete_order, :place_order, :retrieve_order, :retrieve_orders, @@ -31,6 +32,7 @@ def initialize(api_client = ApiClient.default) # 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 + # @option opts [Integer] :patch_version # @return [OrderResponse] def cancel_order(id, opts = {}) @@ -42,6 +44,7 @@ def cancel_order(id, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def cancel_order_with_http_info(id, opts = {}) if @api_client.config.debugging @@ -59,8 +62,11 @@ def cancel_order_with_http_info(id, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -92,9 +98,10 @@ def cancel_order_with_http_info(id, opts = {}) end # Creates an order - # Creates an order in the `placed` or `draft` state. + # Creates an order in the `placed` or `draft`, or `reserved` state. # @param create_order_request [CreateOrderRequest] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [OrderResponse] def create_order(create_order_request = {}, opts = {}) _create_order_request = Patch::CreateOrderRequest.new(create_order_request) @@ -103,9 +110,10 @@ def create_order(create_order_request = {}, opts = {}) end # Creates an order - # Creates an order in the `placed` or `draft` state. + # Creates an order in the `placed` or `draft`, or `reserved` state. # @param create_order_request [CreateOrderRequest] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def create_order_with_http_info(create_order_request, opts = {}) if @api_client.config.debugging @@ -123,6 +131,7 @@ def create_order_with_http_info(create_order_request, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -130,6 +139,8 @@ def create_order_with_http_info(create_order_request, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -160,10 +171,80 @@ def create_order_with_http_info(create_order_request, opts = {}) return data, status_code, headers end + # Deletes a draft order + # Deletes an order that is in the `draft` state. + # @param uid [String] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [DeleteOrderResponse] + def delete_order(uid, opts = {}) + + data, _status_code, _headers = delete_order_with_http_info(uid, opts) + data + end + + # Deletes a draft order + # Deletes an order that is in the `draft` state. + # @param uid [String] + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [Array<(DeleteOrderResponse, Integer, Hash)>] DeleteOrderResponse data, response status code and response headers + def delete_order_with_http_info(uid, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: OrdersApi.delete_order ...' + end + # verify the required parameter 'uid' is set + if @api_client.config.client_side_validation && uid.nil? + fail ArgumentError, "Missing the required parameter 'uid' when calling OrdersApi.delete_order" + end + # resource path + local_var_path = '/v1/orders/{uid}'.sub('{' + 'uid' + '}', CGI.escape(uid.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'DeleteOrderResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['bearer_auth'] + + new_options = opts.merge( + :operation => :"OrdersApi.delete_order", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: OrdersApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + 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] # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @option opts [PlaceOrderRequest] :place_order_request # @return [OrderResponse] def place_order(id, opts = {}) @@ -176,6 +257,7 @@ def place_order(id, opts = {}) # 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 [Integer] :patch_version # @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 = {}) @@ -194,6 +276,7 @@ def place_order_with_http_info(id, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' @@ -201,6 +284,8 @@ def place_order_with_http_info(id, opts = {}) if !content_type.nil? header_params['Content-Type'] = content_type end + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -235,6 +320,7 @@ def place_order_with_http_info(id, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [OrderResponse] def retrieve_order(id, opts = {}) @@ -246,6 +332,7 @@ def retrieve_order(id, opts = {}) # 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 + # @option opts [Integer] :patch_version # @return [Array<(OrderResponse, Integer, Hash)>] OrderResponse data, response status code and response headers def retrieve_order_with_http_info(id, opts = {}) if @api_client.config.debugging @@ -263,8 +350,11 @@ def retrieve_order_with_http_info(id, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -302,6 +392,7 @@ def retrieve_order_with_http_info(id, opts = {}) # @option opts [String] :metadata # @option opts [String] :metadata_example1 # @option opts [String] :metadata_example2 + # @option opts [Integer] :patch_version # @return [OrderListResponse] def retrieve_orders(opts = {}) @@ -316,6 +407,7 @@ def retrieve_orders(opts = {}) # @option opts [String] :metadata # @option opts [String] :metadata_example1 # @option opts [String] :metadata_example2 + # @option opts [Integer] :patch_version # @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 @@ -333,8 +425,11 @@ def retrieve_orders_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} diff --git a/lib/patch_ruby/api/projects_api.rb b/lib/patch_ruby/api/projects_api.rb index 982a13b..b433bfe 100644 --- a/lib/patch_ruby/api/projects_api.rb +++ b/lib/patch_ruby/api/projects_api.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -29,6 +29,7 @@ def initialize(api_client = ApiClient.default) # @param id [String] # @param [Hash] opts the optional parameters # @option opts [String] :accept_language + # @option opts [Integer] :patch_version # @return [ProjectResponse] def retrieve_project(id, opts = {}) @@ -41,6 +42,7 @@ def retrieve_project(id, opts = {}) # @param id [String] # @param [Hash] opts the optional parameters # @option opts [String] :accept_language + # @option opts [Integer] :patch_version # @return [Array<(ProjectResponse, Integer, Hash)>] ProjectResponse data, response status code and response headers def retrieve_project_with_http_info(id, opts = {}) if @api_client.config.debugging @@ -58,9 +60,12 @@ def retrieve_project_with_http_info(id, opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil? + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} @@ -99,6 +104,7 @@ def retrieve_project_with_http_info(id, opts = {}) # @option opts [String] :type # @option opts [Integer] :minimum_available_mass # @option opts [String] :accept_language + # @option opts [Integer] :patch_version # @return [ProjectListResponse] def retrieve_projects(opts = {}) @@ -114,6 +120,7 @@ def retrieve_projects(opts = {}) # @option opts [String] :type # @option opts [Integer] :minimum_available_mass # @option opts [String] :accept_language + # @option opts [Integer] :patch_version # @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers def retrieve_projects_with_http_info(opts = {}) if @api_client.config.debugging @@ -131,9 +138,12 @@ def retrieve_projects_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil? + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} diff --git a/lib/patch_ruby/api/technology_types_api.rb b/lib/patch_ruby/api/technology_types_api.rb index b353a47..d343ae7 100644 --- a/lib/patch_ruby/api/technology_types_api.rb +++ b/lib/patch_ruby/api/technology_types_api.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -26,6 +26,7 @@ def initialize(api_client = ApiClient.default) # Retrieves the list of technology_types # Retrieves a list of all technology_types. # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [TechnologyTypeListResponse] def retrieve_technology_types(opts = {}) @@ -36,6 +37,7 @@ def retrieve_technology_types(opts = {}) # Retrieves the list of technology_types # Retrieves a list of all technology_types. # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version # @return [Array<(TechnologyTypeListResponse, Integer, Hash)>] TechnologyTypeListResponse data, response status code and response headers def retrieve_technology_types_with_http_info(opts = {}) if @api_client.config.debugging @@ -49,8 +51,11 @@ def retrieve_technology_types_with_http_info(opts = {}) # header parameters header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params['Patch-Version'] = 2 + header_params[:'Patch-Version'] = opts[:'patch_version'] if !opts[:'patch_version'].nil? # form parameters form_params = opts[:form_params] || {} diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 3efcd7a..f9eb816 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -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.2" + @user_agent = "patch-ruby/2.0.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/patch_ruby/api_error.rb b/lib/patch_ruby/api_error.rb index 7c61d3f..d144575 100644 --- a/lib/patch_ruby/api_error.rb +++ b/lib/patch_ruby/api_error.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/configuration.rb b/lib/patch_ruby/configuration.rb index 2b7f018..c962e8c 100644 --- a/lib/patch_ruby/configuration.rb +++ b/lib/patch_ruby/configuration.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_air_shipping_estimate_request.rb b/lib/patch_ruby/models/create_air_shipping_estimate_request.rb index 565b354..a7008c9 100644 --- a/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +++ b/lib/patch_ruby/models/create_air_shipping_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_bitcoin_estimate_request.rb b/lib/patch_ruby/models/create_bitcoin_estimate_request.rb index e37be44..9feaeed 100644 --- a/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +++ b/lib/patch_ruby/models/create_bitcoin_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_ecommerce_estimate_request.rb b/lib/patch_ruby/models/create_ecommerce_estimate_request.rb index 194f7a1..f2e9c24 100644 --- a/lib/patch_ruby/models/create_ecommerce_estimate_request.rb +++ b/lib/patch_ruby/models/create_ecommerce_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_ethereum_estimate_request.rb b/lib/patch_ruby/models/create_ethereum_estimate_request.rb index 23d6c15..f2a3043 100644 --- a/lib/patch_ruby/models/create_ethereum_estimate_request.rb +++ b/lib/patch_ruby/models/create_ethereum_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_flight_estimate_request.rb b/lib/patch_ruby/models/create_flight_estimate_request.rb index f32d811..bb98c78 100644 --- a/lib/patch_ruby/models/create_flight_estimate_request.rb +++ b/lib/patch_ruby/models/create_flight_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_hotel_estimate_request.rb b/lib/patch_ruby/models/create_hotel_estimate_request.rb index efb377b..f3a55af 100644 --- a/lib/patch_ruby/models/create_hotel_estimate_request.rb +++ b/lib/patch_ruby/models/create_hotel_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_mass_estimate_request.rb b/lib/patch_ruby/models/create_mass_estimate_request.rb index b7649a9..742b328 100644 --- a/lib/patch_ruby/models/create_mass_estimate_request.rb +++ b/lib/patch_ruby/models/create_mass_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_order_line_item_request.rb b/lib/patch_ruby/models/create_order_line_item_request.rb new file mode 100644 index 0000000..eb8c7b5 --- /dev/null +++ b/lib/patch_ruby/models/create_order_line_item_request.rb @@ -0,0 +1,375 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'date' +require 'time' + +module Patch + class CreateOrderLineItemRequest + attr_accessor :project_id + + attr_accessor :vintage_year + + attr_accessor :price + + attr_accessor :currency + + attr_accessor :amount + + attr_accessor :unit + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'project_id' => :'project_id', + :'vintage_year' => :'vintage_year', + :'price' => :'price', + :'currency' => :'currency', + :'amount' => :'amount', + :'unit' => :'unit' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'project_id' => :'String', + :'vintage_year' => :'Integer', + :'price' => :'Integer', + :'currency' => :'String', + :'amount' => :'Integer', + :'unit' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'vintage_year', + :'price', + :'currency', + :'amount', + :'unit' + ]) + end + + + # Allows models with corresponding API classes to delegate API operations to those API classes + # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id + # Eg. Order.create_order delegates to OrdersApi.new.create_order + def self.method_missing(message, *args, &block) + if Object.const_defined?('Patch::CreateOrderLineItemRequestsApi::OPERATIONS') && Patch::CreateOrderLineItemRequestsApi::OPERATIONS.include?(message) + Patch::CreateOrderLineItemRequestsApi.new.send(message, *args) + else + super + end + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateOrderLineItemRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateOrderLineItemRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'project_id') + self.project_id = attributes[:'project_id'] + end + + if attributes.key?(:'vintage_year') + self.vintage_year = attributes[:'vintage_year'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'unit') + self.unit = attributes[:'unit'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if !@vintage_year.nil? && @vintage_year > 2100 + invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.') + end + + if !@vintage_year.nil? && @vintage_year < 1900 + invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.') + end + + if !@price.nil? && @price < 2 + invalid_properties.push('invalid value for "price", must be greater than or equal to 2.') + end + + if !@amount.nil? && @amount > 100000000000 + invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000.') + end + + if !@amount.nil? && @amount < 0 + invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if !@vintage_year.nil? && @vintage_year > 2100 + return false if !@vintage_year.nil? && @vintage_year < 1900 + return false if !@price.nil? && @price < 2 + return false if !@amount.nil? && @amount > 100000000000 + return false if !@amount.nil? && @amount < 0 + unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"]) + return false unless unit_validator.valid?(@unit) + true + end + + # Custom attribute writer method with validation + # @param [Object] vintage_year Value to be assigned + def vintage_year=(vintage_year) + if !vintage_year.nil? && vintage_year > 2100 + fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.' + end + + if !vintage_year.nil? && vintage_year < 1900 + fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.' + end + + @vintage_year = vintage_year + end + + # Custom attribute writer method with validation + # @param [Object] price Value to be assigned + def price=(price) + if !price.nil? && price < 2 + fail ArgumentError, 'invalid value for "price", must be greater than or equal to 2.' + end + + @price = price + end + + # Custom attribute writer method with validation + # @param [Object] amount Value to be assigned + def amount=(amount) + if !amount.nil? && amount > 100000000000 + fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000.' + end + + if !amount.nil? && amount < 0 + fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.' + end + + @amount = amount + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] unit Object to be assigned + def unit=(unit) + validator = EnumAttributeValidator.new('String', ["g", "Wh"]) + unless validator.valid?(unit) + fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}." + end + @unit = unit + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + project_id == o.project_id && + vintage_year == o.vintage_year && + price == o.price && + currency == o.currency && + amount == o.amount && + unit == o.unit + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [project_id, vintage_year, price, currency, amount, unit].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/patch_ruby/models/create_order_request.rb b/lib/patch_ruby/models/create_order_request.rb index aefc04d..f679fce 100644 --- a/lib/patch_ruby/models/create_order_request.rb +++ b/lib/patch_ruby/models/create_order_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -15,10 +15,6 @@ module Patch class CreateOrderRequest - attr_accessor :mass_g - - attr_accessor :total_price_cents_usd - attr_accessor :project_id attr_accessor :metadata @@ -62,8 +58,6 @@ def valid?(value) # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'mass_g' => :'mass_g', - :'total_price_cents_usd' => :'total_price_cents_usd', :'project_id' => :'project_id', :'metadata' => :'metadata', :'state' => :'state', @@ -84,8 +78,6 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'mass_g' => :'Integer', - :'total_price_cents_usd' => :'Integer', :'project_id' => :'String', :'metadata' => :'Object', :'state' => :'String', @@ -101,8 +93,6 @@ def self.openapi_types # List of attributes with nullable: true def self.openapi_nullable Set.new([ - :'mass_g', - :'total_price_cents_usd', :'project_id', :'metadata', :'state', @@ -141,14 +131,6 @@ def initialize(attributes = {}) h[k.to_sym] = v } - if attributes.key?(:'mass_g') - self.mass_g = attributes[:'mass_g'] - end - - if attributes.key?(:'total_price_cents_usd') - self.total_price_cents_usd = attributes[:'total_price_cents_usd'] - end - if attributes.key?(:'project_id') self.project_id = attributes[:'project_id'] end @@ -190,18 +172,6 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new - if !@mass_g.nil? && @mass_g > 100000000000 - invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 100000000000.') - end - - if !@mass_g.nil? && @mass_g < 0 - invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.') - end - - if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1 - invalid_properties.push('invalid value for "total_price_cents_usd", must be greater than or equal to 1.') - end - if !@vintage_year.nil? && @vintage_year > 2100 invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.') end @@ -210,8 +180,8 @@ def list_invalid_properties invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.') end - if !@total_price.nil? && @total_price < 1 - invalid_properties.push('invalid value for "total_price", must be greater than or equal to 1.') + if !@total_price.nil? && @total_price < 2 + invalid_properties.push('invalid value for "total_price", must be greater than or equal to 2.') end if !@amount.nil? && @amount > 100000000000 @@ -228,14 +198,11 @@ def list_invalid_properties # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - return false if !@mass_g.nil? && @mass_g > 100000000000 - return false if !@mass_g.nil? && @mass_g < 0 - return false if !@total_price_cents_usd.nil? && @total_price_cents_usd < 1 state_validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed"]) return false unless state_validator.valid?(@state) return false if !@vintage_year.nil? && @vintage_year > 2100 return false if !@vintage_year.nil? && @vintage_year < 1900 - return false if !@total_price.nil? && @total_price < 1 + return false if !@total_price.nil? && @total_price < 2 return false if !@amount.nil? && @amount > 100000000000 return false if !@amount.nil? && @amount < 0 unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"]) @@ -243,30 +210,6 @@ def valid? true end - # Custom attribute writer method with validation - # @param [Object] mass_g Value to be assigned - def mass_g=(mass_g) - if !mass_g.nil? && mass_g > 100000000000 - fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 100000000000.' - end - - if !mass_g.nil? && mass_g < 0 - fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.' - end - - @mass_g = mass_g - end - - # Custom attribute writer method with validation - # @param [Object] total_price_cents_usd Value to be assigned - def total_price_cents_usd=(total_price_cents_usd) - if !total_price_cents_usd.nil? && total_price_cents_usd < 1 - fail ArgumentError, 'invalid value for "total_price_cents_usd", must be greater than or equal to 1.' - end - - @total_price_cents_usd = total_price_cents_usd - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] state Object to be assigned def state=(state) @@ -294,8 +237,8 @@ def vintage_year=(vintage_year) # Custom attribute writer method with validation # @param [Object] total_price Value to be assigned def total_price=(total_price) - if !total_price.nil? && total_price < 1 - fail ArgumentError, 'invalid value for "total_price", must be greater than or equal to 1.' + if !total_price.nil? && total_price < 2 + fail ArgumentError, 'invalid value for "total_price", must be greater than or equal to 2.' end @total_price = total_price @@ -330,8 +273,6 @@ def unit=(unit) def ==(o) return true if self.equal?(o) self.class == o.class && - mass_g == o.mass_g && - total_price_cents_usd == o.total_price_cents_usd && project_id == o.project_id && metadata == o.metadata && state == o.state && @@ -352,7 +293,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [mass_g, total_price_cents_usd, project_id, metadata, state, vintage_year, total_price, currency, amount, unit, issued_to].hash + [project_id, metadata, state, vintage_year, total_price, currency, amount, unit, issued_to].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb b/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb index a8b78e9..03a3615 100644 --- a/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +++ b/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_road_shipping_estimate_request.rb b/lib/patch_ruby/models/create_road_shipping_estimate_request.rb index 44fbac2..19e61e4 100644 --- a/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +++ b/lib/patch_ruby/models/create_road_shipping_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb b/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb index 3d78579..e8a72c2 100644 --- a/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +++ b/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_shipping_estimate_request.rb b/lib/patch_ruby/models/create_shipping_estimate_request.rb index 474e5dc..c9b91af 100644 --- a/lib/patch_ruby/models/create_shipping_estimate_request.rb +++ b/lib/patch_ruby/models/create_shipping_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_success_response.rb b/lib/patch_ruby/models/create_success_response.rb index 8dbc821..8584fa1 100644 --- a/lib/patch_ruby/models/create_success_response.rb +++ b/lib/patch_ruby/models/create_success_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/create_vehicle_estimate_request.rb b/lib/patch_ruby/models/create_vehicle_estimate_request.rb index a82d452..102096f 100644 --- a/lib/patch_ruby/models/create_vehicle_estimate_request.rb +++ b/lib/patch_ruby/models/create_vehicle_estimate_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/delete_order_line_item_response.rb b/lib/patch_ruby/models/delete_order_line_item_response.rb new file mode 100644 index 0000000..0168ae2 --- /dev/null +++ b/lib/patch_ruby/models/delete_order_line_item_response.rb @@ -0,0 +1,257 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'date' +require 'time' + +module Patch + class DeleteOrderLineItemResponse + attr_accessor :success + + attr_accessor :error + + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'success' => :'success', + :'error' => :'error', + :'data' => :'data' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'success' => :'Boolean', + :'error' => :'Object', + :'data' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'error', + ]) + end + + + # Allows models with corresponding API classes to delegate API operations to those API classes + # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id + # Eg. Order.create_order delegates to OrdersApi.new.create_order + def self.method_missing(message, *args, &block) + if Object.const_defined?('Patch::DeleteOrderLineItemResponsesApi::OPERATIONS') && Patch::DeleteOrderLineItemResponsesApi::OPERATIONS.include?(message) + Patch::DeleteOrderLineItemResponsesApi.new.send(message, *args) + else + super + end + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::DeleteOrderLineItemResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::DeleteOrderLineItemResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'success') + self.success = attributes[:'success'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @success.nil? + invalid_properties.push('invalid value for "success", success cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @success.nil? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + success == o.success && + error == o.error && + data == o.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [success, error, data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/patch_ruby/models/delete_order_response.rb b/lib/patch_ruby/models/delete_order_response.rb new file mode 100644 index 0000000..32c7603 --- /dev/null +++ b/lib/patch_ruby/models/delete_order_response.rb @@ -0,0 +1,257 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'date' +require 'time' + +module Patch + class DeleteOrderResponse + attr_accessor :success + + attr_accessor :error + + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'success' => :'success', + :'error' => :'error', + :'data' => :'data' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'success' => :'Boolean', + :'error' => :'Object', + :'data' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'error', + ]) + end + + + # Allows models with corresponding API classes to delegate API operations to those API classes + # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id + # Eg. Order.create_order delegates to OrdersApi.new.create_order + def self.method_missing(message, *args, &block) + if Object.const_defined?('Patch::DeleteOrderResponsesApi::OPERATIONS') && Patch::DeleteOrderResponsesApi::OPERATIONS.include?(message) + Patch::DeleteOrderResponsesApi.new.send(message, *args) + else + super + end + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::DeleteOrderResponse` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::DeleteOrderResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'success') + self.success = attributes[:'success'] + end + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @success.nil? + invalid_properties.push('invalid value for "success", success cannot be nil.') + end + + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @success.nil? + return false if @data.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + success == o.success && + error == o.error && + data == o.data + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [success, error, data].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/patch_ruby/models/error_response.rb b/lib/patch_ruby/models/error_response.rb index bb3cc29..3d8c49c 100644 --- a/lib/patch_ruby/models/error_response.rb +++ b/lib/patch_ruby/models/error_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/estimate.rb b/lib/patch_ruby/models/estimate.rb index ead8a01..5597f5e 100644 --- a/lib/patch_ruby/models/estimate.rb +++ b/lib/patch_ruby/models/estimate.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/estimate_list_response.rb b/lib/patch_ruby/models/estimate_list_response.rb index b1081ac..1c361e2 100644 --- a/lib/patch_ruby/models/estimate_list_response.rb +++ b/lib/patch_ruby/models/estimate_list_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/estimate_response.rb b/lib/patch_ruby/models/estimate_response.rb index 29a2deb..a1c5648 100644 --- a/lib/patch_ruby/models/estimate_response.rb +++ b/lib/patch_ruby/models/estimate_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/highlight.rb b/lib/patch_ruby/models/highlight.rb index 475fdfb..4d40244 100644 --- a/lib/patch_ruby/models/highlight.rb +++ b/lib/patch_ruby/models/highlight.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/inventory.rb b/lib/patch_ruby/models/inventory.rb index 1f19455..d308d7c 100644 --- a/lib/patch_ruby/models/inventory.rb +++ b/lib/patch_ruby/models/inventory.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/meta_index_object.rb b/lib/patch_ruby/models/meta_index_object.rb index 5455750..d13a882 100644 --- a/lib/patch_ruby/models/meta_index_object.rb +++ b/lib/patch_ruby/models/meta_index_object.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/order.rb b/lib/patch_ruby/models/order.rb index addab63..c46068b 100644 --- a/lib/patch_ruby/models/order.rb +++ b/lib/patch_ruby/models/order.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -21,9 +21,6 @@ class Order # The timestamp at which the order was created attr_accessor :created_at - # DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order. - attr_accessor :mass_g - # A boolean indicating if this order is a production or demo mode order. attr_accessor :production @@ -45,26 +42,14 @@ class Order # The currency code for the `price` and `patch_fee`. attr_accessor :currency - # DEPRECATED. Indicates if the order has been fully allocated to projects. - attr_accessor :allocation_state - - # DEPRECATED, use the `price` and `currency` fields instead. The total price in cents USD of the carbon offsets purchased through this order. - attr_accessor :price_cents_usd - - # DEPRECATED, use the `patch_fee` and `currency` fields instead. The Patch Fee in cents USD for this order. - attr_accessor :patch_fee_cents_usd - - # DEPRECATED. An array containing the inventory allocations for this order. - attr_accessor :allocations - # The url of this order in the public registry. attr_accessor :registry_url # An optional JSON object containing metadata for this order. attr_accessor :metadata - # An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price. - attr_accessor :inventory + # An array containing the line items allocated for this order. Line items are grouped by project, vintage year, and price. + attr_accessor :line_items # An object containing the name & email of the party the inventory will be issued to. attr_accessor :issued_to @@ -96,7 +81,6 @@ def self.attribute_map { :'id' => :'id', :'created_at' => :'created_at', - :'mass_g' => :'mass_g', :'production' => :'production', :'state' => :'state', :'amount' => :'amount', @@ -104,13 +88,9 @@ def self.attribute_map :'price' => :'price', :'patch_fee' => :'patch_fee', :'currency' => :'currency', - :'allocation_state' => :'allocation_state', - :'price_cents_usd' => :'price_cents_usd', - :'patch_fee_cents_usd' => :'patch_fee_cents_usd', - :'allocations' => :'allocations', :'registry_url' => :'registry_url', :'metadata' => :'metadata', - :'inventory' => :'inventory', + :'line_items' => :'line_items', :'issued_to' => :'issued_to' } end @@ -125,7 +105,6 @@ def self.openapi_types { :'id' => :'String', :'created_at' => :'Time', - :'mass_g' => :'Integer', :'production' => :'Boolean', :'state' => :'String', :'amount' => :'Integer', @@ -133,13 +112,9 @@ def self.openapi_types :'price' => :'Integer', :'patch_fee' => :'Integer', :'currency' => :'String', - :'allocation_state' => :'String', - :'price_cents_usd' => :'Integer', - :'patch_fee_cents_usd' => :'Integer', - :'allocations' => :'Array', :'registry_url' => :'String', :'metadata' => :'Object', - :'inventory' => :'Array', + :'line_items' => :'Array', :'issued_to' => :'OrderIssuedTo' } end @@ -147,8 +122,6 @@ def self.openapi_types # List of attributes with nullable: true def self.openapi_nullable Set.new([ - :'price_cents_usd', - :'patch_fee_cents_usd', ]) end @@ -187,10 +160,6 @@ def initialize(attributes = {}) self.created_at = attributes[:'created_at'] end - if attributes.key?(:'mass_g') - self.mass_g = attributes[:'mass_g'] - end - if attributes.key?(:'production') self.production = attributes[:'production'] end @@ -219,24 +188,6 @@ def initialize(attributes = {}) self.currency = attributes[:'currency'] end - if attributes.key?(:'allocation_state') - self.allocation_state = attributes[:'allocation_state'] - end - - if attributes.key?(:'price_cents_usd') - self.price_cents_usd = attributes[:'price_cents_usd'] - end - - if attributes.key?(:'patch_fee_cents_usd') - self.patch_fee_cents_usd = attributes[:'patch_fee_cents_usd'] - end - - if attributes.key?(:'allocations') - if (value = attributes[:'allocations']).is_a?(Array) - self.allocations = value - end - end - if attributes.key?(:'registry_url') self.registry_url = attributes[:'registry_url'] end @@ -245,9 +196,9 @@ def initialize(attributes = {}) self.metadata = attributes[:'metadata'] end - if attributes.key?(:'inventory') - if (value = attributes[:'inventory']).is_a?(Array) - self.inventory = value + if attributes.key?(:'line_items') + if (value = attributes[:'line_items']).is_a?(Array) + self.line_items = value end end @@ -267,18 +218,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "id", id cannot be nil.') end - if @mass_g.nil? - invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.') - end - - if @mass_g > 100000000000 - invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 100000000000.') - end - - if @mass_g < 0 - invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.') - end - if @production.nil? invalid_properties.push('invalid value for "production", production cannot be nil.') end @@ -315,10 +254,6 @@ def list_invalid_properties invalid_properties.push('invalid value for "currency", currency cannot be nil.') end - if @allocation_state.nil? - invalid_properties.push('invalid value for "allocation_state", allocation_state cannot be nil.') - end - if @metadata.nil? invalid_properties.push('invalid value for "metadata", metadata cannot be nil.') end @@ -330,9 +265,6 @@ def list_invalid_properties # @return true if the model is valid def valid? return false if @id.nil? - return false if @mass_g.nil? - return false if @mass_g > 100000000000 - return false if @mass_g < 0 return false if @production.nil? return false if @state.nil? state_validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"]) @@ -344,31 +276,10 @@ def valid? return false if @price.nil? return false if @patch_fee.nil? return false if @currency.nil? - return false if @allocation_state.nil? - allocation_state_validator = EnumAttributeValidator.new('String', ["pending", "allocated"]) - return false unless allocation_state_validator.valid?(@allocation_state) return false if @metadata.nil? true end - # Custom attribute writer method with validation - # @param [Object] mass_g Value to be assigned - def mass_g=(mass_g) - if mass_g.nil? - fail ArgumentError, 'mass_g cannot be nil' - end - - if mass_g > 100000000000 - fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 100000000000.' - end - - if mass_g < 0 - fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.' - end - - @mass_g = mass_g - end - # Custom attribute writer method checking allowed values (enum). # @param [Object] state Object to be assigned def state=(state) @@ -397,16 +308,6 @@ def amount=(amount) @amount = amount end - # Custom attribute writer method checking allowed values (enum). - # @param [Object] allocation_state Object to be assigned - def allocation_state=(allocation_state) - validator = EnumAttributeValidator.new('String', ["pending", "allocated"]) - unless validator.valid?(allocation_state) - fail ArgumentError, "invalid value for \"allocation_state\", must be one of #{validator.allowable_values}." - end - @allocation_state = allocation_state - end - # Checks equality by comparing each attribute. # @param [Object] Object to be compared def ==(o) @@ -414,7 +315,6 @@ def ==(o) self.class == o.class && id == o.id && created_at == o.created_at && - mass_g == o.mass_g && production == o.production && state == o.state && amount == o.amount && @@ -422,13 +322,9 @@ def ==(o) price == o.price && patch_fee == o.patch_fee && currency == o.currency && - allocation_state == o.allocation_state && - price_cents_usd == o.price_cents_usd && - patch_fee_cents_usd == o.patch_fee_cents_usd && - allocations == o.allocations && registry_url == o.registry_url && metadata == o.metadata && - inventory == o.inventory && + line_items == o.line_items && issued_to == o.issued_to end @@ -441,7 +337,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory, issued_to].hash + [id, created_at, production, state, amount, unit, price, patch_fee, currency, registry_url, metadata, line_items, issued_to].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/order_issued_to.rb b/lib/patch_ruby/models/order_issued_to.rb index 8955de6..86e41e5 100644 --- a/lib/patch_ruby/models/order_issued_to.rb +++ b/lib/patch_ruby/models/order_issued_to.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/order_inventory.rb b/lib/patch_ruby/models/order_line_item.rb similarity index 92% rename from lib/patch_ruby/models/order_inventory.rb rename to lib/patch_ruby/models/order_line_item.rb index 6f4e9a6..9275b0b 100644 --- a/lib/patch_ruby/models/order_inventory.rb +++ b/lib/patch_ruby/models/order_line_item.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -14,7 +14,10 @@ require 'time' module Patch - class OrderInventory + class OrderLineItem + # The identifier for this order line item + attr_accessor :id + # An object containing information about the project associated with the inventory allocated. attr_accessor :project @@ -36,6 +39,7 @@ class OrderInventory # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { + :'id' => :'id', :'project' => :'project', :'vintage_year' => :'vintage_year', :'amount' => :'amount', @@ -53,7 +57,8 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'project' => :'OrderInventoryProject', + :'id' => :'String', + :'project' => :'OrderLineItemProject', :'vintage_year' => :'Integer', :'amount' => :'Integer', :'unit' => :'String', @@ -73,8 +78,8 @@ def self.openapi_nullable # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order def self.method_missing(message, *args, &block) - if Object.const_defined?('Patch::OrderInventorysApi::OPERATIONS') && Patch::OrderInventorysApi::OPERATIONS.include?(message) - Patch::OrderInventorysApi.new.send(message, *args) + if Object.const_defined?('Patch::OrderLineItemsApi::OPERATIONS') && Patch::OrderLineItemsApi::OPERATIONS.include?(message) + Patch::OrderLineItemsApi.new.send(message, *args) else super end @@ -84,17 +89,21 @@ def self.method_missing(message, *args, &block) # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderInventory` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderLineItem` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderInventory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderLineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + if attributes.key?(:'project') if (value = attributes[:'project']).is_a?(Hash) self.project = value @@ -171,6 +180,7 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && + id == o.id && project == o.project && vintage_year == o.vintage_year && amount == o.amount && @@ -188,7 +198,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [project, vintage_year, amount, unit, price, currency].hash + [id, project, vintage_year, amount, unit, price, currency].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/order_inventory_project.rb b/lib/patch_ruby/models/order_line_item_project.rb similarity index 93% rename from lib/patch_ruby/models/order_inventory_project.rb rename to lib/patch_ruby/models/order_line_item_project.rb index a8a42a3..72c3cfc 100644 --- a/lib/patch_ruby/models/order_inventory_project.rb +++ b/lib/patch_ruby/models/order_line_item_project.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -14,7 +14,7 @@ require 'time' module Patch - class OrderInventoryProject + class OrderLineItemProject # The unique uid for a project. UIDs will be prepended by pro_prod or pro_test depending on the mode it was created in. attr_accessor :id @@ -53,8 +53,8 @@ def self.openapi_nullable # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order def self.method_missing(message, *args, &block) - if Object.const_defined?('Patch::OrderInventoryProjectsApi::OPERATIONS') && Patch::OrderInventoryProjectsApi::OPERATIONS.include?(message) - Patch::OrderInventoryProjectsApi.new.send(message, *args) + if Object.const_defined?('Patch::OrderLineItemProjectsApi::OPERATIONS') && Patch::OrderLineItemProjectsApi::OPERATIONS.include?(message) + Patch::OrderLineItemProjectsApi.new.send(message, *args) else super end @@ -64,13 +64,13 @@ def self.method_missing(message, *args, &block) # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderInventoryProject` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderLineItemProject` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderInventoryProject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderLineItemProject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } diff --git a/lib/patch_ruby/models/allocation.rb b/lib/patch_ruby/models/order_line_item_response.rb similarity index 78% rename from lib/patch_ruby/models/allocation.rb rename to lib/patch_ruby/models/order_line_item_response.rb index 52cef07..ca2a46b 100644 --- a/lib/patch_ruby/models/allocation.rb +++ b/lib/patch_ruby/models/order_line_item_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -14,22 +14,19 @@ require 'time' module Patch - class Allocation - # A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in. - attr_accessor :id + class OrderLineItemResponse + attr_accessor :success - # A boolean indicating if this project is a production or demo mode project. - attr_accessor :production + attr_accessor :error - # The amount (in grams) of allocated carbon offsets. - attr_accessor :mass_g + attr_accessor :data # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { - :'id' => :'id', - :'production' => :'production', - :'mass_g' => :'mass_g' + :'success' => :'success', + :'error' => :'error', + :'data' => :'data' } end @@ -41,15 +38,16 @@ def self.acceptable_attributes # Attribute type mapping. def self.openapi_types { - :'id' => :'String', - :'production' => :'Boolean', - :'mass_g' => :'Integer' + :'success' => :'Boolean', + :'error' => :'Object', + :'data' => :'OrderLineItem' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ + :'error', ]) end @@ -58,8 +56,8 @@ def self.openapi_nullable # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id # Eg. Order.create_order delegates to OrdersApi.new.create_order def self.method_missing(message, *args, &block) - if Object.const_defined?('Patch::AllocationsApi::OPERATIONS') && Patch::AllocationsApi::OPERATIONS.include?(message) - Patch::AllocationsApi.new.send(message, *args) + if Object.const_defined?('Patch::OrderLineItemResponsesApi::OPERATIONS') && Patch::OrderLineItemResponsesApi::OPERATIONS.include?(message) + Patch::OrderLineItemResponsesApi.new.send(message, *args) else super end @@ -69,27 +67,27 @@ def self.method_missing(message, *args, &block) # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::Allocation` initialize method" + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::OrderLineItemResponse` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::Allocation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::OrderLineItemResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } - if attributes.key?(:'id') - self.id = attributes[:'id'] + if attributes.key?(:'success') + self.success = attributes[:'success'] end - if attributes.key?(:'production') - self.production = attributes[:'production'] + if attributes.key?(:'error') + self.error = attributes[:'error'] end - if attributes.key?(:'mass_g') - self.mass_g = attributes[:'mass_g'] + if attributes.key?(:'data') + self.data = attributes[:'data'] end end @@ -97,16 +95,12 @@ def initialize(attributes = {}) # @return Array for valid properties with the reasons def list_invalid_properties invalid_properties = Array.new - if @id.nil? - invalid_properties.push('invalid value for "id", id cannot be nil.') + if @success.nil? + invalid_properties.push('invalid value for "success", success cannot be nil.') end - if @production.nil? - invalid_properties.push('invalid value for "production", production cannot be nil.') - end - - if @mass_g.nil? - invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.') + if @data.nil? + invalid_properties.push('invalid value for "data", data cannot be nil.') end invalid_properties @@ -115,9 +109,8 @@ def list_invalid_properties # Check to see if the all the properties in the model are valid # @return true if the model is valid def valid? - return false if @id.nil? - return false if @production.nil? - return false if @mass_g.nil? + return false if @success.nil? + return false if @data.nil? true end @@ -126,9 +119,9 @@ def valid? def ==(o) return true if self.equal?(o) self.class == o.class && - id == o.id && - production == o.production && - mass_g == o.mass_g + success == o.success && + error == o.error && + data == o.data end # @see the `==` method @@ -140,7 +133,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, production, mass_g].hash + [success, error, data].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/order_list_response.rb b/lib/patch_ruby/models/order_list_response.rb index 3aede68..dd3fdea 100644 --- a/lib/patch_ruby/models/order_list_response.rb +++ b/lib/patch_ruby/models/order_list_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/order_response.rb b/lib/patch_ruby/models/order_response.rb index f501c1d..b76f010 100644 --- a/lib/patch_ruby/models/order_response.rb +++ b/lib/patch_ruby/models/order_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/parent_technology_type.rb b/lib/patch_ruby/models/parent_technology_type.rb index 146fecb..a35b441 100644 --- a/lib/patch_ruby/models/parent_technology_type.rb +++ b/lib/patch_ruby/models/parent_technology_type.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/photo.rb b/lib/patch_ruby/models/photo.rb index 8f859d8..7bc77cd 100644 --- a/lib/patch_ruby/models/photo.rb +++ b/lib/patch_ruby/models/photo.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/place_order_request.rb b/lib/patch_ruby/models/place_order_request.rb index 2f914a3..3760224 100644 --- a/lib/patch_ruby/models/place_order_request.rb +++ b/lib/patch_ruby/models/place_order_request.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/project.rb b/lib/patch_ruby/models/project.rb index 3fa11b0..89fb5d3 100644 --- a/lib/patch_ruby/models/project.rb +++ b/lib/patch_ruby/models/project.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -27,9 +27,6 @@ class Project # The description of the project. attr_accessor :description - # DEPRECATED. Favor the technology_type field instead. - attr_accessor :type - # The mechanism of the project. One of: removal, avoidance, avoidance_and_removal. attr_accessor :mechanism @@ -45,18 +42,12 @@ class Project # The longitude at which this project is located. attr_accessor :longitude - # The name of the project developer. - attr_accessor :developer + # The name of the project project partner. + attr_accessor :project_partner # An array of URLs for photos of the project. attr_accessor :photos - # DEPRECATED. The average price per tonne in USD cents for carbon offsets supplied by this project. - attr_accessor :average_price_per_tonne_cents_usd - - # DEPRECATED. The remaining mass in grams available for purchase for this project. - attr_accessor :remaining_mass_g - # The name of the project verifier, when applicable. A verifier is the organization that verifies the calculations of the actual amount of greenhouse gas emissions that have been avoided or sequestered through implementation of the project. attr_accessor :verifier @@ -84,16 +75,13 @@ def self.attribute_map :'production' => :'production', :'name' => :'name', :'description' => :'description', - :'type' => :'type', :'mechanism' => :'mechanism', :'country' => :'country', :'state' => :'state', :'latitude' => :'latitude', :'longitude' => :'longitude', - :'developer' => :'developer', + :'project_partner' => :'project_partner', :'photos' => :'photos', - :'average_price_per_tonne_cents_usd' => :'average_price_per_tonne_cents_usd', - :'remaining_mass_g' => :'remaining_mass_g', :'verifier' => :'verifier', :'standard' => :'standard', :'sdgs' => :'sdgs', @@ -116,16 +104,13 @@ def self.openapi_types :'production' => :'Boolean', :'name' => :'String', :'description' => :'String', - :'type' => :'String', :'mechanism' => :'String', :'country' => :'String', :'state' => :'String', :'latitude' => :'Float', :'longitude' => :'Float', - :'developer' => :'String', + :'project_partner' => :'String', :'photos' => :'Array', - :'average_price_per_tonne_cents_usd' => :'Integer', - :'remaining_mass_g' => :'Integer', :'verifier' => :'String', :'standard' => :'Standard', :'sdgs' => :'Array', @@ -191,10 +176,6 @@ def initialize(attributes = {}) self.description = attributes[:'description'] end - if attributes.key?(:'type') - self.type = attributes[:'type'] - end - if attributes.key?(:'mechanism') self.mechanism = attributes[:'mechanism'] end @@ -215,8 +196,8 @@ def initialize(attributes = {}) self.longitude = attributes[:'longitude'] end - if attributes.key?(:'developer') - self.developer = attributes[:'developer'] + if attributes.key?(:'project_partner') + self.project_partner = attributes[:'project_partner'] end if attributes.key?(:'photos') @@ -225,14 +206,6 @@ def initialize(attributes = {}) end end - if attributes.key?(:'average_price_per_tonne_cents_usd') - self.average_price_per_tonne_cents_usd = attributes[:'average_price_per_tonne_cents_usd'] - end - - if attributes.key?(:'remaining_mass_g') - self.remaining_mass_g = attributes[:'remaining_mass_g'] - end - if attributes.key?(:'verifier') self.verifier = attributes[:'verifier'] end @@ -295,16 +268,8 @@ def list_invalid_properties invalid_properties.push('invalid value for "country", country cannot be nil.') end - if @developer.nil? - invalid_properties.push('invalid value for "developer", developer cannot be nil.') - end - - if @average_price_per_tonne_cents_usd.nil? - invalid_properties.push('invalid value for "average_price_per_tonne_cents_usd", average_price_per_tonne_cents_usd cannot be nil.') - end - - if @remaining_mass_g.nil? - invalid_properties.push('invalid value for "remaining_mass_g", remaining_mass_g cannot be nil.') + if @project_partner.nil? + invalid_properties.push('invalid value for "project_partner", project_partner cannot be nil.') end if @technology_type.nil? @@ -330,9 +295,7 @@ def valid? return false if @name.nil? return false if @description.nil? return false if @country.nil? - return false if @developer.nil? - return false if @average_price_per_tonne_cents_usd.nil? - return false if @remaining_mass_g.nil? + return false if @project_partner.nil? return false if @technology_type.nil? return false if @highlights.nil? return false if @inventory.nil? @@ -348,16 +311,13 @@ def ==(o) production == o.production && name == o.name && description == o.description && - type == o.type && mechanism == o.mechanism && country == o.country && state == o.state && latitude == o.latitude && longitude == o.longitude && - developer == o.developer && + project_partner == o.project_partner && photos == o.photos && - average_price_per_tonne_cents_usd == o.average_price_per_tonne_cents_usd && - remaining_mass_g == o.remaining_mass_g && verifier == o.verifier && standard == o.standard && sdgs == o.sdgs && @@ -376,7 +336,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [id, production, name, description, type, mechanism, country, state, latitude, longitude, developer, photos, average_price_per_tonne_cents_usd, remaining_mass_g, verifier, standard, sdgs, tagline, technology_type, highlights, inventory].hash + [id, production, name, description, mechanism, country, state, latitude, longitude, project_partner, photos, verifier, standard, sdgs, tagline, technology_type, highlights, inventory].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/project_list_response.rb b/lib/patch_ruby/models/project_list_response.rb index f47bff5..25b4cdd 100644 --- a/lib/patch_ruby/models/project_list_response.rb +++ b/lib/patch_ruby/models/project_list_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/project_response.rb b/lib/patch_ruby/models/project_response.rb index 5d41c78..6cb0a42 100644 --- a/lib/patch_ruby/models/project_response.rb +++ b/lib/patch_ruby/models/project_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/sdg.rb b/lib/patch_ruby/models/sdg.rb index 4395aeb..4ea7438 100644 --- a/lib/patch_ruby/models/sdg.rb +++ b/lib/patch_ruby/models/sdg.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/standard.rb b/lib/patch_ruby/models/standard.rb index 1eb89e3..bd0f275 100644 --- a/lib/patch_ruby/models/standard.rb +++ b/lib/patch_ruby/models/standard.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/technology_type.rb b/lib/patch_ruby/models/technology_type.rb index db9eeb1..8e3196c 100644 --- a/lib/patch_ruby/models/technology_type.rb +++ b/lib/patch_ruby/models/technology_type.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/technology_type_list_response.rb b/lib/patch_ruby/models/technology_type_list_response.rb index fb7e4c7..d84e461 100644 --- a/lib/patch_ruby/models/technology_type_list_response.rb +++ b/lib/patch_ruby/models/technology_type_list_response.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/lib/patch_ruby/models/update_order_line_item_request.rb b/lib/patch_ruby/models/update_order_line_item_request.rb new file mode 100644 index 0000000..6e07505 --- /dev/null +++ b/lib/patch_ruby/models/update_order_line_item_request.rb @@ -0,0 +1,366 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'date' +require 'time' + +module Patch + class UpdateOrderLineItemRequest + attr_accessor :vintage_year + + attr_accessor :price + + attr_accessor :currency + + attr_accessor :amount + + attr_accessor :unit + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'vintage_year' => :'vintage_year', + :'price' => :'price', + :'currency' => :'currency', + :'amount' => :'amount', + :'unit' => :'unit' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'vintage_year' => :'Integer', + :'price' => :'Integer', + :'currency' => :'String', + :'amount' => :'Integer', + :'unit' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'vintage_year', + :'price', + :'currency', + :'amount', + :'unit' + ]) + end + + + # Allows models with corresponding API classes to delegate API operations to those API classes + # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id + # Eg. Order.create_order delegates to OrdersApi.new.create_order + def self.method_missing(message, *args, &block) + if Object.const_defined?('Patch::UpdateOrderLineItemRequestsApi::OPERATIONS') && Patch::UpdateOrderLineItemRequestsApi::OPERATIONS.include?(message) + Patch::UpdateOrderLineItemRequestsApi.new.send(message, *args) + else + super + end + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::UpdateOrderLineItemRequest` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::UpdateOrderLineItemRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'vintage_year') + self.vintage_year = attributes[:'vintage_year'] + end + + if attributes.key?(:'price') + self.price = attributes[:'price'] + end + + if attributes.key?(:'currency') + self.currency = attributes[:'currency'] + end + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end + + if attributes.key?(:'unit') + self.unit = attributes[:'unit'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if !@vintage_year.nil? && @vintage_year > 2100 + invalid_properties.push('invalid value for "vintage_year", must be smaller than or equal to 2100.') + end + + if !@vintage_year.nil? && @vintage_year < 1900 + invalid_properties.push('invalid value for "vintage_year", must be greater than or equal to 1900.') + end + + if !@price.nil? && @price < 2 + invalid_properties.push('invalid value for "price", must be greater than or equal to 2.') + end + + if !@amount.nil? && @amount > 100000000000 + invalid_properties.push('invalid value for "amount", must be smaller than or equal to 100000000000.') + end + + if !@amount.nil? && @amount < 0 + invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if !@vintage_year.nil? && @vintage_year > 2100 + return false if !@vintage_year.nil? && @vintage_year < 1900 + return false if !@price.nil? && @price < 2 + return false if !@amount.nil? && @amount > 100000000000 + return false if !@amount.nil? && @amount < 0 + unit_validator = EnumAttributeValidator.new('String', ["g", "Wh"]) + return false unless unit_validator.valid?(@unit) + true + end + + # Custom attribute writer method with validation + # @param [Object] vintage_year Value to be assigned + def vintage_year=(vintage_year) + if !vintage_year.nil? && vintage_year > 2100 + fail ArgumentError, 'invalid value for "vintage_year", must be smaller than or equal to 2100.' + end + + if !vintage_year.nil? && vintage_year < 1900 + fail ArgumentError, 'invalid value for "vintage_year", must be greater than or equal to 1900.' + end + + @vintage_year = vintage_year + end + + # Custom attribute writer method with validation + # @param [Object] price Value to be assigned + def price=(price) + if !price.nil? && price < 2 + fail ArgumentError, 'invalid value for "price", must be greater than or equal to 2.' + end + + @price = price + end + + # Custom attribute writer method with validation + # @param [Object] amount Value to be assigned + def amount=(amount) + if !amount.nil? && amount > 100000000000 + fail ArgumentError, 'invalid value for "amount", must be smaller than or equal to 100000000000.' + end + + if !amount.nil? && amount < 0 + fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 0.' + end + + @amount = amount + end + + # Custom attribute writer method checking allowed values (enum). + # @param [Object] unit Object to be assigned + def unit=(unit) + validator = EnumAttributeValidator.new('String', ["g", "Wh"]) + unless validator.valid?(unit) + fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}." + end + @unit = unit + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + vintage_year == o.vintage_year && + price == o.price && + currency == o.currency && + amount == o.amount && + unit == o.unit + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [vintage_year, price, currency, amount, unit].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Patch.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index e8182e8..03b2663 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.24.2' + VERSION = '2.0.0' end diff --git a/patch_ruby.gemspec b/patch_ruby.gemspec index 08ecffb..1c73231 100644 --- a/patch_ruby.gemspec +++ b/patch_ruby.gemspec @@ -1,11 +1,11 @@ # -*- encoding: utf-8 -*- =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/spec/api/order_line_items_api_spec.rb b/spec/api/order_line_items_api_spec.rb new file mode 100644 index 0000000..270881e --- /dev/null +++ b/spec/api/order_line_items_api_spec.rb @@ -0,0 +1,78 @@ +=begin +#Patch API V2 + +#The core API used to integrate with Patch's service + +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.3.1 + +=end + +require 'spec_helper' +require 'json' + +# Unit tests for Patch::OrderLineItemsApi +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'OrderLineItemsApi' do + before do + # run before each test + @api_instance = Patch::OrderLineItemsApi.new + end + + after do + # run after each test + end + + describe 'test an instance of OrderLineItemsApi' do + it 'should create an instance of OrderLineItemsApi' do + expect(@api_instance).to be_instance_of(Patch::OrderLineItemsApi) + end + end + + # unit tests for create_order_line_item + # Creates an order line item + # Creates a line item on an order that is in the `draft` state. + # @param order_id + # @param create_order_line_item_request + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [OrderLineItemResponse] + describe 'create_order_line_item test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for delete_order_line_item + # Deletes an order line item + # Deletes a line item on an order that is in the `draft` state. + # @param order_id + # @param serial_number + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [DeleteOrderLineItemResponse] + describe 'delete_order_line_item test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for update_order_line_item + # Updates an order line item + # Updates a line item on an order that is in the `draft` state. + # @param order_id + # @param serial_number + # @param update_order_line_item_request + # @param [Hash] opts the optional parameters + # @option opts [Integer] :patch_version + # @return [OrderLineItemResponse] + describe 'update_order_line_item test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/api_client_spec.rb b/spec/api_client_spec.rb index b15de0a..ade5029 100644 --- a/spec/api_client_spec.rb +++ b/spec/api_client_spec.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 188a947..99d4440 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1 diff --git a/spec/factories/allocations.rb b/spec/factories/allocations.rb deleted file mode 100644 index ac14f80..0000000 --- a/spec/factories/allocations.rb +++ /dev/null @@ -1,7 +0,0 @@ -FactoryBot.define do - factory :allocation, class: Patch::Allocation do - sequence(:id) { |n| n } - production { false } - mass_g { 100 } - end -end diff --git a/spec/factories/create_order_requests.rb b/spec/factories/create_order_requests.rb index eae587e..cb4ea89 100644 --- a/spec/factories/create_order_requests.rb +++ b/spec/factories/create_order_requests.rb @@ -1,8 +1,10 @@ FactoryBot.define do factory :create_order_request, class: Patch::CreateOrderRequest do sequence(:project_id) { |n| n } - mass_g { 100 } - total_price_cents_usd { 100 } + amount { 100 } + unit { "g" } + total_price { 100 } + currency { "USD" } metadata { {} } end end diff --git a/spec/factories/orders.rb b/spec/factories/orders.rb index 1b4457f..c3fa2df 100644 --- a/spec/factories/orders.rb +++ b/spec/factories/orders.rb @@ -1,12 +1,13 @@ FactoryBot.define do factory :order, class: Patch::Order do sequence(:id) { |n| n } - mass_g { 1_000 } + amount { 1_000 } + unit { "g" } production { false } state { "draft" } - allocation_state { "pending" } - price_cents_usd { 500 } - patch_fee_cents_usd { 5 } + price { 500 } + patch_fee { 5 } + currency { "USD" } metadata { {} } end end diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 2e7a05e..9406949 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -7,12 +7,9 @@ production { false } name { "New Project" } description { "New Descirption" } - type { "biomass" } country { "DK" } - developer { "Danish Developer" } + project_partner { "Danish Developer" } photos { [] } - average_price_per_tonne_cents_usd { 120 } - remaining_mass_g { 1_000 } standard { 'european_biochar_certificate' } state { 'CO' } latitude { 45.0 } diff --git a/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index edd9224..a1a330a 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Orders Integration' do it 'supports create, place, cancel, retrieve and list' do - create_order_response = Patch::Order.create_order(mass_g: 100) + create_order_response = Patch::Order.create_order(amount: 100, unit: "g") order_id = create_order_response.data.id retrieve_order_response = Patch::Order.retrieve_order(order_id) @@ -25,20 +25,21 @@ ) project_id = retrieve_project_response.data.id - average_price_per_tonne_cents_usd = retrieve_project_response.data.average_price_per_tonne_cents_usd - order_mass_g = 100_000 + order_amount = 100_000 tonne_per_gram = 1_000_000 - create_order_response = Patch::Order.create_order(mass_g: order_mass_g, project_id: project_id) + create_order_response = Patch::Order + .create_order(amount: order_amount, unit: "g", project_id: project_id) order = create_order_response.data expect(create_order_response.success).to eq true expect(order.id).not_to be_nil expect(order.created_at).to be_a_kind_of(Time) - expect(order.mass_g).to eq(order_mass_g) - expect(order.price_cents_usd).to be_kind_of(Integer) - expect(order.patch_fee_cents_usd).to be_kind_of(Integer) + expect(order.amount).to eq(order_amount) + expect(order.unit).to eq("g") + expect(order.price).to be_kind_of(Integer) + expect(order.patch_fee).to be_kind_of(Integer) expect(order.registry_url).not_to be_empty end @@ -48,10 +49,11 @@ ) issued_to = { email: 'envimpact@companyb.com', name: 'Company B' } - total_price_cents_usd = 50_00 + total_price = 50_00 create_order_response = Patch::Order.create_order( - total_price_cents_usd: total_price_cents_usd, + total_price: total_price, + currency: "USD", issued_to: issued_to ) @@ -60,42 +62,21 @@ order = create_order_response.data expect(order.id).not_to be_nil - expect(order.price_cents_usd + order.patch_fee_cents_usd).to eq total_price_cents_usd + expect(order.price + order.patch_fee).to eq total_price expect(order.issued_to.email).to eq(issued_to[:email]) expect(order.issued_to.name).to eq(issued_to[:name]) end - it 'supports create with a total price' do - retrieve_project_response = Patch::Project.retrieve_project( - Constants::BIOMASS_TEST_PROJECT_ID - ) - - project_id = retrieve_project_response.data.id - total_price_cents_usd = 50_00 - - create_order_response = Patch::Order.create_order( - total_price_cents_usd: total_price_cents_usd, - project_id: project_id - ) - - expect(create_order_response.success).to eq true - - order = create_order_response.data - - expect(order.id).not_to be_nil - expect(order.price_cents_usd + order.patch_fee_cents_usd).to eq total_price_cents_usd - expect(order.registry_url).not_to be_empty - end - it 'supports creation with and querying by metadata' do metadata = { user: 'john doe' } create_order_response = - Patch::Order.create_order(mass_g: 100, metadata: metadata) + Patch::Order.create_order(amount: 100, unit: "g", metadata: metadata) expect(create_order_response.success).to eq true expect(create_order_response.data.id).not_to be_nil - expect(create_order_response.data.mass_g).to eq(100) + expect(create_order_response.data.amount).to eq(100) + expect(create_order_response.data.unit).to eq("g") expect(create_order_response.data.metadata).to eq(metadata) retrieve_orders_response = Patch::Order.retrieve_orders( @@ -109,11 +90,12 @@ it 'supports creation in draft state' do create_order_response = - Patch::Order.create_order(mass_g: 100, state: "draft") + Patch::Order.create_order(amount: 100, unit: "g", state: "draft") expect(create_order_response.success).to eq true expect(create_order_response.data.id).not_to be_nil - expect(create_order_response.data.mass_g).to eq(100) + expect(create_order_response.data.amount).to eq(100) + expect(create_order_response.data.unit).to eq("g") expect(create_order_response.data.state).to eq("draft") end @@ -144,11 +126,12 @@ it 'supports create with a vintage year' do create_order_response = - Patch::Order.create_order(mass_g: 100, vintage_year: 2022) + Patch::Order.create_order(amount: 100, unit: "g", vintage_year: 2022) expect(create_order_response.success).to eq true expect(create_order_response.data.id).not_to be_nil - expect(create_order_response.data.mass_g).to eq(100) + expect(create_order_response.data.amount).to eq(100) + expect(create_order_response.data.unit).to eq("g") end it 'supports create with an amount and unit' do @@ -159,16 +142,16 @@ expect(create_order_response.data.id).not_to be_nil expect(create_order_response.data.amount).to eq(100) expect(create_order_response.data.unit).to eq("g") - expect(create_order_response.data.inventory[0]).to be_an_instance_of( - Patch::OrderInventory + expect(create_order_response.data.line_items[0]).to be_an_instance_of( + Patch::OrderLineItem ) - expect(create_order_response.data.inventory[0].project).to be_an_instance_of( - Patch::OrderInventoryProject + expect(create_order_response.data.line_items[0].project).to be_an_instance_of( + Patch::OrderLineItemProject ) - expect(create_order_response.data.inventory[0].unit).to eq("g") + expect(create_order_response.data.line_items[0].unit).to eq("g") end - it 'supports create with a total price and currency' do + it 'supports create with a total price and foreign currency' do create_order_response = Patch::Order.create_order(total_price: 100, currency: "EUR") @@ -178,4 +161,62 @@ ).to be_within(1).of(100) expect(create_order_response.data.currency).to eq "EUR" end + + it 'supports creating an empty draft order and adding/editing line items' do + # Create empty order + create_order_response = + Patch::Order.create_order(state: "draft") + + expect(create_order_response.success).to eq true + expect(create_order_response.data.id).not_to be_nil + expect(create_order_response.data.price).to eq(0) + expect(create_order_response.data.amount).to eq(0) + expect(create_order_response.data.line_items).to eq([]) + + # Add project to order + order_id = create_order_response.data.id + retrieve_project_response = Patch::Project.retrieve_project( + Constants::BIOMASS_TEST_PROJECT_ID + ) + project_id = retrieve_project_response.data.id + + create_line_item_response = Patch::OrderLineItem + .create_order_line_item(order_id, { project_id: project_id }) + + expect(create_line_item_response.success).to eq(true) + expect(create_line_item_response.data.id).not_to be_nil + expect(create_line_item_response.data.amount).to eq(0) + + # Update amount on line item + line_item_id = create_line_item_response.data.id + update_order_line_item_response = Patch::OrderLineItem + .update_order_line_item(order_id, line_item_id, { amount: 100000, unit: "g" }) + + expect(update_order_line_item_response.success).to eq(true) + expect(update_order_line_item_response.data.id).not_to be_nil + expect(update_order_line_item_response.data.amount).to eq(100000) + expect(update_order_line_item_response.data.price).to be >= 0 + + # Fetch order and check line item matches + retrieve_order_response = Patch::Order.retrieve_order(order_id) + expect(retrieve_order_response.data.id).to eq order_id + expect(retrieve_order_response.data.line_items.length).to eq(1) + expect(retrieve_order_response.data.line_items[0].id).to eq(line_item_id) + expect(retrieve_order_response.data.line_items[0].amount).to eq(100000) + + # Delete line item + delete_line_item_response = Patch::OrderLineItem.delete_order_line_item(order_id, line_item_id) + expect(delete_line_item_response.success).to eq(true) + expect(delete_line_item_response.data).to eq(line_item_id) + + # Fetch order and see it has no line items + retrieve_order_response = Patch::Order.retrieve_order(order_id) + expect(retrieve_order_response.data.id).to eq order_id + expect(retrieve_order_response.data.line_items.length).to eq(0) + + # Delete order + delete_order_response = Patch::Order.delete_order(order_id) + expect(delete_order_response.success).to eq(true) + expect(delete_order_response.data).to eq(order_id) + end end diff --git a/spec/integration/projects_spec.rb b/spec/integration/projects_spec.rb index ebc880d..b1ccf69 100644 --- a/spec/integration/projects_spec.rb +++ b/spec/integration/projects_spec.rb @@ -34,7 +34,8 @@ minimum_available_mass = 100 projects = Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass) projects.data.map do |project| - expect(project.remaining_mass_g >= minimum_available_mass).to be true + project_mass = project.inventory.sum(&:amount_available) + expect(project_mass >= minimum_available_mass).to be true end end @@ -45,9 +46,6 @@ expect(project.to_hash.keys).to include(*keys) expect(project.photos).to be_an_instance_of(Array) - expect(project.average_price_per_tonne_cents_usd) - .to be_an_instance_of(Integer) - expect(project.remaining_mass_g).to be_an_instance_of(Integer) expect(project.longitude).to be_an_instance_of(Float) expect(project.latitude).to be_an_instance_of(Float) diff --git a/spec/models/allocation_spec.rb b/spec/models/allocation_spec.rb deleted file mode 100644 index 80cc959..0000000 --- a/spec/models/allocation_spec.rb +++ /dev/null @@ -1,59 +0,0 @@ -=begin -#Patch API V1 - -#The core API used to integrate with Patch's service - -The version of the OpenAPI document: v1 -Contact: developers@usepatch.com -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 4.3.1 - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Patch::Allocation -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'Allocation' do - before do - # run before each test - @instance = build(:allocation) - end - - after do - # run after each test - end - - it_behaves_like "a generated class" do - let(:instance) { @instance } - let(:instance_hash) { { id: @instance.id, mass_g: @instance.mass_g, production: @instance.production } } - let(:nullable_properties) { Set.new } - end - - describe 'test an instance of Allocation' do - it 'should create an instance of Allocation' do - expect(@instance).to be_instance_of(Patch::Allocation) - end - end - - describe 'test attribute "id"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "production"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "mass_g"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end -end diff --git a/spec/models/create_order_request_spec.rb b/spec/models/create_order_request_spec.rb index a182190..5393847 100644 --- a/spec/models/create_order_request_spec.rb +++ b/spec/models/create_order_request_spec.rb @@ -29,9 +29,16 @@ it_behaves_like "a generated class" do let(:instance) { @instance } - let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, total_price_cents_usd: @instance.total_price_cents_usd, metadata: @instance.metadata } } + let(:instance_hash) { { + project_id: @instance.project_id, + amount: @instance.amount, + unit: @instance.unit, + total_price: @instance.total_price, + currency: @instance.currency, + metadata: @instance.metadata + } } let(:nullable_properties) do - Set.new(%i[mass_g total_price_cents_usd project_id metadata state vintage_year total_price currency amount unit]) + Set.new(%i[project_id metadata state vintage_year total_price currency amount unit]) end end @@ -40,7 +47,7 @@ expect(@instance).to be_instance_of(Patch::CreateOrderRequest) end end - describe 'test attribute "mass_g"' do + describe 'test attribute "amount"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index deb9673..d3c12b6 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -32,16 +32,17 @@ let(:instance_hash) { { id: @instance.id, - mass_g: @instance.mass_g, + amount: @instance.amount, + unit: @instance.unit, production: @instance.production, state: @instance.state, - allocation_state: @instance.allocation_state, - price_cents_usd: @instance.price_cents_usd, - patch_fee_cents_usd: @instance.patch_fee_cents_usd, + price: @instance.price, + patch_fee: @instance.patch_fee, + currency: @instance.currency, metadata: @instance.metadata } } - let(:nullable_properties) { Set.new([:patch_fee_cents_usd, :price_cents_usd]) } + let(:nullable_properties) { Set.new([]) } end describe 'test an instance of Order' do @@ -55,7 +56,7 @@ end end - describe 'test attribute "mass_g"' do + describe 'test attribute "amount"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end @@ -77,23 +78,7 @@ end end - describe 'test attribute "allocation_state"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["pending", "partially_allocated", "allocated"]) - # validator.allowable_values.each do |value| - # expect { @instance.allocation_state = value }.not_to raise_error - # end - end - end - - describe 'test attribute "price_cents_usd"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "allocations"' do + describe 'test attribute "price"' do it 'should work' do # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 05b3e94..c7c34c5 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -35,12 +35,9 @@ name: @instance.name, description: @instance.description, production: @instance.production, - type: @instance.type, country: @instance.country, - developer: @instance.developer, + project_partner: @instance.project_partner, photos: @instance.photos, - average_price_per_tonne_cents_usd: @instance.average_price_per_tonne_cents_usd, - remaining_mass_g: @instance.remaining_mass_g, state: @instance.state, longitude: @instance.longitude, latitude: @instance.latitude, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0f1998e..05b06d7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,9 @@ =begin -#Patch API V1 +#Patch API V2 #The core API used to integrate with Patch's service -The version of the OpenAPI document: v1 +The version of the OpenAPI document: 2 Contact: engineering@usepatch.com Generated by: https://openapi-generator.tech OpenAPI Generator version: 5.3.1