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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0f19b8ce1c8e56b9d7b5527a2a0f9fbae877ffc8
4
- data.tar.gz: d0d66c38e43bf342e36f23c45589a20e2e4cea4f
2
+ SHA256:
3
+ metadata.gz: c7957e3d0dec3844222ff970c64a81872eacc270078d53a8655991c494903b19
4
+ data.tar.gz: 19fc5201e2b1f29c5aaf3dbf526a633d69b378a9c722112cb7cc5b828dcfa184
5
5
  SHA512:
6
- metadata.gz: c17aa7ea0ef517b1124be90404512b62e97b44337f3bc121175c9410057a0d71ff0f6af72d97cfadb77ccc09acf06afe775dd3a97c34fc0a9ba336fa1081cc31
7
- data.tar.gz: b1f53ead06baac642b28112cfa30c67e4885053e6d4d2044518cde64e411f78537f16ebca893caf0c68f977ca8eb2155f2ed6a9875b002401333d08e6da53cf1
6
+ metadata.gz: b524e4c4f0162aa8d53e40884113b38bdda1518f828fd144f46c5b77ba8fe1408fc5a28b61fddd8ebcce445310cbb49417028e2fe6d13dcaf0c0a43983da8710
7
+ data.tar.gz: fb323a5b723b5ff3d7790d9366db536a59687a64fb72e7b0d1ea0c376ca8f3ad045e502506f54d1835118b1aa9c35b50e98be9b0d4612ac33f38d68e8c378f2c
@@ -0,0 +1,26 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [2.7.3, 2.6.7, 2.5.9]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ - name: Install dependencies
24
+ run: bundle install
25
+ - name: Run tests
26
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  examples.txt
13
13
  /clickmeetings.yml
14
14
  /clickmeetings-*.gem
