Class: AdvancedBilling::Seller

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

Overview

Seller Model.

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) ⇒ Seller

Returns a new instance of Seller.



55
56
57
58
59
60
# File 'lib/advanced_billing/models/seller.rb', line 55

def initialize(name = SKIP, address = SKIP, phone = SKIP, logo_url = SKIP)
  @name = name unless name == SKIP
  @address = address unless address == SKIP
  @phone = phone unless phone == SKIP
  @logo_url = logo_url unless logo_url == SKIP
end

Instance Attribute Details

#addressInvoiceAddress

TODO: Write general description for this method

Returns:



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

def address
  @address
end

#logo_urlString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/seller.rb', line 26

def logo_url
  @logo_url
end

#nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def name
  @name
end

#phoneString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/seller.rb', line 22

def phone
  @phone
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/advanced_billing/models/seller.rb', line 63

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

  # Create object from extracted values.

  Seller.new(name,
             address,
             phone,
             logo_url)
end

.namesObject

A mapping from model property names to API property names.



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

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



49
50
51
52
53
# File 'lib/advanced_billing/models/seller.rb', line 49

def self.nullables
  %w[
    logo_url
  ]
end

.optionalsObject

An array for optional fields



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

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 (Seller | Hash)

    value against the validation is performed.



81
82
83
84
85
86
87
# File 'lib/advanced_billing/models/seller.rb', line 81

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

  return false unless value.instance_of? Hash

  true
end