clickmeetings 0.1.3.1 → 0.1.3.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,26 @@
1
+ [
2
+ "Asia/Anadyr",
3
+ "Asia/Barnaul",
4
+ "Asia/Chita",
5
+ "Asia/Irkutsk",
6
+ "Asia/Kamchatka",
7
+ "Asia/Khandyga",
8
+ "Asia/Krasnoyarsk",
9
+ "Asia/Magadan",
10
+ "Asia/Novokuznetsk",
11
+ "Asia/Novosibirsk",
12
+ "Asia/Omsk",
13
+ "Asia/Sakhalin",
14
+ "Asia/Srednekolymsk",
15
+ "Asia/Ust-Nera",
16
+ "Asia/Vladivostok",
17
+ "Asia/Yakutsk",
18
+ "Asia/Yekaterinburg",
19
+ "Europe/Astrakhan",
20
+ "Europe/Kaliningrad",
21
+ "Europe/Moscow",
22
+ "Europe/Samara",
23
+ "Europe/Simferopol",
24
+ "Europe/Ulyanovsk",
25
+ "Europe/Volgograd"
26
+ ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "status": "OK",
3
+ "exist": 1,
4
+ "url": "http://qwerewrq.anysecond.com/861961162?r=AmDkZwp2AKk8Jz54ozHtHzI6Lau1qzS8sUWyrz54BGINqUchqaxhpTW6sUjmZwNmZQL2",
5
+ "r": "AmDkZwp2AKk8Jz54ozHtHzI6Lau1qzS8sUWyrz54BGINqUchqaxhpTW6sUjmZwNmZQL2"
6
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "autologin_hash": "BQtlZGDkDUjgsROxMUWdMTcxnaWlMTcNMTIdpaWynzEypzbhMTcNsP18DTEdpzEdMUWNsP18DREXHxEXHxO8YKkNZQx5omxmpz42Z3SmpGqmZKV5owuhpwNjAGtmZUV3AaONsP18DN____"
3
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "access_tokens": [
3
+ {
4
+ "token": "87969E",
5
+ "sent_to_email": null,
6
+ "first_use_date": null
7
+ },
8
+ {
9
+ "token": "Y7P4HP",
10
+ "sent_to_email": null,
11
+ "first_use_date": null
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "status": "OK"
3
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "id": 774922,
3
+ "name": "pdf-5.pdf",
4
+ "document_type": "presentation_pdf",
5
+ "conversion_progress": 0,
6
+ "upload_date": "2016-11-24 15:41:41",
7
+ "status": "waiting_for_conversion",
8
+ "status_message": "waiting for multiconverter to download file.",
9
+ "url": "http://api.anysecond.com/v1/file-library/774922/download"
10
+ }
@@ -5,7 +5,7 @@ module FixturesHelpers
5
5
  end
6
6
 
7
7
  def build_file_name(verb, name)
8
- name = [verb, name.gsub("/", "_")].join("_")
8
+ name = [verb, name.gsub("/", "_").sub(/_+$/, '')].join("_")
9
9
  "./spec/fixtures/#{name}.json"
10
10
  end
11
11
  end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::Chat do
4
+ describe '::find' do
5
+ before do
6
+ stub_request(:get, 'https://api.clickmeeting.com/v1/chats/1')
7
+ .to_return(
8
+ status: 200,
9
+ headers: {
10
+ "content-type"=>"application/zip",
11
+ "transfer-encoding"=>"chunked",
12
+ "connection"=>"close",
13
+ "content-disposition"=>"attachment; filename=chat_history_5342110_20161117_161522.zip"
14
+ },
15
+ body: File.read('spec/fixtures/get_chats_1.zip')
16
+ )
17
+ end
18
+
19
+ subject { described_class.find(1) }
20
+
21
+ it "responds with file content" do
22
+ expect(subject).to eq(File.read('spec/fixtures/get_chats_1.zip'))
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'WithConference' do
4
+ before(:all) do
5
+ class TestClassWithConference < Clickmeetings::Open::Model
6
+ include Clickmeetings::Open::WithConference
7
+ end
8
+ end
9
+
10
+ let(:described_class) { TestClassWithConference }
11
+
12
+ describe '::by_conference' do
13
+ context 'when use without block' do
14
+ subject { described_class.conference_id }
15
+
16
+ specify do
17
+ described_class.by_conference conference_id: 1
18
+ expect(subject).to eq 1
19
+ end
20
+
21
+ context 'gives conference_id to objects' do
22
+ subject { described_class.new.conference_id }
23
+
24
+ specify do
25
+ described_class.by_conference conference_id: 1
26
+ expect(subject).to eq 1
27
+ end
28
+ end
29
+ end
30
+
31
+ context 'when use with block' do
32
+ subject do
33
+ described_class.by_conference conference_id: 1 do
34
+ described_class.conference_id
35
+ end
36
+ end
37
+
38
+ it "uses specified conference_id in block" do
39
+ expect(subject).to eq 1
40
+ end
41
+
42
+ it "hasn't conference_id out of block" do
43
+ expect(described_class.conference_id).to be_nil
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#remote_url' do
49
+ subject { described_class.by_conference(conference_id: 1).remote_url(:all) }
50
+
51
+ it "uses conference prefix" do
52
+ expect(subject).to match(/^conferences\/1\//)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe 'WithLocale' do
4
+ before(:all) do
5
+ class TestClassWithLocale < Clickmeetings::Open::Model
6
+ include Clickmeetings::Open::WithLocale
7
+ end
8
+ end
9
+
10
+ let(:described_class) { TestClassWithLocale }
11
+
12
+ describe '::with_locale' do
13
+ subject { described_class.with_locale("ru") { described_class.locale } }
14
+
15
+ it "uses specified locale in block" do
16
+ expect(subject).to eq("ru")
17
+ end
18
+
19
+ it "uses default locale out of block" do
20
+ expect(described_class.locale).to eq(:en)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,132 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::Conference do
4
+ describe '::all' do
5
+ subject { described_class.all }
6
+
7
+ before do
8
+ mock_api(:get, 'conferences/active', open: true)
9
+ mock_api(:get, 'conferences/inactive', open: true)
10
+ end
11
+
12
+ it "responds with array of conferences", :aggregate_failures do
13
+ expect(subject).to be_an_instance_of(Array)
14
+ expect(subject.first).to be_an_instance_of(described_class)
15
+ end
16
+ end
17
+
18
+ %w(active inactive).each do |m|
19
+ describe "::#{m}" do
20
+ subject { described_class.send m }
21
+
22
+ before { mock_api(:get, "conferences/#{m}", open: true) }
23
+
24
+ it "responds with array of conferences", :aggregate_failures do
25
+ expect(subject).to be_an_instance_of(Array)
26
+ expect(subject.first).to be_an_instance_of(described_class)
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '::skins' do
32
+ before { mock_api(:get, 'conferences/skins', open: true) }
33
+
34
+ subject { described_class.skins }
35
+
36
+ it "responds with array of hashes", :aggregate_failures do
37
+ expect(subject).to be_an_instance_of(Array)
38
+ expect(subject.first).to be_an_instance_of(Hash)
39
+ end
40
+ end
41
+
42
+ describe '#tokens' do
43
+ before { mock_api(:get, 'conferences/1/tokens', open: true) }
44
+
45
+ subject { described_class.new(id: 1).tokens }
46
+
47
+ it_behaves_like 'tokens list'
48
+ end
49
+
50
+ %w(sessions registrations recordings).each do |m|
51
+ context "##{m}" do
52
+ before { mock_api :get, "conferences/1/#{m}", open: true }
53
+
54
+ subject { described_class.new(id: 1).send m }
55
+
56
+ it "responds with an array of #{m}" do
57
+ klass = "Clickmeetings::Open::#{m.singularize.capitalize}".constantize
58
+ expect(subject).to be_an_instance_of(Array)
59
+ expect(subject.first).to be_an_instance_of(klass)
60
+ end
61
+
62
+ it "response has conference_id" do
63
+ expect(subject.first.conference_id).to eq(1)
64
+ end
65
+ end
66
+ end
67
+
68
+ context 'files' do
69
+ before { mock_api :get, "file-library/conferences/1", open: true }
70
+
71
+ subject { described_class.new(id: 1).files }
72
+
73
+ it "responds with an array of files" do
74
+ expect(subject).to be_an_instance_of(Array)
75
+ expect(subject.first).to be_an_instance_of Clickmeetings::Open::FileLibrary
76
+ end
77
+ end
78
+
79
+ describe '#create_tokens' do
80
+ before { mock_api(:post, 'conferences/1/tokens', open: true) }
81
+
82
+ subject { described_class.new(id: 1).create_tokens 2 }
83
+
84
+ it_behaves_like 'tokens list'
85
+
86
+ it "response has conference_id" do
87
+ expect(subject.first.conference_id).to eq(1)
88
+ end
89
+ end
90
+
91
+ describe '#create_hash' do
92
+ before do
93
+ mock_api :get, 'conferences/1', open: true
94
+ mock_api :post, 'conferences/1/room/autologin_hash', open: true
95
+ end
96
+
97
+ subject do
98
+ described_class.new(id: 1).create_hash(
99
+ nickname: 'qwe',
100
+ email: 'qwe',
101
+ role: 'listener',
102
+ token: 'qweqwe'
103
+ )
104
+ end
105
+
106
+ it "responds with LoginHash object" do
107
+ expect(subject).to be_an_instance_of(Clickmeetings::Open::LoginHash)
108
+ expect(subject.conference_id).to eq(1)
109
+ end
110
+ end
111
+
112
+ describe '#send_invites' do
113
+ before { mock_api(:post, 'conferences/1/invitation/email/en', open: true) }
114
+ subject { described_class.new(id: 1).send_invites(attendees: [{email: "q@q.qq"}], role: "listener") }
115
+
116
+ it "responds with Invitation object" do
117
+ expect(subject).to be_an_instance_of(Clickmeetings::Open::Invitation)
118
+ expect(subject.conference_id).to eq 1
119
+ end
120
+ end
121
+
122
+ describe '#register' do
123
+ before { mock_api :post, "conferences/1/registration", open: true }
124
+
125
+ let(:params) { {registration: {1 => "qwer", 2 => 'qwer', 3 => 'qwer@qwer.qw'}} }
126
+ subject { described_class.new(id: 1).register(params) }
127
+
128
+ it "responds with hash" do
129
+ expect(subject).to be_an_instance_of(Hash)
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::Contact do
4
+ describe '::create' do
5
+ before { mock_api :post, 'contacts', open: true }
6
+
7
+ let(:params) { {email: "q@q.qq", firstname: 'q', lastname: 'Q'} }
8
+ subject { described_class.create(params) }
9
+
10
+ it "responds with a Contact object", :aggregate_failures do
11
+ expect(subject).to be_an_instance_of(described_class)
12
+ expect(subject.email).to eq('q@q.qq')
13
+ expect(subject.firstname).to eq('q')
14
+ expect(subject.lastname).to eq('Q')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,46 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::FileLibrary do
4
+ describe '::create' do
5
+ before { mock_api :post, 'file-library', open: true }
6
+
7
+ subject { described_class.create(path: 'spec/fixtures/presentation.pdf') }
8
+
9
+ it "responds with FileLibrary object" do
10
+ expect(subject).to be_an_instance_of(described_class)
11
+ end
12
+ end
13
+
14
+ describe '::for_conference' do
15
+ before { mock_api :get, 'file-library/conferences/1', open: true }
16
+
17
+ subject { described_class.for_conference(conference_id: 1) }
18
+
19
+ it "responds with an array of files" do
20
+ expect(subject).to be_an_instance_of(Array)
21
+ expect(subject.first).to be_an_instance_of(described_class)
22
+ end
23
+ end
24
+
25
+ describe '#download' do
26
+ before do
27
+ stub_request(:get, 'https://api.clickmeeting.com/v1/file-library/1/download')
28
+ .to_return(status: 200,
29
+ body: File.read('spec/fixtures/presentation.pdf'),
30
+ headers: {
31
+ "Content-Type"=>"application/octet-stream",
32
+ "Content-Length"=>"357552",
33
+ "Connection"=>"close",
34
+ "Pragma"=>"public",
35
+ "Content-Disposition"=>"attachment; filename=\"pdf.pdf\"",
36
+ "Content-Transfer-Encoding"=>"binary"
37
+ })
38
+ end
39
+
40
+ subject { described_class.new(id: 1).download }
41
+
42
+ it "responds with file content" do
43
+ expect(subject).to eq File.read('spec/fixtures/presentation.pdf')
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,43 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::Invitation do
4
+ describe '::send_emails' do
5
+ let(:params) { {attendees: [{email: "qwer@qwer.qw"}], role: "listener"} }
6
+ let(:additional_params) { {} }
7
+ subject do
8
+ described_class.by_conference(conference_id: 1).send_emails(params.merge additional_params)
9
+ end
10
+
11
+ context 'without additional params' do
12
+ before { mock_api(:post, 'conferences/1/invitation/email/en', open: true) }
13
+
14
+ it "returns Invitation", :aggregate_failures do
15
+ expect(subject).to be_an_instance_of(described_class)
16
+ expect(subject.attendees).to be_an_instance_of(Array)
17
+ expect(subject.attendees.first).to be_an_instance_of(Hash)
18
+ expect(subject.attendees.first[:email]).to eq("qwer@qwer.qw")
19
+ expect(subject.role).to eq("listener")
20
+ end
21
+ end
22
+
23
+ context 'when params include lang' do
24
+ let(:additional_params) { {lang: :ru} }
25
+
26
+ before { mock_api(:post, 'conferences/1/invitation/email/ru', open: true) }
27
+
28
+ it "uses lang from params" do
29
+ expect(subject).to be_an_instance_of(described_class)
30
+ end
31
+ end
32
+
33
+ context 'when params include conference_id' do
34
+ let(:additional_params) { {conference_id: 2} }
35
+
36
+ before { mock_api(:post, 'conferences/2/invitation/email/en', open: true) }
37
+
38
+ it "uses conference_id from params" do
39
+ expect(subject).to be_an_instance_of(described_class)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,59 @@
1
+ require "spec_helper"
2
+
3
+ describe Clickmeetings::Open::LoginHash do
4
+ describe '::create' do
5
+ let(:params) do
6
+ {
7
+ conference_id: 1, nickname: 'makar', email: 'qwer@qwer.qw',
8
+ token: Clickmeetings::Open::Token.new(token: "QWEQWE"),
9
+ role: 'listener'
10
+ }
11
+ end
12
+
13
+ before do
14
+ mock_api(:get, 'conferences/1', open: true)
15
+ mock_api(:post, 'conferences/1/room/autologin_hash', open: true)
16
+ end
17
+
18
+ subject { described_class.create(params) }
19
+
20
+ it "responds with LoginHash object", :aggregate_failures do
21
+ expect(subject).to be_an_instance_of(described_class)
22
+ expect(subject.conference_id).to eq(1)
23
+ expect(subject.nickname).to eq('makar')
24
+ expect(subject.email).to eq('qwer@qwer.qw')
25
+ expect(subject.role).to eq('listener')
26
+ expect(subject.token).to eq("QWEQWE")
27
+ end
28
+
29
+ context 'validation' do
30
+ %i(conference_id nickname email role token).each do |opt_name|
31
+ context opt_name.to_s do
32
+ let(:bad_params) do
33
+ p = params
34
+ p[opt_name] = nil
35
+ p
36
+ end
37
+
38
+ subject { described_class.create(bad_params) }
39
+
40
+ specify { expect { subject }.to raise_error(described_class::InvalidParamsError) }
41
+ end
42
+ end
43
+
44
+ context 'password' do
45
+ before do
46
+ mock_api(:get, 'conferences/2', open: true)
47
+ end
48
+
49
+ let(:bad_params) do
50
+ { conference_id: 2, nickname: 'makar', email: 'qwe@qwe.qw', role: 'listener' }
51
+ end
52
+
53
+ subject { described_class.create(bad_params) }
54
+
55
+ specify { expect { subject }.to raise_error(described_class::InvalidParamsError) }
56
+ end
57
+ end
58
+ end
59
+ end