@@ -23,13 +23,38 @@ class CreateOrderRequest
2323
2424 attr_accessor :metadata
2525
26+ attr_accessor :state
27+
28+ class EnumAttributeValidator
29+ attr_reader :datatype
30+ attr_reader :allowable_values
31+
32+ def initialize ( datatype , allowable_values )
33+ @allowable_values = allowable_values . map do |value |
34+ case datatype . to_s
35+ when /Integer/i
36+ value . to_i
37+ when /Float/i
38+ value . to_f
39+ else
40+ value
41+ end
42+ end
43+ end
44+
45+ def valid? ( value )
46+ !value || allowable_values . include? ( value )
47+ end
48+ end
49+
2650 # Attribute mapping from ruby-style variable name to JSON key.
2751 def self . attribute_map
2852 {
2953 :'mass_g' => :'mass_g' ,
3054 :'total_price_cents_usd' => :'total_price_cents_usd' ,
3155 :'project_id' => :'project_id' ,
32- :'metadata' => :'metadata'
56+ :'metadata' => :'metadata' ,
57+ :'state' => :'state'
3358 }
3459 end
3560
@@ -44,7 +69,8 @@ def self.openapi_types
4469 :'mass_g' => :'Integer' ,
4570 :'total_price_cents_usd' => :'Integer' ,
4671 :'project_id' => :'String' ,
47- :'metadata' => :'Object'
72+ :'metadata' => :'Object' ,
73+ :'state' => :'String'
4874 }
4975 end
5076
@@ -96,6 +122,10 @@ def initialize(attributes = {})
96122 if attributes . key? ( :'metadata' )
97123 self . metadata = attributes [ :'metadata' ]
98124 end
125+
126+ if attributes . key? ( :'state' )
127+ self . state = attributes [ :'state' ]
128+ end
99129 end
100130
101131 # Show invalid properties with the reasons. Usually used together with valid?
@@ -123,6 +153,8 @@ def valid?
123153 return false if !@mass_g . nil? && @mass_g > 100000000000
124154 return false if !@mass_g . nil? && @mass_g < 0
125155 return false if !@total_price_cents_usd . nil? && @total_price_cents_usd < 1
156+ state_validator = EnumAttributeValidator . new ( 'String' , [ "draft" , "placed" ] )
157+ return false unless state_validator . valid? ( @state )
126158 true
127159 end
128160
@@ -150,6 +182,16 @@ def total_price_cents_usd=(total_price_cents_usd)
150182 @total_price_cents_usd = total_price_cents_usd
151183 end
152184
185+ # Custom attribute writer method checking allowed values (enum).
186+ # @param [Object] state Object to be assigned
187+ def state = ( state )
188+ validator = EnumAttributeValidator . new ( 'String' , [ "draft" , "placed" ] )
189+ unless validator . valid? ( state )
190+ fail ArgumentError , "invalid value for \" state\" , must be one of #{ validator . allowable_values } ."
191+ end
192+ @state = state
193+ end
194+
153195 # Checks equality by comparing each attribute.
154196 # @param [Object] Object to be compared
155197 def ==( o )
@@ -158,7 +200,8 @@ def ==(o)
158200 mass_g == o . mass_g &&
159201 total_price_cents_usd == o . total_price_cents_usd &&
160202 project_id == o . project_id &&
161- metadata == o . metadata
203+ metadata == o . metadata &&
204+ state == o . state
162205 end
163206
164207 # @see the `==` method
@@ -170,7 +213,7 @@ def eql?(o)
170213 # Calculates hash code according to all attributes.
171214 # @return [Integer] Hash code
172215 def hash
173- [ mass_g , total_price_cents_usd , project_id , metadata ] . hash
216+ [ mass_g , total_price_cents_usd , project_id , metadata , state ] . hash
174217 end
175218
176219 # Builds the object from hash
0 commit comments