Class: AdvancedBilling::Metafield
- Defined in:
- lib/advanced_billing/models/metafield.rb
Overview
Metafield Model.
Instance Attribute Summary collapse
-
#data_count ⇒ Integer
the amount of subscriptions this metafield has been applied to in Chargify.
-
#enum ⇒ Array[String]
the amount of subscriptions this metafield has been applied to in Chargify.
-
#id ⇒ Float
TODO: Write general description for this method.
-
#input_type ⇒ String
the amount of subscriptions this metafield has been applied to in Chargify.
-
#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(id = SKIP, name = SKIP, scope = SKIP, data_count = SKIP, input_type = SKIP, enum = SKIP) ⇒ Metafield
constructor
A new instance of Metafield.
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, name = SKIP, scope = SKIP, data_count = SKIP, input_type = SKIP, enum = SKIP) ⇒ Metafield
Returns a new instance of Metafield.
69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/metafield.rb', line 69 def initialize(id = SKIP, name = SKIP, scope = SKIP, data_count = SKIP, input_type = SKIP, enum = SKIP) @id = id unless id == SKIP @name = name unless name == SKIP @scope = scope unless scope == SKIP @data_count = data_count unless data_count == SKIP @input_type = input_type unless input_type == SKIP @enum = enum unless enum == SKIP end |
Instance Attribute Details
#data_count ⇒ Integer
the amount of subscriptions this metafield has been applied to in Chargify
28 29 30 |
# File 'lib/advanced_billing/models/metafield.rb', line 28 def data_count @data_count end |
#enum ⇒ Array[String]
the amount of subscriptions this metafield has been applied to in Chargify
36 37 38 |
# File 'lib/advanced_billing/models/metafield.rb', line 36 def enum @enum end |
#id ⇒ Float
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/metafield.rb', line 14 def id @id end |
#input_type ⇒ String
the amount of subscriptions this metafield has been applied to in Chargify
32 33 34 |
# File 'lib/advanced_billing/models/metafield.rb', line 32 def input_type @input_type end |
#name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/metafield.rb', line 18 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.
24 25 26 |
# File 'lib/advanced_billing/models/metafield.rb', line 24 def scope @scope end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/advanced_billing/models/metafield.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP scope = MetafieldScope.from_hash(hash['scope']) if hash['scope'] data_count = hash.key?('data_count') ? hash['data_count'] : SKIP input_type = hash.key?('input_type') ? hash['input_type'] : SKIP enum = hash.key?('enum') ? APIHelper.deserialize_union_type( UnionTypeLookUp.get(:MetafieldEnum), hash['enum'] ) : SKIP # Create object from extracted values. Metafield.new(id, name, scope, data_count, input_type, enum) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/advanced_billing/models/metafield.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['scope'] = 'scope' @_hash['data_count'] = 'data_count' @_hash['input_type'] = 'input_type' @_hash['enum'] = 'enum' @_hash end |
.nullables ⇒ Object
An array for nullable fields
63 64 65 66 67 |
# File 'lib/advanced_billing/models/metafield.rb', line 63 def self.nullables %w[ enum ] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/advanced_billing/models/metafield.rb', line 51 def self.optionals %w[ id name scope data_count input_type enum ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
104 105 106 107 108 109 110 |
# File 'lib/advanced_billing/models/metafield.rb', line 104 def self.validate(value) return true if value.instance_of? self return false unless value.instance_of? Hash true end |