Class: Asdawqw::Company

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/company.rb

Overview

Company model

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(company_details = nil, policies = nil, payment = nil, id = nil) ⇒ Company

Returns a new instance of Company.



35
36
37
38
39
40
41
42
43
# File 'lib/asdawqw/models/company.rb', line 35

def initialize(company_details = nil,
               policies = nil,
               payment = nil,
               id = nil)
  @company_details = company_details
  @policies = policies
  @payment = payment
  @id = id
end

Instance Attribute Details

#company_detailsCompanyDetails

Company Details Model

Returns:



11
12
13
# File 'lib/asdawqw/models/company.rb', line 11

def company_details
  @company_details
end

#idInteger

Supplier id. Not expected in any requests. Will be only in responses.

Returns:

  • (Integer)


23
24
25
# File 'lib/asdawqw/models/company.rb', line 23

def id
  @id
end

#paymentPayment

Payment Model

Returns:



19
20
21
# File 'lib/asdawqw/models/company.rb', line 19

def payment
  @payment
end

#policiesPolicies

Policies Model

Returns:



15
16
17
# File 'lib/asdawqw/models/company.rb', line 15

def policies
  @policies
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/asdawqw/models/company.rb', line 46

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  company_details = CompanyDetails.from_hash(hash['companyDetails']) if
    hash['companyDetails']
  policies = Policies.from_hash(hash['policies']) if hash['policies']
  payment = Payment.from_hash(hash['payment']) if hash['payment']
  id = hash['id']

  # Create object from extracted values.
  Company.new(company_details,
              policies,
              payment,
              id)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
33
# File 'lib/asdawqw/models/company.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['company_details'] = 'companyDetails'
  @_hash['policies'] = 'policies'
  @_hash['payment'] = 'payment'
  @_hash['id'] = 'id'
  @_hash
end