Class: Plangrade::Resources::Company
- Inherits:
-
Base
- Object
- Base
- Plangrade::Resources::Company
show all
- Defined in:
- lib/plangrade/resources/company.rb
Instance Attribute Summary
Attributes inherited from Base
#attrs, #id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#api_handler, base_name, #base_name, #changes, #delete!, fetch, identity_map, #initialize, #load!, #loaded?, model_attributes, #modified?, #new_record?, #persisted?, #reload!, #save
Methods included from ApiHandler
#api_handler, #establish_api_handler
Class Method Details
.all(params) ⇒ Object
20
21
22
23
24
|
# File 'lib/plangrade/resources/company.rb', line 20
def self.all(params)
api_handler.all_companies(params)
return nil unless result.success?
new(result.body[:companies])
end
|
.create(ein, name) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/plangrade/resources/company.rb', line 5
def self.create(ein, name)
result = api_handler.create_company(:ein => ein, :name => name)
return nil unless result.created?
id = result.[:location].split('/').last.to_i
new(:id => id)
end
|
.get(id) ⇒ Object
14
15
16
17
18
|
# File 'lib/plangrade/resources/company.rb', line 14
def self.get(id)
api_handler.get_company(id)
return nil unless result.success?
new(result.body[:company])
end
|
Instance Method Details
#update!(params) ⇒ Object
26
27
28
|
# File 'lib/plangrade/resources/company.rb', line 26
def update!(params)
api_handler.update_company(@id, params)
end
|