Module: Subledger::Store::Api::Reports

Included in:
Store
Defined in:
lib/subledger/store/api/roles/reports.rb

Instance Method Summary collapse

Instance Method Details

#attach_category_to_report(args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/subledger/store/api/roles/reports.rb', line 5

def attach_category_to_report args
  report   = args[:report]
  category = args[:category]
  parent   = args[:parent]

  path = Path.for_entity( :anchor => report ) + '/attach'

  attach_post_hash = { 'category' => category.id }

  attach_post_hash['parent'] = parent.id unless parent.nil?

  begin
    json_body = http.post do |req|
                  req.url    path
                  req.body = attach_post_hash
                end.body
  rescue Exception => e
    raise AttachError, "Cannot attach #{category}: #{e}"
  end

  category
end

#collect_categories_for_report(report, &block) ⇒ Object

Raises:



67
68
69
# File 'lib/subledger/store/api/roles/reports.rb', line 67

def collect_categories_for_report report, &block
  raise ReportError, 'report#categories is not yet implemented'
end

#detach_category_from_report(args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/subledger/store/api/roles/reports.rb', line 28

def detach_category_from_report args
  category = args[:category]
  report   = args[:report]

  path = Path.for_entity( :anchor => report ) + '/detach'

  detach_post_hash = { 'category' => category.id }

  begin
    json_body = http.post do |req|
                  req.url    path
                  req.body = detach_post_hash
                end.body
  rescue Exception => e
    raise DetachError, "Cannot detach #{category}: #{e}"
  end

  category
end

#render(args) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/subledger/store/api/roles/reports.rb', line 48

def render args
  at = args[:at].iso8601

  building_report_rendering = args[:building_report_rendering]
  report                    = building_report_rendering.report

  path = Path.for_entity( :anchor => report ) + "/render?at=#{at}"

  begin
    json_body = http.post do |req|
                            req.url path
                          end.body
  rescue Exception => e
    raise ReportError, "Cannot render #{report}: #{e}"
  end

  new_or_initialize json_body, building_report_rendering
end

#report_structure_for(report, &block) ⇒ Object

Raises:



71
72
73
# File 'lib/subledger/store/api/roles/reports.rb', line 71

def report_structure_for report, &block
  raise ReportError, 'report#structure is not yet implemented'
end