adobe_connect 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/adobe_connect.gemspec +1 -1
  3. data/lib/adobe_connect.rb +5 -0
  4. data/lib/adobe_connect/acl_field.rb +60 -0
  5. data/lib/adobe_connect/base.rb +128 -0
  6. data/lib/adobe_connect/group.rb +91 -0
  7. data/lib/adobe_connect/meeting.rb +99 -0
  8. data/lib/adobe_connect/meeting_folder.rb +12 -0
  9. data/lib/adobe_connect/param_formatter.rb +6 -0
  10. data/lib/adobe_connect/response.rb +5 -19
  11. data/lib/adobe_connect/service.rb +1 -1
  12. data/lib/adobe_connect/telephony_profile.rb +87 -0
  13. data/lib/adobe_connect/user.rb +21 -55
  14. data/lib/adobe_connect/version.rb +1 -1
  15. data/test/fixtures/acl_field_save_error.xml +6 -0
  16. data/test/fixtures/acl_field_save_success.xml +7 -0
  17. data/test/fixtures/acl_field_update_success.xml +7 -0
  18. data/test/fixtures/{log_in_success.xml → generic_success.xml} +0 -0
  19. data/test/fixtures/group_is_member.xml +13 -0
  20. data/test/fixtures/group_is_not_member.xml +5 -0
  21. data/test/fixtures/group_save_error.xml +6 -0
  22. data/test/fixtures/group_save_success.xml +9 -0
  23. data/test/fixtures/group_update_success.xml +9 -0
  24. data/test/fixtures/meeting_find_by_id_error.xml +4 -0
  25. data/test/fixtures/meeting_find_by_id_success.xml +16 -0
  26. data/test/fixtures/meeting_save_error.xml +6 -0
  27. data/test/fixtures/meeting_save_success.xml +11 -0
  28. data/test/fixtures/meeting_update_success.xml +11 -0
  29. data/test/fixtures/telephony_profile_info_success.xml +13 -0
  30. data/test/fixtures/telephony_profile_list_success.xml +16 -0
  31. data/test/fixtures/telephony_profile_save_error.xml +6 -0
  32. data/test/fixtures/telephony_profile_save_success.xml +7 -0
  33. data/test/fixtures/telephony_profile_update_success.xml +7 -0
  34. data/test/fixtures/user_update_success.xml +4 -0
  35. data/test/lib/adobe_connect/acl_field_test.rb +39 -0
  36. data/test/lib/adobe_connect/adobe_connect_base_tests.rb +121 -0
  37. data/test/lib/adobe_connect/config_test.rb +1 -1
  38. data/test/lib/adobe_connect/group_test.rb +77 -0
  39. data/test/lib/adobe_connect/meeting_folder_test.rb +3 -7
  40. data/test/lib/adobe_connect/meeting_test.rb +117 -0
  41. data/test/lib/adobe_connect/param_formatter_test.rb +1 -1
  42. data/test/lib/adobe_connect/response_test.rb +1 -1
  43. data/test/lib/adobe_connect/service_test.rb +5 -8
  44. data/test/lib/adobe_connect/telephony_profile_test.rb +41 -0
  45. data/test/lib/adobe_connect/user_test.rb +29 -84
  46. data/test/test_helper.rb +16 -0
  47. metadata +87 -28
@@ -1,7 +1,9 @@
1
+ require 'delegate'
2
+
1
3
  module AdobeConnect
2
4
 
3
5
  # Public: A response from the Connect API.
4
- class Response
6
+ class Response < SimpleDelegator
5
7
  attr_reader :status, :body
6
8
 
7
9
  # Public: Create a new AdobeConnect::Response.
@@ -11,6 +13,8 @@ module AdobeConnect
11
13
  @response = response
12
14
  @status = response.code.to_i
13
15
  @body = Nokogiri::XML(response.body)
16
+
17
+ __setobj__(@body)
14
18
  end
15
19
 
16
20
  # Public: Fetch the given header's value.
@@ -21,23 +25,5 @@ module AdobeConnect
21
25
  def fetch(header)
22
26
  @response.fetch(header)
23
27
  end
24
-
25
- # Public: Execute an xpath call against the response body.
26
- #
27
- # *args - Arguments to pass to Nokogiri's xpath method.
28
- #
29
- # Returns a Nokogiri object.
30
- def xpath(*args)
31
- @body.xpath(*args)
32
- end
33
-
34
- # Public: Execute an at_xpath call against the response body.
35
- #
36
- # *args - Arguments to pass to Nokogiri's xpath method.
37
- #
38
- # Returns a Nokogiri object.
39
- def at_xpath(*args)
40
- @body.at_xpath(*args)
41
- end
42
28
  end
43
29
  end
@@ -79,7 +79,7 @@ module AdobeConnect
79
79
  # use_session - If true, require an active session (default: true).
80
80
  #
81
81
  # Returns an AdobeConnect::Response.
82
- def request(action, params, use_session = true)
82
+ def request(action, params={}, use_session = true)
83
83
  if use_session
84
84
  log_in unless authenticated?
85
85
  params[:session] = session
@@ -0,0 +1,87 @@
1
+ module AdobeConnect
2
+
3
+ # Public: Represents a Group in a Connect environment.
4
+ class TelephonyProfile < Base
5
+ attr_accessor :conf_number, :location, :principal_id,
6
+ :name, :status, :provider_id
7
+
8
+ #
9
+ # telephony_profile_options - A hash with the following keys:
10
+ # name - The profile's name.
11
+ # status - Status of the profile (enabled or disabled)
12
+ # conf_number - Conference number associated with profile
13
+ # location - Country code for conference number, required
14
+ # if conf_number present
15
+ # principal_id- ID of User that the profile should belong
16
+ # to, defaults to logged in user
17
+ # provider_id - ID of the telephony provider
18
+ #
19
+
20
+ def attrs
21
+ atrs = { :profile_name => self.name }
22
+
23
+ if !self.id.nil?
24
+ atrs.merge!(:profile_id => self.id)
25
+ end
26
+
27
+ [:id, :status].each do |atr|
28
+ if !self.send(atr).nil?
29
+ atrs.merge!("profile_#{atr}".to_sym => self.send(atr))
30
+ end
31
+ end
32
+
33
+ [:principal_id, :provider_id].each do |atr|
34
+ if !self.send(atr).nil?
35
+ atrs.merge!(atr => self.send(atr))
36
+ end
37
+ end
38
+
39
+ if !self.conf_number.nil? && !self.location.nil?
40
+ atrs.merge!(:conf_number => self.conf_number, :location => self.location)
41
+ end
42
+
43
+ atrs
44
+ end
45
+
46
+ def self.config
47
+ super.merge({ :ac_obj_type => 'profile', :delete_method_is_plural => false,
48
+ :ac_obj_node_name => 'telephony-profile', :ac_method_prefix => 'telephony_profile' })
49
+ end
50
+
51
+ # Public: Find the specified profile on the Connect server.
52
+ #
53
+ # name - Profile's name on Connect server
54
+ # principal_id - ID of user on Connect server that the Telephony
55
+ # Profile belongs to. Will use API user by default.
56
+ #
57
+ # Returns an AdobeConnect::TelephonyProfile or nil.
58
+ def self.find_by_name(name, principal_id = nil, service = AdobeConnect::Service.new)
59
+ params = {}
60
+ params.merge!(:principal_id => principal_id) unless principal_id.nil?
61
+
62
+ response = service.telephony_profile_list(params)
63
+
64
+ matching_profiles = response.at_xpath('//telephony-profiles').children.select{|c|
65
+ name_node = c.children.select{|ch| ch.name == 'profile-name' }[0]
66
+ name_node.text == name
67
+ }
68
+
69
+ if matching_profiles.count == 1
70
+ prof_id = matching_profiles[0].attr('profile-id')
71
+ resp = service.telephony_profile_info(:profile_id => prof_id)
72
+ self.load_from_xml(resp.at_xpath('//telephony-profile'), principal_id)
73
+ end
74
+ end
75
+
76
+ private
77
+ def self.load_from_xml(p, principal_id)
78
+ self.new({
79
+ :name => p.at_xpath('//profile-name').text,
80
+ :id => p.attr('profile-id'),
81
+ :status => p.attr('profile-status'),
82
+ :principal_id => principal_id,
83
+ :provider_id => p.attr('provider-id')
84
+ })
85
+ end
86
+ end
87
+ end
@@ -1,26 +1,35 @@
1
1
  module AdobeConnect
2
2
 
3
3
  # Public: Represents a user in a Connect environment.
4
- class User
5
- # Public: SCO-ID from the Adobe Connect instance.
6
- attr_reader :id
4
+ class User < Base
5
+ attr_accessor :first_name, :last_name, :email, :username, :uuid, :send_email
7
6
 
8
- attr_reader :service, :errors
9
- attr_accessor :first_name, :last_name, :email, :username, :uuid
10
-
11
- # Public: Create a new AdobeConnect User.
12
7
  #
13
8
  # user_options - A hash with the following keys:
14
9
  # first_name - User's first name.
15
10
  # last_name - User's last name.
16
11
  # email - The email address for the user.
12
+ # username - The login for the connect user.
17
13
  # uuid - A unique identifier for this user (used to
18
14
  # generate a password).
19
- # service - An AdobeConnect::Service object (default: Service.new)
20
- def initialize(user_options, service = Service.new)
21
- user_options.each { |key, value| send(:"#{key}=", value) }
22
- @service = service
23
- @errors = []
15
+ # send_email - The server sends a welcome e-mail with login information
16
+ # to the user’s e-mail address.
17
+ #
18
+
19
+ def attrs
20
+ atrs = { :first_name => first_name,
21
+ :last_name => last_name, :login => username,
22
+ :email => email, :send_email => send_email,
23
+ :has_children => 0 }
24
+ if !self.id.nil?
25
+ atrs.merge!(:principal_id => self.id)
26
+ else
27
+ atrs.merge!(
28
+ :password => password,
29
+ :type => 'user'
30
+ )
31
+ end
32
+ atrs
24
33
  end
25
34
 
26
35
  # Public: Getter for the Connect user's username. If no username is
@@ -38,37 +47,6 @@ module AdobeConnect
38
47
  Digest::MD5.hexdigest(uuid)[0..9]
39
48
  end
40
49
 
41
- # Public: Save this user to the Adobe Connect instance.
42
- #
43
- # Returns a boolean.
44
- def save
45
- response = service.principal_update(:first_name => first_name,
46
- :last_name => last_name, :login => username,
47
- :password => password, :type => 'user', :has_children => 0,
48
- :email => email)
49
-
50
- if response.at_xpath('//status').attr('code') == 'ok'
51
- self.id = response.at_xpath('//principal').attr('principal-id')
52
- true
53
- else
54
- save_errors(response)
55
- false
56
- end
57
- end
58
-
59
- # Public: Create a Connect user from the given app user.
60
- #
61
- # user_options - Generic user options (see #initialize for required
62
- # attributes).
63
- #
64
- # Returns an AdobeConnect::User.
65
- def self.create(user_options)
66
- user = AdobeConnect::User.new(user_options)
67
- user.save
68
-
69
- user
70
- end
71
-
72
50
  # Public: Find the given app user on the Connect server.
73
51
  #
74
52
  # app_user - Generic user options (see #initialize for required
@@ -84,17 +62,5 @@ module AdobeConnect
84
62
  user
85
63
  end
86
64
  end
87
-
88
- private
89
- attr_writer :id
90
-
91
- # Internal: Store request errors in @errors.
92
- #
93
- # response - An AdobeConnect::Response.
94
- #
95
- # Returns nothing.
96
- def save_errors(response)
97
- @errors = response.xpath('//invalid').map(&:attributes)
98
- end
99
65
  end
100
66
  end
@@ -1,4 +1,4 @@
1
1
  module AdobeConnect
2
2
  # Public: Current Gem version.
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.2'
4
4
  end
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="invalid">
4
+ <invalid field="prepared-statement" type="long" subcode="format"/>
5
+ </status>
6
+ </results>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <field account-id="7" is-primary="true" is-required="false" field-id="26243" object-type="object-type-principal" display-seq="11" field-type="text" permission-id="manage">
5
+ <name>Phone</name>
6
+ </field>
7
+ </results>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <field display-seq="12" account-id="7" is-primary="true" is-required="false" field-id="26243" object-type="object-type-principal" field-type="text" permission-id="manage">
5
+ <name>Phone 2</name>
6
+ </field>
7
+ </results>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <principal-list>
5
+ <principal principal-id="26243" account-id="7" type="user" has-children="false" is-primary="false" is-hidden="false" training-group-id="">
6
+ <name>Testing User</name>
7
+ <login>testinguser@example.com</login>
8
+ <email>testinguser@example.com</email>
9
+ <display-uid>testinguser@example.com</display-uid>
10
+ <is-member>true</is-member>
11
+ </principal>
12
+ </principal-list>
13
+ </results>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <principal-list/>
5
+ </results>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="invalid">
4
+ <invalid field="login" type="string" subcode="duplicate"/>
5
+ </status>
6
+ </results>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <principal type="group" has-children="1" account-id="7" principal-id="26243">
5
+ <description>This is for testing</description>
6
+ <name>Test group name</name>
7
+ <login>Test group name</login>
8
+ </principal>
9
+ </results>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <principal type="group" has-children="1" account-id="7" principal-id="26243">
5
+ <description>This is for testing updates</description>
6
+ <name>Test group name</name>
7
+ <login>Test group name</login>
8
+ </principal>
9
+ </results>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="no-access" subcode="denied"/>
4
+ </results>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok" />
4
+ <sco account-id="1234" disabled="" display-seq="0" folder-id="1234567" icon="meeting" lang="en" max-retries="" sco-id="98765" source-sco-id="" type="meeting" version="0">
5
+ <date-begin>2014-03-05T16:00:00.000-08:00</date-begin>
6
+ <date-created>2014-03-06T08:40:36.757-08:00</date-created>
7
+ <date-end>2014-03-05T17:00:00.000-08:00</date-end>
8
+ <date-modified>2014-03-06T09:51:10.407-08:00</date-modified>
9
+ <name>THE Meeting</name>
10
+ <url-path>/r3wrt7zkrpg/</url-path>
11
+ <update-linked-item>true</update-linked-item>
12
+ </sco>
13
+ <seminar-session-expiry-info>
14
+ <seminar-session-expired>false</seminar-session-expired>
15
+ </seminar-session-expiry-info>
16
+ </results>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="invalid">
4
+ <invalid field="folder-id" type="id" subcode="format"/>
5
+ </status>
6
+ </results>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <sco account-id="7" disabled="" display-seq="0" folder-id="12345" icon="meeting" lang="en" max-retries="" sco-id="26243" source-sco-id="" type="meeting" version="0">
5
+ <date-created>2013-06-22T14:22:14.380-04:00</date-created>
6
+ <date-modified>2013-06-22T14:22:14.380-04:00</date-modified>
7
+ <description>This is an important meeting</description>
8
+ <name>Important Meeting</name>
9
+ <url-path>/r2zssih0kaq/</url-path>
10
+ </sco>
11
+ </results>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <sco account-id="7" disabled="" display-seq="0" folder-id="12345" icon="meeting" lang="en" max-retries="" sco-id="26243" source-sco-id="" type="meeting" version="0">
5
+ <date-created>2013-06-22T14:22:14.380-04:00</date-created>
6
+ <date-modified>2013-06-22T14:22:14.380-04:00</date-modified>
7
+ <description>This is an important meeting</description>
8
+ <name>Important Meeting</name>
9
+ <url-path>/r2zssih0kaq/</url-path>
10
+ </sco>
11
+ </results>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <telephony-profile profile-id="26243" provider-id="987654321" profile-status="enabled" hide-toll-free="false" provider-type="user-conf">
5
+ <adaptor-id>987654321-adaptor</adaptor-id>
6
+ <provider-name>SoundConnect</provider-name>
7
+ <profile-name>SoundConnect</profile-name>
8
+ <provider-status>enabled</provider-status>
9
+ </telephony-profile>
10
+ <telephony-profile-fields disabled="" hide-toll-free="false" principal-id="123456" profile-id="26243" profile-status="enabled" provider-id="987654321">
11
+ <profile-name>SoundConnect</profile-name>
12
+ </telephony-profile-fields>
13
+ </results>
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <telephony-profiles>
5
+ <profile profile-id="789456" provider-id="987654321" profile-status="enabled">
6
+ <adaptor-id>987654321-adaptor</adaptor-id>
7
+ <name>SoundConnect Provider</name>
8
+ <profile-name>SoundConnect2</profile-name>
9
+ </profile>
10
+ <profile profile-id="26243" provider-id="987654321" profile-status="enabled">
11
+ <adaptor-id>987654321-adaptor</adaptor-id>
12
+ <name>SoundConnect Provider</name>
13
+ <profile-name>SoundConnect</profile-name>
14
+ </profile>
15
+ </telephony-profiles>
16
+ </results>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="invalid">
4
+ <invalid field="profile-name" type="string" subcode="duplicate"/>
5
+ </status>
6
+ </results>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <telephony-profile profile-status="enabled" provider-id="1160437530" principal-id="1144604670" profile-id="26243">
5
+ <profile-name>SoundConnect</profile-name>
6
+ </telephony-profile>
7
+ </results>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <results>
3
+ <status code="ok"/>
4
+ <telephony-profile profile-status="enabled" provider-id="1160437530" principal-id="1144604670" profile-id="26243">
5
+ <profile-name>SoundConnect2</profile-name>
6
+ </telephony-profile>
7
+ </results>