From 7f587c22b8d88fd13a1d28fe698ae10865bdda62 Mon Sep 17 00:00:00 2001 From: James Klein Date: Wed, 11 Aug 2021 16:23:03 -0600 Subject: [PATCH 1/8] update sdk post-addition of metadata query param --- bin/rspec | 29 ++ lib/patch_ruby/api/orders_api.rb | 6 + .../models/bulk_create_success_response.rb | 237 +++++++++++++++ .../models/create_bulk_offsets_request.rb | 271 ++++++++++++++++++ .../models/create_bulk_recs_request.rb | 271 ++++++++++++++++++ .../create_ethereum_estimate_request.rb | 13 +- lib/patch_ruby/models/error.rb | 237 +++++++++++++++ lib/patch_ruby/models/error_response.rb | 2 +- lib/patch_ruby/models/estimate.rb | 2 +- 9 files changed, 1065 insertions(+), 3 deletions(-) create mode 100755 bin/rspec create mode 100644 lib/patch_ruby/models/bulk_create_success_response.rb create mode 100644 lib/patch_ruby/models/create_bulk_offsets_request.rb create mode 100644 lib/patch_ruby/models/create_bulk_recs_request.rb create mode 100644 lib/patch_ruby/models/error.rb diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..a6c7852 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index 20f8b64..c73265f 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -281,6 +281,8 @@ def retrieve_order_with_http_info(id, opts = {}) # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [String] :metadata_ext_id + # @option opts [String] :metadata_disregarded # @return [OrderListResponse] def retrieve_orders(opts = {}) data, _status_code, _headers = retrieve_orders_with_http_info(opts) @@ -291,6 +293,8 @@ def retrieve_orders(opts = {}) # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [String] :metadata_ext_id + # @option opts [String] :metadata_disregarded # @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers def retrieve_orders_with_http_info(opts = {}) if @api_client.config.debugging @@ -302,6 +306,8 @@ def retrieve_orders_with_http_info(opts = {}) # query parameters query_params = opts[:query_params] || {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'metadata[ext_id]'] = opts[:'metadata_ext_id'] if !opts[:'metadata_ext_id'].nil? + query_params[:'metadata[disregarded]'] = opts[:'metadata_disregarded'] if !opts[:'metadata_disregarded'].nil? # header parameters header_params = opts[:header_params] || {} diff --git a/lib/patch_ruby/models/bulk_create_success_response.rb b/lib/patch_ruby/models/bulk_create_success_response.rb new file mode 100644 index 0000000..6136c0e --- /dev/null +++ b/lib/patch_ruby/models/bulk_create_success_response.rb @@ -0,0 +1,237 @@ +=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 'date' + +module Patch + class BulkCreateSuccessResponse + attr_accessor :success + + attr_accessor :error + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'success' => :'success', + :'error' => :'error' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'success' => :'Boolean', + :'error' => :'Error' + } + end + + # Set with nullable attributes. + def self.openapi_nullable + nullable_properties = Set.new + + nullable_properties + 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::BulkCreateSuccessResponsesApi::OPERATIONS') && Patch::BulkCreateSuccessResponsesApi::OPERATIONS.include?(message) + Patch::BulkCreateSuccessResponsesApi.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::BulkCreateSuccessResponse` 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::BulkCreateSuccessResponse`. 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 + 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 @error.nil? + invalid_properties.push('invalid value for "error", error 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 @error.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 + 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].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional + 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 :DateTime + DateTime.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 + Patch.const_get(type).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_bulk_offsets_request.rb b/lib/patch_ruby/models/create_bulk_offsets_request.rb new file mode 100644 index 0000000..681a25a --- /dev/null +++ b/lib/patch_ruby/models/create_bulk_offsets_request.rb @@ -0,0 +1,271 @@ +=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 'date' + +module Patch + class CreateBulkOffsetsRequest + attr_accessor :price_cents_usd + + attr_accessor :project_id + + attr_accessor :vintage_year + + attr_accessor :serial_number + + attr_accessor :count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'price_cents_usd' => :'price_cents_usd', + :'project_id' => :'project_id', + :'vintage_year' => :'vintage_year', + :'serial_number' => :'serial_number', + :'count' => :'count' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'price_cents_usd' => :'Integer', + :'project_id' => :'String', + :'vintage_year' => :'Integer', + :'serial_number' => :'String', + :'count' => :'Integer' + } + end + + # Set with nullable attributes. + def self.openapi_nullable + nullable_properties = Set.new + + nullable_properties.add("serial_number") + + nullable_properties + 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::CreateBulkOffsetsRequestsApi::OPERATIONS') && Patch::CreateBulkOffsetsRequestsApi::OPERATIONS.include?(message) + Patch::CreateBulkOffsetsRequestsApi.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::CreateBulkOffsetsRequest` 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::CreateBulkOffsetsRequest`. 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?(:'price_cents_usd') + self.price_cents_usd = attributes[:'price_cents_usd'] + end + + if attributes.key?(:'project_id') + self.project_id = attributes[:'project_id'] + end + + if attributes.key?(:'vintage_year') + self.vintage_year = attributes[:'vintage_year'] + end + + if attributes.key?(:'serial_number') + self.serial_number = attributes[:'serial_number'] + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + 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 !@price_cents_usd.nil? && @price_cents_usd < 1 + invalid_properties.push('invalid value for "price_cents_usd", must be greater than or equal to 1.') + 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 !@price_cents_usd.nil? && @price_cents_usd < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] price_cents_usd Value to be assigned + def price_cents_usd=(price_cents_usd) + if !price_cents_usd.nil? && price_cents_usd < 1 + fail ArgumentError, 'invalid value for "price_cents_usd", must be greater than or equal to 1.' + end + + @price_cents_usd = price_cents_usd + 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 && + price_cents_usd == o.price_cents_usd && + project_id == o.project_id && + vintage_year == o.vintage_year && + serial_number == o.serial_number && + count == o.count + 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 + [price_cents_usd, project_id, vintage_year, serial_number, count].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional + 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 :DateTime + DateTime.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 + Patch.const_get(type).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_bulk_recs_request.rb b/lib/patch_ruby/models/create_bulk_recs_request.rb new file mode 100644 index 0000000..420eb4c --- /dev/null +++ b/lib/patch_ruby/models/create_bulk_recs_request.rb @@ -0,0 +1,271 @@ +=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 'date' + +module Patch + class CreateBulkRecsRequest + attr_accessor :price_cents_usd + + attr_accessor :project_id + + attr_accessor :vintage_year + + attr_accessor :serial_number + + attr_accessor :count + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'price_cents_usd' => :'price_cents_usd', + :'project_id' => :'project_id', + :'vintage_year' => :'vintage_year', + :'serial_number' => :'serial_number', + :'count' => :'count' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'price_cents_usd' => :'Integer', + :'project_id' => :'String', + :'vintage_year' => :'Integer', + :'serial_number' => :'String', + :'count' => :'Integer' + } + end + + # Set with nullable attributes. + def self.openapi_nullable + nullable_properties = Set.new + + nullable_properties.add("serial_number") + + nullable_properties + 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::CreateBulkRecsRequestsApi::OPERATIONS') && Patch::CreateBulkRecsRequestsApi::OPERATIONS.include?(message) + Patch::CreateBulkRecsRequestsApi.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::CreateBulkRecsRequest` 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::CreateBulkRecsRequest`. 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?(:'price_cents_usd') + self.price_cents_usd = attributes[:'price_cents_usd'] + end + + if attributes.key?(:'project_id') + self.project_id = attributes[:'project_id'] + end + + if attributes.key?(:'vintage_year') + self.vintage_year = attributes[:'vintage_year'] + end + + if attributes.key?(:'serial_number') + self.serial_number = attributes[:'serial_number'] + end + + if attributes.key?(:'count') + self.count = attributes[:'count'] + 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 !@price_cents_usd.nil? && @price_cents_usd < 1 + invalid_properties.push('invalid value for "price_cents_usd", must be greater than or equal to 1.') + 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 !@price_cents_usd.nil? && @price_cents_usd < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] price_cents_usd Value to be assigned + def price_cents_usd=(price_cents_usd) + if !price_cents_usd.nil? && price_cents_usd < 1 + fail ArgumentError, 'invalid value for "price_cents_usd", must be greater than or equal to 1.' + end + + @price_cents_usd = price_cents_usd + 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 && + price_cents_usd == o.price_cents_usd && + project_id == o.project_id && + vintage_year == o.vintage_year && + serial_number == o.serial_number && + count == o.count + 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 + [price_cents_usd, project_id, vintage_year, serial_number, count].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional + 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 :DateTime + DateTime.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 + Patch.const_get(type).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_ethereum_estimate_request.rb b/lib/patch_ruby/models/create_ethereum_estimate_request.rb index 3521122..b5d30bf 100644 --- a/lib/patch_ruby/models/create_ethereum_estimate_request.rb +++ b/lib/patch_ruby/models/create_ethereum_estimate_request.rb @@ -18,6 +18,8 @@ class CreateEthereumEstimateRequest attr_accessor :gas_used + attr_accessor :transaction_value_eth_gwei + attr_accessor :project_id attr_accessor :create_order @@ -27,6 +29,7 @@ def self.attribute_map { :'timestamp' => :'timestamp', :'gas_used' => :'gas_used', + :'transaction_value_eth_gwei' => :'transaction_value_eth_gwei', :'project_id' => :'project_id', :'create_order' => :'create_order' } @@ -37,6 +40,7 @@ def self.openapi_types { :'timestamp' => :'String', :'gas_used' => :'Integer', + :'transaction_value_eth_gwei' => :'Integer', :'project_id' => :'String', :'create_order' => :'Boolean' } @@ -50,6 +54,8 @@ def self.openapi_nullable nullable_properties.add("gas_used") + nullable_properties.add("transaction_value_eth_gwei") + nullable_properties.add("project_id") nullable_properties.add("create_order") @@ -91,6 +97,10 @@ def initialize(attributes = {}) self.gas_used = attributes[:'gas_used'] end + if attributes.key?(:'transaction_value_eth_gwei') + self.transaction_value_eth_gwei = attributes[:'transaction_value_eth_gwei'] + end + if attributes.key?(:'project_id') self.project_id = attributes[:'project_id'] end @@ -120,6 +130,7 @@ def ==(o) self.class == o.class && timestamp == o.timestamp && gas_used == o.gas_used && + transaction_value_eth_gwei == o.transaction_value_eth_gwei && project_id == o.project_id && create_order == o.create_order end @@ -133,7 +144,7 @@ def eql?(o) # Calculates hash code according to all attributes. # @return [Integer] Hash code def hash - [timestamp, gas_used, project_id, create_order].hash + [timestamp, gas_used, transaction_value_eth_gwei, project_id, create_order].hash end # Builds the object from hash diff --git a/lib/patch_ruby/models/error.rb b/lib/patch_ruby/models/error.rb new file mode 100644 index 0000000..6913353 --- /dev/null +++ b/lib/patch_ruby/models/error.rb @@ -0,0 +1,237 @@ +=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 'date' + +module Patch + class Error + attr_accessor :code + + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'code' => :'code', + :'message' => :'message' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'code' => :'Integer', + :'message' => :'String' + } + end + + # Set with nullable attributes. + def self.openapi_nullable + nullable_properties = Set.new + + nullable_properties + 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::ErrorsApi::OPERATIONS') && Patch::ErrorsApi::OPERATIONS.include?(message) + Patch::ErrorsApi.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::Error` 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::Error`. 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?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + 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 @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message 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 @code.nil? + return false if @message.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 && + code == o.code && + message == o.message + 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 + [code, message].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional + 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 :DateTime + DateTime.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 + Patch.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/patch_ruby/models/error_response.rb b/lib/patch_ruby/models/error_response.rb index dd0ff95..9aa261b 100644 --- a/lib/patch_ruby/models/error_response.rb +++ b/lib/patch_ruby/models/error_response.rb @@ -33,7 +33,7 @@ def self.attribute_map def self.openapi_types { :'success' => :'Boolean', - :'error' => :'Object', + :'error' => :'Error', :'data' => :'Object' } end diff --git a/lib/patch_ruby/models/estimate.rb b/lib/patch_ruby/models/estimate.rb index 69f2bd7..3ab7b3d 100644 --- a/lib/patch_ruby/models/estimate.rb +++ b/lib/patch_ruby/models/estimate.rb @@ -20,7 +20,7 @@ class Estimate # A boolean indicating if this estimate is a production or test mode estimate. attr_accessor :production - # The type of estimate. Available types are mass, flight, shipping, and vehicle. + # The type of estimate. Available types are mass, flight, shipping, vehicle, and crypto. attr_accessor :type # The estimated mass in grams for this estimate. From 3fb156a8fdd3e56eaca90d462a3f5ae8c0766fe4 Mon Sep 17 00:00:00 2001 From: James Klein Date: Thu, 12 Aug 2021 18:01:00 -0600 Subject: [PATCH 2/8] toggle local dev env + test for metadata --- lib/patch_ruby/configuration.rb | 4 ++-- spec/integration/estimates_spec.rb | 6 ------ spec/integration/orders_spec.rb | 17 +++++++++-------- spec/integration/preferences_spec.rb | 6 ------ spec/integration/projects_spec.rb | 4 ---- spec/spec_helper.rb | 20 ++++++++++++++------ 6 files changed, 25 insertions(+), 32 deletions(-) diff --git a/lib/patch_ruby/configuration.rb b/lib/patch_ruby/configuration.rb index 641dc97..b985c52 100644 --- a/lib/patch_ruby/configuration.rb +++ b/lib/patch_ruby/configuration.rb @@ -126,8 +126,8 @@ class Configuration attr_accessor :force_ending_format def initialize - @scheme = 'https' - @host = 'api.patch.io' + @scheme = ENV.fetch('LOCAL_SDK_TEST', false) ? 'http' : 'https' + @host = ENV.fetch('LOCAL_SDK_TEST', false) ? 'api.patch.test:3000' : 'api.patch.io' @base_path = '' @api_key = {} @api_key_prefix = {} diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb index 49e3c70..c0d4124 100644 --- a/spec/integration/estimates_spec.rb +++ b/spec/integration/estimates_spec.rb @@ -1,10 +1,4 @@ RSpec.describe 'Estimates Integration' do - before do - Patch.configure do |config| - config.access_token = ENV['SANDBOX_API_KEY'] - end - end - 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 diff --git a/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index 19daf8a..4fca748 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -1,10 +1,4 @@ RSpec.describe 'Orders Integration' do - before do - Patch.configure do |config| - config.access_token = ENV['SANDBOX_API_KEY'] - end - end - it 'supports create, place, cancel, retrieve and list' do create_order_response = Patch::Order.create_order(mass_g: 100) order_id = create_order_response.data.id @@ -71,15 +65,22 @@ expect(order.registry_url).not_to be_empty end - it 'supports create with metadata' do + it 'supports creation with and querying by metadata' do metadata = { user: 'john doe' } - create_order_response = Patch::Order.create_order(mass_g: 100, metadata: metadata) + create_order_response = + Patch::Order.create_order(mass_g: 100, metadata: metadata) expect(create_order_response.success).to eq true expect(create_order_response.data.id).not_to be_nil expect(create_order_response.data.mass_g).to eq(100) expect(create_order_response.data.metadata).to eq(metadata) + + retrieve_orders_response = Patch::Order.retrieve_orders( + page: 1, query_params: { metadata: { user: 'john' } } + ) + expect(retrieve_orders_response.success).to eq true + expect(retrieve_orders_response.data.count).to be >= 1 end it 'supports place and cancel for orders created via an estimate' do diff --git a/spec/integration/preferences_spec.rb b/spec/integration/preferences_spec.rb index 979b149..55021f6 100644 --- a/spec/integration/preferences_spec.rb +++ b/spec/integration/preferences_spec.rb @@ -1,10 +1,4 @@ RSpec.describe 'Preferences Integration' do - before do - Patch.configure do |config| - config.access_token = ENV['SANDBOX_API_KEY'] - end - end - it 'supports create, delete, retrieve and list' do retrieve_projects_response = Patch::Project.retrieve_projects expect(retrieve_projects_response.data.length).not_to be_zero diff --git a/spec/integration/projects_spec.rb b/spec/integration/projects_spec.rb index c91d6c3..72ca77c 100644 --- a/spec/integration/projects_spec.rb +++ b/spec/integration/projects_spec.rb @@ -1,8 +1,4 @@ RSpec.describe 'Projects Integration' do - Patch.configure do |config| - config.access_token = ENV['SANDBOX_API_KEY'] - end - it 'supports retrieve and list' do page_limit = 1 next_page = 1 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f9bc511..1f71c13 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -41,6 +41,14 @@ config.include FactoryBot::Syntax::Methods config.before(:suite) do FactoryBot.find_definitions + Patch.configure do |config| + config.access_token = + if ENV.fetch('LOCAL_SDK_TEST', false) + ENV.fetch('LOCAL_PATCH_API_KEY') + else + ENV.fetch('SANDBOX_API_KEY') + end + end end # rspec-expectations config goes here. You can use an alternate @@ -66,6 +74,12 @@ mocks.verify_partial_doubles = true end + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. =begin @@ -107,12 +121,6 @@ # particularly slow. config.profile_examples = 10 - # Run specs in random order to surface order dependencies. If you find an - # order dependency and want to debug it, you can fix the order by providing - # the seed, which is printed after each run. - # --seed 1234 - config.order = :random - # Seed global randomization in this process using the `--seed` CLI option. # Setting this allows you to use `--seed` to deterministically reproduce # test failures related to randomization by passing the same `--seed` value From 5073430385b590b3a683e1ca69d8b96d2cb06d43 Mon Sep 17 00:00:00 2001 From: James Klein Date: Thu, 12 Aug 2021 18:14:59 -0600 Subject: [PATCH 3/8] use metadata method signature --- lib/patch_ruby/api/orders_api.rb | 3 + lib/patch_ruby/configuration.rb | 4 +- .../models/bulk_create_success_response.rb | 237 --------------- .../models/create_bulk_offsets_request.rb | 271 ------------------ .../models/create_bulk_recs_request.rb | 271 ------------------ spec/integration/orders_spec.rb | 4 +- spec/spec_helper.rb | 13 +- 7 files changed, 15 insertions(+), 788 deletions(-) delete mode 100644 lib/patch_ruby/models/bulk_create_success_response.rb delete mode 100644 lib/patch_ruby/models/create_bulk_offsets_request.rb delete mode 100644 lib/patch_ruby/models/create_bulk_recs_request.rb diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index c73265f..69b1af4 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -281,6 +281,7 @@ def retrieve_order_with_http_info(id, opts = {}) # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [String] :metadata # @option opts [String] :metadata_ext_id # @option opts [String] :metadata_disregarded # @return [OrderListResponse] @@ -293,6 +294,7 @@ def retrieve_orders(opts = {}) # Retrieves a list of orders and its allocation offsets or negative emissions. You can only retrieve orders associated with the organization you are querying for. # @param [Hash] opts the optional parameters # @option opts [Integer] :page + # @option opts [String] :metadata # @option opts [String] :metadata_ext_id # @option opts [String] :metadata_disregarded # @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers @@ -306,6 +308,7 @@ def retrieve_orders_with_http_info(opts = {}) # query parameters query_params = opts[:query_params] || {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? + query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil? query_params[:'metadata[ext_id]'] = opts[:'metadata_ext_id'] if !opts[:'metadata_ext_id'].nil? query_params[:'metadata[disregarded]'] = opts[:'metadata_disregarded'] if !opts[:'metadata_disregarded'].nil? diff --git a/lib/patch_ruby/configuration.rb b/lib/patch_ruby/configuration.rb index b985c52..641dc97 100644 --- a/lib/patch_ruby/configuration.rb +++ b/lib/patch_ruby/configuration.rb @@ -126,8 +126,8 @@ class Configuration attr_accessor :force_ending_format def initialize - @scheme = ENV.fetch('LOCAL_SDK_TEST', false) ? 'http' : 'https' - @host = ENV.fetch('LOCAL_SDK_TEST', false) ? 'api.patch.test:3000' : 'api.patch.io' + @scheme = 'https' + @host = 'api.patch.io' @base_path = '' @api_key = {} @api_key_prefix = {} diff --git a/lib/patch_ruby/models/bulk_create_success_response.rb b/lib/patch_ruby/models/bulk_create_success_response.rb deleted file mode 100644 index 6136c0e..0000000 --- a/lib/patch_ruby/models/bulk_create_success_response.rb +++ /dev/null @@ -1,237 +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 'date' - -module Patch - class BulkCreateSuccessResponse - attr_accessor :success - - attr_accessor :error - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'success' => :'success', - :'error' => :'error' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'success' => :'Boolean', - :'error' => :'Error' - } - end - - # Set with nullable attributes. - def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties - 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::BulkCreateSuccessResponsesApi::OPERATIONS') && Patch::BulkCreateSuccessResponsesApi::OPERATIONS.include?(message) - Patch::BulkCreateSuccessResponsesApi.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::BulkCreateSuccessResponse` 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::BulkCreateSuccessResponse`. 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 - 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 @error.nil? - invalid_properties.push('invalid value for "error", error 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 @error.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 - 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].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional - 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 :DateTime - DateTime.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 - Patch.const_get(type).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_bulk_offsets_request.rb b/lib/patch_ruby/models/create_bulk_offsets_request.rb deleted file mode 100644 index 681a25a..0000000 --- a/lib/patch_ruby/models/create_bulk_offsets_request.rb +++ /dev/null @@ -1,271 +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 'date' - -module Patch - class CreateBulkOffsetsRequest - attr_accessor :price_cents_usd - - attr_accessor :project_id - - attr_accessor :vintage_year - - attr_accessor :serial_number - - attr_accessor :count - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'price_cents_usd' => :'price_cents_usd', - :'project_id' => :'project_id', - :'vintage_year' => :'vintage_year', - :'serial_number' => :'serial_number', - :'count' => :'count' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'price_cents_usd' => :'Integer', - :'project_id' => :'String', - :'vintage_year' => :'Integer', - :'serial_number' => :'String', - :'count' => :'Integer' - } - end - - # Set with nullable attributes. - def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("serial_number") - - nullable_properties - 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::CreateBulkOffsetsRequestsApi::OPERATIONS') && Patch::CreateBulkOffsetsRequestsApi::OPERATIONS.include?(message) - Patch::CreateBulkOffsetsRequestsApi.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::CreateBulkOffsetsRequest` 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::CreateBulkOffsetsRequest`. 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?(:'price_cents_usd') - self.price_cents_usd = attributes[:'price_cents_usd'] - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'vintage_year') - self.vintage_year = attributes[:'vintage_year'] - end - - if attributes.key?(:'serial_number') - self.serial_number = attributes[:'serial_number'] - end - - if attributes.key?(:'count') - self.count = attributes[:'count'] - 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 !@price_cents_usd.nil? && @price_cents_usd < 1 - invalid_properties.push('invalid value for "price_cents_usd", must be greater than or equal to 1.') - 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 !@price_cents_usd.nil? && @price_cents_usd < 1 - true - end - - # Custom attribute writer method with validation - # @param [Object] price_cents_usd Value to be assigned - def price_cents_usd=(price_cents_usd) - if !price_cents_usd.nil? && price_cents_usd < 1 - fail ArgumentError, 'invalid value for "price_cents_usd", must be greater than or equal to 1.' - end - - @price_cents_usd = price_cents_usd - 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 && - price_cents_usd == o.price_cents_usd && - project_id == o.project_id && - vintage_year == o.vintage_year && - serial_number == o.serial_number && - count == o.count - 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 - [price_cents_usd, project_id, vintage_year, serial_number, count].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional - 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 :DateTime - DateTime.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 - Patch.const_get(type).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_bulk_recs_request.rb b/lib/patch_ruby/models/create_bulk_recs_request.rb deleted file mode 100644 index 420eb4c..0000000 --- a/lib/patch_ruby/models/create_bulk_recs_request.rb +++ /dev/null @@ -1,271 +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 'date' - -module Patch - class CreateBulkRecsRequest - attr_accessor :price_cents_usd - - attr_accessor :project_id - - attr_accessor :vintage_year - - attr_accessor :serial_number - - attr_accessor :count - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'price_cents_usd' => :'price_cents_usd', - :'project_id' => :'project_id', - :'vintage_year' => :'vintage_year', - :'serial_number' => :'serial_number', - :'count' => :'count' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'price_cents_usd' => :'Integer', - :'project_id' => :'String', - :'vintage_year' => :'Integer', - :'serial_number' => :'String', - :'count' => :'Integer' - } - end - - # Set with nullable attributes. - def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties.add("serial_number") - - nullable_properties - 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::CreateBulkRecsRequestsApi::OPERATIONS') && Patch::CreateBulkRecsRequestsApi::OPERATIONS.include?(message) - Patch::CreateBulkRecsRequestsApi.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::CreateBulkRecsRequest` 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::CreateBulkRecsRequest`. 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?(:'price_cents_usd') - self.price_cents_usd = attributes[:'price_cents_usd'] - end - - if attributes.key?(:'project_id') - self.project_id = attributes[:'project_id'] - end - - if attributes.key?(:'vintage_year') - self.vintage_year = attributes[:'vintage_year'] - end - - if attributes.key?(:'serial_number') - self.serial_number = attributes[:'serial_number'] - end - - if attributes.key?(:'count') - self.count = attributes[:'count'] - 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 !@price_cents_usd.nil? && @price_cents_usd < 1 - invalid_properties.push('invalid value for "price_cents_usd", must be greater than or equal to 1.') - 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 !@price_cents_usd.nil? && @price_cents_usd < 1 - true - end - - # Custom attribute writer method with validation - # @param [Object] price_cents_usd Value to be assigned - def price_cents_usd=(price_cents_usd) - if !price_cents_usd.nil? && price_cents_usd < 1 - fail ArgumentError, 'invalid value for "price_cents_usd", must be greater than or equal to 1.' - end - - @price_cents_usd = price_cents_usd - 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 && - price_cents_usd == o.price_cents_usd && - project_id == o.project_id && - vintage_year == o.vintage_year && - serial_number == o.serial_number && - count == o.count - 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 - [price_cents_usd, project_id, vintage_year, serial_number, count].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional - 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 :DateTime - DateTime.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 - Patch.const_get(type).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/spec/integration/orders_spec.rb b/spec/integration/orders_spec.rb index 4fca748..0ebf711 100644 --- a/spec/integration/orders_spec.rb +++ b/spec/integration/orders_spec.rb @@ -77,10 +77,12 @@ expect(create_order_response.data.metadata).to eq(metadata) retrieve_orders_response = Patch::Order.retrieve_orders( - page: 1, query_params: { metadata: { user: 'john' } } + page: 1, metadata: { user: 'john' } ) expect(retrieve_orders_response.success).to eq true expect(retrieve_orders_response.data.count).to be >= 1 + expect(retrieve_orders_response.data.map(&:metadata)) + .to all(have_key(:user)) end it 'supports place and cancel for orders created via an estimate' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1f71c13..7dd5a5d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,12 +42,13 @@ config.before(:suite) do FactoryBot.find_definitions Patch.configure do |config| - config.access_token = - if ENV.fetch('LOCAL_SDK_TEST', false) - ENV.fetch('LOCAL_PATCH_API_KEY') - else - ENV.fetch('SANDBOX_API_KEY') - end + if ENV.fetch('LOCAL_SDK_TEST', false) + config.access_token = ENV.fetch('LOCAL_PATCH_API_KEY') + config.scheme = 'http' + config.host = 'api.patch.test:3000' + else + config.access_token = ENV.fetch('SANDBOX_API_KEY') + end end end From ef8337f8ef66123c31cb0722bc9f02c09905a08c Mon Sep 17 00:00:00 2001 From: James Klein Date: Fri, 13 Aug 2021 18:45:59 -0600 Subject: [PATCH 4/8] remove error model --- lib/patch_ruby/models/error.rb | 237 ------------------------ lib/patch_ruby/models/error_response.rb | 2 +- 2 files changed, 1 insertion(+), 238 deletions(-) delete mode 100644 lib/patch_ruby/models/error.rb diff --git a/lib/patch_ruby/models/error.rb b/lib/patch_ruby/models/error.rb deleted file mode 100644 index 6913353..0000000 --- a/lib/patch_ruby/models/error.rb +++ /dev/null @@ -1,237 +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 'date' - -module Patch - class Error - attr_accessor :code - - attr_accessor :message - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'code' => :'code', - :'message' => :'message' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'code' => :'Integer', - :'message' => :'String' - } - end - - # Set with nullable attributes. - def self.openapi_nullable - nullable_properties = Set.new - - nullable_properties - 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::ErrorsApi::OPERATIONS') && Patch::ErrorsApi::OPERATIONS.include?(message) - Patch::ErrorsApi.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::Error` 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::Error`. 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?(:'code') - self.code = attributes[:'code'] - end - - if attributes.key?(:'message') - self.message = attributes[:'message'] - 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 @code.nil? - invalid_properties.push('invalid value for "code", code cannot be nil.') - end - - if @message.nil? - invalid_properties.push('invalid value for "message", message 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 @code.nil? - return false if @message.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 && - code == o.code && - message == o.message - 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 - [code, message].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 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 # or else data not found in attributes(hash), not an issue as the data can be optional - 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 :DateTime - DateTime.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 - Patch.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/lib/patch_ruby/models/error_response.rb b/lib/patch_ruby/models/error_response.rb index 9aa261b..dd0ff95 100644 --- a/lib/patch_ruby/models/error_response.rb +++ b/lib/patch_ruby/models/error_response.rb @@ -33,7 +33,7 @@ def self.attribute_map def self.openapi_types { :'success' => :'Boolean', - :'error' => :'Error', + :'error' => :'Object', :'data' => :'Object' } end From fcccd4c9432b658775ce65ab9f97592ac4b76d2c Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 11:21:55 -0600 Subject: [PATCH 5/8] fix specs --- spec/integration/estimates_spec.rb | 2 +- spec/integration/projects_spec.rb | 18 +++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/spec/integration/estimates_spec.rb b/spec/integration/estimates_spec.rb index c0d4124..4aea197 100644 --- a/spec/integration/estimates_spec.rb +++ b/spec/integration/estimates_spec.rb @@ -27,7 +27,7 @@ ) expect(flight_estimate.data.type).to eq 'flight' - expect(flight_estimate.data.mass_g).to eq 1_031_697 + expect(flight_estimate.data.mass_g).to eq 1_000_622 end it 'supports creating vehicle estimates' do diff --git a/spec/integration/projects_spec.rb b/spec/integration/projects_spec.rb index 72ca77c..2ef98e8 100644 --- a/spec/integration/projects_spec.rb +++ b/spec/integration/projects_spec.rb @@ -39,20 +39,12 @@ end describe 'returned fields' do - before do - @project = Patch::Project.retrieve_projects(page: 1).data.first - end - - it 'returns photos' do - expect(@project.photos).to be_an_instance_of(Array) - end - - it 'returns average_price_per_tonne_cents_usd' do - expect(@project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer) - end + it 'returns the expected fields' do + project = Patch::Project.retrieve_projects(page: 1).data.first - it 'returns remaining_mass_g' do - expect(@project.remaining_mass_g).to be_an_instance_of(Integer) + expect(project.photos).to be_an_instance_of(Array) + expect(project.average_price_per_tonne_cents_usd).to be_an_instance_of(Integer) + expect(project.remaining_mass_g).to be_an_instance_of(Integer) end end end From 67adf5f9ed944cc795aaacfa4d060c191e193a86 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 11:25:02 -0600 Subject: [PATCH 6/8] do not run the tests in parallel --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1937123..fad8453 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: strategy: matrix: ruby-version: [3.0.1, 2.7.4, 2.6.8] + max-parallel: 1 steps: - name: Check out code From 2172df60880a035535460e577ff0e30448471ca0 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 12:03:11 -0600 Subject: [PATCH 7/8] bump version and update changelog --- CHANGELOG.md | 6 ++++++ Gemfile.lock | 2 +- lib/patch_ruby/version.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 788affe..f9c3215 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ 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). +## [1.9.0] - 2021-08-17 + +### Added + +- Add support for querying Orders by `metadata` + ## [1.8.0] - 2021-07-20 ### Added diff --git a/Gemfile.lock b/Gemfile.lock index dc279d7..31a2694 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - patch_ruby (1.8.0) + patch_ruby (1.9.0) json (~> 2.1, >= 2.1.0) typhoeus (~> 1.0, >= 1.0.1) diff --git a/lib/patch_ruby/version.rb b/lib/patch_ruby/version.rb index b68ae7e..f992fe1 100644 --- a/lib/patch_ruby/version.rb +++ b/lib/patch_ruby/version.rb @@ -11,5 +11,5 @@ =end module Patch - VERSION = '1.8.0' + VERSION = '1.9.0' end From c11b163a85f639e2aa38747be97fe35c1e0fc4ed Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 17:47:19 -0600 Subject: [PATCH 8/8] add ruby version, regenerate sdk, and update changelog --- .ruby-version | 1 + CHANGELOG.md | 1 + lib/patch_ruby/api/orders_api.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..4a36342 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.0.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index f9c3215..91a394f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add support for querying Orders by `metadata` +- Added `transaction_value_eth_gwei` as an alternative way to compute transaction level emissions for ethereum ## [1.8.0] - 2021-07-20 diff --git a/lib/patch_ruby/api/orders_api.rb b/lib/patch_ruby/api/orders_api.rb index 69b1af4..901c8ad 100644 --- a/lib/patch_ruby/api/orders_api.rb +++ b/lib/patch_ruby/api/orders_api.rb @@ -282,8 +282,8 @@ def retrieve_order_with_http_info(id, opts = {}) # @param [Hash] opts the optional parameters # @option opts [Integer] :page # @option opts [String] :metadata - # @option opts [String] :metadata_ext_id - # @option opts [String] :metadata_disregarded + # @option opts [String] :metadata_example1 + # @option opts [String] :metadata_example2 # @return [OrderListResponse] def retrieve_orders(opts = {}) data, _status_code, _headers = retrieve_orders_with_http_info(opts) @@ -295,8 +295,8 @@ def retrieve_orders(opts = {}) # @param [Hash] opts the optional parameters # @option opts [Integer] :page # @option opts [String] :metadata - # @option opts [String] :metadata_ext_id - # @option opts [String] :metadata_disregarded + # @option opts [String] :metadata_example1 + # @option opts [String] :metadata_example2 # @return [Array<(OrderListResponse, Integer, Hash)>] OrderListResponse data, response status code and response headers def retrieve_orders_with_http_info(opts = {}) if @api_client.config.debugging @@ -309,8 +309,8 @@ def retrieve_orders_with_http_info(opts = {}) query_params = opts[:query_params] || {} query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'metadata'] = opts[:'metadata'] if !opts[:'metadata'].nil? - query_params[:'metadata[ext_id]'] = opts[:'metadata_ext_id'] if !opts[:'metadata_ext_id'].nil? - query_params[:'metadata[disregarded]'] = opts[:'metadata_disregarded'] if !opts[:'metadata_disregarded'].nil? + query_params[:'metadata[example1]'] = opts[:'metadata_example1'] if !opts[:'metadata_example1'].nil? + query_params[:'metadata[example2]'] = opts[:'metadata_example2'] if !opts[:'metadata_example2'].nil? # header parameters header_params = opts[:header_params] || {}