Class: Connectwise::Company

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/connectwise/company.rb,
lib/connectwise/connectwise.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

#defined_attributes, #destroy, included, #persisted?, #save, #to_h

Constructor Details

#initialize(connection, attrs) ⇒ Company

Returns a new instance of Company.



14
15
16
17
18
# File 'lib/connectwise/company.rb', line 14

def initialize(connection, attrs)
  super
  @company_id ||= SecureRandom.hex(12)
  @status ||= 'Active'
end

Instance Attribute Details

#company_idObject

Returns the value of attribute company_id.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def company_id
  @company_id
end

#company_nameObject

Returns the value of attribute company_name.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def company_name
  @company_name
end

#fax_numberObject

Returns the value of attribute fax_number.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def fax_number
  @fax_number
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def id
  @id
end

#marketObject

Returns the value of attribute market.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def market
  @market
end

#phone_numberObject

Returns the value of attribute phone_number.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def phone_number
  @phone_number
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def status
  @status
end

#territoryObject

Returns the value of attribute territory.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def territory
  @territory
end

#typeObject

Returns the value of attribute type.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def type
  @type
end

#urlObject

Returns the value of attribute url.



90
91
92
# File 'lib/connectwise/connectwise.rb', line 90

def url
  @url
end

#web_siteObject

Returns the value of attribute web_site.



7
8
9
# File 'lib/connectwise/company.rb', line 7

def web_site
  @web_site
end

Class Method Details

.transform(attrs) ⇒ Object



9
10
11
12
# File 'lib/connectwise/company.rb', line 9

def self.transform(attrs)
  attrs[:company_name] ||= attrs.delete(:name)
  attrs
end

Instance Method Details

#to_cw_hObject



20
21
22
23
24
# File 'lib/connectwise/company.rb', line 20

def to_cw_h
  attrs = super
  attrs['CompanyID'] = attrs.delete('CompanyId')
  attrs
end