Class: AdvancedBilling::InvoiceDisplaySettings

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

Overview

InvoiceDisplaySettings Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(hide_zero_subtotal_lines: SKIP, include_discounts_on_lines: SKIP, additional_properties: {}) ⇒ InvoiceDisplaySettings

Returns a new instance of InvoiceDisplaySettings.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 41

def initialize(hide_zero_subtotal_lines: SKIP,
               include_discounts_on_lines: SKIP, additional_properties: {})
  @hide_zero_subtotal_lines = hide_zero_subtotal_lines unless hide_zero_subtotal_lines == SKIP
  unless include_discounts_on_lines == SKIP
    @include_discounts_on_lines =
      include_discounts_on_lines
  end

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#hide_zero_subtotal_linesTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def hide_zero_subtotal_lines
  @hide_zero_subtotal_lines
end

#include_discounts_on_linesTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def include_discounts_on_lines
  @include_discounts_on_lines
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  hide_zero_subtotal_lines =
    hash.key?('hide_zero_subtotal_lines') ? hash['hide_zero_subtotal_lines'] : SKIP
  include_discounts_on_lines =
    hash.key?('include_discounts_on_lines') ? hash['include_discounts_on_lines'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  InvoiceDisplaySettings.new(hide_zero_subtotal_lines: hide_zero_subtotal_lines,
                             include_discounts_on_lines: include_discounts_on_lines,
                             additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['hide_zero_subtotal_lines'] = 'hide_zero_subtotal_lines'
  @_hash['include_discounts_on_lines'] = 'include_discounts_on_lines'
  @_hash
end

.nullablesObject

An array for nullable fields



37
38
39
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 37

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
32
33
34
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 29

def self.optionals
  %w[
    hide_zero_subtotal_lines
    include_discounts_on_lines
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/invoice_display_settings.rb', line 76

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

  return false unless value.instance_of? Hash

  true
end