Class: AdvancedBilling::MetafieldScope

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

Overview

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(csv: SKIP, invoices: SKIP, statements: SKIP, portal: SKIP, public_show: SKIP, public_edit: SKIP, hosted: SKIP, additional_properties: {}) ⇒ MetafieldScope

Returns a new instance of MetafieldScope.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/metafield_scope.rb', line 79

def initialize(csv: SKIP, invoices: SKIP, statements: SKIP, portal: SKIP,
               public_show: SKIP, public_edit: SKIP, hosted: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @csv = csv unless csv == SKIP
  @invoices = invoices unless invoices == SKIP
  @statements = statements unless statements == SKIP
  @portal = portal unless portal == SKIP
  @public_show = public_show unless public_show == SKIP
  @public_edit = public_edit unless public_edit == SKIP
  @hosted = hosted unless hosted == SKIP
end

Instance Attribute Details

#csvIncludeOption

Include (1) or exclude (0) metafields from the csv export.

Returns:



16
17
18
# File 'lib/advanced_billing/models/metafield_scope.rb', line 16

def csv
  @csv
end

#hostedArray[String]

Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being editable by your ecosystem.

Returns:

  • (Array[String])


46
47
48
# File 'lib/advanced_billing/models/metafield_scope.rb', line 46

def hosted
  @hosted
end

#invoicesIncludeOption

Include (1) or exclude (0) metafields from invoices.

Returns:



20
21
22
# File 'lib/advanced_billing/models/metafield_scope.rb', line 20

def invoices
  @invoices
end

#portalIncludeOption

Include (1) or exclude (0) metafields from the portal.

Returns:



28
29
30
# File 'lib/advanced_billing/models/metafield_scope.rb', line 28

def portal
  @portal
end

#public_editIncludeOption

Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being editable by your ecosystem.

Returns:



40
41
42
# File 'lib/advanced_billing/models/metafield_scope.rb', line 40

def public_edit
  @public_edit
end

#public_showIncludeOption

Include (1) or exclude (0) metafields used in [Embeddable Components](page:development-tools/embeddable-components/overview) from being viewable by your ecosystem.

Returns:



34
35
36
# File 'lib/advanced_billing/models/metafield_scope.rb', line 34

def public_show
  @public_show
end

#statementsIncludeOption

Include (1) or exclude (0) metafields from statements.

Returns:



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

def statements
  @statements
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/advanced_billing/models/metafield_scope.rb', line 97

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  csv = hash.key?('csv') ? hash['csv'] : SKIP
  invoices = hash.key?('invoices') ? hash['invoices'] : SKIP
  statements = hash.key?('statements') ? hash['statements'] : SKIP
  portal = hash.key?('portal') ? hash['portal'] : SKIP
  public_show = hash.key?('public_show') ? hash['public_show'] : SKIP
  public_edit = hash.key?('public_edit') ? hash['public_edit'] : SKIP
  hosted = hash.key?('hosted') ? hash['hosted'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  MetafieldScope.new(csv: csv,
                     invoices: invoices,
                     statements: statements,
                     portal: portal,
                     public_show: public_show,
                     public_edit: public_edit,
                     hosted: hosted,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['csv'] = 'csv'
  @_hash['invoices'] = 'invoices'
  @_hash['statements'] = 'statements'
  @_hash['portal'] = 'portal'
  @_hash['public_show'] = 'public_show'
  @_hash['public_edit'] = 'public_edit'
  @_hash['hosted'] = 'hosted'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/advanced_billing/models/metafield_scope.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/metafield_scope.rb', line 62

def self.optionals
  %w[
    csv
    invoices
    statements
    portal
    public_show
    public_edit
    hosted
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (MetafieldScope | Hash)

    value against the validation is performed.



125
126
127
128
129
130
131
# File 'lib/advanced_billing/models/metafield_scope.rb', line 125

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

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



142
143
144
145
146
147
148
# File 'lib/advanced_billing/models/metafield_scope.rb', line 142

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} csv: #{@csv.inspect}, invoices: #{@invoices.inspect}, statements:"\
  " #{@statements.inspect}, portal: #{@portal.inspect}, public_show: #{@public_show.inspect},"\
  " public_edit: #{@public_edit.inspect}, hosted: #{@hosted.inspect}, additional_properties:"\
  " #{get_additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



134
135
136
137
138
139
# File 'lib/advanced_billing/models/metafield_scope.rb', line 134

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} csv: #{@csv}, invoices: #{@invoices}, statements: #{@statements}, portal:"\
  " #{@portal}, public_show: #{@public_show}, public_edit: #{@public_edit}, hosted:"\
  " #{@hosted}, additional_properties: #{get_additional_properties}>"
end