15
+
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Clickmeetings
1
+ [![Ruby CI](https://github.com/teachbase/clickmeetings/actions/workflows/run-tests.yml/badge.svg)](https://github.com/teachbase/clickmeetings/actions/workflows/run-tests.yml/badge.svg)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/clickmeetings`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ # Clickmeetings
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Simple REST API client to interact with [Clickmeeting](https://clickmeeting.com) open and Privatelabel API.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,17 +22,315 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### Configuration
26
+
27
+ With Rails:
28
+
29
+ + in `config/secrets.yml` add:
30
+ ```yml
31
+ clickmeetings:
32
+ privatelabel_host: https://api.clickmeetings.com/privatelabel/v1 # or http://api.anysecond.com/privatelabel/v1
33
+ privatelabel_api_key: your_privatelabel_api_key
34
+ host: https://api.clickmeetings.com/v1 # or http://api.anysecond.com/v1
35
+ api_key: your_open_api_key
36
+ locale: es # default language (uses e.g. in invitations)
37
+ ```
38
+ + in `config/clickmeetings.yml`:
39
+ ```yml
40
+ privatelabel_host: https://api.clickmeetings.com/privatelabel/v1 # or http://api.anysecond.com/privatelabel/v1
41
+ privatelabel_api_key: your_privatelabel_api_key
42
+ host: https://api.clickmeetings.com/v1 # or http://api.anysecond.com/v1
43
+ api_key: your_open_api_key
44
+ locale: es # default language (uses e.g. in invitations)
45
+ ```
46
+
47
+ With or without Rails:
48
+
49
+ + Use environment variables `CLICKMEETINGS_*` (e.g. `CLICKMEETINGS_PRIVATELABEL_HOST`).
50
+ + Use `configure` method:
51
+ ```ruby
52
+ Clickmeetings.configure do |config|
53
+ config.privatelabel_api_key = 'your_privatelabel_api_key'
54
+ # and another configs like above
55
+ end
56
+ ```
57
+
58
+ ### Usage
59
+
60
+ + Privatelabel API
61
+ + Your profile
62
+ ```ruby
63
+ profile = Clickmeetings::PrivateLabel::Profile.get # => get your PrivateLabel profile details
64
+ ```
65
+ + Accounts
66
+ ```ruby
67
+ account = Clickmeetings::PrivateLabel::Account.create(params)
68
+ # => Clickmeetings::PrivateLabel::Account object
69
+ # params is a Hash; see specification for params
70
+ # in your clickmeeting account
71
+ account = account.update username: "New account name"
72
+ # => updated Clickmeetings::PrivateLabel::Account object
73
+ # see specification to know what params you can provide
74
+ account = account.disable # sets account's status to 'disabled'
75
+ account = account.enable # sets account's status to 'active'
76
+ account.destroy # => deleted account
77
+ Clickmeetings::PrivateLabel::Account.all # => array of accounts
78
+ Clickmeetings::PrivateLabel::Account.find(1) # => account details with id = 1 or
79
+ # Clickmeetings::NotFoundError
80
+ ```
81
+ + Conferences
82
+ + Specify an account
83
+ ```ruby
84
+ Clickmeetings::PrivateLabel::Conference.account_id # => nil
85
+ Clickmeetings::PrivateLabel::Conference.by_account(account_id: 1)
86
+ # => Clickmeetings::PrivateLabel::Conference, so you can use #create,
87
+ # #update and #find in chain
88
+ Clickmeetings::PrivateLabel::Conference.account_id # => 1
89
+ ```
90
+ or
91
+ ```ruby
92
+ # Clickmeetings::PrivateLabel::Conference.account_id equals to nil
93
+ Clickmeetings::PrivateLabel::Conference.by_account(account_id: 1) do
94
+ # there Clickmeetings::PrivateLabel::Conference.account_id equals to 1
95
+ end
96
+ # and there Clickmeetings::PrivateLabel::Conference.account_id equals to nil
97
+
98
+ Clickmeetings::PrivateLabel::Conference.by_account(account_id: 1).new
99
+ # => #<Clickmeetings::PrivateLabel::Conference:0x... @account_id=1>
100
+ ```
101
+ + Do anything
102
+ ```ruby
103
+ Clickmeetings::PrivateLabel::Conference.by_account(account_id: 1) do
104
+ # use Clickmeetings::PrivateLabel::Conference.create, .all and .find methods+
105
+ # to create conference, get list of conferences for account or get conference
106
+ # details
107
+
108
+ # and #update and #destroy instance methods to change or delete any conference
109
+
110
+ # params same as in Open API (see below)
111
+ end
112
+ ```
113
+ + [Open API](http://dev.clickmeeting.com/api-doc/)
114
+
115
+ Account is based on your config (from api key) or with every class you can use
116
+ ```ruby
117
+ Clickmeetings::Open::Conference.with_account(account_api_key: 'another_account_api_key') do
118
+ # do anything in another account
119
+ end
120
+ ```
121
+ + Сonference
122
+ ```ruby
123
+ Clickmeetings::Open::Conference.active # => list of active conferences
124
+ Clickmeetings::Open::Conference.inactive # => list of inactive conferences
125
+ # .all, .find, .create, #update, #destroy as usual
126
+ ```
127
+ + params for `.create` and `#update`
128
+ + Required:
129
+ + name (String): room name
130
+ + room_type (String): 'webinar' or 'meeting'
131
+ + permanent_room (Integer): 1 - room is permanent; 0 - has start time and duration
132
+ + access_type (Integer): 1 - open, 2 - password (requires password in params), 3 - token
133
+ + Optional
134
+ + password (String): password for rooms with access_type 2
135
+ + custom_room_url_name (String): room url will be `https://{account_name}.clickmeeting.com/{custom_room_url_name}`
136
+ + lobby_description (String): Messagee in lobby
137
+ + lobby_enabled (String): 1 - true, 0 - false
138
+ + starts_at (iso8601 datetime): time conference starts at (if it is not permanent). Default is `now`
139
+ + duration (String "h:mm"): duration of conference, between 0:05 and 3:00
140
+ + timezone (String): Time zone of conference (e.g. “America/New_York”)
141
+ + skin_id (integer): Skin identifier
142
+ + registration (Hash):
143
+ + enabled (Boolean)
144
+ + template (Integer): registration template, between 1 and 3
145
+ + status (String): "active" or "inactive"
146
+ + settings (Hash): please, see on [Clickmeting API documentation](http://dev.clickmeeting.com/api-doc/#post_conferences) if need
147
+ + Other helpful methods
148
+ ```ruby
149
+ Clickmeetings::Open::Conference.skins # => array of available skins; each skin is a Hash
150
+ Clickmeetings::Open::Conference.find(1).create_tokens(10)
151
+ # creates tokens for confereces with access_type = 3;
152
+ # param specifies how many tokens will be created (default is 1)
153
+
154
+ Clickmeetings::Open::Conference.new(id: 1).send_invites(
155
+ attendees: [
156
+ {email: "first@teachbase.ru"},
157
+ {email: "second@teachbase.ru"}
158
+ ]
159
+ role: "presenter",
160
+ template: "basic" # or "advanced"
161
+ )
162
+ # send invites to emails in attendees for specified role. Template means view of email
163
+ # .new(id: 1) specifies id of conference. Unlike .find(1) it doesn't request to clickmeetings
164
+
165
+ Clickmeetings::Open::Conference.new(id: 1).files # => files for conference
166
+ Clickmeetings::Open::Conference.new(id: 1).tokens # => tokens for conference (if access_type is 3)
167
+ Clickmeetings::Open::Conference.new(id: 1).sessions # => sessions for conference
168
+ Clickmeetings::Open::Conference.new(id: 1).registrations # => registrations for conference
169
+ Clickmeetings::Open::Conference.new(id: 1).recordings # => recordings for conference
170
+
171
+ Clickmeetings::Open::Conference.new(id: 1).register(
172
+ registration: {
173
+ 1 => "firstname",
174
+ 2 => "lastname",
175
+ 3 => "email@teachbase.ru"
176
+ },
177
+ confirmation_email: { # optional
178
+ enabled: 1, # or 0
179
+ lang: "ru", # or something else
180
+ }
181
+ )
182
+
183
+ Clickmeetings::Open::Conference.find(1).create_hash(
184
+ nickname: "User#1",
185
+ role: "presenter",
186
+ email: "user1@teachbase.ru
187
+ # :password for conference with access_type 2
188
+ # :token for conference with access_type 3
189
+ )
190
+ # creates autologin hash for user, specified in params
191
+ ```
192
+ For more information about autologin hashes see [docs](http://dev.clickmeeting.com/api-doc/#post_autologin_hash).
193
+ + Session
194
+ ```ruby
195
+ Clickmeetings::Open::Session.by_conference(conference_id: 1).all
196
+ # => sessions for conference with id 1
197
+ # now u can use
198
+ Clickmeetings::Open::Session.all
199
+ # => sessions for conference with id 1
200
+ Сlickmeetings::Open::Session.find(1)
201
+ # => session with id 1 in conference with id 1
202
+ ```
203
+ or
204
+ ```ruby
205
+ Clickmeetings::Open::Session.by_conference(conferecne_id: 1) do
206
+ Clickmeetings::Open::Session.all
207
+ # => sessions for conference with id 1
208
+ Сlickmeetings::Open::Session.find(1)
209
+ # => session with id 1 in conference with id 1
210
+ end
211
+ Clickmeetings::Open::Session.all
212
+ # => Clickmeetings::NotFoundError
213
+ ```
214
+ You can use only `.all`, `.find` and one of methods below
215
+ + `#attendees`
216
+
217
+ ```ruby
218
+ Clickmeetings::Open::Session.by_conference(conferecne_id: 1) do
219
+ Сlickmeetings::Open::Session.find(1).attendees
220
+ # => array of attendees; each attendee is a hash
221
+ end
222
+ ```
223
+ + `#generate_pdf`
224
+
225
+ ```ruby
226
+ Clickmeetings::Open::Session.by_conference(conferecne_id: 1) do
227
+ Сlickmeetings::Open::Session.find(1).generate_pdf :ru
228
+ # => hash { status: "...", ... }
229
+ # if status id "FINISHED", it contains :url key with url of pdf
230
+ # params sets locale; default locale in config; default for config is "en"
231
+ end
232
+ ```
233
+ + `#get_report`
234
+
235
+ ```ruby
236
+ Clickmeetings::Open::Session.by_conference(conferecne_id: 1) do
237
+ Сlickmeetings::Open::Session.find(1).generate_pdf :ru
238
+ # => url of pdf is status for specified locale is "FINISHED"
239
+ # nil else
240
+ end
241
+ ```
242
+ + `#registrations`
243
+
244
+ ```ruby
245
+ Clickmeetings::Open::Session.by_conference(conferecne_id: 1) do
246
+ Сlickmeetings::Open::Session.find(1).registrations
247
+ # => array of registrations
248
+ end
249
+ ```
250
+ + Contacts
251
+
252
+ Only `.create` method:
253
+ ```ruby
254
+ Clickmeetings::Open::Contact.create(
255
+ email: "...",
256
+ firstname: "...",
257
+ lastname: "...",
258
+ phone: "...", # optional
259
+ company: "...", # optional
260
+ country: "..." # optional
261
+ )
262
+ ```
263
+ If contact with passed email exists, it will be updated
264
+  
265
+ + TimeZone
266
+
267
+ Only `.all` method with optional param `:country`. Returns array of strings.
268
+ ```ruby
269
+ Clickmeetings::Open::TimeZone.all country: :ru # => time zones in Russia
270
+ Clickmeetings::Open::TimeZone.all # => all time zones
271
+ ```
272
+
273
+ + PhoneGateway
274
+
275
+ ```ruby
276
+ Clickmeetings::Open::PhoneGateway.all # => array of phone gateways
277
+ ```
278
+
279
+ + Registration
280
+
281
+ ```ruby
282
+ Clickmeetings::Open::Registration.by_conference(conference_id: 1) do
283
+ Clickmeetings::Open::Registration.all # => array of registrations
284
+ Clickmeetings::Open::Registration.active # => array of active registrations
285
+ Clickmeetings::Open::Registration.create(params) # => registration hash
286
+ # => params like in Clickmeetings::Open::Conference#register
287
+ Clickmeetings::Open::Registration.for_session(session_id: 1)
288
+ # => registrations for session with id 1
289
+ end
290
+ ```
291
+
292
+ + FileLibrary
293
+
294
+ ```ruby
295
+ Clickmeetings::Open::FileLibrary.create(path: '/path/to/file.pdf')
296
+ # => FileLibrary instance; creates file in your library
297
+ Clickmeetings::Open::FileLibrary.create(path: '/path/to/file.pdf', conference_id: 1)
298
+ # => FileLibrary instance; creates file in conference with id 1
299
+ Clickmeetings::Open::FileLibrary.all # => array of FileLibrary instances
300
+ Clickmeetings::Open::FileLibrary.for_conference(conference_id: 1)
301
+ # array of files in conference with id 1
302
+
303
+ # find and destroy as usually
304
+
305
+ Clickmeetings::Open::FileLibrary.new(id: 1).download # => content of file with id 1 as String
306
+ ```
307
+
308
+ + Recording
309
+
310
+ `Clickmeetings::Open::Recordings` interacts with recordings. Specify a conference with `by_conference` (as above) method and use `.all`, `.find`, and `.destroy_all` (to destroy all recordings of conference) methods.
311
+
312
+ + Chat
313
+
314
+ `Clickmeetings::Open::Chat` interacts with chats. Use `.all` to get info about chats. `.find` returns content of zip-archive with a chat.
315
+
316
+ + Other
317
+
318
+ Use `.ping` with any class to check API status.
26
319
 
27
320
  ## Development
28
321
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
322
+ + Fork repo
323
+ + Create new branch
324
+ + install dependencies
325
+
326
+ $ bundle install
30
327
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
328
+ + Commit your changes (do not forget about specs)
329
+ + Create a pull request
32
330
 
33
331
  ## Contributing
34
332
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clickmeetings.
333
+ Bug reports and pull requests are welcome on GitHub at https://github.com/teachbase/clickmeetings.
36
334
 
37
335
 
38
336
  ## License
@@ -1,31 +1,36 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'clickmeetings/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "clickmeetings"
8
+ spec.name = 'clickmeetings'
8
9
  spec.version = Clickmeetings::VERSION
9
- spec.authors = ["Sergei Alekseenko", "Makar Ermokhin"]
10
- spec.email = ["alekseenkoss@gmail.com", "ermak95@gmail.com"]
11
- spec.summary = %q{Simple REST API client for ClickMeetings Private Label API}
12
- spec.description = %q{Simple REST API client for ClickMeetings Private Label API}
13
- spec.homepage = "https://github.com/teachbase/clickmeetings"
14
- spec.license = "MIT"
10
+ spec.authors = ['Sergei Alekseenko', 'Makar Ermokhin']
11
+ spec.email = ['alekseenkoss@gmail.com', 'ermak95@gmail.com']
12
+ spec.summary = 'Simple REST API client for ClickMeetings Private Label and Open API'
13
+ spec.description = 'Simple REST API client for ClickMeetings Private Label and Open API'
14
+ spec.homepage = 'https://github.com/teachbase/clickmeetings'
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.required_ruby_version = '>= 2.5'
20
23
 
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
24
- spec.add_development_dependency "webmock", "~> 2"
25
- spec.add_development_dependency 'pry', "~> 0.10"
26
- spec.add_dependency "anyway_config", "~> 0", ">= 0.3"
27
- spec.add_dependency "faraday", "~> 0.9"
28
- spec.add_dependency "faraday_middleware", "~> 0.10"
29
- spec.add_dependency 'activemodel', "~> 4.1"
24
+ spec.add_development_dependency 'pry', '~> 0.10'
25
+ spec.add_development_dependency 'pry-byebug'
26
+ spec.add_development_dependency 'rake', '~> 12.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'simplecov'
29
+ spec.add_development_dependency 'simplecov-gem-profile'
30
+ spec.add_development_dependency 'webmock', '~> 2'
31
+ spec.add_dependency 'activemodel', '>= 4.1', '< 6'
32
+ spec.add_dependency 'anyway_config', '>= 0.3'
33
+ spec.add_dependency 'faraday', '>= 1.0', '< 2'
34
+ spec.add_dependency 'faraday_middleware', '>= 1.0'
30
35
  spec.add_dependency 'json', '~> 1.0'
31
36
  end
@@ -4,17 +4,16 @@ require 'json'
4
4
 
5
5
  module Clickmeetings
6
6
  class Client
7
- attr_reader :url, :api_key
8
-
9
- def initialize(url: Clickmeetings.config.host,
10
- api_key: Clickmeetings.config.api_key)
7
+ attr_reader :url, :connect
11
8
 
9
+ def initialize(url: Clickmeetings.config.host)
12
10
  @url = url
13
- @api_key = api_key
14
11
 
15
12
  @connect = Faraday.new(url: url) do |faraday|
16
- faraday.adapter Faraday.default_adapter
13
+ faraday.request :multipart
14
+ faraday.request :url_encoded
17
15
  faraday.use :instrumentation
16
+ faraday.adapter Faraday.default_adapter
18
17
  end
19
18
  end
20
19
 
@@ -52,10 +51,10 @@ module Clickmeetings
52
51
  end
53
52
 
54
53
  %w(get post put patch delete).each do |method|
55
- define_method method do |url, params = {}|
54
+ define_method method do |url, params = {}, headers = {}|
56
55
  l = lambda do |req|
57
- req.headers["Content-Type"] = "application/x-www-form-urlencoded"
58
- req.body = params.merge(api_key: api_key).to_query
56
+ req.headers.merge! headers
57
+ req.body = params
59
58
  end
60
59
  request(method, url, &l)
61
60
  end
@@ -6,6 +6,7 @@ module Clickmeetings
6
6
  attr_config privatelabel_host: 'https://api.clickmeeting.com/privatelabel/v1',
7
7
  host: 'https://api.clickmeeting.com/v1',
8
8
  api_key: 'test_key',
9
- privatelabel_api_key: 'privatelabel_api_key'
9
+ privatelabel_api_key: 'privatelabel_api_key',
10
+ locale: :en
10
11
  end
11
12
  end
@@ -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
@@ -8,34 +7,36 @@ module Clickmeetings
8
7
  include ActiveModel::Validations
9
8
 
10
9
  attr_accessor :id
11
-
10
+
12
11
  class << self
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
17
-
15
+ delegate :remote_url, :remote_path, :handle_response, :client,
16
+ :default_params, :default_headers, to: :new
17
+ delegate :first, :last, to: :all
18
+
18
19
  def resource_name
19
20
  @resource_name ||= self.name.demodulize.pluralize.downcase
20
21
  end
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,25 @@ 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
- "#{resource_name}/#{params[:id]}/#{action}"
102
+ action_path(action, params[:id])
101
103
  end
102
104
  end
103
105
 
106
+ def action_path(action, id)
107
+ id ? "#{resource_name}/#{id}/#{action}" : "#{resource_name}/#{action}"
108
+ end
109
+
110
+ def default_params
111
+ Hash.new
112
+ end
113
+
114
+ def default_headers
115
+ Hash.new
116
+ end
117
+
104
118
  private
105
119
 
106
120
  def merge_attributes(attrs)
@@ -117,7 +131,7 @@ module Clickmeetings
117
131
 
118
132
  def merge_object(attrs)
119
133
  attrs.each do |attribute, val|
120
- if respond_to?(attribute)
134
+ if respond_to?("#{attribute}=")
121
135
  send("#{attribute}=", val)
122
136
  elsif val.is_a? Hash
123
137
  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