clickmeetings 0.1.3.1 → 0.2.0

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 (84) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/run-tests.yml +26 -0
  3. data/.gitignore +1 -0
  4. data/README.md +305 -7
  5. data/clickmeetings.gemspec +24 -19
  6. data/lib/clickmeetings/client.rb +8 -9
  7. data/lib/clickmeetings/config.rb +2 -1
  8. data/lib/clickmeetings/engine.rb +0 -1
  9. data/lib/clickmeetings/model.rb +36 -22
  10. data/lib/clickmeetings/models/open/chat.rb +19 -0
  11. data/lib/clickmeetings/models/open/concerns/with_conference.rb +35 -0
  12. data/lib/clickmeetings/models/open/concerns/with_locale.rb +20 -0
  13. data/lib/clickmeetings/models/open/conference.rb +72 -0
  14. data/lib/clickmeetings/models/open/contact.rb +14 -0
  15. data/lib/clickmeetings/models/open/file_library.rb +43 -0
  16. data/lib/clickmeetings/models/open/invitation.rb +30 -0
  17. data/lib/clickmeetings/models/open/login_hash.rb +50 -0
  18. data/lib/clickmeetings/models/open/model.rb +38 -0
  19. data/lib/clickmeetings/models/open/phone_gateway.rb +9 -0
  20. data/lib/clickmeetings/models/open/recording.rb +22 -0
  21. data/lib/clickmeetings/models/open/registration.rb +20 -0
  22. data/lib/clickmeetings/models/open/session.rb +56 -0
  23. data/lib/clickmeetings/models/open/time_zone.rb +15 -0
  24. data/lib/clickmeetings/models/open/token.rb +35 -0
  25. data/lib/clickmeetings/models/privatelabel/account.rb +3 -1
  26. data/lib/clickmeetings/models/privatelabel/conference.rb +20 -11
  27. data/lib/clickmeetings/models/privatelabel/model.rb +5 -4
  28. data/lib/clickmeetings/models/privatelabel/profile.rb +2 -2
  29. data/lib/clickmeetings/storage.rb +10 -0
  30. data/lib/clickmeetings/version.rb +1 -1
  31. data/lib/clickmeetings.rb +6 -8
  32. data/spec/clickmeetings_spec.rb +46 -0
  33. data/spec/client_spec.rb +26 -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 +187 -49
  83. data/.travis.yml +0 -5
  84. data/lib/clickmeetings/models/open_api/.keep +0 -0
@@ -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
@@ -0,0 +1,9 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class PhoneGateway < Model
4
+ set_resource_name 'phone_gateways'
5
+
6
+ attr_accessor :code, :location, :value, :geo
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Recording < Model
4
+ include WithConference
5
+
6
+ attr_accessor :recording_duration, :recording_file_size, :recording_started, :recording_url,
7
+ :recording_start_date
8
+
9
+ class << self
10
+ def destroy_all
11
+ res = all
12
+
13
+ Clickmeetings.with_client(client_options) do
14
+ Clickmeetings.client.delete remote_url(__method__), default_params, default_headers
15
+ end
16
+
17
+ res
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Registration < Model
4
+ include WithConference
5
+
6
+ attr_accessor :registration_date, :registration_confirmed, :fields, :session_id,
7
+ :email, :visitor_nickname, :url, :r, :http_referer, :country, :city
8
+
9
+ class << self
10
+ def for_session(session_id: nil)
11
+ Session.by_conference(conference_id: conference_id).new(id: session_id).registrations
12
+ end
13
+
14
+ def create(params = {})
15
+ Conference.new(id: conference_id).register(params)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,56 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Session < Model
4
+ include WithConference
5
+ include WithLocale
6
+
7
+ attr_accessor :total_visitors, :max_vistors, :start_date, :end_date, :attendees, :pdf,
8
+ :associations_api_key
9
+ delegate :locale, :with_locale, :find, to: :class
10
+
11
+ class << self
12
+ def find(id)
13
+ obj = super
14
+ obj.id = id
15
+ obj
16
+ end
17
+ end
18
+
19
+ def attendees
20
+ self.class.with_account account_api_key: associations_api_key do
21
+ Clickmeetings.with_client(client_options) do
22
+ Clickmeetings.client.get remote_url(__method__, id: id), default_params, default_headers
23
+ end
24
+ end
25
+ end
26
+
27
+ def generate_pdf(lang = nil)
28
+ self.class.with_account account_api_key: associations_api_key do
29
+ with_locale lang do
30
+ Clickmeetings.with_client(client_options) do
31
+ Clickmeetings.client.get remote_url("generate-pdf/#{locale}", id: id),
32
+ default_params, default_headers
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ def get_report(lang = nil)
39
+ gen_pdf_response = generate_pdf(lang)
40
+ return unless gen_pdf_response["status"] == "FINISHED"
41
+ gen_pdf_response["url"] # solve this
42
+ end
43
+
44
+ def registrations
45
+ self.class.with_account account_api_key: associations_api_key do
46
+ response = Clickmeetings.with_client(client_options) do
47
+ Clickmeetings.client.get remote_url(__method__, id: id), default_params, default_headers
48
+ end
49
+ Registration.by_conference(conference_id: conference_id) do
50
+ Registration.handle_response response
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class TimeZone < Model
4
+ set_resource_name 'time_zone_list'
5
+
6
+ class << self
7
+ def all(country: nil)
8
+ Clickmeetings.with_client(client_options) do
9
+ Clickmeetings.client.get remote_url(country), default_params, default_headers
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,35 @@
1
+ module Clickmeetings
2
+ module Open
3
+ class Token < Model
4
+ class NoConferenceError < ::Clickmeetings::ClickmeetingError; end
5
+
6
+ include WithConference
7
+
8
+ set_resource_name "tokens"
9
+
10
+ attr_accessor :token, :sent_to_email, :first_use_date
11
+
12
+ class << self
13
+ def all
14
+ fail NoConferenceError if conference_id.nil?
15
+ response = Clickmeetings.with_client(client_options) do
16
+ Clickmeetings.client.get remote_url(__method__), default_params, default_headers
17
+ end
18
+ handle_response response["access_tokens"]
19
+ end
20
+
21
+ def create(params = {})
22
+ fail NoConferenceError if conference_id.nil?
23
+ response = Clickmeetings.with_client(client_options) do
24
+ Clickmeetings.client.post remote_url(__method__), params.merge(default_params), default_headers
25
+ end
26
+ handle_response response["access_tokens"]
27
+ end
28
+ end
29
+
30
+ def create_hash(params = {})
31
+ LoginHash.create params.merge(conference_id: conference_id, token: token)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -20,7 +20,9 @@ module Clickmeetings
20
20
 
21
21
  %w(enable disable).each do |m|
22
22
  define_method m do
23
- Clickmeetings.with_client(client_options) { client.put(remote_url(__method__, id: id)) }
23
+ Clickmeetings.with_client(client_options) do
24
+ client.put(remote_url(__method__, id: id), default_params)
25
+ end
24
26
  @account_status = (m == "enable" ? "active" : "disabled")
25
27
  self
26
28
  end
@@ -5,36 +5,45 @@ module Clickmeetings
5
5
  :access_type, :lobby_description, :status, :created_at,
6
6
  :updated_at, :permanent_room, :ccc, :starts_at, :ends_at,
7
7
  :access_role_hashes, :room_url, :phone_listener_pin,
8
- :phone_presenter_pin, :embed_room_url, :recorder_list, :account_id
8
+ :phone_presenter_pin, :embed_room_url, :recorder_list, :account_id,
9
+ :password
9
10
 
10
11
  class NoAccountError < ::Clickmeetings::ClickmeetingError; end
11
12
 
12
13
  class << self
13
- attr_reader :account_id
14
-
15
14
  def by_account(account_id: nil)
16
- @account_id = account_id
17
- self
15
+ Storage.cm_private_current_account = account_id
16
+ if block_given?
17
+ result = yield
18
+ Storage.cm_private_current_account = nil
19
+ result
20
+ else
21
+ self
22
+ end
18
23
  end
19
24
 
20
25
  def find(id)
21
- fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
26
+ fail Clickmeetings::PrivateLabel::Conference::NoAccountError if account_id.nil?
22
27
  super
23
28
  end
24
29
 
25
30
  def all
26
- fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
31
+ fail Clickmeetings::PrivateLabel::Conference::NoAccountError if account_id.nil?
27
32
  response = Clickmeetings.with_client(client_options) do
28
- Clickmeetings.client.get remote_url(__method__)
33
+ Clickmeetings.client.get remote_url(__method__), default_params
29
34
  end
30
- response = response["active_conferences"] + response["inactive_conferences"]
35
+ response = response["active_conferences"].to_a + response["inactive_conferences"].to_a
31
36
  handle_response response
32
37
  end
33
38
 
34
39
  def create(params = {})
35
- fail Clickmeetings::PrivateLabel::Conference::NoAccountError if @account_id.nil?
40
+ fail Clickmeetings::PrivateLabel::Conference::NoAccountError if account_id.nil?
36
41
  super
37
42
  end
43
+
44
+ def account_id
45
+ Storage.cm_private_current_account
46
+ end
38
47
  end
39
48
 
40
49
  def initialize(params = {})
@@ -43,7 +52,7 @@ module Clickmeetings
43
52
  end
44
53
 
45
54
  def remote_url(action = nil, params = {})
46
- url = Account.remote_path(:find, id: @account_id) + '/' + remote_path(action, params)
55
+ "#{Account.remote_path(:find, id: @account_id)}/#{remote_path(action, params)}"
47
56
  end
48
57
 
49
58
  def update(params = {})
@@ -3,12 +3,13 @@ module Clickmeetings
3
3
  class Model < ::Clickmeetings::Model
