Class: Sched::Client
- Inherits:
-
Object
- Object
- Sched::Client
- Defined in:
- lib/sched/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#conference ⇒ Object
Returns the value of attribute conference.
Instance Method Summary collapse
- #api_url ⇒ Object
- #event(session_key) ⇒ Object
- #events ⇒ Object
-
#initialize(conference, api_key) ⇒ Client
constructor
A new instance of Client.
- #request(path, data = {}, method = :post) ⇒ Object
Constructor Details
#initialize(conference, api_key) ⇒ Client
Returns a new instance of Client.
4 5 6 7 |
# File 'lib/sched/client.rb', line 4 def initialize(conference, api_key) @conference = conference @api_key = api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/sched/client.rb', line 3 def api_key @api_key end |
#conference ⇒ Object
Returns the value of attribute conference.
3 4 5 |
# File 'lib/sched/client.rb', line 3 def conference @conference end |
Instance Method Details
#api_url ⇒ Object
19 20 21 |
# File 'lib/sched/client.rb', line 19 def api_url "https://#{@conference}.sched.com/api" end |
#event(session_key) ⇒ Object
9 10 11 12 13 |
# File 'lib/sched/client.rb', line 9 def event(session_key) event = Sched::Event.new(session_key, self) event = events.find { |e| e.session_key == session_key } if event.exists? event end |
#events ⇒ Object
15 16 17 |
# File 'lib/sched/client.rb', line 15 def events @events ||= parse_sessions(CSV.parse(request("session/list", nil, :get))) end |
#request(path, data = {}, method = :post) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/sched/client.rb', line 23 def request(path, data = {}, method = :post) data ||= {} data[:api_key] = @api_key if method == :post post_request(path, data) elsif method == :get get_request(path, data) end end |