gist: 1069 Download_button fork
public
Public Clone URL: git://gist.github.com/1069.git
Ruby
1
2
3
4
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
class Api::OperatorShortcodePricePointsController < Api::AbstractApiController
  before_filter :check_querystring, :only => [:current, :on]
  before_filter :check_date, :only => :on
 
  def index
    list
  end
 
  def list
    render_for_api OperatorShortcodePricePoint.find(:all)
  end
  
  def current
    render_for_api OperatorShortcodePricePoint.current
  end
  
  def on
    render_for_api OperatorShortcodePricePoint.on(params[:date])
  end
  
  private
  
  def check_date
    raise ArgumentError.new "The date parameter is invalid, expected YYYY-MM-DD." unless /^\d{4}-\d{2}-\d{2}$/.match(params[:date]) if params.has_key?(:date)
  rescue ArgumentError => e
    render_error :message => e.message, :status => :bad_request and return false
  else
    return true
  end
end

Owner

pusewicz

Revisions