4
4
  class << self
5
5
  def client_options
6
- {
7
- url: Clickmeetings.config.privatelabel_host,
8
- api_key: Clickmeetings.config.privatelabel_api_key
9
- }
6
+ { url: Clickmeetings.config.privatelabel_host }
10
7
  end
11
8
  end
9
+
10
+ def default_params
11
+ { api_key: Clickmeetings.config.privatelabel_api_key }
12
+ end
12
13
  end
13
14
  end
14
15
  end
@@ -1,6 +1,6 @@
1
1
  module Clickmeetings
2
2
  module PrivateLabel
3
- class Profile < Model
3
+ class Profile < ::Clickmeetings::PrivateLabel::Model
4
4
  attr_accessor :id, :account_manager_email, :email, :phone,
5
5
  :account_manager_name, :account_manager_phone,
6
6
  :name, :packages
@@ -11,7 +11,7 @@ module Clickmeetings
11
11
 
12
12
  def get
13
13
  response = Clickmeetings.with_client(client_options) do
14
- Clickmeetings.client.get('client')
14
+ Clickmeetings.client.get 'client', default_params, default_headers
15
15
  end
16
16
  handle_response response
17
17
  end
@@ -0,0 +1,10 @@
1
+ require 'active_support/per_thread_registry'
2
+
3
+ module Clickmeetings
4
+ class Storage
5
+ extend ActiveSupport::PerThreadRegistry
6
+
7
+ attr_accessor :cm_current_conference, :cm_current_locale, :cm_open_current_account,
8
+ :cm_private_current_account
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Clickmeetings
2
- VERSION = "0.1.3.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/clickmeetings.rb CHANGED
@@ -3,23 +3,20 @@ require 'clickmeetings/config'
3
3
  require 'clickmeetings/client'
4
4
  require 'clickmeetings/model'
5
5
  require 'clickmeetings/exceptions'
6
+ require 'clickmeetings/storage'
6
7
 
7
8
  require 'clickmeetings/models/privatelabel/model'
8
- require 'clickmeetings/models/privatelabel/account'
9
- require 'clickmeetings/models/privatelabel/conference'
10
- require 'clickmeetings/models/privatelabel/profile'
9
+ Gem.find_files('clickmeetings/models/privatelabel/*.rb').each { |f| require f }
11
10
 
12
- Gem.find_files('clickmeetings/models/open_api/*.rb').each { |f| require f }
11
+ require 'clickmeetings/models/open/model'
12
+ Gem.find_files('clickmeetings/models/open/concerns/*.rb').each { |f| require f }
13
+ Gem.find_files('clickmeetings/models/open/*.rb').each { |f| require f }
13
14
 
14
15
  module Clickmeetings
15
16
  def self.config
16
17
  @config ||= Config.new
17
18
  end
18
19
 
19
- def self.properties
20
- client.properties
21
- end
22
-
23
20
  def self.configure
24
21
  yield(config) if block_given?
25
22
  end
@@ -31,6 +28,7 @@ module Clickmeetings
31
28
  def self.reset
32
29
  @config = nil
33
30
  @client = nil
31
+ ClientRegistry.client = nil
34
32
  end
35
33
 
36
34
  def self.with_client(client)
@@ -4,4 +4,50 @@ describe Clickmeetings do
4
4
  it 'has a version number' do
5
5
  expect(Clickmeetings::VERSION).not_to be nil
6
6
  end
7
+
8
+ describe '::configure' do
9
+ before do
10
+ described_class.configure do |config|
11
+ config.host = "http://teachbase.ru"
12
+ config.privatelabel_host = "http://go.teachbase.ru"
13
+ end
14
+ end
15
+
16
+ subject { described_class.config }
17
+
18
+ it "sets config", :aggregate_failures do
19
+ expect(subject.host).to eq "http://teachbase.ru"
20
+ expect(subject.privatelabel_host).to eq "http://go.teachbase.ru"
21
+ end
22
+ end
23
+
24
+ describe '::reset' do
25
+ subject { described_class.reset }
26
+
27
+ context "config" do
28
+ before(:each) do
29
+ described_class.configure do |config|
30
+ config.host = "http://teachbase.ru"
31
+ config.privatelabel_host = "http://go.teachbase.ru"
32
+ end
33
+ end
34
+
35
+ it "resets config" do
36
+ expect { subject }.to change { described_class.config.host }
37
+ .from("http://teachbase.ru").to("https://api.clickmeeting.com/v1")
38
+ end
39
+ end
40
+
41
+ context "client" do
42
+ before(:each) do
43
+ described_class::ClientRegistry.client =
44
+ described_class::Client.new(url: "http://teachbase.ru")
45
+ end
46
+
47
+ it "resets client" do
48
+ expect { subject }.to change { described_class.client.url }
49
+ .from("http://teachbase.ru").to("https://api.clickmeeting.com/v1")
50
+ end
51
+ end
52
+ end
7
53
  end