Method: Bandsintown::Connection#encode

Defined in:
lib/bandsintown/connection.rb

#encode(args = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/bandsintown/connection.rb', line 27

def encode(args = {})
  start_date = args.delete(:start_date)
  end_date   = args.delete(:end_date)
  if start_date && end_date
    start_date  = start_date.strftime("%Y-%m-%d") unless start_date.is_a?(String)
    end_date    = end_date.strftime("%Y-%m-%d")   unless end_date.is_a?(String)
    args[:date] = "#{start_date},#{end_date}"
  elsif args.has_key?(:date)
    args[:date] = args[:date].strftime("%Y-%m-%d") unless args[:date].is_a?(String)
  end
  args[:format] = "json"
  args[:app_id] = Bandsintown.app_id
  args.to_param
end