lib/patch_ruby/models/project.rb in patch_ruby-1.0.0 vs lib/patch_ruby/models/project.rb in patch_ruby-1.1.0
- old
+ new
@@ -20,31 +20,47 @@
attr_accessor :name
attr_accessor :description
+ attr_accessor :type
+
attr_accessor :country
- attr_accessor :longitude
+ attr_accessor :developer
- attr_accessor :latitude
+ class EnumAttributeValidator
+ attr_reader :datatype
+ attr_reader :allowable_values
- attr_accessor :verifier
+ def initialize(datatype, allowable_values)
+ @allowable_values = allowable_values.map do |value|
+ case datatype.to_s
+ when /Integer/i
+ value.to_i
+ when /Float/i
+ value.to_f
+ else
+ value
+ end
+ end
+ end
- attr_accessor :developer
+ def valid?(value)
+ !value || allowable_values.include?(value)
+ end
+ end
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'production' => :'production',
:'name' => :'name',
:'description' => :'description',
+ :'type' => :'type',
:'country' => :'country',
- :'longitude' => :'longitude',
- :'latitude' => :'latitude',
- :'verifier' => :'verifier',
:'developer' => :'developer'
}
end
# Attribute type mapping.
@@ -52,14 +68,12 @@
{
:'id' => :'String',
:'production' => :'Boolean',
:'name' => :'String',
:'description' => :'String',
+ :'type' => :'String',
:'country' => :'String',
- :'longitude' => :'Float',
- :'latitude' => :'Float',
- :'verifier' => :'String',
:'developer' => :'String'
}
end
# Allows models with corresponding API classes to delegate API operations to those API classes
@@ -102,57 +116,89 @@
if attributes.key?(:'description')
self.description = attributes[:'description']
end
+ if attributes.key?(:'type')
+ self.type = attributes[:'type']
+ end
+
if attributes.key?(:'country')
self.country = attributes[:'country']
end
- if attributes.key?(:'longitude')
- self.longitude = attributes[:'longitude']
- end
-
- if attributes.key?(:'latitude')
- self.latitude = attributes[:'latitude']
- end
-
- if attributes.key?(:'verifier')
- self.verifier = attributes[:'verifier']
- end
-
if attributes.key?(:'developer')
self.developer = attributes[:'developer']
end
end
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
invalid_properties = Array.new
+ if @id.nil?
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
+ end
+
+ if @production.nil?
+ invalid_properties.push('invalid value for "production", production cannot be nil.')
+ end
+
+ if @name.nil?
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
+ end
+
+ if @description.nil?
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
+ end
+
+ if @country.nil?
+ invalid_properties.push('invalid value for "country", country cannot be nil.')
+ end
+
+ if @developer.nil?
+ invalid_properties.push('invalid value for "developer", developer cannot be nil.')
+ end
+
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
+ return false if @id.nil?
+ return false if @production.nil?
+ return false if @name.nil?
+ return false if @description.nil?
+ type_validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
+ return false unless type_validator.valid?(@type)
+ return false if @country.nil?
+ return false if @developer.nil?
true
end
+ # Custom attribute writer method checking allowed values (enum).
+ # @param [Object] type Object to be assigned
+ def type=(type)
+ validator = EnumAttributeValidator.new('String', ["biomass", "dac", "forestry", "mineralization", "ocean", "soil"])
+ unless validator.valid?(type)
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
+ end
+ @type = type
+ end
+
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
id == o.id &&
production == o.production &&
name == o.name &&
description == o.description &&
+ type == o.type &&
country == o.country &&
- longitude == o.longitude &&
- latitude == o.latitude &&
- verifier == o.verifier &&
developer == o.developer
end
# @see the `==` method
# @param [Object] Object to be compared
@@ -161,10 +207,10 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [id, production, name, description, country, longitude, latitude, verifier, developer].hash
+ [id, production, name, description, type, country, developer].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself