Class: Cic::Report
Constant Summary
ActiveCic::Base::BASE_URL
Instance Attribute Summary
#attributes, #raw_attributes
Class Method Summary
collapse
Instance Method Summary
collapse
all, #method_missing
Constructor Details
#initialize(hash) ⇒ Report
Returns a new instance of Report.
7
8
9
|
# File 'lib/cic/report.rb', line 7
def initialize(hash)
super(hash)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class ActiveCic::Base
Class Method Details
.find(ticket) ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'lib/cic/report.rb', line 11
def self.find(ticket)
response = self.get("/reports.json")
if response.success?
report_hash = response.parsed_response["reports"].select { |report| report['ticket'] == ticket }.first
report_hash ? self.new(report_hash) : nil
else
raise_exception(response.code, response.body)
end
end
|
.where(params = {}) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/cic/report.rb', line 26
def self.where(params = {})
response = self.get("/reports.json", query: params)
if response.success?
response.parsed_response['reports'].map { |report_hash| self.new(report_hash) }
else
raise_exception(response.code, response.body)
end
end
|
Instance Method Details
#save ⇒ Object
21
22
23
24
|
# File 'lib/cic/report.rb', line 21
def save
self.class.post("/reports.json", body: self.raw_attributes )
true end
|