Class: Mudbase::CreatePlanRequest
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Mudbase::CreatePlanRequest
- Defined in:
- lib/mudbase/models/create_plan_request.rb
Overview
OpenAPI-style body normalized server-side into Plan.pricing (monthly/yearly amounts), features (objects with name/included), and optional limits/trial/metadata. Slug is derived from projectId + name unless a collision occurs.
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#currency ⇒ Object
ISO currency code (stored lowercased).
-
#description ⇒ Object
Returns the value of attribute description.
-
#features ⇒ Object
Strings become
{ name, included: true }. -
#interval ⇒ Object
Which period
priceapplies to; drives pricing.monthly vs pricing.yearly. -
#is_active ⇒ Object
Returns the value of attribute is_active.
-
#is_default ⇒ Object
Only one default plan per project is allowed server-side.
-
#limits ⇒ Object
Returns the value of attribute limits.
-
#metadata ⇒ Object
Arbitrary key/value data stored on the plan document.
-
#name ⇒ Object
Display name; also used to generate a unique slug per project.
-
#price ⇒ Object
Amount for the chosen interval.
-
#sort_order ⇒ Object
Lower numbers list first in UIs.
-
#trial ⇒ Object
Returns the value of attribute trial.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ CreatePlanRequest
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ CreatePlanRequest
Initializes the object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/mudbase/models/create_plan_request.rb', line 127 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Mudbase::CreatePlanRequest` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Mudbase::CreatePlanRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'name') self.name = attributes[:'name'] else self.name = nil end if attributes.key?(:'description') self.description = attributes[:'description'] end if attributes.key?(:'price') self.price = attributes[:'price'] else self.price = nil end if attributes.key?(:'currency') self.currency = attributes[:'currency'] else self.currency = nil end if attributes.key?(:'interval') self.interval = attributes[:'interval'] else self.interval = nil end if attributes.key?(:'features') if (value = attributes[:'features']).is_a?(Array) self.features = value end end if attributes.key?(:'limits') self.limits = attributes[:'limits'] end if attributes.key?(:'trial') self.trial = attributes[:'trial'] end if attributes.key?(:'is_active') self.is_active = attributes[:'is_active'] else self.is_active = true end if attributes.key?(:'is_default') self.is_default = attributes[:'is_default'] else self.is_default = false end if attributes.key?(:'sort_order') self.sort_order = attributes[:'sort_order'] end if attributes.key?(:'metadata') if (value = attributes[:'metadata']).is_a?(Hash) self. = value end end end |
Instance Attribute Details
#currency ⇒ Object
ISO currency code (stored lowercased).
28 29 30 |
# File 'lib/mudbase/models/create_plan_request.rb', line 28 def currency @currency end |
#description ⇒ Object
Returns the value of attribute description.
22 23 24 |
# File 'lib/mudbase/models/create_plan_request.rb', line 22 def description @description end |
#features ⇒ Object
Strings become { name, included: true }. You may send full feature objects instead.
34 35 36 |
# File 'lib/mudbase/models/create_plan_request.rb', line 34 def features @features end |
#interval ⇒ Object
Which period price applies to; drives pricing.monthly vs pricing.yearly.
31 32 33 |
# File 'lib/mudbase/models/create_plan_request.rb', line 31 def interval @interval end |
#is_active ⇒ Object
Returns the value of attribute is_active.
40 41 42 |
# File 'lib/mudbase/models/create_plan_request.rb', line 40 def is_active @is_active end |
#is_default ⇒ Object
Only one default plan per project is allowed server-side.
43 44 45 |
# File 'lib/mudbase/models/create_plan_request.rb', line 43 def is_default @is_default end |
#limits ⇒ Object
Returns the value of attribute limits.
36 37 38 |
# File 'lib/mudbase/models/create_plan_request.rb', line 36 def limits @limits end |
#metadata ⇒ Object
Arbitrary key/value data stored on the plan document.
49 50 51 |
# File 'lib/mudbase/models/create_plan_request.rb', line 49 def @metadata end |
#name ⇒ Object
Display name; also used to generate a unique slug per project.
20 21 22 |
# File 'lib/mudbase/models/create_plan_request.rb', line 20 def name @name end |
#price ⇒ Object
Amount for the chosen interval. The server fills the other billing period (e.g. yearly ≈ monthly × 12 × 0.8 when interval is month).
25 26 27 |
# File 'lib/mudbase/models/create_plan_request.rb', line 25 def price @price end |
#sort_order ⇒ Object
Lower numbers list first in UIs.
46 47 48 |
# File 'lib/mudbase/models/create_plan_request.rb', line 46 def sort_order @sort_order end |
#trial ⇒ Object
Returns the value of attribute trial.
38 39 40 |
# File 'lib/mudbase/models/create_plan_request.rb', line 38 def trial @trial end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
92 93 94 |
# File 'lib/mudbase/models/create_plan_request.rb', line 92 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
97 98 99 |
# File 'lib/mudbase/models/create_plan_request.rb', line 97 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/mudbase/models/create_plan_request.rb', line 74 def self.attribute_map { :'name' => :'name', :'description' => :'description', :'price' => :'price', :'currency' => :'currency', :'interval' => :'interval', :'features' => :'features', :'limits' => :'limits', :'trial' => :'trial', :'is_active' => :'isActive', :'is_default' => :'isDefault', :'sort_order' => :'sortOrder', :'metadata' => :'metadata' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/mudbase/models/create_plan_request.rb', line 317 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif 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[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
120 121 122 123 |
# File 'lib/mudbase/models/create_plan_request.rb', line 120 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/mudbase/models/create_plan_request.rb', line 102 def self.openapi_types { :'name' => :'String', :'description' => :'String', :'price' => :'Float', :'currency' => :'String', :'interval' => :'String', :'features' => :'Array<CreatePlanRequestFeaturesInner>', :'limits' => :'CreatePlanRequestLimits', :'trial' => :'CreatePlanRequestTrial', :'is_active' => :'Boolean', :'is_default' => :'Boolean', :'sort_order' => :'Float', :'metadata' => :'Hash<String, Object>' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/mudbase/models/create_plan_request.rb', line 285 def ==(o) return true if self.equal?(o) self.class == o.class && name == o.name && description == o.description && price == o.price && currency == o.currency && interval == o.interval && features == o.features && limits == o.limits && trial == o.trial && is_active == o.is_active && is_default == o.is_default && sort_order == o.sort_order && == o. end |
#eql?(o) ⇒ Boolean
304 305 306 |
# File 'lib/mudbase/models/create_plan_request.rb', line 304 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
310 311 312 |
# File 'lib/mudbase/models/create_plan_request.rb', line 310 def hash [name, description, price, currency, interval, features, limits, trial, is_active, is_default, sort_order, ].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/mudbase/models/create_plan_request.rb', line 208 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @name.nil? invalid_properties.push('invalid value for "name", name cannot be nil.') end if @price.nil? invalid_properties.push('invalid value for "price", price cannot be nil.') end if @currency.nil? invalid_properties.push('invalid value for "currency", currency cannot be nil.') end if @interval.nil? invalid_properties.push('invalid value for "interval", interval cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/mudbase/models/create_plan_request.rb', line 339 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 |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
232 233 234 235 236 237 238 239 240 241 |
# File 'lib/mudbase/models/create_plan_request.rb', line 232 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @name.nil? return false if @price.nil? return false if @currency.nil? return false if @interval.nil? interval_validator = EnumAttributeValidator.new('String', ["month", "year"]) return false unless interval_validator.valid?(@interval) true end |