Class: Sched::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sched/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/sched/client.rb', line 3

def api_key
  @api_key
end

#conferenceObject

Returns the value of attribute conference.



3
4
5
# File 'lib/sched/client.rb', line 3

def conference
  @conference
end

Instance Method Details

#api_urlObject



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

#eventsObject



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