Class: Wiziq::API
- Inherits:
-
Object
- Object
- Wiziq::API
- Defined in:
- lib/wiziq.rb
Instance Method Summary collapse
-
#add_attendee(session_code, screenname) ⇒ Object
AddAttendee Web Method.
-
#add_attendee_to_session(session_code, screenname) ⇒ Object
AddAttendeeToSession Web Method.
-
#convert_date(from, to, date) ⇒ Object
Convert date from one timezone to another args: TZ 1 ID, TZ 2 ID, date: 2010-01-26T11:00:00.
-
#delete_event(session_code) ⇒ Object
DeleteEvent Web Method.
- #delete_recording(session_codes) ⇒ Object
- #download_recording ⇒ Object
-
#get_account_details ⇒ Object
API Method broken.
-
#get_attendees(session_code) ⇒ Object
GetSessionAttendees Web Method – Broken.
- #get_my_package ⇒ Object
- #get_time_zones ⇒ Object
-
#initialize(username, password) ⇒ API
constructor
A new instance of API.
-
#remove_attendee(session_code, screenname) ⇒ Object
RemoveAttendee Web Method.
- #schedule_new_event(args = {}, attendee_list = {}) ⇒ Object
- #update_event(args = {}) ⇒ Object
Constructor Details
#initialize(username, password) ⇒ API
Returns a new instance of API.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wiziq.rb', line 13 def initialize(username, password) raise ArgumentError.new('You must provide a username.') if username.nil? raise ArgumentError.new('You must provide a password.') if password.nil? Savon.configure do |config| config.log = true # disable logging config.log_level = :debug # changing the log level #config.logger = Rails.logger # using the Rails logger end @username = username @password = password # @logger = Logging.logger(STDOUT) # @logger.level = :warn # @client = Savon::Client.new do wsdl.document = "http://authorlive.com/aGLIVE/aGLive.asmx?WSDL" end end |
Instance Method Details
#add_attendee(session_code, screenname) ⇒ Object
AddAttendee Web Method
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/wiziq.rb', line 104 def add_attendee(session_code, screenname) body = {'AttendeeList' => { 'SessionCode' => session_code, 'AttendeeList' => {'string' => screenname}}} response = call_api(:add_attendee, body) xml = response.to_hash[:add_attendee_response][:add_attendee_result][:attendee_urls] xml_doc = Nokogiri::XML(xml) screennames = xml_doc.xpath("//Attendee/@screenName") urls = xml_doc.xpath("//Attendee/@Url") resulthash = Hash.new screennames.each do |screenname| x = screennames.index(screenname) resulthash[screenname.value] = urls[x].value end resulthash end |
#add_attendee_to_session(session_code, screenname) ⇒ Object
AddAttendeeToSession Web Method
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/wiziq.rb', line 88 def add_attendee_to_session(session_code, screenname) app_credentials = { 'AppUserName' => @username, 'AppPassword' => @password } builder = Nokogiri::XML::Builder.new do |xml| xml.AddAttendeeToSession { xml.SessionCode session_code xml.Attendee { xml.ID 1234 xml.ScreenName screenname } } end body = { 'AppCredentials' => app_credentials, 'AttendeeListXML' => builder.to_xml } response = call_api(:add_attendee_to_session, body) end |
#convert_date(from, to, date) ⇒ Object
Convert date from one timezone to another args: TZ 1 ID, TZ 2 ID, date: 2010-01-26T11:00:00
165 166 167 168 169 170 171 |
# File 'lib/wiziq.rb', line 165 def convert_date(from, to, date) body = { :pin_time_zone_from => from, :pint_time_zone_to => to, :pdt_date => date.strftime("%Y-%m-%dT%H:%M:%S") } response = call_api(:convert_date, body) converted_date = (response.to_hash[:convert_date_response][:convert_date_result]).to_s DateTime.parse(converted_date) end |
#delete_event(session_code) ⇒ Object
DeleteEvent Web Method
80 81 82 83 84 85 |
# File 'lib/wiziq.rb', line 80 def delete_event(session_code) event_details = { :ln_ses_cod => session_code, :sz_usr_nam => @username, :sz_pwd => @password } body = { 'pstEventDet' => event_details } response = call_api(:delete_event, body) response.to_hash[:delete_event_response][:delete_event_result] end |
#delete_recording(session_codes) ⇒ Object
156 157 158 159 160 161 |
# File 'lib/wiziq.rb', line 156 def delete_recording(session_codes) body = {'DeleteRecordings' => { 'SessionCode' => session_code, 'AttendeeList' => {'string' => screenname}}} response = call_api(:remove_attendee, body) response.to_hash[:remove_attendee_response][:remove_attendee_result] end |
#download_recording ⇒ Object
153 154 |
# File 'lib/wiziq.rb', line 153 def download_recording end |
#get_account_details ⇒ Object
API Method broken
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wiziq.rb', line 35 def get_account_details body = { :psz_usr => @username, :psz_pwd => @password } response = call_api(:get_account_details, body) puts "----------------------" puts response.to_hash puts "----------------------" xml = response.to_hash[:get_account_details_response][:get_account_details_result] puts "----------------------" xml # xml_doc = Nokogiri::XML(xml) # puts xml_doc.to_s # time_zone_ids = xml_doc.xpath("//ALW_TblTimeZones/@ID") # time_zone_names = xml_doc.xpath("//ALW_TblTimeZones/@DisplayName") # time_zone_hash = Hash.new # time_zone_ids.each do |id| # x = time_zone_ids.index(id) # time_zone_hash[id.value] = time_zone_names[x].value # end # # time_zone_hash end |
#get_attendees(session_code) ⇒ Object
GetSessionAttendees Web Method – Broken
129 130 131 132 133 134 |
# File 'lib/wiziq.rb', line 129 def get_attendees(session_code) # event_details = { 'SessionCode' => session_code, 'UserName' => @username, 'Password' => @password } # body = { 'Account' => event_details } # response = call_api(:get_session_attendees, body) #response.to_hash[:get_session_attendees_response][:get_session_attendees_result] end |
#get_my_package ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/wiziq.rb', line 174 def get_my_package body = { 'UserName' => @username, 'Password' => @password } response = call_api(:get_my_package, body) xml = response.to_hash[:get_my_package_response][:get_my_package_result] xml_doc = Nokogiri::XML(xml) package = xml_doc.xpath("//Package/text()") if package.nil? package = xml_doc.xpath("//message/text()") end package end |
#get_time_zones ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/wiziq.rb', line 137 def get_time_zones body = { :psz_usr_nam => @username, :psz_pwd => @password } response = call_api(:get_time_zones, body) xml = response.to_hash[:get_time_zones_response][:get_time_zones_result] xml_doc = Nokogiri::XML(xml) time_zone_ids = xml_doc.xpath("//ALW_TblTimeZones/@ID") time_zone_names = xml_doc.xpath("//ALW_TblTimeZones/@DisplayName") time_zone_hash = Hash.new time_zone_ids.each do |id| x = time_zone_ids.index(id) time_zone_hash[id.value.to_i] = time_zone_names[x].value end time_zone_hash end |
#remove_attendee(session_code, screenname) ⇒ Object
RemoveAttendee Web Method
121 122 123 124 125 |
# File 'lib/wiziq.rb', line 121 def remove_attendee(session_code, screenname) body = {'AttendeeList' => { 'SessionCode' => session_code, 'AttendeeList' => {'string' => screenname}}} response = call_api(:remove_attendee, body) response.to_hash[:remove_attendee_response][:remove_attendee_result] end |
#schedule_new_event(args = {}, attendee_list = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/wiziq.rb', line 60 def schedule_new_event(args = {}, attendee_list = {}) #args[:attendee_list] = attendee_list defaults = { 'UserName' => @username, 'Password' => @password } # test = :user_code => 2, :event_name => 'Test schedule class 1', :date_time => '05/24/2011 01:00:00 pm', :time_zone => 23, :duration => 60, :is_extendable_by_mins => true, :extended_mins => 30, :max_users => 5, :video_size => 'notset', :description => 'Test schedule new event', :attendee_list => array("atnd1","atnd2"), :show_timer => true, :default_tab => 'p', :recoding_replay => true, :audio_quality => 2, :timer_type => false, :categorynumber => 4, :end_session_required => 'entrue' event_details = defaults.merge(args) body = { 'EventDetails' => event_details } response = call_api(:schedule_new_event, body) response.to_hash[:schedule_new_event_response][:schedule_new_event_result] end |
#update_event(args = {}) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/wiziq.rb', line 71 def update_event(args = {}) defaults = { 'UserName' => @username, 'Password' => @password } event_details = defaults.merge(args) body = { 'EventDetails' => event_details } response = call_api(:update_new_event, body) response.to_hash[:update_new_event_response][:update_new_event_result] end |