Class: AdvancedBilling::InvoiceSeller

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

Overview

Information about the seller (merchant) listed on the masthead of the invoice.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name: SKIP, address: SKIP, phone: SKIP, logo_url: SKIP, additional_properties: {}) ⇒ InvoiceSeller

Returns a new instance of InvoiceSeller.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/advanced_billing/models/invoice_seller.rb', line 56

def initialize(name: SKIP, address: SKIP, phone: SKIP, logo_url: SKIP,
               additional_properties: {})
  @name = name unless name == SKIP
  @address = address unless address == SKIP
  @phone = phone unless phone == SKIP
  @logo_url = logo_url unless logo_url == SKIP

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

Instance Attribute Details

#addressInvoiceAddress

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/advanced_billing/models/invoice_seller.rb', line 19

def address
  @address
end

#logo_urlString

TODO: Write general description for this method

Returns:

  • (String)


27
28
29
# File 'lib/advanced_billing/models/invoice_seller.rb', line 27

def logo_url
  @logo_url
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/advanced_billing/models/invoice_seller.rb', line 15

def name
  @name
end

#phoneString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/invoice_seller.rb', line 23

def phone
  @phone
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/advanced_billing/models/invoice_seller.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : SKIP
  address = InvoiceAddress.from_hash(hash['address']) if hash['address']
  phone = hash.key?('phone') ? hash['phone'] : SKIP
  logo_url = hash.key?('logo_url') ? hash['logo_url'] : SKIP

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

  # Create object from extracted values.
  InvoiceSeller.new(name: name,
                    address: address,
                    phone: phone,
                    logo_url: logo_url,
                    additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/advanced_billing/models/invoice_seller.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['address'] = 'address'
  @_hash['phone'] = 'phone'
  @_hash['logo_url'] = 'logo_url'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
53
54
# File 'lib/advanced_billing/models/invoice_seller.rb', line 50

def self.nullables
  %w[
    logo_url
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    name
    address
    phone
    logo_url
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceSeller | Hash)

    value against the validation is performed.



92
93
94
95
96
97
98
# File 'lib/advanced_billing/models/invoice_seller.rb', line 92

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

  return false unless value.instance_of? Hash

  true
end