Module: SmsMyBus

Defined in:
lib/sms_my_bus.rb,
lib/sms_my_bus/routes.rb,
lib/sms_my_bus/version.rb,
lib/sms_my_bus/locations.rb,
lib/sms_my_bus/schedules.rb

Defined Under Namespace

Classes: Locations, Routes, Schedules

Constant Summary collapse

BASE_API_URI =
'http://api.smsmybus.com/v1/'
VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.keyObject



18
19
20
21
# File 'lib/sms_my_bus.rb', line 18

def self.key
  raise 'No key set; please see README.md' unless @key
  @key
end

.key=(key) ⇒ Object



14
15
16
# File 'lib/sms_my_bus.rb', line 14

def self.key= key
  @key = key
end

.make_api_request(api_method, opts = {}) ⇒ Object



23
24
25
26
# File 'lib/sms_my_bus.rb', line 23

def self.make_api_request api_method, opts = {}
  response = Curl::Easy.http_get(SmsMyBus.request_uri(api_method, opts))
  JSON.parse(response.body_str)
end

.request_uri(api_method, opts = {}) ⇒ Object



28
29
30
31
32
# File 'lib/sms_my_bus.rb', line 28

def self.request_uri api_method, opts = {}
  opts['key'] = SmsMyBus.key

  "#{BASE_API_URI}#{api_method}?#{URI.encode_www_form(opts)}"
end