lib/patch_ruby/models/order.rb in patch_ruby-1.24.2 vs lib/patch_ruby/models/order.rb in patch_ruby-2.0.0
- old
+ new
@@ -1,11 +1,11 @@
=begin
-#Patch API V1
+#Patch API V2
#The core API used to integrate with Patch's service
-The version of the OpenAPI document: v1
+The version of the OpenAPI document: 2
Contact: engineering@usepatch.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.3.1
=end
@@ -19,13 +19,10 @@
attr_accessor :id
# The timestamp at which the order was created
attr_accessor :created_at
- # DEPRECATED, use `amount` and `unit` fields instead. The amount of carbon offsets in grams purchased through this order.
- attr_accessor :mass_g
-
# A boolean indicating if this order is a production or demo mode order.
attr_accessor :production
# The current state of the order.
attr_accessor :state
@@ -43,30 +40,18 @@
attr_accessor :patch_fee
# The currency code for the `price` and `patch_fee`.
attr_accessor :currency
- # DEPRECATED. Indicates if the order has been fully allocated to projects.
- attr_accessor :allocation_state
-
- # DEPRECATED, use the `price` and `currency` fields instead. The total price in cents USD of the carbon offsets purchased through this order.
- attr_accessor :price_cents_usd
-
- # DEPRECATED, use the `patch_fee` and `currency` fields instead. The Patch Fee in cents USD for this order.
- attr_accessor :patch_fee_cents_usd
-
- # DEPRECATED. An array containing the inventory allocations for this order.
- attr_accessor :allocations
-
# The url of this order in the public registry.
attr_accessor :registry_url
# An optional JSON object containing metadata for this order.
attr_accessor :metadata
- # An array containing the inventory allocated for this order. Inventory is grouped by project, vintage year, and price.
- attr_accessor :inventory
+ # An array containing the line items allocated for this order. Line items are grouped by project, vintage year, and price.
+ attr_accessor :line_items
# An object containing the name & email of the party the inventory will be issued to.
attr_accessor :issued_to
class EnumAttributeValidator
@@ -94,25 +79,20 @@
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'created_at' => :'created_at',
- :'mass_g' => :'mass_g',
:'production' => :'production',
:'state' => :'state',
:'amount' => :'amount',
:'unit' => :'unit',
:'price' => :'price',
:'patch_fee' => :'patch_fee',
:'currency' => :'currency',
- :'allocation_state' => :'allocation_state',
- :'price_cents_usd' => :'price_cents_usd',
- :'patch_fee_cents_usd' => :'patch_fee_cents_usd',
- :'allocations' => :'allocations',
:'registry_url' => :'registry_url',
:'metadata' => :'metadata',
- :'inventory' => :'inventory',
+ :'line_items' => :'line_items',
:'issued_to' => :'issued_to'
}
end
# Returns all the JSON keys this model knows about
@@ -123,34 +103,27 @@
# Attribute type mapping.
def self.openapi_types
{
:'id' => :'String',
:'created_at' => :'Time',
- :'mass_g' => :'Integer',
:'production' => :'Boolean',
:'state' => :'String',
:'amount' => :'Integer',
:'unit' => :'String',
:'price' => :'Integer',
:'patch_fee' => :'Integer',
:'currency' => :'String',
- :'allocation_state' => :'String',
- :'price_cents_usd' => :'Integer',
- :'patch_fee_cents_usd' => :'Integer',
- :'allocations' => :'Array<Allocation>',
:'registry_url' => :'String',
:'metadata' => :'Object',
- :'inventory' => :'Array<OrderInventory>',
+ :'line_items' => :'Array<OrderLineItem>',
:'issued_to' => :'OrderIssuedTo'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
- :'price_cents_usd',
- :'patch_fee_cents_usd',
])
end
# Allows models with corresponding API classes to delegate API operations to those API classes
@@ -185,14 +158,10 @@
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
- if attributes.key?(:'mass_g')
- self.mass_g = attributes[:'mass_g']
- end
-
if attributes.key?(:'production')
self.production = attributes[:'production']
end
if attributes.key?(:'state')
@@ -217,39 +186,21 @@
if attributes.key?(:'currency')
self.currency = attributes[:'currency']
end
- if attributes.key?(:'allocation_state')
- self.allocation_state = attributes[:'allocation_state']
- end
-
- if attributes.key?(:'price_cents_usd')
- self.price_cents_usd = attributes[:'price_cents_usd']
- end
-
- if attributes.key?(:'patch_fee_cents_usd')
- self.patch_fee_cents_usd = attributes[:'patch_fee_cents_usd']
- end
-
- if attributes.key?(:'allocations')
- if (value = attributes[:'allocations']).is_a?(Array)
- self.allocations = value
- end
- end
-
if attributes.key?(:'registry_url')
self.registry_url = attributes[:'registry_url']
end
if attributes.key?(:'metadata')
self.metadata = attributes[:'metadata']
end
- if attributes.key?(:'inventory')
- if (value = attributes[:'inventory']).is_a?(Array)
- self.inventory = value
+ if attributes.key?(:'line_items')
+ if (value = attributes[:'line_items']).is_a?(Array)
+ self.line_items = value
end
end
if attributes.key?(:'issued_to')
if (value = attributes[:'issued_to']).is_a?(Hash)
@@ -265,22 +216,10 @@
invalid_properties = Array.new
if @id.nil?
invalid_properties.push('invalid value for "id", id cannot be nil.')
end
- if @mass_g.nil?
- invalid_properties.push('invalid value for "mass_g", mass_g cannot be nil.')
- end
-
- if @mass_g > 100000000000
- invalid_properties.push('invalid value for "mass_g", must be smaller than or equal to 100000000000.')
- end
-
- if @mass_g < 0
- invalid_properties.push('invalid value for "mass_g", must be greater than or equal to 0.')
- end
-
if @production.nil?
invalid_properties.push('invalid value for "production", production cannot be nil.')
end
if @state.nil?
@@ -313,14 +252,10 @@
if @currency.nil?
invalid_properties.push('invalid value for "currency", currency cannot be nil.')
end
- if @allocation_state.nil?
- invalid_properties.push('invalid value for "allocation_state", allocation_state cannot be nil.')
- end
-
if @metadata.nil?
invalid_properties.push('invalid value for "metadata", metadata cannot be nil.')
end
invalid_properties
@@ -328,13 +263,10 @@
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
return false if @id.nil?
- return false if @mass_g.nil?
- return false if @mass_g > 100000000000
- return false if @mass_g < 0
return false if @production.nil?
return false if @state.nil?
state_validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
return false unless state_validator.valid?(@state)
return false if @amount.nil?
@@ -342,35 +274,14 @@
return false if @amount < 0
return false if @unit.nil?
return false if @price.nil?
return false if @patch_fee.nil?
return false if @currency.nil?
- return false if @allocation_state.nil?
- allocation_state_validator = EnumAttributeValidator.new('String', ["pending", "allocated"])
- return false unless allocation_state_validator.valid?(@allocation_state)
return false if @metadata.nil?
true
end
- # Custom attribute writer method with validation
- # @param [Object] mass_g Value to be assigned
- def mass_g=(mass_g)
- if mass_g.nil?
- fail ArgumentError, 'mass_g cannot be nil'
- end
-
- if mass_g > 100000000000
- fail ArgumentError, 'invalid value for "mass_g", must be smaller than or equal to 100000000000.'
- end
-
- if mass_g < 0
- fail ArgumentError, 'invalid value for "mass_g", must be greater than or equal to 0.'
- end
-
- @mass_g = mass_g
- end
-
# Custom attribute writer method checking allowed values (enum).
# @param [Object] state Object to be assigned
def state=(state)
validator = EnumAttributeValidator.new('String', ["draft", "reserved", "placed", "processing", "complete", "cancelled"])
unless validator.valid?(state)
@@ -395,42 +306,27 @@
end
@amount = amount
end
- # Custom attribute writer method checking allowed values (enum).
- # @param [Object] allocation_state Object to be assigned
- def allocation_state=(allocation_state)
- validator = EnumAttributeValidator.new('String', ["pending", "allocated"])
- unless validator.valid?(allocation_state)
- fail ArgumentError, "invalid value for \"allocation_state\", must be one of #{validator.allowable_values}."
- end
- @allocation_state = allocation_state
- end
-
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
id == o.id &&
created_at == o.created_at &&
- mass_g == o.mass_g &&
production == o.production &&
state == o.state &&
amount == o.amount &&
unit == o.unit &&
price == o.price &&
patch_fee == o.patch_fee &&
currency == o.currency &&
- allocation_state == o.allocation_state &&
- price_cents_usd == o.price_cents_usd &&
- patch_fee_cents_usd == o.patch_fee_cents_usd &&
- allocations == o.allocations &&
registry_url == o.registry_url &&
metadata == o.metadata &&
- inventory == o.inventory &&
+ line_items == o.line_items &&
issued_to == o.issued_to
end
# @see the `==` method
# @param [Object] Object to be compared
@@ -439,10 +335,10 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [id, created_at, mass_g, production, state, amount, unit, price, patch_fee, currency, allocation_state, price_cents_usd, patch_fee_cents_usd, allocations, registry_url, metadata, inventory, issued_to].hash
+ [id, created_at, production, state, amount, unit, price, patch_fee, currency, registry_url, metadata, line_items, issued_to].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself