From 9ca057f6feca072f3e1861e7ef62c04b24679f5e Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Fri, 7 Nov 2025 12:41:06 -0800 Subject: [PATCH 1/3] Remove all remaining estimates --- CHANGELOG.md | 5 + Gemfile | 2 +- Gemfile.lock | 43 +- lib/patch_ruby.rb | 10 - lib/patch_ruby/api_client.rb | 2 +- .../create_air_shipping_estimate_request.rb | 374 ------------- .../models/create_bitcoin_estimate_request.rb | 271 --------- .../models/create_mass_estimate_request.rb | 282 ---------- .../create_rail_shipping_estimate_request.rb | 404 -------------- .../create_road_shipping_estimate_request.rb | 517 ------------------ .../create_sea_shipping_estimate_request.rb | 461 ---------------- lib/patch_ruby/models/estimate.rb | 288 ---------- .../models/estimate_list_response.rb | 273 --------- lib/patch_ruby/models/estimate_response.rb | 257 --------- lib/patch_ruby/version.rb | 2 +- spec/api/estimates_api_spec.rb | 70 --- .../create_mass_estimate_request_spec.rb | 46 -- spec/models/estimate_list_response_spec.rb | 64 --- spec/models/estimate_response_spec.rb | 58 -- spec/models/estimate_spec.rb | 65 --- 20 files changed, 26 insertions(+), 3468 deletions(-) delete mode 100644 lib/patch_ruby/models/create_air_shipping_estimate_request.rb delete mode 100644 lib/patch_ruby/models/create_bitcoin_estimate_request.rb delete mode 100644 lib/patch_ruby/models/create_mass_estimate_request.rb delete mode 100644 lib/patch_ruby/models/create_rail_shipping_estimate_request.rb delete mode 100644 lib/patch_ruby/models/create_road_shipping_estimate_request.rb delete mode 100644 lib/patch_ruby/models/create_sea_shipping_estimate_request.rb delete mode 100644 lib/patch_ruby/models/estimate.rb delete mode 100644 lib/patch_ruby/models/estimate_list_response.rb delete mode 100644 lib/patch_ruby/models/estimate_response.rb delete mode 100644 spec/api/estimates_api_spec.rb delete mode 100644 spec/models/create_mass_estimate_request_spec.rb delete mode 100644 spec/models/estimate_list_response_spec.rb delete mode 100644 spec/models/estimate_response_spec.rb delete mode 100644 spec/models/estimate_spec.rb diff --git a/CHANGELOG.md b/CHANGELOG.md index ce84f84..ee613ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.6.0] - 2025-11-07 + +- Removes create_mass_estimate and create_bitcoin_estimate method +- Retires all remaining estimates functionalities + ## [2.5.0] - 2025-08-19 ### Removed diff --git a/Gemfile b/Gemfile index 5f57599..c2e3127 100644 --- a/Gemfile +++ b/Gemfile @@ -5,5 +5,5 @@ gemspec group :development, :test do gem 'rake', '~> 13.0.1' gem 'pry-byebug' - gem 'rubocop', '~> 1.75.6' + gem 'rubocop', '~> 0.66.0' end diff --git a/Gemfile.lock b/Gemfile.lock index a99eaf6..dcc67f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (2.5.0) + patch_ruby (2.6.0) typhoeus (~> 1.0, >= 1.0.1) GEM @@ -16,34 +16,34 @@ GEM byebug (11.1.3) coderay (1.1.3) concurrent-ruby (1.2.2) + date (3.5.0) diff-lcs (1.4.4) - ethon (0.16.0) + ethon (0.15.0) ffi (>= 1.15.0) factory_bot (6.2.0) activesupport (>= 5.0.0) ffi (1.17.2) i18n (1.12.0) concurrent-ruby (~> 1.0) - json (2.12.0) - language_server-protocol (3.17.0.5) - lint_roller (1.1.0) + jaro_winkler (1.5.6) method_source (1.0.0) minitest (5.18.0) parallel (1.27.0) - parser (3.3.8.0) + parser (3.3.10.0) ast (~> 2.4.1) racc - prism (1.4.0) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) pry-byebug (3.8.0) byebug (~> 11.0) pry (~> 0.10) + psych (5.2.6) + date + stringio racc (1.8.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.10.0) rspec (3.10.0) rspec-core (~> 3.10.0) rspec-expectations (~> 3.10.0) @@ -57,28 +57,21 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.2) - rubocop (1.75.6) - json (~> 2.3) - language_server-protocol (~> 3.17.0.2) - lint_roller (~> 1.1.0) + rubocop (0.66.0) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 3.3.0.2) + parser (>= 2.5, != 2.5.1.1) + psych (>= 3.1.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.44.1) - parser (>= 3.3.7.2) - prism (~> 1.4) + unicode-display_width (>= 1.4.0, < 1.6) ruby-progressbar (1.13.0) - typhoeus (1.4.1) - ethon (>= 0.9.0) + stringio (3.1.7) + typhoeus (1.5.0) + ethon (>= 0.9.0, < 0.16.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (3.1.4) - unicode-emoji (~> 4.0, >= 4.0.4) - unicode-emoji (4.0.4) + unicode-display_width (1.5.0) PLATFORMS arm64-darwin-20 @@ -96,7 +89,7 @@ DEPENDENCIES pry-byebug rake (~> 13.0.1) rspec (~> 3.6, >= 3.6.0) - rubocop (~> 1.75.6) + rubocop (~> 0.66.0) BUNDLED WITH 2.3.9 diff --git a/lib/patch_ruby.rb b/lib/patch_ruby.rb index 1be8d4e..b729312 100644 --- a/lib/patch_ruby.rb +++ b/lib/patch_ruby.rb @@ -17,22 +17,13 @@ require 'patch_ruby/configuration' # Models -require 'patch_ruby/models/create_air_shipping_estimate_request' -require 'patch_ruby/models/create_bitcoin_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' -require 'patch_ruby/models/create_sea_shipping_estimate_request' require 'patch_ruby/models/create_success_response' require 'patch_ruby/models/delete_order_line_item_response' require 'patch_ruby/models/delete_order_response' require 'patch_ruby/models/disclaimer' require 'patch_ruby/models/error_response' -require 'patch_ruby/models/estimate' -require 'patch_ruby/models/estimate_list_response' -require 'patch_ruby/models/estimate_response' require 'patch_ruby/models/highlight' require 'patch_ruby/models/inventory' require 'patch_ruby/models/meta_index_object' @@ -56,7 +47,6 @@ 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' diff --git a/lib/patch_ruby/api_client.rb b/lib/patch_ruby/api_client.rb index 3718793..69d0170 100644 --- a/lib/patch_ruby/api_client.rb +++ b/lib/patch_ruby/api_client.rb @@ -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/2.5.0" + @user_agent = "patch-ruby/2.6.0" @default_headers = { 'Content-Type' => 'application/json', 'User-Agent' => @user_agent diff --git a/lib/patch_ruby/models/create_air_shipping_estimate_request.rb b/lib/patch_ruby/models/create_air_shipping_estimate_request.rb deleted file mode 100644 index a7008c9..0000000 --- a/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +++ /dev/null @@ -1,374 +0,0 @@ -=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 CreateAirShippingEstimateRequest - attr_accessor :destination_airport - - attr_accessor :origin_airport - - attr_accessor :aircraft_code - - attr_accessor :aircraft_type - - attr_accessor :freight_mass_g - - attr_accessor :emissions_scope - - attr_accessor :project_id - - attr_accessor :create_order - - 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 - { - :'destination_airport' => :'destination_airport', - :'origin_airport' => :'origin_airport', - :'aircraft_code' => :'aircraft_code', - :'aircraft_type' => :'aircraft_type', - :'freight_mass_g' => :'freight_mass_g', - :'emissions_scope' => :'emissions_scope', - :'project_id' => :'project_id', - :'create_order' => :'create_order' - } - 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 - { - :'destination_airport' => :'String', - :'origin_airport' => :'String', - :'aircraft_code' => :'String', - :'aircraft_type' => :'String', - :'freight_mass_g' => :'Integer', - :'emissions_scope' => :'String', - :'project_id' => :'String', - :'create_order' => :'Boolean' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'destination_airport', - :'origin_airport', - :'aircraft_code', - :'aircraft_type', - :'emissions_scope', - :'project_id', - :'create_order' - ]) - 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::CreateAirShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateAirShippingEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateAirShippingEstimateRequestsApi.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::CreateAirShippingEstimateRequest` 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::CreateAirShippingEstimateRequest`. 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?(:'destination_airport') - self.destination_airport = attributes[:'destination_airport'] - end - - if attributes.key?(:'origin_airport') - self.origin_airport = attributes[:'origin_airport'] - end - - if attributes.key?(:'aircraft_code') - self.aircraft_code = attributes[:'aircraft_code'] - end - - if attributes.key?(:'aircraft_type') - self.aircraft_type = attributes[:'aircraft_type'] - else - self.aircraft_type = 'unknown' - end - - if attributes.key?(:'freight_mass_g') - self.freight_mass_g = attributes[:'freight_mass_g'] - end - - if attributes.key?(:'emissions_scope') - self.emissions_scope = attributes[:'emissions_scope'] - else - self.emissions_scope = 'ttw' - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - 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 !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.') - end - - if !@freight_mass_g.nil? && @freight_mass_g < 0 - invalid_properties.push('invalid value for "freight_mass_g", 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? - aircraft_type_validator = EnumAttributeValidator.new('String', ["passenger", "cargo", "unknown"]) - return false unless aircraft_type_validator.valid?(@aircraft_type) - return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - return false if !@freight_mass_g.nil? && @freight_mass_g < 0 - emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - return false unless emissions_scope_validator.valid?(@emissions_scope) - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] aircraft_type Object to be assigned - def aircraft_type=(aircraft_type) - validator = EnumAttributeValidator.new('String', ["passenger", "cargo", "unknown"]) - unless validator.valid?(aircraft_type) - fail ArgumentError, "invalid value for \"aircraft_type\", must be one of #{validator.allowable_values}." - end - @aircraft_type = aircraft_type - end - - # Custom attribute writer method with validation - # @param [Object] freight_mass_g Value to be assigned - def freight_mass_g=(freight_mass_g) - if !freight_mass_g.nil? && freight_mass_g > 2000000000 - fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.' - end - - if !freight_mass_g.nil? && freight_mass_g < 0 - fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.' - end - - @freight_mass_g = freight_mass_g - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] emissions_scope Object to be assigned - def emissions_scope=(emissions_scope) - validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - unless validator.valid?(emissions_scope) - fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}." - end - @emissions_scope = emissions_scope - 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 && - destination_airport == o.destination_airport && - origin_airport == o.origin_airport && - aircraft_code == o.aircraft_code && - aircraft_type == o.aircraft_type && - freight_mass_g == o.freight_mass_g && - emissions_scope == o.emissions_scope && - project_id == o.project_id && - create_order == o.create_order - 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 - [destination_airport, origin_airport, aircraft_code, aircraft_type, freight_mass_g, emissions_scope, project_id, create_order].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_bitcoin_estimate_request.rb b/lib/patch_ruby/models/create_bitcoin_estimate_request.rb deleted file mode 100644 index 9feaeed..0000000 --- a/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +++ /dev/null @@ -1,271 +0,0 @@ -=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 CreateBitcoinEstimateRequest - attr_accessor :timestamp - - attr_accessor :transaction_value_btc_sats - - attr_accessor :average_daily_balance_btc_sats - - attr_accessor :project_id - - attr_accessor :create_order - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'timestamp' => :'timestamp', - :'transaction_value_btc_sats' => :'transaction_value_btc_sats', - :'average_daily_balance_btc_sats' => :'average_daily_balance_btc_sats', - :'project_id' => :'project_id', - :'create_order' => :'create_order' - } - 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 - { - :'timestamp' => :'Time', - :'transaction_value_btc_sats' => :'Integer', - :'average_daily_balance_btc_sats' => :'Integer', - :'project_id' => :'String', - :'create_order' => :'Boolean' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'timestamp', - :'transaction_value_btc_sats', - :'average_daily_balance_btc_sats', - :'project_id', - :'create_order' - ]) - 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::CreateBitcoinEstimateRequestsApi::OPERATIONS') && Patch::CreateBitcoinEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateBitcoinEstimateRequestsApi.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::CreateBitcoinEstimateRequest` 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::CreateBitcoinEstimateRequest`. 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?(:'timestamp') - self.timestamp = attributes[:'timestamp'] - end - - if attributes.key?(:'transaction_value_btc_sats') - self.transaction_value_btc_sats = attributes[:'transaction_value_btc_sats'] - end - - if attributes.key?(:'average_daily_balance_btc_sats') - self.average_daily_balance_btc_sats = attributes[:'average_daily_balance_btc_sats'] - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - 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 - 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? - 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 && - timestamp == o.timestamp && - transaction_value_btc_sats == o.transaction_value_btc_sats && - average_daily_balance_btc_sats == o.average_daily_balance_btc_sats && - project_id == o.project_id && - create_order == o.create_order - 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 - [timestamp, transaction_value_btc_sats, average_daily_balance_btc_sats, project_id, create_order].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_mass_estimate_request.rb b/lib/patch_ruby/models/create_mass_estimate_request.rb deleted file mode 100644 index f90da64..0000000 --- a/lib/patch_ruby/models/create_mass_estimate_request.rb +++ /dev/null @@ -1,282 +0,0 @@ -=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 CreateMassEstimateRequest - attr_accessor :mass_g - - attr_accessor :create_order - - attr_accessor :project_id - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'mass_g' => :'mass_g', - :'create_order' => :'create_order', - :'project_id' => :'project_id' - } - 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 - { - :'mass_g' => :'Integer', - :'create_order' => :'Boolean', - :'project_id' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'create_order', - ]) - 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::CreateMassEstimateRequestsApi::OPERATIONS') && Patch::CreateMassEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateMassEstimateRequestsApi.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::CreateMassEstimateRequest` 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::CreateMassEstimateRequest`. 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?(:'mass_g') - self.mass_g = attributes[:'mass_g'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - 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 @mass_g.nil? - invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.') - end - - if @mass_g > 100000000000000 - invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 100000000000000.') - end - - if @mass_g < 0 - invalid_properties.push('invalid value for "mass_g", 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 @mass_g.nil? - return false if @mass_g > 100000000000000 - return false if @mass_g < 0 - 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 > 100000000000000 - fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 100000000000000.' - 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 - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - mass_g == o.mass_g && - create_order == o.create_order && - project_id == o.project_id - 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 - [mass_g, create_order, project_id].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_rail_shipping_estimate_request.rb b/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb deleted file mode 100644 index 03a3615..0000000 --- a/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +++ /dev/null @@ -1,404 +0,0 @@ -=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 CreateRailShippingEstimateRequest - attr_accessor :destination_country_code - - attr_accessor :destination_locode - - attr_accessor :destination_postal_code - - attr_accessor :origin_country_code - - attr_accessor :origin_locode - - attr_accessor :origin_postal_code - - attr_accessor :fuel_type - - attr_accessor :freight_mass_g - - attr_accessor :emissions_scope - - attr_accessor :project_id - - attr_accessor :create_order - - 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 - { - :'destination_country_code' => :'destination_country_code', - :'destination_locode' => :'destination_locode', - :'destination_postal_code' => :'destination_postal_code', - :'origin_country_code' => :'origin_country_code', - :'origin_locode' => :'origin_locode', - :'origin_postal_code' => :'origin_postal_code', - :'fuel_type' => :'fuel_type', - :'freight_mass_g' => :'freight_mass_g', - :'emissions_scope' => :'emissions_scope', - :'project_id' => :'project_id', - :'create_order' => :'create_order' - } - 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 - { - :'destination_country_code' => :'String', - :'destination_locode' => :'String', - :'destination_postal_code' => :'String', - :'origin_country_code' => :'String', - :'origin_locode' => :'String', - :'origin_postal_code' => :'String', - :'fuel_type' => :'String', - :'freight_mass_g' => :'Integer', - :'emissions_scope' => :'String', - :'project_id' => :'String', - :'create_order' => :'Boolean' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'destination_country_code', - :'destination_locode', - :'destination_postal_code', - :'origin_country_code', - :'origin_locode', - :'origin_postal_code', - :'fuel_type', - :'emissions_scope', - :'project_id', - :'create_order' - ]) - 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::CreateRailShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateRailShippingEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateRailShippingEstimateRequestsApi.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::CreateRailShippingEstimateRequest` 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::CreateRailShippingEstimateRequest`. 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?(:'destination_country_code') - self.destination_country_code = attributes[:'destination_country_code'] - end - - if attributes.key?(:'destination_locode') - self.destination_locode = attributes[:'destination_locode'] - end - - if attributes.key?(:'destination_postal_code') - self.destination_postal_code = attributes[:'destination_postal_code'] - end - - if attributes.key?(:'origin_country_code') - self.origin_country_code = attributes[:'origin_country_code'] - end - - if attributes.key?(:'origin_locode') - self.origin_locode = attributes[:'origin_locode'] - end - - if attributes.key?(:'origin_postal_code') - self.origin_postal_code = attributes[:'origin_postal_code'] - end - - if attributes.key?(:'fuel_type') - self.fuel_type = attributes[:'fuel_type'] - else - self.fuel_type = 'default' - end - - if attributes.key?(:'freight_mass_g') - self.freight_mass_g = attributes[:'freight_mass_g'] - end - - if attributes.key?(:'emissions_scope') - self.emissions_scope = attributes[:'emissions_scope'] - else - self.emissions_scope = 'ttw' - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - 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 !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.') - end - - if !@freight_mass_g.nil? && @freight_mass_g < 0 - invalid_properties.push('invalid value for "freight_mass_g", 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? - fuel_type_validator = EnumAttributeValidator.new('String', ["default", "diesel", "elec"]) - return false unless fuel_type_validator.valid?(@fuel_type) - return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - return false if !@freight_mass_g.nil? && @freight_mass_g < 0 - emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - return false unless emissions_scope_validator.valid?(@emissions_scope) - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] fuel_type Object to be assigned - def fuel_type=(fuel_type) - validator = EnumAttributeValidator.new('String', ["default", "diesel", "elec"]) - unless validator.valid?(fuel_type) - fail ArgumentError, "invalid value for \"fuel_type\", must be one of #{validator.allowable_values}." - end - @fuel_type = fuel_type - end - - # Custom attribute writer method with validation - # @param [Object] freight_mass_g Value to be assigned - def freight_mass_g=(freight_mass_g) - if !freight_mass_g.nil? && freight_mass_g > 2000000000 - fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.' - end - - if !freight_mass_g.nil? && freight_mass_g < 0 - fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.' - end - - @freight_mass_g = freight_mass_g - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] emissions_scope Object to be assigned - def emissions_scope=(emissions_scope) - validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - unless validator.valid?(emissions_scope) - fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}." - end - @emissions_scope = emissions_scope - 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 && - destination_country_code == o.destination_country_code && - destination_locode == o.destination_locode && - destination_postal_code == o.destination_postal_code && - origin_country_code == o.origin_country_code && - origin_locode == o.origin_locode && - origin_postal_code == o.origin_postal_code && - fuel_type == o.fuel_type && - freight_mass_g == o.freight_mass_g && - emissions_scope == o.emissions_scope && - project_id == o.project_id && - create_order == o.create_order - 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 - [destination_country_code, destination_locode, destination_postal_code, origin_country_code, origin_locode, origin_postal_code, fuel_type, freight_mass_g, emissions_scope, project_id, create_order].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_road_shipping_estimate_request.rb b/lib/patch_ruby/models/create_road_shipping_estimate_request.rb deleted file mode 100644 index 3f84219..0000000 --- a/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +++ /dev/null @@ -1,517 +0,0 @@ -=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 CreateRoadShippingEstimateRequest - attr_accessor :destination_country_code - - attr_accessor :destination_locode - - attr_accessor :destination_postal_code - - attr_accessor :origin_country_code - - attr_accessor :origin_locode - - attr_accessor :origin_postal_code - - attr_accessor :cargo_type - - attr_accessor :container_size_code - - attr_accessor :emissions_scope - - attr_accessor :freight_mass_g - - attr_accessor :fuel_type - - attr_accessor :number_of_containers - - attr_accessor :truck_weight_t - - attr_accessor :carrier_scac - - attr_accessor :project_id - - attr_accessor :create_order - - 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 - { - :'destination_country_code' => :'destination_country_code', - :'destination_locode' => :'destination_locode', - :'destination_postal_code' => :'destination_postal_code', - :'origin_country_code' => :'origin_country_code', - :'origin_locode' => :'origin_locode', - :'origin_postal_code' => :'origin_postal_code', - :'cargo_type' => :'cargo_type', - :'container_size_code' => :'container_size_code', - :'emissions_scope' => :'emissions_scope', - :'freight_mass_g' => :'freight_mass_g', - :'fuel_type' => :'fuel_type', - :'number_of_containers' => :'number_of_containers', - :'truck_weight_t' => :'truck_weight_t', - :'carrier_scac' => :'carrier_scac', - :'project_id' => :'project_id', - :'create_order' => :'create_order' - } - 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 - { - :'destination_country_code' => :'String', - :'destination_locode' => :'String', - :'destination_postal_code' => :'String', - :'origin_country_code' => :'String', - :'origin_locode' => :'String', - :'origin_postal_code' => :'String', - :'cargo_type' => :'String', - :'container_size_code' => :'String', - :'emissions_scope' => :'String', - :'freight_mass_g' => :'Integer', - :'fuel_type' => :'String', - :'number_of_containers' => :'Integer', - :'truck_weight_t' => :'Integer', - :'carrier_scac' => :'String', - :'project_id' => :'String', - :'create_order' => :'Boolean' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'destination_country_code', - :'destination_locode', - :'destination_postal_code', - :'origin_country_code', - :'origin_locode', - :'origin_postal_code', - :'emissions_scope', - :'fuel_type', - :'number_of_containers', - :'truck_weight_t', - :'carrier_scac', - :'project_id', - :'create_order' - ]) - 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::CreateRoadShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateRoadShippingEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateRoadShippingEstimateRequestsApi.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::CreateRoadShippingEstimateRequest` 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::CreateRoadShippingEstimateRequest`. 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?(:'destination_country_code') - self.destination_country_code = attributes[:'destination_country_code'] - end - - if attributes.key?(:'destination_locode') - self.destination_locode = attributes[:'destination_locode'] - end - - if attributes.key?(:'destination_postal_code') - self.destination_postal_code = attributes[:'destination_postal_code'] - end - - if attributes.key?(:'origin_country_code') - self.origin_country_code = attributes[:'origin_country_code'] - end - - if attributes.key?(:'origin_locode') - self.origin_locode = attributes[:'origin_locode'] - end - - if attributes.key?(:'origin_postal_code') - self.origin_postal_code = attributes[:'origin_postal_code'] - end - - if attributes.key?(:'cargo_type') - self.cargo_type = attributes[:'cargo_type'] - else - self.cargo_type = 'average_mixed' - end - - if attributes.key?(:'container_size_code') - self.container_size_code = attributes[:'container_size_code'] - end - - if attributes.key?(:'emissions_scope') - self.emissions_scope = attributes[:'emissions_scope'] - else - self.emissions_scope = 'ttw' - end - - if attributes.key?(:'freight_mass_g') - self.freight_mass_g = attributes[:'freight_mass_g'] - end - - if attributes.key?(:'fuel_type') - self.fuel_type = attributes[:'fuel_type'] - else - self.fuel_type = 'diesel' - end - - if attributes.key?(:'number_of_containers') - self.number_of_containers = attributes[:'number_of_containers'] - end - - if attributes.key?(:'truck_weight_t') - self.truck_weight_t = attributes[:'truck_weight_t'] - end - - if attributes.key?(:'carrier_scac') - self.carrier_scac = attributes[:'carrier_scac'] - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - 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 !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.') - end - - if !@freight_mass_g.nil? && @freight_mass_g < 0 - invalid_properties.push('invalid value for "freight_mass_g", must be greater than or equal to 0.') - end - - if !@number_of_containers.nil? && @number_of_containers < 0 - invalid_properties.push('invalid value for "number_of_containers", must be greater than or equal to 0.') - end - - if !@truck_weight_t.nil? && @truck_weight_t > 60 - invalid_properties.push('invalid value for "truck_weight_t", must be smaller than or equal to 60.') - end - - if !@truck_weight_t.nil? && @truck_weight_t < 0 - invalid_properties.push('invalid value for "truck_weight_t", 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? - cargo_type_validator = EnumAttributeValidator.new('String', ["average_mixed", "container"]) - return false unless cargo_type_validator.valid?(@cargo_type) - container_size_code_validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"]) - return false unless container_size_code_validator.valid?(@container_size_code) - emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - return false unless emissions_scope_validator.valid?(@emissions_scope) - return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - return false if !@freight_mass_g.nil? && @freight_mass_g < 0 - fuel_type_validator = EnumAttributeValidator.new('String', ["cng", "diesel", "lng", "petrol"]) - return false unless fuel_type_validator.valid?(@fuel_type) - return false if !@number_of_containers.nil? && @number_of_containers < 0 - return false if !@truck_weight_t.nil? && @truck_weight_t > 60 - return false if !@truck_weight_t.nil? && @truck_weight_t < 0 - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] cargo_type Object to be assigned - def cargo_type=(cargo_type) - validator = EnumAttributeValidator.new('String', ["average_mixed", "container"]) - unless validator.valid?(cargo_type) - fail ArgumentError, "invalid value for \"cargo_type\", must be one of #{validator.allowable_values}." - end - @cargo_type = cargo_type - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] container_size_code Object to be assigned - def container_size_code=(container_size_code) - validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"]) - unless validator.valid?(container_size_code) - fail ArgumentError, "invalid value for \"container_size_code\", must be one of #{validator.allowable_values}." - end - @container_size_code = container_size_code - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] emissions_scope Object to be assigned - def emissions_scope=(emissions_scope) - validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - unless validator.valid?(emissions_scope) - fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}." - end - @emissions_scope = emissions_scope - end - - # Custom attribute writer method with validation - # @param [Object] freight_mass_g Value to be assigned - def freight_mass_g=(freight_mass_g) - if !freight_mass_g.nil? && freight_mass_g > 2000000000 - fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.' - end - - if !freight_mass_g.nil? && freight_mass_g < 0 - fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.' - end - - @freight_mass_g = freight_mass_g - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] fuel_type Object to be assigned - def fuel_type=(fuel_type) - validator = EnumAttributeValidator.new('String', ["cng", "diesel", "lng", "petrol"]) - unless validator.valid?(fuel_type) - fail ArgumentError, "invalid value for \"fuel_type\", must be one of #{validator.allowable_values}." - end - @fuel_type = fuel_type - end - - # Custom attribute writer method with validation - # @param [Object] number_of_containers Value to be assigned - def number_of_containers=(number_of_containers) - if !number_of_containers.nil? && number_of_containers < 0 - fail ArgumentError, 'invalid value for "number_of_containers", must be greater than or equal to 0.' - end - - @number_of_containers = number_of_containers - end - - # Custom attribute writer method with validation - # @param [Object] truck_weight_t Value to be assigned - def truck_weight_t=(truck_weight_t) - if !truck_weight_t.nil? && truck_weight_t > 60 - fail ArgumentError, 'invalid value for "truck_weight_t", must be smaller than or equal to 60.' - end - - if !truck_weight_t.nil? && truck_weight_t < 0 - fail ArgumentError, 'invalid value for "truck_weight_t", must be greater than or equal to 0.' - end - - @truck_weight_t = truck_weight_t - 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 && - destination_country_code == o.destination_country_code && - destination_locode == o.destination_locode && - destination_postal_code == o.destination_postal_code && - origin_country_code == o.origin_country_code && - origin_locode == o.origin_locode && - origin_postal_code == o.origin_postal_code && - cargo_type == o.cargo_type && - container_size_code == o.container_size_code && - emissions_scope == o.emissions_scope && - freight_mass_g == o.freight_mass_g && - fuel_type == o.fuel_type && - number_of_containers == o.number_of_containers && - truck_weight_t == o.truck_weight_t && - carrier_scac == o.carrier_scac && - project_id == o.project_id && - create_order == o.create_order - 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 - [destination_country_code, destination_locode, destination_postal_code, origin_country_code, origin_locode, origin_postal_code, cargo_type, container_size_code, emissions_scope, freight_mass_g, fuel_type, number_of_containers, truck_weight_t, carrier_scac, project_id, create_order].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_sea_shipping_estimate_request.rb b/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb deleted file mode 100644 index e8a72c2..0000000 --- a/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +++ /dev/null @@ -1,461 +0,0 @@ -=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 CreateSeaShippingEstimateRequest - attr_accessor :destination_country_code - - attr_accessor :destination_locode - - attr_accessor :destination_postal_code - - attr_accessor :origin_country_code - - attr_accessor :origin_locode - - attr_accessor :origin_postal_code - - attr_accessor :container_size_code - - attr_accessor :emissions_scope - - attr_accessor :freight_mass_g - - attr_accessor :freight_volume_cubic_m - - attr_accessor :number_of_containers - - attr_accessor :vessel_imo - - attr_accessor :project_id - - attr_accessor :create_order - - 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 - { - :'destination_country_code' => :'destination_country_code', - :'destination_locode' => :'destination_locode', - :'destination_postal_code' => :'destination_postal_code', - :'origin_country_code' => :'origin_country_code', - :'origin_locode' => :'origin_locode', - :'origin_postal_code' => :'origin_postal_code', - :'container_size_code' => :'container_size_code', - :'emissions_scope' => :'emissions_scope', - :'freight_mass_g' => :'freight_mass_g', - :'freight_volume_cubic_m' => :'freight_volume_cubic_m', - :'number_of_containers' => :'number_of_containers', - :'vessel_imo' => :'vessel_imo', - :'project_id' => :'project_id', - :'create_order' => :'create_order' - } - 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 - { - :'destination_country_code' => :'String', - :'destination_locode' => :'String', - :'destination_postal_code' => :'String', - :'origin_country_code' => :'String', - :'origin_locode' => :'String', - :'origin_postal_code' => :'String', - :'container_size_code' => :'String', - :'emissions_scope' => :'String', - :'freight_mass_g' => :'Integer', - :'freight_volume_cubic_m' => :'Integer', - :'number_of_containers' => :'Integer', - :'vessel_imo' => :'Integer', - :'project_id' => :'String', - :'create_order' => :'Boolean' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'destination_country_code', - :'destination_locode', - :'destination_postal_code', - :'origin_country_code', - :'origin_locode', - :'origin_postal_code', - :'emissions_scope', - :'freight_volume_cubic_m', - :'number_of_containers', - :'vessel_imo', - :'project_id', - :'create_order' - ]) - 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::CreateSeaShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateSeaShippingEstimateRequestsApi::OPERATIONS.include?(message) - Patch::CreateSeaShippingEstimateRequestsApi.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::CreateSeaShippingEstimateRequest` 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::CreateSeaShippingEstimateRequest`. 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?(:'destination_country_code') - self.destination_country_code = attributes[:'destination_country_code'] - end - - if attributes.key?(:'destination_locode') - self.destination_locode = attributes[:'destination_locode'] - end - - if attributes.key?(:'destination_postal_code') - self.destination_postal_code = attributes[:'destination_postal_code'] - end - - if attributes.key?(:'origin_country_code') - self.origin_country_code = attributes[:'origin_country_code'] - end - - if attributes.key?(:'origin_locode') - self.origin_locode = attributes[:'origin_locode'] - end - - if attributes.key?(:'origin_postal_code') - self.origin_postal_code = attributes[:'origin_postal_code'] - end - - if attributes.key?(:'container_size_code') - self.container_size_code = attributes[:'container_size_code'] - end - - if attributes.key?(:'emissions_scope') - self.emissions_scope = attributes[:'emissions_scope'] - else - self.emissions_scope = 'ttw' - end - - if attributes.key?(:'freight_mass_g') - self.freight_mass_g = attributes[:'freight_mass_g'] - end - - if attributes.key?(:'freight_volume_cubic_m') - self.freight_volume_cubic_m = attributes[:'freight_volume_cubic_m'] - end - - if attributes.key?(:'number_of_containers') - self.number_of_containers = attributes[:'number_of_containers'] - end - - if attributes.key?(:'vessel_imo') - self.vessel_imo = attributes[:'vessel_imo'] - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'create_order') - self.create_order = attributes[:'create_order'] - else - self.create_order = false - 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 !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.') - end - - if !@freight_mass_g.nil? && @freight_mass_g < 0 - invalid_properties.push('invalid value for "freight_mass_g", must be greater than or equal to 0.') - end - - if !@freight_volume_cubic_m.nil? && @freight_volume_cubic_m < 0 - invalid_properties.push('invalid value for "freight_volume_cubic_m", must be greater than or equal to 0.') - end - - if !@number_of_containers.nil? && @number_of_containers < 0 - invalid_properties.push('invalid value for "number_of_containers", 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? - container_size_code_validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"]) - return false unless container_size_code_validator.valid?(@container_size_code) - emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - return false unless emissions_scope_validator.valid?(@emissions_scope) - return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000 - return false if !@freight_mass_g.nil? && @freight_mass_g < 0 - return false if !@freight_volume_cubic_m.nil? && @freight_volume_cubic_m < 0 - return false if !@number_of_containers.nil? && @number_of_containers < 0 - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] container_size_code Object to be assigned - def container_size_code=(container_size_code) - validator = EnumAttributeValidator.new('String', ["20GP", "40GP", "22G1", "42G1", "40HC", "45G1"]) - unless validator.valid?(container_size_code) - fail ArgumentError, "invalid value for \"container_size_code\", must be one of #{validator.allowable_values}." - end - @container_size_code = container_size_code - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] emissions_scope Object to be assigned - def emissions_scope=(emissions_scope) - validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"]) - unless validator.valid?(emissions_scope) - fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}." - end - @emissions_scope = emissions_scope - end - - # Custom attribute writer method with validation - # @param [Object] freight_mass_g Value to be assigned - def freight_mass_g=(freight_mass_g) - if !freight_mass_g.nil? && freight_mass_g > 2000000000 - fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.' - end - - if !freight_mass_g.nil? && freight_mass_g < 0 - fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.' - end - - @freight_mass_g = freight_mass_g - end - - # Custom attribute writer method with validation - # @param [Object] freight_volume_cubic_m Value to be assigned - def freight_volume_cubic_m=(freight_volume_cubic_m) - if !freight_volume_cubic_m.nil? && freight_volume_cubic_m < 0 - fail ArgumentError, 'invalid value for "freight_volume_cubic_m", must be greater than or equal to 0.' - end - - @freight_volume_cubic_m = freight_volume_cubic_m - end - - # Custom attribute writer method with validation - # @param [Object] number_of_containers Value to be assigned - def number_of_containers=(number_of_containers) - if !number_of_containers.nil? && number_of_containers < 0 - fail ArgumentError, 'invalid value for "number_of_containers", must be greater than or equal to 0.' - end - - @number_of_containers = number_of_containers - 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 && - destination_country_code == o.destination_country_code && - destination_locode == o.destination_locode && - destination_postal_code == o.destination_postal_code && - origin_country_code == o.origin_country_code && - origin_locode == o.origin_locode && - origin_postal_code == o.origin_postal_code && - container_size_code == o.container_size_code && - emissions_scope == o.emissions_scope && - freight_mass_g == o.freight_mass_g && - freight_volume_cubic_m == o.freight_volume_cubic_m && - number_of_containers == o.number_of_containers && - vessel_imo == o.vessel_imo && - project_id == o.project_id && - create_order == o.create_order - 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 - [destination_country_code, destination_locode, destination_postal_code, origin_country_code, origin_locode, origin_postal_code, container_size_code, emissions_scope, freight_mass_g, freight_volume_cubic_m, number_of_containers, vessel_imo, project_id, create_order].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/estimate.rb b/lib/patch_ruby/models/estimate.rb deleted file mode 100644 index 13a7fe0..0000000 --- a/lib/patch_ruby/models/estimate.rb +++ /dev/null @@ -1,288 +0,0 @@ -=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 Estimate - # A unique uid for the record. UIDs will be prepended by est_prod or est_test depending on the mode it was created in. - attr_accessor :id - - # A boolean indicating if this estimate is a production or demo mode estimate. - attr_accessor :production - - # The type of estimate. Available types are mass, shipping, and crypto. - attr_accessor :type - - # The estimated mass in grams for this estimate. - attr_accessor :mass_g - - # An object returning the order associated with this estimate. See the [Order section](/?id=orders) for the full schema. - attr_accessor :order - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'production' => :'production', - :'type' => :'type', - :'mass_g' => :'mass_g', - :'order' => :'order' - } - 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 - { - :'id' => :'String', - :'production' => :'Boolean', - :'type' => :'String', - :'mass_g' => :'Integer', - :'order' => :'Order' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - :'order' - ]) - 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::EstimatesApi::OPERATIONS') && Patch::EstimatesApi::OPERATIONS.include?(message) - Patch::EstimatesApi.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::Estimate` 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::Estimate`. 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?(:'production') - self.production = attributes[:'production'] - end - - if attributes.key?(:'type') - self.type = attributes[:'type'] - end - - if attributes.key?(:'mass_g') - self.mass_g = attributes[:'mass_g'] - end - - if attributes.key?(:'order') - if (value = attributes[:'order']).is_a?(Hash) - self.order = value - end - self.order = attributes[:'order'] - 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 @id.nil? - invalid_properties.push('invalid value for "id", id cannot be nil.') - end - - if @production.nil? - invalid_properties.push('invalid value for "production", production cannot be nil.') - end - - if @type.nil? - invalid_properties.push('invalid value for "type", type 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 @id.nil? - return false if @production.nil? - return false if @type.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 && - id == o.id && - production == o.production && - type == o.type && - mass_g == o.mass_g && - order == o.order - 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 - [id, production, type, mass_g, order].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/estimate_list_response.rb b/lib/patch_ruby/models/estimate_list_response.rb deleted file mode 100644 index 1c361e2..0000000 --- a/lib/patch_ruby/models/estimate_list_response.rb +++ /dev/null @@ -1,273 +0,0 @@ -=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 EstimateListResponse - attr_accessor :success - - attr_accessor :error - - attr_accessor :data - - attr_accessor :meta - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'success' => :'success', - :'error' => :'error', - :'data' => :'data', - :'meta' => :'meta' - } - 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' => :'Array', - :'meta' => :'MetaIndexObject' - } - 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::EstimateListResponsesApi::OPERATIONS') && Patch::EstimateListResponsesApi::OPERATIONS.include?(message) - Patch::EstimateListResponsesApi.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::EstimateListResponse` 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::EstimateListResponse`. 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') - if (value = attributes[:'data']).is_a?(Array) - self.data = value - end - end - - if attributes.key?(:'meta') - self.meta = attributes[:'meta'] - 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 - - if @meta.nil? - invalid_properties.push('invalid value for "meta", meta 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? - return false if @meta.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 && - meta == o.meta - 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, meta].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/estimate_response.rb b/lib/patch_ruby/models/estimate_response.rb deleted file mode 100644 index a1c5648..0000000 --- a/lib/patch_ruby/models/estimate_response.rb +++ /dev/null @@ -1,257 +0,0 @@ -=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 EstimateResponse - 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' => :'Estimate' - } - 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::EstimateResponsesApi::OPERATIONS') && Patch::EstimateResponsesApi::OPERATIONS.include?(message) - Patch::EstimateResponsesApi.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::EstimateResponse` 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::EstimateResponse`. 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/version.rb b/lib/patch_ruby/version.rb index c802198..5b87bb4 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '2.5.0' + VERSION = '2.6.0' end diff --git a/spec/api/estimates_api_spec.rb b/spec/api/estimates_api_spec.rb deleted file mode 100644 index 0aa8535..0000000 --- a/spec/api/estimates_api_spec.rb +++ /dev/null @@ -1,70 +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' - -# Unit tests for Patch::EstimatesApi -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'EstimatesApi' do - before do - # run before each test - @api_instance = Patch::EstimatesApi.new - end - - after do - # run after each test - end - - describe 'test an instance of EstimatesApi' do - it 'should create an instance of EstimatesApi' do - expect(@api_instance).to be_instance_of(Patch::EstimatesApi) - end - end - - # unit tests for create_mass_estimate - # Create an estimate based on mass of CO2 - # 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 - # @param [Hash] opts the optional parameters - # @return [EstimateResponse] - describe 'create_mass_estimate 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 retrieve_estimate - # Retrieves an estimate - # Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. - # @param id - # @param [Hash] opts the optional parameters - # @return [EstimateResponse] - describe 'retrieve_estimate 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 retrieve_estimates - # Retrieves a list of estimates - # 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 - # @return [EstimateListResponse] - describe 'retrieve_estimates 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/models/create_mass_estimate_request_spec.rb b/spec/models/create_mass_estimate_request_spec.rb deleted file mode 100644 index a57d2fe..0000000 --- a/spec/models/create_mass_estimate_request_spec.rb +++ /dev/null @@ -1,46 +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::CreateMassEstimateRequest -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'CreateMassEstimateRequest' do - before do - # run before each test - @instance = build(:create_mass_estimate_request) - end - - after do - # run after each test - end - - it_behaves_like "a generated class" do - let(:instance) { @instance } - let(:instance_hash) { { project_id: @instance.project_id, mass_g: @instance.mass_g, create_order: @instance.create_order } } - let(:nullable_properties) { Set.new([:create_order]) } - end - - describe 'test an instance of CreateMassEstimateRequest' do - it 'should create an instance of CreateMassEstimateRequest' do - expect(@instance).to be_instance_of(Patch::CreateMassEstimateRequest) - 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/estimate_list_response_spec.rb b/spec/models/estimate_list_response_spec.rb deleted file mode 100644 index 60dd673..0000000 --- a/spec/models/estimate_list_response_spec.rb +++ /dev/null @@ -1,64 +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::EstimateListResponse -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'EstimateListResponse' do - before do - # run before each test - @instance = build(:estimate_list_response) - end - - after do - # run after each test - end - - it_behaves_like "a generated class" do - let(:instance) { @instance } - let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data, meta: @instance.meta } } - let(:nullable_properties) { Set.new([:error]) } - end - - describe 'test an instance of EstimateListResponse' do - it 'should create an instance of EstimateListResponse' do - expect(@instance).to be_instance_of(Patch::EstimateListResponse) - end - end - describe 'test attribute "success"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "error"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "data"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "meta"' 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/estimate_response_spec.rb b/spec/models/estimate_response_spec.rb deleted file mode 100644 index 651328d..0000000 --- a/spec/models/estimate_response_spec.rb +++ /dev/null @@ -1,58 +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::EstimateResponse -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'EstimateResponse' do - before do - # run before each test - @instance = build(:estimate_response) - end - - after do - # run after each test - end - - it_behaves_like "a generated class" do - let(:instance) { @instance } - let(:instance_hash) { { success: @instance.success, error: @instance.error, data: @instance.data } } - let(:nullable_properties) { Set.new([:error]) } - end - - describe 'test an instance of EstimateResponse' do - it 'should create an instance of EstimateResponse' do - expect(@instance).to be_instance_of(Patch::EstimateResponse) - end - end - describe 'test attribute "success"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "error"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "data"' 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/estimate_spec.rb b/spec/models/estimate_spec.rb deleted file mode 100644 index 141b094..0000000 --- a/spec/models/estimate_spec.rb +++ /dev/null @@ -1,65 +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::Estimate -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'Estimate' do - before do - # run before each test - @instance = build(:estimate) - end - - after do - # run after each test - end - - it_behaves_like "a generated class" do - let(:instance) { @instance } - let(:instance_hash) { { id: @instance.id, order: @instance.order.to_hash, production: @instance.production, type: @instance.type } } - let(:nullable_properties) { Set.new([:order]) } - end - - describe 'test an instance of Estimate' do - it 'should create an instance of Estimate' do - expect(@instance).to be_instance_of(Patch::Estimate) - 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 "type"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "order"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end -end From b5f743e7085b842773e5cb3cf5cee129b70e5a3e Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Fri, 7 Nov 2025 12:45:43 -0800 Subject: [PATCH 2/3] Tweaks --- README.md | 52 -- lib/patch_ruby/api/estimates_api.rb | 612 ------------------ spec/api/orders_api_spec.rb | 1 - .../create_mass_estimate_requests.rb | 6 - spec/factories/estimate_list_responses.rb | 8 - spec/factories/estimate_responses.rb | 7 - spec/factories/estimates.rb | 8 - spec/integration/estimates_spec.rb | 218 ------- spec/integration/orders_spec.rb | 25 - 9 files changed, 937 deletions(-) delete mode 100644 lib/patch_ruby/api/estimates_api.rb delete mode 100644 spec/factories/create_mass_estimate_requests.rb delete mode 100644 spec/factories/estimate_list_responses.rb delete mode 100644 spec/factories/estimate_responses.rb delete mode 100644 spec/factories/estimates.rb delete mode 100644 spec/integration/estimates_spec.rb diff --git a/README.md b/README.md index 682bef0..9231ae9 100644 --- a/README.md +++ b/README.md @@ -110,58 +110,6 @@ page = 1 # Pass in which page of orders you'd like Patch::Order.retrieve_orders(page: page) ``` -### Estimates - -Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled. - -[API Reference](https://docs.patch.io/#/?id=estimates) - -#### Examples - -```ruby -# Create a mass estimate -mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne) -Patch::Estimate.create_mass_estimate(mass_g: mass) - -# Create a vehicle estimate -distance_m = 1_000_000 # Pass in the shipping distance in meters -make = "Toyota" # Pass in the car make -model = "Corolla" # Pass in the car model -year = 2000 # Pass in the car year -Patch::Estimate.create_vehicle_estimate( - distance_m: distance_m, - make: make, - model: model, - year: year -) - -# Create a Bitcoin estimate -transaction_value_btc_sats = 1000; # [Optional] Pass in the transaction value in satoshis -Patch::Estimate.create_bitcoin_estimate(transaction_value_btc_sats: transaction_value_btc_sats) - -# Create an ecommerce estimate -distance_m = 1_000_000 # Pass in the shipping distance in meters -package_mass_g = 10_000 # Pass in the weight of the package shipped in grams -transportation_method = "air" # Pass in the transportation method (air, rail, road, sea) -Patch::Estimate.create_ecommerce_estimate( - distance_m: distance_m, - package_mass_g: package_mass_g, - transportation_method: transportation_method -) - -## You can also specify a project-id field (optional) to be used instead of the preferred one -project_id = 'pro_test_1234' # Pass in the project's ID -Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id) - -# Retrieve an estimate -estimate_id = 'est_test_1234' -Patch::Estimate.retrieve_estimate(estimate_id) - -# Retrieve a list of estimates -page = 1 # Pass in which page of estimates you'd like -Patch::Estimate.retrieve_estimates(page: page) -``` - ### Projects Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project. diff --git a/lib/patch_ruby/api/estimates_api.rb b/lib/patch_ruby/api/estimates_api.rb deleted file mode 100644 index fee6fb1..0000000 --- a/lib/patch_ruby/api/estimates_api.rb +++ /dev/null @@ -1,612 +0,0 @@ -=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 EstimatesApi - OPERATIONS = [ - :create_air_shipping_estimate, - :create_bitcoin_estimate, - :create_mass_estimate, - :create_rail_shipping_estimate, - :create_road_shipping_estimate, - :create_sea_shipping_estimate, - :retrieve_estimate, - :retrieve_estimates, - ] - - attr_accessor :api_client - - def initialize(api_client = ApiClient.default) - @api_client = api_client - end - # Creates a GLEC air shipping estimate given freight mass and logistics - # Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. - # @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) - data, _status_code, _headers = create_air_shipping_estimate_with_http_info(_create_air_shipping_estimate_request, opts) - data - end - - # Creates a GLEC air shipping estimate given freight mass and logistics - # Creates a GLEC air shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. - # @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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_air_shipping_estimate ...' - end - # verify the required parameter 'create_air_shipping_estimate_request' is set - if @api_client.config.client_side_validation && create_air_shipping_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_air_shipping_estimate_request' when calling EstimatesApi.create_air_shipping_estimate" - end - # resource path - local_var_path = '/v1/estimates/shipping/air' - - # 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_air_shipping_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_air_shipping_estimate", - :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: EstimatesApi#create_air_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Create a bitcoin estimate given a timestamp and transaction value - # Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `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) - data, _status_code, _headers = create_bitcoin_estimate_with_http_info(_create_bitcoin_estimate_request, opts) - data - end - - # Create a bitcoin estimate given a timestamp and transaction value - # Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_bitcoin_estimate ...' - end - # verify the required parameter 'create_bitcoin_estimate_request' is set - if @api_client.config.client_side_validation && create_bitcoin_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_bitcoin_estimate_request' when calling EstimatesApi.create_bitcoin_estimate" - end - # resource path - local_var_path = '/v1/estimates/crypto/btc' - - # 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_bitcoin_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_bitcoin_estimate", - :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: EstimatesApi#create_bitcoin_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Create an estimate based on mass of CO2 - # 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) - data, _status_code, _headers = create_mass_estimate_with_http_info(_create_mass_estimate_request, opts) - data - end - - # Create an estimate based on mass of CO2 - # 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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_mass_estimate ...' - end - # verify the required parameter 'create_mass_estimate_request' is set - if @api_client.config.client_side_validation && create_mass_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_mass_estimate_request' when calling EstimatesApi.create_mass_estimate" - end - # resource path - local_var_path = '/v1/estimates/mass' - - # 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_mass_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_mass_estimate", - :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: EstimatesApi#create_mass_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Creates a GLEC rail shipping estimate given freight mass and logistics - # Creates a GLEC rail shipping estimate for the amount of CO2 to be compensated. An order in the `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) - data, _status_code, _headers = create_rail_shipping_estimate_with_http_info(_create_rail_shipping_estimate_request, opts) - data - end - - # Creates a GLEC rail shipping estimate given freight mass and logistics - # Creates a GLEC rail shipping estimate for the amount of CO2 to be compensated. An order in the `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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_rail_shipping_estimate ...' - end - # verify the required parameter 'create_rail_shipping_estimate_request' is set - if @api_client.config.client_side_validation && create_rail_shipping_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_rail_shipping_estimate_request' when calling EstimatesApi.create_rail_shipping_estimate" - end - # resource path - local_var_path = '/v1/estimates/shipping/rail' - - # 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_rail_shipping_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_rail_shipping_estimate", - :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: EstimatesApi#create_rail_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Creates a GLEC road shipping estimate given freight mass and logistics - # Creates a GLEC road shipping estimate for the amount of CO2 to be compensated. An order in the `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) - data, _status_code, _headers = create_road_shipping_estimate_with_http_info(_create_road_shipping_estimate_request, opts) - data - end - - # Creates a GLEC road shipping estimate given freight mass and logistics - # Creates a GLEC road shipping estimate for the amount of CO2 to be compensated. An order in the `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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_road_shipping_estimate ...' - end - # verify the required parameter 'create_road_shipping_estimate_request' is set - if @api_client.config.client_side_validation && create_road_shipping_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_road_shipping_estimate_request' when calling EstimatesApi.create_road_shipping_estimate" - end - # resource path - local_var_path = '/v1/estimates/shipping/road' - - # 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_road_shipping_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_road_shipping_estimate", - :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: EstimatesApi#create_road_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Creates a GLEC sea shipping estimate given freight mass and logistics - # Creates a GLEC sea shipping estimate for the amount of CO2 to be compensated. An order in the `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) - data, _status_code, _headers = create_sea_shipping_estimate_with_http_info(_create_sea_shipping_estimate_request, opts) - data - end - - # Creates a GLEC sea shipping estimate given freight mass and logistics - # Creates a GLEC sea shipping estimate for the amount of CO2 to be compensated. An order in the `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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.create_sea_shipping_estimate ...' - end - # verify the required parameter 'create_sea_shipping_estimate_request' is set - if @api_client.config.client_side_validation && create_sea_shipping_estimate_request.nil? - fail ArgumentError, "Missing the required parameter 'create_sea_shipping_estimate_request' when calling EstimatesApi.create_sea_shipping_estimate" - end - # resource path - local_var_path = '/v1/estimates/shipping/sea' - - # 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_sea_shipping_estimate_request) - - # return_type - return_type = opts[:debug_return_type] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.create_sea_shipping_estimate", - :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: EstimatesApi#create_sea_shipping_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Retrieves an estimate - # 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 = {}) - - data, _status_code, _headers = retrieve_estimate_with_http_info(id, opts) - data - end - - # Retrieves an estimate - # 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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimate ...' - end - # verify the required parameter 'id' is set - if @api_client.config.client_side_validation && id.nil? - fail ArgumentError, "Missing the required parameter 'id' when calling EstimatesApi.retrieve_estimate" - end - # resource path - local_var_path = '/v1/estimates/{id}'.sub('{' + 'id' + '}', CGI.escape(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']) - 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] || 'EstimateResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.retrieve_estimate", - :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(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimate\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - - # Retrieves a list of estimates - # 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 = {}) - - data, _status_code, _headers = retrieve_estimates_with_http_info(opts) - data - end - - # Retrieves a list of estimates - # 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 - @api_client.config.logger.debug 'Calling API: EstimatesApi.retrieve_estimates ...' - end - # resource path - local_var_path = '/v1/estimates' - - # query parameters - query_params = opts[:query_params] || {} - query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? - - # 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] || 'EstimateListResponse' - - # auth_names - auth_names = opts[:debug_auth_names] || ['bearer_auth'] - - new_options = opts.merge( - :operation => :"EstimatesApi.retrieve_estimates", - :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(:GET, local_var_path, new_options) - if @api_client.config.debugging - @api_client.config.logger.debug "API called: EstimatesApi#retrieve_estimates\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" - end - return data, status_code, headers - end - end -end diff --git a/spec/api/orders_api_spec.rb b/spec/api/orders_api_spec.rb index 4e08208..4d921a2 100644 --- a/spec/api/orders_api_spec.rb +++ b/spec/api/orders_api_spec.rb @@ -46,7 +46,6 @@ # unit tests for create_order # Creates an order - # Creates an order in the `placed` state. To create a `draft` order, create an estimate first. # @param create_order_request # @param [Hash] opts the optional parameters # @return [OrderResponse] diff --git a/spec/factories/create_mass_estimate_requests.rb b/spec/factories/create_mass_estimate_requests.rb deleted file mode 100644 index c86faa7..0000000 --- a/spec/factories/create_mass_estimate_requests.rb +++ /dev/null @@ -1,6 +0,0 @@ -FactoryBot.define do - factory :create_mass_estimate_request, class: Patch::CreateMassEstimateRequest do - sequence(:project_id) { |n| n } - mass_g { 100 } - end -end diff --git a/spec/factories/estimate_list_responses.rb b/spec/factories/estimate_list_responses.rb deleted file mode 100644 index 9aa3af6..0000000 --- a/spec/factories/estimate_list_responses.rb +++ /dev/null @@ -1,8 +0,0 @@ -FactoryBot.define do - factory :estimate_list_response, class: Patch::EstimateListResponse do - success { true } - error { {} } - data { {} } - meta { {} } - end -end diff --git a/spec/factories/estimate_responses.rb b/spec/factories/estimate_responses.rb deleted file mode 100644 index ff27c80..0000000 --- a/spec/factories/estimate_responses.rb +++ /dev/null @@ -1,7 +0,0 @@ -FactoryBot.define do - factory :estimate_response, class: Patch::EstimateResponse do - success { true } - error { {} } - data { {} } - end -end diff --git a/spec/factories/estimates.rb b/spec/factories/estimates.rb deleted file mode 100644 index afc8033..0000000 --- a/spec/factories/estimates.rb +++ /dev/null @@ -1,8 +0,0 @@ -FactoryBot.define do - factory :estimate, class: Patch::Estimate do - sequence(:id) { |n| n } - association :order - production { false } - type { "mass" } - end -end diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb deleted file mode 100644 index f08c640..0000000 --- a/spec/integration/estimates_spec.rb +++ /dev/null @@ -1,218 +0,0 @@ -RSpec.describe 'Estimates Integration' do - it 'supports create, retrieve and list' do - create_estimate_response = Patch::Estimate.create_mass_estimate(mass_g: 100) - estimate_id = create_estimate_response.data.id - - retrieve_estimate_response = Patch::Estimate.retrieve_estimate(estimate_id) - expect(retrieve_estimate_response.data.id).to eq estimate_id - - page_limit = 1 - next_page = 1 - estimates = [] - - while !next_page.nil? && next_page <= page_limit - retrieve_estimates_response = Patch::Estimate.retrieve_estimates(page: next_page) - next_page = retrieve_estimates_response.meta.next_page - estimates += retrieve_estimates_response.data - end - - expect(estimates.length).not_to be_zero - end - - it 'supports creating bitcoin estimates with partial information' do - bitcoin_estimate = Patch::Estimate.create_bitcoin_estimate() - - expect(bitcoin_estimate.data.type).to eq 'bitcoin' - expect(bitcoin_estimate.data.mass_g).to be >= 2_000 - end - - it 'supports creating bitcoin estimates with a transaction amount' do - bitcoin_estimate = Patch::Estimate.create_bitcoin_estimate( - transaction_value_btc_sats: 10_000 - ) - - bitcoin_estimate_2 = Patch::Estimate.create_bitcoin_estimate( - transaction_value_btc_sats: 100_000 - ) - - expect(bitcoin_estimate.data.type).to eq 'bitcoin' - expect(bitcoin_estimate.data.mass_g).to be < bitcoin_estimate_2.data.mass_g - end - - it 'supports creating bitcoin estimates with a timestamp' do - bitcoin_estimate_1 = Patch::Estimate.create_bitcoin_estimate( - timestamp: '2021-06-01T20:31:18.403Z' - ) - - bitcoin_estimate_2 = Patch::Estimate.create_bitcoin_estimate( - timestamp: '2021-07-01T20:31:18.403Z' - ) - - expect(bitcoin_estimate_1.data.type).to eq 'bitcoin' - expect(bitcoin_estimate_1.data.mass_g).to be > bitcoin_estimate_2.data.mass_g # Bitcoin was emitting less in July 2021 than in June - end - - it 'supports creating bitcoin estimates with a average_daily_balance_btc_sats' do - bitcoin_estimate_1 = Patch::Estimate.create_bitcoin_estimate( - average_daily_balance_btc_sats: 1000000 - ) - - bitcoin_estimate_2 = Patch::Estimate.create_bitcoin_estimate( - average_daily_balance_btc_sats: 10000000 - ) - - expect(bitcoin_estimate_1.data.type).to eq 'bitcoin' - expect(bitcoin_estimate_1.data.mass_g).to be < bitcoin_estimate_2.data.mass_g - end - - context "when creating an air shipping estimate" do - it "supports creating an estimate using airports" do - air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate( - aircraft_type: "cargo", - create_order: false, - destination_airport: "JFK", - freight_mass_g: 31_300, - origin_airport: "SFO" - ) - expect(air_shipping_estimate.data.type).to eq('shipping_air') - expect(air_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate with an order" do - air_shipping_estimate = Patch::Estimate.create_air_shipping_estimate( - aircraft_type: "cargo", - create_order: true, - destination_airport: "JFK", - freight_mass_g: 19_140, - origin_airport: "SFO" - ) - expect(air_shipping_estimate.data.type).to eq('shipping_air') - expect(air_shipping_estimate.data.mass_g).to be > 0 - expect(air_shipping_estimate.data.order.amount).to be > 0 - end - end - - context "when creating a rail shipping estimate" do - it "supports creating an estimate using locodes" do - rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate( - create_order: false, - destination_locode: "USSEA", - emissions_scope: "wtw", - freight_mass_g: 419_060, - fuel_type: "diesel", - origin_locode: "USSD2" - ) - expect(rail_shipping_estimate.data.type).to eq('shipping_rail') - expect(rail_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate using postal codes" do - rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate( - create_order: false, - destination_country_code: "US", - destination_postal_code: "97209", - emissions_scope: "wtw", - freight_mass_g: 226_000, - fuel_type: "diesel", - origin_country_code: "US", - origin_postal_code: "90210" - ) - expect(rail_shipping_estimate.data.type).to eq('shipping_rail') - expect(rail_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate with an order" do - rail_shipping_estimate = Patch::Estimate.create_rail_shipping_estimate( - create_order: true, - destination_locode: "USSEA", - freight_mass_g: 359_000, - origin_locode: "USSD2" - ) - expect(rail_shipping_estimate.data.type).to eq('shipping_rail') - expect(rail_shipping_estimate.data.mass_g).to be > 0 - expect(rail_shipping_estimate.data.order.amount).to be > 0 - end - end - - context "when creating a road shipping estimate" do - it "supports creating an estimate using locodes" do - road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate( - create_order: false, - container_size_code: "20GP", - destination_locode: "USSEA", - emissions_scope: "wtw", - freight_mass_g: 124_870, - origin_locode: "USSD2" - ) - expect(road_shipping_estimate.data.type).to eq('shipping_road') - expect(road_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate using postal codes" do - road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate( - create_order: false, - destination_country_code: "US", - destination_postal_code: "97209", - emissions_scope: "wtw", - freight_mass_g: 226_000, - origin_country_code: "US", - origin_postal_code: "90210" - ) - expect(road_shipping_estimate.data.type).to eq('shipping_road') - expect(road_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate with an order" do - road_shipping_estimate = Patch::Estimate.create_road_shipping_estimate( - create_order: true, - destination_locode: "USSEA", - freight_mass_g: 359_000, - origin_locode: "USSD2" - ) - expect(road_shipping_estimate.data.type).to eq('shipping_road') - expect(road_shipping_estimate.data.mass_g).to be > 0 - expect(road_shipping_estimate.data.order.amount).to be > 0 - end - end - - context "when creating a sea shipping estimate" do - it "supports creating an estimate using locodes" do - sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate( - create_order: false, - container_size_code: "20GP", - destination_locode: "HKHKG", - emissions_scope: "wtw", - freight_mass_g: 124_870, - origin_locode: "FRMRS" - ) - expect(sea_shipping_estimate.data.type).to eq('shipping_sea') - expect(sea_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate using postal codes" do - sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate( - create_order: false, - destination_country_code: "US", - destination_postal_code: "97209", - emissions_scope: "wtw", - freight_mass_g: 226_000, - origin_country_code: "US", - origin_postal_code: "90210" - ) - expect(sea_shipping_estimate.data.type).to eq('shipping_sea') - expect(sea_shipping_estimate.data.mass_g).to be > 0 - end - - it "supports creating an estimate with an order" do - sea_shipping_estimate = Patch::Estimate.create_sea_shipping_estimate( - create_order: true, - destination_locode: "USSEA", - freight_mass_g: 359_000, - origin_locode: "USSD2" - ) - expect(sea_shipping_estimate.data.type).to eq('shipping_sea') - expect(sea_shipping_estimate.data.mass_g).to be > 0 - expect(sea_shipping_estimate.data.order.amount).to be > 0 - end - end -end diff --git a/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index c4bb31f..9bb3cbf 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -99,31 +99,6 @@ expect(create_order_response.data.state).to eq("draft") end - it 'supports place and cancel for orders created via an estimate' do - create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true) - order_to_place_id = create_estimate_to_place_response.data.order.id - - place_order_response = Patch::Order.place_order(order_to_place_id) - expect(place_order_response.data.state).to eq 'placed' - - create_estimate_to_cancel_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true) - order_to_cancel_id = create_estimate_to_cancel_response.data.order.id - - cancel_order_response = Patch::Order.cancel_order(order_to_cancel_id) - expect(cancel_order_response.data.state).to eq 'cancelled' - end - - it 'supports place order with issued_to' do - create_estimate_to_place_response = Patch::Estimate.create_mass_estimate(mass_g: 100, create_order: true) - order_to_place_id = create_estimate_to_place_response.data.order.id - - issued_to = { email: 'envimpact@companya.com', name: 'Company A' } - place_order_response = Patch::Order.place_order(order_to_place_id, issued_to: issued_to) - expect(place_order_response.data.state).to eq 'placed' - expect(place_order_response.data.issued_to.email).to eq(issued_to[:email]) - expect(place_order_response.data.issued_to.name).to eq(issued_to[:name]) - end - it 'supports create with a vintage year' do create_order_response = Patch::Order.create_order(amount: 100, unit: "g", vintage_year: 2022) From fa0374acc69a1c6572d4b7699cc8a338872dca39 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Fri, 7 Nov 2025 12:49:03 -0800 Subject: [PATCH 3/3] Fix tech type in spec --- spec/integration/projects_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/projects_spec.rb b/spec/integration/projects_spec.rb index 8bd6211..5a3b0e7 100644 --- a/spec/integration/projects_spec.rb +++ b/spec/integration/projects_spec.rb @@ -25,7 +25,7 @@ expect(project.country).to eq country end - type = 'dac' + type = 'biogas' projects = Patch::Project.retrieve_projects(type: type) projects.data.map do |project| expect(project.type).to eq type