Class: ApiController

Inherits:
ApplicationController show all
Defined in:
app/controllers/api_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#act, #convert, #render_not_found

Instance Method Details

#clause_noteObject


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/api_controller.rb', line 5

def clause_note
  @error = nil
  @clause_text = ""
  @clause_html = ""
  
  bill_id = params[:bill_id]
  clause_num = params[:clause]
  format = params[:format]
  
  unless bill_id && clause_num
    @error = "You need to supply a bill id and a clause number"
  else
    bill = Bill.find_by_id(bill_id)
    unless bill
      @error = "Bill not found"
    else
      clause = bill.find_note_for_clause_number(clause_num, true)
      unless clause
        @error = "Clause not found"
      else
        @clause_text = clause.note_text
        @clause_html = clause.html_note_text
      end
    end
  end
  
  respond_to do |format|
    format.html { render }
    format.xml  { render :layout => false }
    format.json { render :json => note_to_json(@clause_text, @error) }
    format.js   { render :json => note_to_json(@clause_text, @error) }
    format.text { render :text => note_to_text(@clause_text, @error) }
    format.csv  { render :text => note_to_csv(@clause_text, @error) }
    format.yaml { render :text => note_to_yaml(@clause_text, @error) }
  end
end

#indexObject


2
3
# File 'app/controllers/api_controller.rb', line 2

def index
end

#schedule_noteObject


42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/controllers/api_controller.rb', line 42

def schedule_note
  @error = nil
  @schedule_text = ""
  @schedule_html = ""
  
  bill_id = params[:bill_id]
  schedule_num = params[:schedule]
  format = params[:format]
  
  unless bill_id && schedule_num
    @error = "You need to supply a bill id and a schedule number"
  else
    bill = Bill.find_by_id(bill_id)
    unless bill
      @error = "Bill not found"
    else
      schedule = bill.find_note_for_schedule_number(schedule_num)
      unless schedule
        @error = "Schedule not found"
      else
        @schedule_text = schedule.note_text
        @schedule_html = schedule.html_note_text
      end
    end
  end
  
  respond_to do |format|
    format.html { render }
    format.xml  { render :layout => false }
    format.json { render :json => note_to_json(@schedule_text, @error) }
    format.js   { render :json => note_to_json(@schedule_text, @error) }
    format.text { render :text => note_to_text(@schedule_text, @error) }
    format.csv  { render :text => note_to_csv(@schedule_text, @error) }
    format.yaml { render :text => note_to_yaml(@schedule_text, @error) }
  end
end