Class: GoToWebinar::Webinar

Inherits:
Object
  • Object
show all
Defined in:
lib/go_to_webinar/webinar.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Webinar

Returns a new instance of Webinar.



3
4
5
# File 'lib/go_to_webinar/webinar.rb', line 3

def initialize(data)
  @data = data
end

Class Method Details

.find(webinar_key:) ⇒ Object



26
27
28
29
# File 'lib/go_to_webinar/webinar.rb', line 26

def self.find(webinar_key:)
  data = GoToWebinar.client.get("/organizers/:organizer_key:/webinars/#{webinar_key}")
  Webinar.new(data)
end

.for_account(account_key:, from:, to:, page: nil, page_size: nil) ⇒ Object

Retrieves the list of webinars for an account within a given date range. Page and size parameters are optional. Default page is 0 and default size is 20.



34
35
36
37
38
39
40
41
# File 'lib/go_to_webinar/webinar.rb', line 34

def self.(account_key:, from:, to:, page: nil, page_size: nil)
  options = { fromTime: from, toTime: to }
  options[:page] = page if page.present?
  options[:size] = page_size if page_size.present?

  GoToWebinar.client.get("/accounts/#{}/webinars", options)
  # TODO: montar retorno
end

.for_organizerObject

Returns webinars scheduled for the future for a specified organizer.



52
53
54
# File 'lib/go_to_webinar/webinar.rb', line 52

def self.for_organizer
  make(GoToWebinar.client.get("/organizers/:organizer_key:/webinars"))
end

.historical(from: nil, to: nil) ⇒ Object

Returns details for completed webinars for the specified organizer and completed webinars of other organizers where the specified organizer is a co-organizer.



46
47
48
49
# File 'lib/go_to_webinar/webinar.rb', line 46

def self.historical(from: nil, to: nil)
  options = { fromTime: from, toTime: to }
  make(GoToWebinar.client.get("/organizers/:organizer_key:/historicalWebinars", options))
end

.make(data) ⇒ Object



63
64
65
# File 'lib/go_to_webinar/webinar.rb', line 63

def self.make(data)
  data.map { |webinar| Webinar.new(webinar) }
end

.upcomingObject

Returns webinars scheduled for the future for the specified organizer and webinars of other organizers where the specified organizer is a co-organizer.



59
60
61
# File 'lib/go_to_webinar/webinar.rb', line 59

def self.upcoming
  make(GoToWebinar.client.get("/organizers/:organizer_key:/upcomingWebinars"))
end

Instance Method Details

#add_registrant(first_name:, last_name:, email:) ⇒ Object



11
12
13
14
15
16
# File 'lib/go_to_webinar/webinar.rb', line 11

def add_registrant(first_name:, last_name:, email:)
  Registrant.create(
    webinar_key: webinar_key,
    data: { firstName: first_name, lastName: last_name, email: email }.to_json
  )
end

#get_session(session_key:) ⇒ Object



22
23
24
# File 'lib/go_to_webinar/webinar.rb', line 22

def get_session(session_key:)
  Session.find(webinar_key: webinar_key, session_key: session_key)
end

#sessionsObject



18
19
20
# File 'lib/go_to_webinar/webinar.rb', line 18

def sessions
  Session.for_webinar(webinar_key: webinar_key)
end

#webinar_keyObject



7
8
9
# File 'lib/go_to_webinar/webinar.rb', line 7

def webinar_key
  @data['webinarKey'].to_s
end