Class: AdvancedBilling::Metafields1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/metafields1.rb

Overview

Metafields1 Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(current_name = SKIP, name = SKIP, scope = SKIP, input_type = MetafieldInput::TEXT, enum = SKIP) ⇒ Metafields1

Returns a new instance of Metafields1.



65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/metafields1.rb', line 65

def initialize(current_name = SKIP, name = SKIP, scope = SKIP,
               input_type = MetafieldInput::TEXT, enum = SKIP)
  @current_name = current_name unless current_name == SKIP
  @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

#current_nameString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/metafields1.rb', line 14

def current_name
  @current_name
end

#enumArray[String]

Only applicable when input_type is radio or dropdown

Returns:

  • (Array[String])


36
37
38
# File 'lib/advanced_billing/models/metafields1.rb', line 36

def enum
  @enum
end

#input_typeMetafieldInput

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.

Returns:



32
33
34
# File 'lib/advanced_billing/models/metafields1.rb', line 32

def input_type
  @input_type
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/metafields1.rb', line 18

def name
  @name
end

#scopeMetafieldScope

Warning: When updating a metafield’s scope attribute, all scope attributes must be passed. Partially complete scope attributes will override the existing settings.

Returns:



24
25
26
# File 'lib/advanced_billing/models/metafields1.rb', line 24

def scope
  @scope
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/advanced_billing/models/metafields1.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  current_name = hash.key?('current_name') ? hash['current_name'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  scope = MetafieldScope.from_hash(hash['scope']) if hash['scope']
  input_type = hash['input_type'] ||= MetafieldInput::TEXT
  enum = hash.key?('enum') ? hash['enum'] : SKIP

  # Create object from extracted values.
  Metafields1.new(current_name,
                  name,
                  scope,
                  input_type,
                  enum)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
# File 'lib/advanced_billing/models/metafields1.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['current_name'] = 'current_name'
  @_hash['name'] = 'name'
  @_hash['scope'] = 'scope'
  @_hash['input_type'] = 'input_type'
  @_hash['enum'] = 'enum'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
# File 'lib/advanced_billing/models/metafields1.rb', line 61

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
# File 'lib/advanced_billing/models/metafields1.rb', line 50

def self.optionals
  %w[
    current_name
    name
    scope
    input_type
    enum
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Metafields1 | Hash)

    value against the validation is performed.



95
96
97
98
99
100
101
# File 'lib/advanced_billing/models/metafields1.rb', line 95

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end