Class: AdvancedBilling::CreateMetafield
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateMetafield
- Defined in:
- lib/advanced_billing/models/create_metafield.rb
Overview
CreateMetafield Model.
Instance Attribute Summary collapse
-
#enum ⇒ Array[String]
Only applicable when input_type is radio or dropdown.
-
#input_type ⇒ MetafieldInput
Indicates how data should be added to the metafield.
-
#name ⇒ String
TODO: Write general description for this method.
-
#scope ⇒ MetafieldScope
Warning: When updating a metafield’s scope attribute, all scope attributes must be passed.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(name: SKIP, scope: SKIP, input_type: SKIP, enum: SKIP, additional_properties: {}) ⇒ CreateMetafield
constructor
A new instance of CreateMetafield.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name: SKIP, scope: SKIP, input_type: SKIP, enum: SKIP, additional_properties: {}) ⇒ CreateMetafield
Returns a new instance of CreateMetafield.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 60 def initialize(name: SKIP, scope: SKIP, input_type: SKIP, enum: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @name = name unless name == SKIP @scope = scope unless scope == SKIP @input_type = input_type unless input_type == SKIP @enum = enum unless enum == SKIP end |
Instance Attribute Details
#enum ⇒ Array[String]
Only applicable when input_type is radio or dropdown. Empty strings will not be submitted.
33 34 35 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 33 def enum @enum end |
#input_type ⇒ MetafieldInput
Indicates how data should be added to the metafield. For example, a text type is just a string, so a given metafield of this type can have any value attached. On the other hand, dropdown and radio have a set of allowed values that can be input, and appear differently on a Public Signup Page. Defaults to ‘text’
28 29 30 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 28 def input_type @input_type end |
#name ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 14 def name @name end |
#scope ⇒ MetafieldScope
Warning: When updating a metafield’s scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings.
20 21 22 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 20 def scope @scope end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 74 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : SKIP scope = MetafieldScope.from_hash(hash['scope']) if hash['scope'] input_type = hash.key?('input_type') ? hash['input_type'] : SKIP enum = hash.key?('enum') ? hash['enum'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. CreateMetafield.new(name: name, scope: scope, input_type: input_type, enum: enum, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
36 37 38 39 40 41 42 43 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 36 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['scope'] = 'scope' @_hash['input_type'] = 'input_type' @_hash['enum'] = 'enum' @_hash end |
.nullables ⇒ Object
An array for nullable fields
56 57 58 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 56 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
46 47 48 49 50 51 52 53 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 46 def self.optionals %w[ name scope input_type enum ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
96 97 98 99 100 101 102 |
# File 'lib/advanced_billing/models/create_metafield.rb', line 96 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |