clickmeetings 0.1.3.1 → 0.1.3.3

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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -1
  4. data/README.md +303 -7
  5. data/clickmeetings.gemspec +5 -3
  6. data/lib/clickmeetings.rb +6 -8
  7. data/lib/clickmeetings/client.rb +7 -8
  8. data/lib/clickmeetings/config.rb +2 -1
  9. data/lib/clickmeetings/engine.rb +0 -1
  10. data/lib/clickmeetings/model.rb +29 -19
  11. data/lib/clickmeetings/models/open/chat.rb +19 -0
  12. data/lib/clickmeetings/models/open/concerns/with_conference.rb +35 -0
  13. data/lib/clickmeetings/models/open/concerns/with_locale.rb +20 -0
  14. data/lib/clickmeetings/models/open/conference.rb +72 -0
  15. data/lib/clickmeetings/models/open/contact.rb +14 -0
  16. data/lib/clickmeetings/models/open/file_library.rb +43 -0
  17. data/lib/clickmeetings/models/open/invitation.rb +30 -0
  18. data/lib/clickmeetings/models/open/login_hash.rb +50 -0
  19. data/lib/clickmeetings/models/open/model.rb +38 -0
  20. data/lib/clickmeetings/models/open/phone_gateway.rb +9 -0
  21. data/lib/clickmeetings/models/open/recording.rb +22 -0
  22. data/lib/clickmeetings/models/open/registration.rb +20 -0
  23. data/lib/clickmeetings/models/open/session.rb +56 -0
  24. data/lib/clickmeetings/models/open/time_zone.rb +15 -0
  25. data/lib/clickmeetings/models/open/token.rb +35 -0
  26. data/lib/clickmeetings/models/privatelabel/account.rb +3 -1
  27. data/lib/clickmeetings/models/privatelabel/conference.rb +20 -11
  28. data/lib/clickmeetings/models/privatelabel/model.rb +5 -4
  29. data/lib/clickmeetings/models/privatelabel/profile.rb +2 -2
  30. data/lib/clickmeetings/storage.rb +10 -0
  31. data/lib/clickmeetings/version.rb +1 -1
  32. data/spec/clickmeetings_spec.rb +46 -0
  33. data/spec/client_spec.rb +27 -4
  34. data/spec/fixtures/delete_conferences_1_recordings.json +3 -0
  35. data/spec/fixtures/get_chats_1.zip +0 -0
  36. data/spec/fixtures/get_conferences.json +48 -0
  37. data/spec/fixtures/get_conferences_1.json +45 -0
  38. data/spec/fixtures/get_conferences_1_recordings.json +10 -0
  39. data/spec/fixtures/get_conferences_1_registrations.json +42 -0
  40. data/spec/fixtures/get_conferences_1_sessions.json +16 -0
  41. data/spec/fixtures/get_conferences_1_sessions_1.json +54 -0
  42. data/spec/fixtures/get_conferences_1_sessions_1_attendees.json +38 -0
  43. data/spec/fixtures/get_conferences_1_sessions_1_generate-pdf_en.json +4 -0
  44. data/spec/fixtures/get_conferences_1_sessions_1_generate-pdf_pl.json +5 -0
  45. data/spec/fixtures/get_conferences_1_sessions_1_generate-pdf_ru.json +4 -0
  46. data/spec/fixtures/get_conferences_1_sessions_1_registrations.json +42 -0
  47. data/spec/fixtures/get_conferences_1_tokens.json +254 -0
  48. data/spec/fixtures/get_conferences_2.json +45 -0
  49. data/spec/fixtures/get_conferences_active.json +1 -0
  50. data/spec/fixtures/get_conferences_inactive.json +1 -0
  51. data/spec/fixtures/get_conferences_skins.json +57 -0
  52. data/spec/fixtures/get_file-library_conferences_1.json +13 -0
  53. data/spec/fixtures/get_time_zone_list.json +422 -0
  54. data/spec/fixtures/get_time_zone_list_ru.json +26 -0
  55. data/spec/fixtures/post_conferences_1_invitation_email_en.json +1 -0
  56. data/spec/fixtures/post_conferences_1_invitation_email_ru.json +1 -0
  57. data/spec/fixtures/post_conferences_1_registration.json +6 -0
  58. data/spec/fixtures/post_conferences_1_room_autologin_hash.json +3 -0
  59. data/spec/fixtures/post_conferences_1_tokens.json +14 -0
  60. data/spec/fixtures/post_conferences_2_invitation_email_en.json +1 -0
  61. data/spec/fixtures/post_contacts.json +3 -0
  62. data/spec/fixtures/post_file-library.json +10 -0
  63. data/spec/fixtures/presentation.pdf +0 -0
  64. data/spec/helpers/fixtures_helpers.rb +1 -1
  65. data/spec/models/open/chat_spec.rb +25 -0
  66. data/spec/models/open/concerns/with_conference_spec.rb +55 -0
  67. data/spec/models/open/concerns/with_locale_spec.rb +23 -0
  68. data/spec/models/open/conference_spec.rb +132 -0
  69. data/spec/models/open/contact_spec.rb +17 -0
  70. data/spec/models/open/file_spec.rb +46 -0
  71. data/spec/models/open/invitation_spec.rb +43 -0
  72. data/spec/models/open/login_hash_spec.rb +59 -0
  73. data/spec/models/open/model_spec.rb +55 -0
  74. data/spec/models/open/recording_spec.rb +21 -0
  75. data/spec/models/open/registration_spec.rb +25 -0
  76. data/spec/models/open/session_spec.rb +73 -0
  77. data/spec/models/open/time_zone_spec.rb +27 -0
  78. data/spec/models/open/token_spec.rb +54 -0
  79. data/spec/models/privatelabel/conference_spec.rb +25 -7
  80. data/spec/shared_examples/tokens_examples.rb +6 -0
  81. data/spec/spec_helper.rb +7 -0
  82. metadata +147 -8
  83. data/lib/clickmeetings/models/open_api/.keep +0 -0
@@ -1,4 +1,3 @@
1
- require 'clickmeetings'
2
1
  require 'rails'
3
2
 
4
3
  module Clickmeetings
@@ -1,4 +1,3 @@
1
- require 'clickmeetings'
2
1
  require 'active_model'
3
2
 
4
3
  module Clickmeetings
@@ -13,7 +12,9 @@ module Clickmeetings
13
12
  attr_accessor :resource_name
14
13
  attr_reader :client_host, :client_api_key
15
14
 
16
- delegate :remote_url, :remote_path, :handle_response, :client, to: :new
15
+ delegate :remote_url, :remote_path, :handle_response, :client,
16
+ :default_params, :default_headers, to: :new
17
+ delegate :first, :last, to: :all
17
18
 
18
19
  def resource_name
19
20
  @resource_name ||= self.name.demodulize.pluralize.downcase
@@ -21,21 +22,21 @@ module Clickmeetings
21
22
 
22
23
  def find(id)
23
24
  response = Clickmeetings.with_client(client_options) do
24
- client.get(remote_url(__method__, id: id))
25
+ client.get(remote_url(__method__, id: id), default_params, default_headers)
25
26
  end
26
27
  handle_response(response)
27
28
  end
28
29
 
29
30
  def all
30
31
  response = Clickmeetings.with_client(client_options) do
31
- client.get(remote_url(__method__))
32
+ client.get(remote_url(__method__), default_params, default_headers)
32
33
  end
33
34
  handle_response(response)
34
35
  end
35
36
 
36
37
  def create(params = {})
37
38
  response = Clickmeetings.with_client(client_options) do
38
- client.post(remote_url(__method__), params)
39
+ client.post(remote_url(__method__), params.merge(default_params), default_headers)
39
40
  end
40
41
  handle_response(response)
41
42
  end
@@ -45,10 +46,7 @@ module Clickmeetings
45
46
  end
46
47
 
47
48
  def client_options
48
- {
49
- url: Clickmeetings.config.host,
50
- api_key: Clickmeetings.config.api_key
51
- }
49
+ { url: Clickmeetings.config.host }
52
50
  end
53
51
  end
54
52
 
@@ -60,28 +58,30 @@ module Clickmeetings
60
58
  end
61
59
 
62
60
  def remote_url(action = nil, params = {})
63
- url = remote_path(action, params)
64
- end
65
-
66
- def persist?
67
- !!id
61
+ remote_path(action, params)
68
62
  end
69
63
 
70
64
  def update(params = {})
71
65
  response = Clickmeetings.with_client(client_options) do
72
- client.put(remote_url(__method__), params)
66
+ client.put(remote_url(__method__), params.merge(default_params), default_headers)
73
67
  end
74
68
  handle_response response
75
69
  end
76
70
 
77
- def destroy(params = {})
78
- Clickmeetings.with_client(client_options) { client.delete(remote_url(__method__), params) }
71
+ def destroy()
72
+ Clickmeetings.with_client(client_options) do
73
+ client.delete(remote_url(__method__), default_params, default_headers)
74
+ end
79
75
  self
80
76
  end
81
77
 
82
78
  def handle_response(body)
83
79
  return unless [Hash, Array].include? body.class
84
- merge_attributes(body)
80
+ result = merge_attributes(body)
81
+ if respond_to?("api_key") && result.respond_to?("associations_api_key=")
82
+ result.associations_api_key = api_key
83
+ end
84
+ result
85
85
  end
86
86
 
87
87
  def remote_path(action = nil, params = {})
@@ -96,11 +96,21 @@ module Clickmeetings
96
96
  "#{resource_name}/#{id}"
97
97
  when :destroy
98
98
  "#{resource_name}/#{id}"
99
+ when :destroy_all
100
+ resource_name
99
101
  else
100
102
  "#{resource_name}/#{params[:id]}/#{action}"
101
103
  end
102
104
  end
103
105
 
106
+ def default_params
107
+ Hash.new
108
+ end
109
+
110
+ def default_headers
111
+ Hash.new
112
+ end
113
+
104
114
  private
105
115
 
106
116
  def merge_attributes(attrs)
@@ -117,7 +127,7 @@ module Clickmeetings
117
127
 
118
128
  def merge_object(attrs)
119
129
  attrs.each do |attribute, val|
120
- if respond_to?(attribute)
130
+ if respond_to?("#{attribute}=")
121
131
  send("#{attribute}=", val)
122
132
  elsif val.is_a? Hash
123
133
  merge_object val
@@ -0,0 +1,19 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Chat < Model
4
+ attr_accessor :name, :time_zone, :date, :time, :download_link
5
+
6
+ class << self
7
+ def find(id)
8
+ response = Clickmeetings.with_client(client_options) do
9
+ Clickmeetings.client.connect.get remote_url(__method__, id: id) do |req|
10
+ req.headers.merge! default_headers
11
+ end
12
+ end
13
+
14
+ response.body
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,35 @@
1
+ module Clickmeetings
2
+ module Open
3
+ module WithConference
4
+ extend ActiveSupport::Concern
5
+
6
+ included { attr_accessor :conference_id }
7
+
8
+ module ClassMethods
9
+ def by_conference(conference_id: nil)
10
+ Storage.cm_current_conference = conference_id
11
+ if block_given?
12
+ result = yield
13
+ Storage.cm_current_conference = nil
14
+ result
15
+ else
16
+ self
17
+ end
18
+ end
19
+
20
+ def conference_id
21
+ Storage.cm_current_conference
22
+ end
23
+ end
24
+
25
+ def initialize(params = {})
26
+ super
27
+ @conference_id ||= self.class.conference_id
28
+ end
29
+
30
+ def remote_url(action = nil, params = {})
31
+ Conference.remote_path(:find, id: conference_id) + '/' + remote_path(action, params)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ module Clickmeetings
2
+ module Open
3
+ module WithLocale
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def locale
8
+ Storage.cm_current_locale || Clickmeetings.config.locale
9
+ end
10
+
11
+ def with_locale(lang = Clickmeetings.config.locale)
12
+ Storage.cm_current_locale = lang
13
+ result = yield if block_given?
14
+ Storage.cm_current_locale = nil
15
+ result
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,72 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Conference < Model
4
+ set_resource_name "conferences"
5
+
6
+ attr_accessor :id, :room_type, :room_pin, :name, :name_url, :description,
7
+ :access_type, :lobby_description, :status, :created_at,
8
+ :updated_at, :permanent_room, :ccc, :starts_at, :ends_at,
9
+ :access_role_hashes, :room_url, :phone_listener_pin,
10
+ :phone_presenter_pin, :embed_room_url, :recorder_list, :account_id,
11
+ :password, :settings, :autologin_hashes, :autologin_hash, :skin_id,
12
+ :registration_enabled, :registration, :associations_api_key
13
+
14
+ class << self
15
+ def all
16
+ active + inactive
17
+ end
18
+
19
+ %w(active inactive).each do |m|
20
+ define_method m do
21
+ response = Clickmeetings.with_client(client_options) do
22
+ Clickmeetings.client.get remote_url(__method__), default_params, default_headers
23
+ end
24
+ handle_response response
25
+ end
26
+ end
27
+
28
+ def skins
29
+ Clickmeetings.with_client(client_options) do
30
+ Clickmeetings.client.get remote_url(__method__), default_params, default_headers
31
+ end
32
+ end
33
+ end
34
+
35
+ def create_tokens(how_many = 1)
36
+ Token.by_conference(conference_id: id) do
37
+ Token.create(how_many: how_many)
38
+ end
39
+ end
40
+
41
+ def create_hash(params = {})
42
+ LoginHash.create params.merge(conference_id: id)
43
+ end
44
+
45
+ def send_invites(params)
46
+ Invitation.send_emails params.merge(conference_id: id)
47
+ end
48
+
49
+ %w(tokens sessions registrations recordings).each do |m|
50
+ define_method m do
51
+ const = "Clickmeetings::Open::#{m.singularize.capitalize}".constantize
52
+ const.with_account(account_api_key: associations_api_key || api_key) do
53
+ const.by_conference(conference_id: id) do
54
+ const.all
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ def files
61
+ FileLibrary.for_conference(conference_id: id)
62
+ end
63
+
64
+ def register(params = {})
65
+ Clickmeetings.with_client(client_options) do
66
+ Clickmeetings.client.post remote_url('registration', id: id),
67
+ params.merge(default_params), default_headers
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,14 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Contact < Model
4
+ attr_accessor :email, :firstname, :lastname, :phone, :company, :country
5
+
6
+ class << self
7
+ def create(params = {})
8
+ super
9
+ new(params)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,43 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class FileLibrary < Model
4
+ set_resource_name 'file-library'
5
+
6
+ attr_accessor :status, :url, :document_type, :conversion_progress, :status_message,
7
+ :name, :upload_date
8
+
9
+ class << self
10
+ def create(path: '', conference_id: nil)
11
+ params = { uploaded: Faraday::UploadIO.new(path, '') }
12
+ if conference_id.present?
13
+ response = Clickmeetings.with_client(client_options) do
14
+ Clickmeetings.client.post remote_url("conferences/#{conference_id}"),
15
+ params.merge(default_params), default_headers
16
+ end
17
+ handle_response response
18
+ else
19
+ super(params)
20
+ end
21
+ end
22
+
23
+ def for_conference(conference_id: nil)
24
+ response = Clickmeetings.with_client(client_options) do
25
+ Clickmeetings.client.get remote_url("conferences/#{conference_id}"),
26
+ default_params, default_headers
27
+ end
28
+ handle_response response
29
+ end
30
+ end
31
+
32
+ # returns content of file; use File#write to save it
33
+ def download
34
+ response = Clickmeetings.with_client(client_options) do
35
+ Clickmeetings.client.connect.get remote_url(__method__, id: id) do |req|
36
+ req.headers.merge! default_headers
37
+ end
38
+ end
39
+ response.body
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,30 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Invitation < Model
4
+ include WithConference
5
+ include WithLocale
6
+
7
+ set_resource_name 'invitation/email'
8
+
9
+ attr_accessor :attendees, :role, :template
10
+
11
+ class << self
12
+ def send_emails(params = {})
13
+ Storage.cm_current_conference =
14
+ params.delete(:conference_id) if params[:conference_id].present?
15
+ with_locale params.delete(:lang) do
16
+ Clickmeetings.with_client(client_options) do
17
+ Clickmeetings.client.post remote_url(locale),
18
+ params.merge(default_params), default_headers
19
+ end
20
+ end
21
+ new(params)
22
+ end
23
+ end
24
+
25
+ def remote_url(action = nil, params = {})
26
+ Conference.remote_path(:find, id: conference_id) + '/' + remote_path(action, params)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,50 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class LoginHash < Model
4
+ class InvalidParamsError < ::Clickmeetings::ClickmeetingError; end
5
+
6
+ set_resource_name "room/autologin_hash"
7
+
8
+ attr_accessor :conference_id, :nickname, :email, :token, :password, :role, :autologin_hash
9
+
10
+ class << self
11
+ attr_reader :conference_id
12
+
13
+ def create(params = {})
14
+ validate_params params
15
+ params[:token] = params[:token].token if params[:token].is_a? Token
16
+ @conference_id = params.delete(:conference_id)
17
+ obj = super
18
+ params.each do |key, value|
19
+ obj.send("#{key}=", value)
20
+ end
21
+ obj
22
+ end
23
+
24
+ private
25
+
26
+ def validate_params(params)
27
+ %i(conference_id nickname email role).each do |param|
28
+ fail InvalidParamsError, "Missing required parameter #{param}" if params[param].nil?
29
+ end
30
+ conf = Conference.find(params[:conference_id])
31
+ if conf.access_type == 2 && params[:password].nil?
32
+ fail InvalidParamsError, "Missing required parameter password"
33
+ elsif conf.access_type == 3 && params[:token].nil?
34
+ fail InvalidParamsError, "Missing required parameter token"
35
+ end
36
+ end
37
+ end
38
+
39
+ def initialize(params = {})
40
+ super
41
+ @conference_id ||= self.class.conference_id
42
+ end
43
+
44
+ def remote_url(action = nil, params = {})
45
+ Conference.remote_path(:find, id: params[:conference_id] || conference_id) +
46
+ '/' + remote_path(action, params)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,38 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Model < ::Clickmeetings::Model
4
+ class << self
5
+ def client_options
6
+ { url: Clickmeetings.config.host }
7
+ end
8
+
9
+ def with_account(account_api_key: nil)
10
+ Storage.cm_open_current_account = account_api_key
11
+ if block_given?
12
+ result = yield
13
+ Storage.cm_open_current_account = nil
14
+ result
15
+ else
16
+ self
17
+ end
18
+ end
19
+
20
+ def ping
21
+ Clickmeetings.with_client(client_options) do
22
+ client.get "ping", default_params, default_headers
23
+ end
24
+ end
25
+
26
+ def api_key
27
+ Storage.cm_open_current_account || Clickmeetings.config.api_key
28
+ end
29
+ end
30
+
31
+ delegate :api_key, to: :class
32
+
33
+ def default_headers
34
+ { "X-Api-Key" => api_key || Clickmeetings.config.api_key }
35
+ end
36
+ end
37
+ end
38
+ end