Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.2.5] - 2020-01-08

### Fixed

- Fixes [issues/5](https://github.com/patch-technology/patch-ruby/issues/5). Adds method `.openapi_nullable` which returns a set with all nullable properties. This method is referenced in `#to_hash` which returns a hash representation of the resource.
- Removes non-deterministic integration spec that is creating an Estimate with a specific project-id. Since we do not control the test data (yet) and make queries against our Test projects, we cannot be sure that we will have offsets available for a project ID. Instead we can rely on Patch core specs to cover this.
- Fixes a spec that was failing due to a Patch core change.
- Add spec factories and refactor generated method specs to shared examples.

## [1.2.4] - 2020-10-14

### Added
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ group :development, :test do
gem 'rake', '~> 13.0.1'
gem 'pry-byebug'
gem 'rubocop'
gem 'factory_bot'
end
20 changes: 18 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
PATH
remote: .
specs:
patch_ruby (1.2.4)
patch_ruby (1.2.5)
json (~> 2.1, >= 2.1.0)
typhoeus (~> 1.0, >= 1.0.1)

GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ast (2.4.1)
byebug (11.1.3)
coderay (1.1.3)
concurrent-ruby (1.1.7)
diff-lcs (1.4.3)
ethon (0.12.0)
ffi (>= 1.3.0)
factory_bot (6.1.0)
activesupport (>= 5.0.0)
ffi (1.13.1)
json (2.3.1)
i18n (1.8.7)
concurrent-ruby (~> 1.0)
json (2.4.1)
method_source (1.0.0)
minitest (5.14.3)
parallel (1.19.2)
parser (2.7.1.4)
ast (~> 2.4.1)
Expand Down Expand Up @@ -57,12 +69,16 @@ GEM
ruby-progressbar (1.10.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode-display_width (1.7.0)
zeitwerk (2.4.2)

PLATFORMS
ruby

DEPENDENCIES
factory_bot
patch_ruby!
pry-byebug
rake (~> 13.0.1)
Expand Down
10 changes: 10 additions & 0 deletions lib/patch_ruby/models/allocation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@

module Patch
class Allocation
# A unique uid for the record. UIDs will be prepended by all_prod or all_test depending on the mode it was created in.
attr_accessor :id

# A boolean indicating if this project is a production or test mode project.
attr_accessor :production

# The amount (in grams) of allocated carbon offsets.
attr_accessor :mass_g

# Attribute mapping from ruby-style variable name to JSON key.
Expand All @@ -38,6 +41,13 @@ def self.openapi_types
}
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
Expand Down
7 changes: 7 additions & 0 deletions lib/patch_ruby/models/create_mass_estimate_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def self.openapi_types
}
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
Expand Down
7 changes: 7 additions & 0 deletions lib/patch_ruby/models/create_order_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def self.openapi_types
}
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
Expand Down
7 changes: 7 additions & 0 deletions lib/patch_ruby/models/create_preference_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ def self.openapi_types
}
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
Expand Down
9 changes: 9 additions & 0 deletions lib/patch_ruby/models/error_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("data")

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
Expand Down
15 changes: 14 additions & 1 deletion lib/patch_ruby/models/estimate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@

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 test mode estimate.
attr_accessor :production

# The type of estimate. Currently mass is the only supported value.
attr_accessor :type

# 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.
Expand All @@ -42,6 +46,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("order")

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
Expand Down Expand Up @@ -226,7 +239,7 @@ def to_hash
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
Expand Down
9 changes: 9 additions & 0 deletions lib/patch_ruby/models/estimate_list_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("error")

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
Expand Down
9 changes: 9 additions & 0 deletions lib/patch_ruby/models/estimate_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("error")

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
Expand Down
11 changes: 11 additions & 0 deletions lib/patch_ruby/models/meta_index_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("prev_page")

nullable_properties.add("next_page")

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
Expand Down
20 changes: 20 additions & 0 deletions lib/patch_ruby/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,31 @@

module Patch
class Order
# A unique uid for the record. UIDs will be prepended by ord_prod or ord_test depending on the mode it was created in.
attr_accessor :id

# The amount of carbon offsets in grams purchased through this order.
attr_accessor :mass_g

# A boolean indicating if this order is a production or test mode order.
attr_accessor :production

# The current state of the order.
attr_accessor :state

# The current state of the allocated carbon offsets of the order.
attr_accessor :allocation_state

# The total price in cents USD of the carbon offsets purchased through this order.
attr_accessor :price_cents_usd

# The Patch Fee in cents USD for this order.
attr_accessor :patch_fee_cents_usd

# An array containing the inventory allocations for this order.
attr_accessor :allocations

# An optional JSON object containing metadata for this order.
attr_accessor :metadata

class EnumAttributeValidator
Expand Down Expand Up @@ -84,6 +93,17 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("price_cents_usd")

nullable_properties.add("patch_fee_cents_usd")

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
Expand Down
9 changes: 9 additions & 0 deletions lib/patch_ruby/models/order_list_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("error")

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
Expand Down
9 changes: 9 additions & 0 deletions lib/patch_ruby/models/order_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ def self.openapi_types
}
end

# Set with nullable attributes.
def self.openapi_nullable
nullable_properties = Set.new

nullable_properties.add("error")

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
Expand Down
Loading