zoom_rb 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -0
- data/lib/zoom/actions/token.rb +5 -0
- data/lib/zoom/actions/webinar.rb +8 -4
- data/lib/zoom/client.rb +1 -0
- data/lib/zoom/clients/server_to_server_oauth.rb +39 -0
- data/lib/zoom/params.rb +9 -1
- data/lib/zoom/utils.rb +1 -1
- data/lib/zoom/version.rb +1 -1
- data/spec/lib/zoom/client_spec.rb +65 -0
- data/spec/lib/zoom/params_spec.rb +18 -0
- data/spec/lib/zoom/utils_spec.rb +5 -0
- data/spec/spec_helper.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53629dfe332dda4f0b07d194539fd7276e072e3f70d483202f31af40c693c007
|
4
|
+
data.tar.gz: c429987cdd4f12aa9ed17649fb0c498f65eb454cc21602bda075331c136f0f7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faeb2547f3560c6911be1814d4cacc0fade3015123e70bf7011045055dad8548de0984afe130d9541415db98814049fe25844d3a79cd75bec965c9a01ffe4953
|
7
|
+
data.tar.gz: 295ea2103ba5817d381ae85b7f93baf3858fd3d4ac326d9fac685a864eef994d487eae35f59aabe6e2c91f88825db31853ace378c6a9e166f7169f43567038e1
|
data/Gemfile.lock
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/zoom/actions/token.rb
CHANGED
@@ -12,6 +12,11 @@ module Zoom
|
|
12
12
|
permit: :code_verifier,
|
13
13
|
args_to_params: { auth_code: :code }
|
14
14
|
|
15
|
+
post 'access_tokens_account_credentials',
|
16
|
+
'/oauth/token?grant_type=account_credentials',
|
17
|
+
oauth: true,
|
18
|
+
require: :account_id
|
19
|
+
|
15
20
|
post 'refresh_tokens',
|
16
21
|
'/oauth/token',
|
17
22
|
oauth: true,
|
data/lib/zoom/actions/webinar.rb
CHANGED
@@ -18,14 +18,18 @@ module Zoom
|
|
18
18
|
post_webinar_survey survey_url registrants_email_notification
|
19
19
|
meeting_authentication authentication_option
|
20
20
|
authentication_domains registrants_confirmation_email
|
21
|
-
]
|
21
|
+
],
|
22
22
|
{
|
23
|
+
language_interpretation: [
|
24
|
+
:enable,
|
25
|
+
interpreters: %i[email languages]
|
26
|
+
],
|
23
27
|
question_and_answer: %i[
|
24
|
-
allow_anonymous_questions
|
25
|
-
attendees_can_upvote
|
28
|
+
allow_anonymous_questions answer_questions attendees_can_comment
|
29
|
+
attendees_can_upvote enable
|
26
30
|
]
|
27
31
|
}
|
28
|
-
]
|
32
|
+
].freeze
|
29
33
|
|
30
34
|
get 'webinar_list', '/users/:host_id/webinars',
|
31
35
|
permit: %i[page_size page_number]
|
data/lib/zoom/client.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Zoom
|
4
|
+
class Client
|
5
|
+
class ServerToServerOAuth < Zoom::Client
|
6
|
+
attr_reader :access_token, :expires_in, :expires_at
|
7
|
+
|
8
|
+
def initialize(config)
|
9
|
+
Zoom::Params.new(config).permit(%i[access_token account_id client_id client_secret timeout])
|
10
|
+
Zoom::Params.new(config).require_one_of(%i[access_token account_id])
|
11
|
+
|
12
|
+
config.each { |k, v| instance_variable_set("@#{k}", v) }
|
13
|
+
self.class.default_timeout(@timeout || 20)
|
14
|
+
end
|
15
|
+
|
16
|
+
def auth
|
17
|
+
response = access_tokens_account_credentials(account_id: @account_id)
|
18
|
+
set_tokens(response)
|
19
|
+
response
|
20
|
+
end
|
21
|
+
|
22
|
+
def auth_token
|
23
|
+
return Base64.urlsafe_encode64("#{@client_id}:#{@client_secret}") if @client_id && @client_secret
|
24
|
+
|
25
|
+
Base64.urlsafe_encode64("#{Zoom.configuration.api_key}:#{Zoom.configuration.api_secret}")
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def set_tokens(response)
|
31
|
+
if response.is_a?(Hash) && !response.key?(:error)
|
32
|
+
@access_token = response["access_token"]
|
33
|
+
@expires_in = response["expires_in"]
|
34
|
+
@expires_at = @expires_in ? (Time.now + @expires_in).to_i : nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/zoom/params.rb
CHANGED
@@ -32,7 +32,7 @@ module Zoom
|
|
32
32
|
array << hash_filter(filter)
|
33
33
|
end
|
34
34
|
end
|
35
|
-
non_permitted_params =
|
35
|
+
non_permitted_params = parameters_keys - permitted_keys.flatten
|
36
36
|
raise Zoom::ParameterNotPermitted, non_permitted_params.to_s unless non_permitted_params.empty?
|
37
37
|
end
|
38
38
|
|
@@ -106,5 +106,13 @@ module Zoom
|
|
106
106
|
raise Zoom::ParameterValueNotPermitted, "#{key}: #{value}"
|
107
107
|
end
|
108
108
|
end
|
109
|
+
|
110
|
+
def parameters_keys
|
111
|
+
if @parameters.kind_of?(Array)
|
112
|
+
@parameters.map(&:keys).flatten.uniq
|
113
|
+
else
|
114
|
+
@parameters.keys
|
115
|
+
end
|
116
|
+
end
|
109
117
|
end
|
110
118
|
end
|
data/lib/zoom/utils.rb
CHANGED
data/lib/zoom/version.rb
CHANGED
@@ -120,4 +120,69 @@ describe Zoom::Client do
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
describe 'ServerToServerOAuth client' do
|
125
|
+
let(:access_token) {'xxx'}
|
126
|
+
let(:client) do
|
127
|
+
Zoom::Client::ServerToServerOAuth.new(access_token: access_token, timeout: 30)
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'raises an error if there is no arguments' do
|
131
|
+
expect { Zoom::Client::ServerToServerOAuth.new(timeout: 30) }.to raise_error(Zoom::ParameterMissing)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'requires at least an access token' do
|
135
|
+
expect { Zoom::Client::ServerToServerOAuth.new(access_token: access_token) }.not_to raise_error
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'requires at least an account_id' do
|
139
|
+
expect { Zoom::Client::ServerToServerOAuth.new(access_token: access_token) }.not_to raise_error
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'creates instance of Zoom::Client if api_key and api_secret is provided' do
|
143
|
+
expect(client).to be_kind_of(Zoom::Client)
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'has the bearer token in the auth header' do
|
147
|
+
expect(client.request_headers['Authorization']).to eq("Bearer #{access_token}")
|
148
|
+
end
|
149
|
+
|
150
|
+
describe 'set_tokens' do
|
151
|
+
let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx') }
|
152
|
+
|
153
|
+
before :each do
|
154
|
+
Zoom.configure do |config|
|
155
|
+
config.timeout = 20
|
156
|
+
end
|
157
|
+
|
158
|
+
stub_request(
|
159
|
+
:post,
|
160
|
+
zoom_auth_url('oauth/token')
|
161
|
+
).to_return(body: json_response('token', 'access_token'),
|
162
|
+
headers: { 'Content-Type' => 'application/json' })
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'sets the access_token, expires_in and expires_at' do
|
166
|
+
expected_values = JSON.parse(json_response('token', 'access_token'))
|
167
|
+
client.auth
|
168
|
+
expect(client.access_token).to eq(expected_values['access_token'])
|
169
|
+
expect(client.expires_in).to eq(expected_values['expires_in'])
|
170
|
+
expect(client.expires_at).to eq((Time.now + expected_values['expires_in']).to_i)
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'when client_id and client_secret is not provided' do
|
174
|
+
it 'has the basic auth authorization header based on api_key and api_secret' do
|
175
|
+
expect(client.oauth_request_headers['Authorization']).to eq("Basic eHh4Onh4eA==")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context 'when client_id and client_secret are provided' do
|
180
|
+
let(:client) { Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx', client_id: 'yyy', client_secret: 'yyy') }
|
181
|
+
|
182
|
+
it 'has the basic auth authorization header based on client_id and client_secret' do
|
183
|
+
expect(client.oauth_request_headers['Authorization']).to eq("Basic eXl5Onl5eQ==")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
123
188
|
end
|
@@ -98,4 +98,22 @@ RSpec.describe Zoom::Params do
|
|
98
98
|
expect { params.permit_value(:baz, values) }.to raise_error(Zoom::ParameterValueNotPermitted, "#{:baz.to_s}: #{:bang.to_s}")
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
describe '#parameters_keys' do
|
103
|
+
context 'when param is array ' do
|
104
|
+
let(:params) { Zoom::Params.new([{foo: :bar, baz: :bang}, {foo: :bar1, baz: :bang1}]) }
|
105
|
+
|
106
|
+
it 'get each object keys and return unique of them' do
|
107
|
+
expect(params.parameters_keys).to eq([:foo, :baz])
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
context 'when param is Hash ' do
|
112
|
+
let(:params) { Zoom::Params.new({foo: :bar, baz: :bang}) }
|
113
|
+
|
114
|
+
it 'return hash keys' do
|
115
|
+
expect(params.parameters_keys).to eq([:foo, :baz])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
101
119
|
end
|
data/spec/lib/zoom/utils_spec.rb
CHANGED
@@ -30,6 +30,11 @@ describe Zoom::Utils do
|
|
30
30
|
expect { Utils.raise_if_error!(response) }.to_not raise_error
|
31
31
|
end
|
32
32
|
|
33
|
+
it 'does not raise Zoom::Error if response is not a Hash' do
|
34
|
+
response = 'xxx'
|
35
|
+
expect { Utils.raise_if_error!(response) }.to_not raise_error
|
36
|
+
end
|
37
|
+
|
33
38
|
it 'raises Zoom::Error if http code is not 200' do
|
34
39
|
response = { 'code' => 180, 'message' => 'lol error' }
|
35
40
|
expect { Utils.raise_if_error!(response, 400) }.to raise_error(Zoom::Error)
|
data/spec/spec_helper.rb
CHANGED
@@ -45,6 +45,10 @@ def oauth_client
|
|
45
45
|
Zoom::Client::OAuth.new(auth_token: 'xxx', auth_code: 'xxx', redirect_uri: 'xxx', timeout: 15)
|
46
46
|
end
|
47
47
|
|
48
|
+
def server_to_server_oauth_client
|
49
|
+
Zoom::Client::ServerToServerOAuth.new(account_id: 'xxx')
|
50
|
+
end
|
51
|
+
|
48
52
|
def zoom_client
|
49
53
|
jwt_client
|
50
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zoom_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- LICENSE
|
152
152
|
- Makefile
|
153
153
|
- README.md
|
154
|
+
- Rakefile
|
154
155
|
- lib/zoom/actions.rb
|
155
156
|
- lib/zoom/actions/account.rb
|
156
157
|
- lib/zoom/actions/billing.rb
|
@@ -171,6 +172,7 @@ files:
|
|
171
172
|
- lib/zoom/client.rb
|
172
173
|
- lib/zoom/clients/jwt.rb
|
173
174
|
- lib/zoom/clients/oauth.rb
|
175
|
+
- lib/zoom/clients/server_to_server_oauth.rb
|
174
176
|
- lib/zoom/constants/account/options/pay_modes.rb
|
175
177
|
- lib/zoom/constants/account/settings/permitted_settings.rb
|
176
178
|
- lib/zoom/constants/constants.rb
|