Class: AdvancedBilling::Metadata
- Defined in:
- lib/advanced_billing/models/metadata.rb
Overview
Metadata Model.
Instance Attribute Summary collapse
-
#deleted_at ⇒ DateTime
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#metafield_id ⇒ Integer
TODO: Write general description for this method.
-
#name ⇒ String
TODO: Write general description for this method.
-
#resource_id ⇒ Integer
TODO: Write general description for this method.
-
#value ⇒ String
TODO: Write general description for this method.
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.
Instance Method Summary collapse
-
#initialize(id: SKIP, value: SKIP, resource_id: SKIP, name: SKIP, deleted_at: SKIP, metafield_id: SKIP, additional_properties: {}) ⇒ Metadata
constructor
A new instance of Metadata.
- #to_custom_deleted_at ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(id: SKIP, value: SKIP, resource_id: SKIP, name: SKIP, deleted_at: SKIP, metafield_id: SKIP, additional_properties: {}) ⇒ Metadata
Returns a new instance of Metadata.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/advanced_billing/models/metadata.rb', line 72 def initialize(id: SKIP, value: SKIP, resource_id: SKIP, name: SKIP, deleted_at: SKIP, metafield_id: SKIP, additional_properties: {}) @id = id unless id == SKIP @value = value unless value == SKIP @resource_id = resource_id unless resource_id == SKIP @name = name unless name == SKIP @deleted_at = deleted_at unless deleted_at == SKIP @metafield_id = unless == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#deleted_at ⇒ DateTime
TODO: Write general description for this method
31 32 33 |
# File 'lib/advanced_billing/models/metadata.rb', line 31 def deleted_at @deleted_at end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/advanced_billing/models/metadata.rb', line 15 def id @id end |
#metafield_id ⇒ Integer
TODO: Write general description for this method
35 36 37 |
# File 'lib/advanced_billing/models/metadata.rb', line 35 def @metafield_id end |
#name ⇒ String
TODO: Write general description for this method
27 28 29 |
# File 'lib/advanced_billing/models/metadata.rb', line 27 def name @name end |
#resource_id ⇒ Integer
TODO: Write general description for this method
23 24 25 |
# File 'lib/advanced_billing/models/metadata.rb', line 23 def resource_id @resource_id end |
#value ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/advanced_billing/models/metadata.rb', line 19 def value @value end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/advanced_billing/models/metadata.rb', line 89 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP value = hash.key?('value') ? hash['value'] : SKIP resource_id = hash.key?('resource_id') ? hash['resource_id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP deleted_at = if hash.key?('deleted_at') (DateTimeHelper.from_rfc3339(hash['deleted_at']) if hash['deleted_at']) else SKIP end = hash.key?('metafield_id') ? hash['metafield_id'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. Metadata.new(id: id, value: value, resource_id: resource_id, name: name, deleted_at: deleted_at, metafield_id: , additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/advanced_billing/models/metadata.rb', line 38 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['value'] = 'value' @_hash['resource_id'] = 'resource_id' @_hash['name'] = 'name' @_hash['deleted_at'] = 'deleted_at' @_hash['metafield_id'] = 'metafield_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 65 66 67 68 69 70 |
# File 'lib/advanced_billing/models/metadata.rb', line 62 def self.nullables %w[ id value resource_id deleted_at metafield_id ] end |
.optionals ⇒ Object
An array for optional fields
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/models/metadata.rb', line 50 def self.optionals %w[ id value resource_id name deleted_at metafield_id ] end |
Instance Method Details
#to_custom_deleted_at ⇒ Object
117 118 119 |
# File 'lib/advanced_billing/models/metadata.rb', line 117 def to_custom_deleted_at DateTimeHelper.to_rfc3339(deleted_at) end |