zoom_rb 0.8.1 → 0.8.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 771899544953b6b67911aad77c629938839f2942637fa1bbe0a633a2dab50a16
4
- data.tar.gz: a25c504655e94701ea41d60912af9e505f33afdae244def78504ab06ab06ab54
3
+ metadata.gz: 4721f6d74fda716d1e2ddd654d86b1609c421b415186db4277424fb3d52242af
4
+ data.tar.gz: cf96f9fc938c62b9bd453232f2dc8030506d628a9dc6d302a607c7553edcf353
5
5
  SHA512:
6
- metadata.gz: 34e6fae6ea6e5e7c17e0ed82eadbce2139eae11aea858320459c51cf2aa43e14dd5660fa194bcbf6322d38e9fbe3a3de47f3852946c08c0ea7e10e710bc762a7
7
- data.tar.gz: 17926672d35bb693e3d73f839f007695ec9f1034c2dde19233d4642778eade7a3bf484d5b9ea2d1885874dd89b32374e6a1ed13ff3966efd8d32f344477e3b2b
6
+ metadata.gz: 1a8ccb722f1dd4cc279d4da8751ef799649d06bd7b0d0eb0ca8b57f8012f96d095097187d39b6fc8a2a558072fb27c81fe8ffe2d5781bbf3c12bbb8bc4e096ee
7
+ data.tar.gz: 409d4446a67bdc8c67b0d178fe3ba470a0fdbaa965b5c5b5e87b0bf951108255585e0ff82e49b85e98d386951d711fd174f47fbeb281c7dc8e25cf7f2adb2478
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zoom_rb (0.8.0)
4
+ zoom_rb (0.8.1)
5
5
  httparty (~> 0.13)
6
6
  json (>= 1.8)
7
7
  jwt
data/README.md CHANGED
@@ -19,7 +19,7 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  ```ruby
22
- require 'zoom_rb'
22
+ require 'zoom'
23
23
 
24
24
  Zoom.configure do |c|
25
25
  c.api_key = 'xxx'
@@ -2,7 +2,7 @@
2
2
 
3
3
  $:.unshift File.dirname(__FILE__)
4
4
 
5
- require 'zoom/defaults'
5
+ require 'zoom/constants'
6
6
  require 'zoom/params'
7
7
  require 'zoom/utils'
8
8
  require 'zoom/actions/account'
@@ -21,8 +21,6 @@ module Zoom
21
21
  # TODO implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes.
22
22
  Utils.parse_response self.class.post('/chat/list', query: options)
23
23
  end
24
-
25
- Utils.define_bang_methods(self)
26
24
  end
27
25
  end
28
26
  end
@@ -73,8 +73,6 @@ module Zoom
73
73
  # TODO Handle `option_auto_record_type`, Can be "local", “cloud” or "none".
74
74
  Utils.parse_response self.class.post('/meeting/update', query: options)
75
75
  end
76
-
77
- Utils.define_bang_methods(self)
78
76
  end
79
77
  end
80
78
  end
@@ -22,8 +22,6 @@ module Zoom
22
22
  Utils.require_params(%i[meeting_id type], options)
23
23
  Utils.parse_response self.class.post('/metrics/meetingdetail', query: options)
24
24
  end
25
-
26
- Utils.define_bang_methods(self)
27
25
  end
28
26
  end
29
27
  end
@@ -28,8 +28,6 @@ module Zoom
28
28
  Utils.require_params([:meeting_id], options)
29
29
  Utils.parse_response self.class.post('/recording/delete', query: options)
30
30
  end
31
-
32
- Utils.define_bang_methods(self)
33
31
  end
34
32
  end
35
33
  end
@@ -22,8 +22,6 @@ module Zoom
22
22
  Utils.require_params(%i[year month], options)
23
23
  Utils.parse_response self.class.post('/report/getdailyreport', query: options)
24
24
  end
25
-
26
- Utils.define_bang_methods(self)
27
25
  end
28
26
  end
29
27
  end
@@ -13,7 +13,7 @@ module Zoom
13
13
  def user_create(*args)
14
14
  params = Zoom::Params.new(Utils.extract_options!(args))
15
15
  params.require(%i[email type first_name last_name password])
16
- Utils.parse_response self.class.post('/users', body: { action: 'create', user_info: params }, query: { access_token: access_token })
16
+ Utils.parse_response self.class.post('/users', body: { action: 'create', user_info: params }.to_json, query: { access_token: access_token })
17
17
  end
18
18
 
19
19
  def user_get(*args)
@@ -139,8 +139,6 @@ module Zoom
139
139
  # options = Utils.extract_options!(args)
140
140
  raise Zoom::NotImplemented, 'user_vanity_name_check is not yet implemented'
141
141
  end
142
-
143
- Utils.define_bang_methods(self)
144
142
  end
145
143
  end
146
144
  end
@@ -21,8 +21,8 @@ module Zoom
21
21
  :timezone, :password, :agenda,
22
22
  recurrence: RECURRENCE_KEYS,
23
23
  settings: SETTINGS_KEYS)
24
- # process recurrence keys based on defaults
25
- # process settings keys based on defaults
24
+ # process recurrence keys based on constants
25
+ # process settings keys based on constants
26
26
  Utils.parse_response self.class.post("/users/#{params[:host_id]}/webinars", body: params.except(:host_id).to_json, query: { access_token: access_token })
27
27
  end
28
28
 
@@ -103,8 +103,6 @@ module Zoom
103
103
  # options = Utils.extract_options!(args)
104
104
  raise Zoom::NotImplemented, 'past_webinars_list is not yet implemented'
105
105
  end
106
-
107
- Utils.define_bang_methods(self)
108
106
  end
109
107
  end
110
108
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zoom
4
- class Defaults
4
+ class Constants
5
5
  ACCOUNT_OPTIONS_PAY_MODES = { 'Master account holder pays' => 'master', # default
6
6
  'Sub account holder pays' => 'sub'
7
7
  }.freeze
@@ -12,7 +12,7 @@ module Zoom
12
12
  end
13
13
 
14
14
  def raise_if_error!(response)
15
- if response['code'] == 300
15
+ if response&.[]('code') && response['code'] >= 300
16
16
  error_hash = { base: response['message']}
17
17
  raise Error, error_hash unless response['errors']
18
18
  error_hash[response['message']] = response['errors']
@@ -23,8 +23,7 @@ module Zoom
23
23
  end
24
24
 
25
25
  def parse_response(http_response)
26
- response = http_response.parsed_response
27
- response.nil? ? http_response.code : JSON.parse(response)
26
+ raise_if_error!(http_response.parsed_response) || http_response.code
28
27
  end
29
28
 
30
29
  def require_params(params, options)
@@ -42,14 +41,14 @@ module Zoom
42
41
  end
43
42
 
44
43
  # Dynamically defines bang methods for Actions modules
45
- def define_bang_methods(klass)
46
- klass.instance_methods.each do |m|
47
- klass.send(:define_method, "#{m}!") do |*args|
48
- response = send(m, *args)
49
- Utils.raise_if_error!(response)
50
- end
51
- end
52
- end
44
+ # def define_bang_methods(klass)
45
+ # klass.instance_methods.each do |m|
46
+ # klass.send(:define_method, "#{m}!") do |*args|
47
+ # response = send(m, *args)
48
+ # Utils.raise_if_error!(response)
49
+ # end
50
+ # end
51
+ # end
53
52
 
54
53
  def extract_options!(array)
55
54
  array.last.is_a?(::Hash) ? array.pop : {}
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 1005,
3
+ "message": "User already in the account: foo@bar.com"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "code": 1010,
3
+ "message": "User not belong to this account"
4
+ }
@@ -13,57 +13,63 @@ describe Zoom::Actions::User do
13
13
  end
14
14
 
15
15
  describe '#user_create' do
16
- before :each do
17
- stub_request(
18
- :post,
19
- zoom_url('/users')
20
- ).to_return(body: json_response('user', 'create'))
21
- end
16
+ context 'with 201 response' do
17
+ before :each do
18
+ stub_request(
19
+ :post,
20
+ zoom_url('/users')
21
+ ).to_return(status: 201,
22
+ body: json_response('user', 'create'),
23
+ headers: {"Content-Type"=> "application/json"})
24
+ end
22
25
 
23
- it 'requires email param' do
24
- expect { zc.user_create(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s)
25
- end
26
+ it 'requires email param' do
27
+ expect { zc.user_create(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s)
28
+ end
26
29
 
27
- it 'requires first_name param' do
28
- expect { zc.user_create(filter_key(args, :first_name)) }.to raise_error(Zoom::ParameterMissing, [:first_name].to_s)
29
- end
30
+ it 'requires first_name param' do
31
+ expect { zc.user_create(filter_key(args, :first_name)) }.to raise_error(Zoom::ParameterMissing, [:first_name].to_s)
32
+ end
30
33
 
31
- it 'requires last_name param' do
32
- expect { zc.user_create(filter_key(args, :last_name)) }.to raise_error(Zoom::ParameterMissing, [:last_name].to_s)
33
- end
34
+ it 'requires last_name param' do
35
+ expect { zc.user_create(filter_key(args, :last_name)) }.to raise_error(Zoom::ParameterMissing, [:last_name].to_s)
36
+ end
34
37
 
35
- it 'requires type param' do
36
- expect { zc.user_create(filter_key(args, :type)) }.to raise_error(Zoom::ParameterMissing, [:type].to_s)
37
- end
38
+ it 'requires type param' do
39
+ expect { zc.user_create(filter_key(args, :type)) }.to raise_error(Zoom::ParameterMissing, [:type].to_s)
40
+ end
38
41
 
39
- it 'requires password param' do
40
- expect { zc.user_create(filter_key(args, :password)) }.to raise_error(Zoom::ParameterMissing, [:password].to_s)
41
- end
42
+ it 'requires password param' do
43
+ expect { zc.user_create(filter_key(args, :password)) }.to raise_error(Zoom::ParameterMissing, [:password].to_s)
44
+ end
42
45
 
43
- it 'returns a hash' do
44
- expect(zc.user_create(args)).to be_kind_of(Hash)
45
- end
46
+ it 'returns a hash' do
47
+ expect(zc.user_create(args)).to be_kind_of(Hash)
48
+ end
46
49
 
47
- it 'returns same params' do
48
- res = zc.user_create(args)
50
+ it 'returns same params' do
51
+ res = zc.user_create(args)
49
52
 
50
- expect(res['email']).to eq(args[:email])
51
- expect(res['first_name']).to eq(args[:first_name])
52
- expect(res['last_name']).to eq(args[:last_name])
53
- expect(res['type']).to eq(args[:type])
53
+ expect(res['email']).to eq(args[:email])
54
+ expect(res['first_name']).to eq(args[:first_name])
55
+ expect(res['last_name']).to eq(args[:last_name])
56
+ expect(res['type']).to eq(args[:type])
57
+ end
54
58
  end
55
- end
56
59
 
57
- describe '#user_create! action' do
58
- before :each do
59
- stub_request(
60
- :post,
61
- zoom_url('/users')
62
- ).to_return(body: json_response('error', 'validation'))
63
- end
60
+ context 'with 409 response' do
61
+ before :each do
62
+ stub_request(
63
+ :post,
64
+ zoom_url('/users')
65
+ ).to_return(status: 409,
66
+ body: json_response('error', 'already_exists'),
67
+ headers: {"Content-Type"=> "application/json"})
68
+ end
64
69
 
65
- it 'raises Zoom::Error exception' do
66
- expect { zc.user_create!(args) }.to raise_error(Zoom::Error)
70
+ it 'raises an error' do
71
+ expect { zc.user_create(args) }.to raise_error(Zoom::Error)
72
+ end
67
73
  end
68
74
  end
69
75
  end
@@ -7,34 +7,38 @@ describe Zoom::Actions::User do
7
7
  let(:args) { { id: 'eIimBAXqSrWOcB_EOIXTog' } }
8
8
 
9
9
  describe '#user_delete' do
10
- before :each do
11
- stub_request(
12
- :delete,
13
- zoom_url("/users/#{args[:id]}")
14
- ).to_return(status: 204, body: json_response('user', 'delete'))
15
- end
10
+ context 'with a 204 response' do
11
+ before :each do
12
+ stub_request(
13
+ :delete,
14
+ zoom_url("/users/#{args[:id]}")
15
+ ).to_return(status: 204,
16
+ body: json_response('user', 'delete'),
17
+ headers: {"Content-Type"=> "application/json"})
18
+ end
16
19
 
17
- it 'requires id param' do
18
- expect { zc.user_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
19
- end
20
+ it 'requires id param' do
21
+ expect { zc.user_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
22
+ end
20
23
 
21
- it 'returns the http status code as a number' do
22
- expect(zc.user_delete(args)).to eql(204)
24
+ it 'returns the http status code as a number' do
25
+ expect(zc.user_delete(args)).to eql(204)
26
+ end
23
27
  end
24
- end
25
28
 
26
- describe '#user_delete!' do
27
- before :each do
28
- stub_request(
29
- :delete,
30
- zoom_url("/users/#{args[:id]}")
31
- ).to_return(status: 404, body: json_response('error', 'validation'))
32
- end
29
+ context 'with a 4xx when the user is not found' do
30
+ before :each do
31
+ stub_request(
32
+ :delete,
33
+ zoom_url("/users/#{args[:id]}")
34
+ ).to_return(status: 404,
35
+ body: json_response('error', 'not_found'),
36
+ headers: {"Content-Type"=> "application/json"})
37
+ end
33
38
 
34
- it 'raises Zoom::Error exception' do
35
- expect {
36
- zc.user_delete!(args)
37
- }.to raise_error(Zoom::Error)
39
+ it 'raises an error' do
40
+ expect { zc.user_delete(args) }.to raise_error(Zoom::Error)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -7,44 +7,48 @@ describe Zoom::Actions::User do
7
7
  let(:args) { { id: 'ufR9342pRyf8ePFN92dttQ' } }
8
8
 
9
9
  describe '#user_get action' do
10
- before :each do
11
- stub_request(
12
- :get,
13
- zoom_url("/users/#{args[:id]}")
14
- ).to_return(body: json_response('user', 'get'))
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/users/#{args[:id]}")
15
+ ).to_return(status: 200,
16
+ body: json_response('user', 'get'),
17
+ headers: {"Content-Type"=> "application/json"})
18
+ end
19
+
20
+ it 'requires id param' do
21
+ expect { zc.user_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]')
22
+ end
23
+
24
+ it 'returns a hash' do
25
+ expect(zc.user_get(args)).to be_kind_of(Hash)
26
+ end
27
+
28
+ it 'returns same params' do
29
+ res = zc.user_get(args)
30
+
31
+ expect(res['id']).to eq(args[:id])
32
+ expect(res).to have_key('first_name')
33
+ expect(res).to have_key('last_name')
34
+ expect(res).to have_key('email')
35
+ expect(res).to have_key('type')
36
+ end
15
37
  end
16
38
 
17
- it 'requires id param' do
18
- expect { zc.user_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]')
19
- end
20
-
21
- it 'returns a hash' do
22
- expect(zc.user_get(args)).to be_kind_of(Hash)
23
- end
24
-
25
- it 'returns same params' do
26
- res = zc.user_get(args)
27
-
28
- expect(res['id']).to eq(args[:id])
29
- expect(res).to have_key('first_name')
30
- expect(res).to have_key('last_name')
31
- expect(res).to have_key('email')
32
- expect(res).to have_key('type')
33
- end
34
- end
35
-
36
- describe '#user_get! action' do
37
- before :each do
38
- stub_request(
39
- :get,
40
- zoom_url("/users/#{args[:id]}")
41
- ).to_return(body: json_response('error', 'validation'))
42
- end
43
-
44
- it 'raises Zoom::Error exception' do
45
- expect {
46
- zc.user_get!(args)
47
- }.to raise_error(Zoom::Error)
39
+ context 'with a 4xx response' do
40
+ before :each do
41
+ stub_request(
42
+ :get,
43
+ zoom_url("/users/#{args[:id]}")
44
+ ).to_return(status: 404,
45
+ body: json_response('error', 'validation'),
46
+ headers: {"Content-Type"=> "application/json"})
47
+ end
48
+
49
+ it 'raises Zoom::Error exception' do
50
+ expect { zc.user_get(args) }.to raise_error(Zoom::Error)
51
+ end
48
52
  end
49
53
  end
50
54
  end
@@ -6,42 +6,45 @@ describe Zoom::Actions::User do
6
6
  let(:zc) { zoom_client }
7
7
 
8
8
  describe '#user_list action' do
9
- before :each do
10
- stub_request(
11
- :get,
12
- zoom_url('/users')
13
- ).to_return(body: json_response('user', 'list'))
9
+ context 'with a valid response' do
10
+ before :each do
11
+ stub_request(
12
+ :get,
13
+ zoom_url('/users')
14
+ ).to_return(body: json_response('user', 'list'),
15
+ headers: {"Content-Type"=> "application/json"})
16
+ end
17
+
18
+ it 'returns a hash' do
19
+ expect(zc.user_list).to be_kind_of(Hash)
20
+ end
21
+
22
+ it "returns 'total_records" do
23
+ expect(zc.user_list['total_records']).to eq(1)
24
+ end
25
+
26
+ it "returns 'users' Array" do
27
+ expect(zc.user_list['users']).to be_kind_of(Array)
28
+ end
29
+
30
+ it 'raises an error when passed an invalid option' do
31
+ expect { zc.user_list(foo: 'bar', status: 'active') }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s)
32
+ end
14
33
  end
15
34
 
16
- it 'returns a hash' do
17
- expect(zc.user_list).to be_kind_of(Hash)
18
- end
19
-
20
- it "returns 'total_records" do
21
- expect(zc.user_list['total_records']).to eq(1)
22
- end
23
-
24
- it "returns 'users' Array" do
25
- expect(zc.user_list['users']).to be_kind_of(Array)
26
- end
27
-
28
- it 'raises an error when passed an invalid option' do
29
- expect { zc.user_list(foo: 'bar', status: 'active') }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s)
30
- end
31
- end
32
-
33
- describe '#user_list! action' do
34
- before :each do
35
- stub_request(
36
- :get,
37
- zoom_url('/users')
38
- ).to_return(body: json_response('error', 'validation'))
39
- end
40
-
41
- it 'raises Zoom::Error exception' do
42
- expect {
43
- zc.user_list!
44
- }.to raise_error(Zoom::Error)
35
+ context 'with a 4xx response' do
36
+ before :each do
37
+ stub_request(
38
+ :get,
39
+ zoom_url('/users')
40
+ ).to_return(status: 404,
41
+ body: json_response('error', 'not_found'),
42
+ headers: {"Content-Type"=> "application/json"})
43
+ end
44
+
45
+ it 'raises Zoom::Error exception' do
46
+ expect { zc.user_list }.to raise_error(Zoom::Error)
47
+ end
45
48
  end
46
49
  end
47
50
  end
@@ -9,32 +9,37 @@ describe Zoom::Actions::User do
9
9
  last_name: 'Foo' } }
10
10
 
11
11
  describe '#user_update' do
12
- before :each do
13
- stub_request(
14
- :patch,
15
- zoom_url("/users/#{args[:id]}")
16
- ).to_return(status: 204, body: json_response('user', 'update'))
17
- end
18
-
19
- it 'requires id param' do
20
- expect { zc.user_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
21
- end
12
+ context 'with a valid response' do
13
+ before :each do
14
+ stub_request(
15
+ :patch,
16
+ zoom_url("/users/#{args[:id]}")
17
+ ).to_return(status: 204,
18
+ body: json_response('user', 'update'),
19
+ headers: {"Content-Type"=> "application/json"})
20
+ end
22
21
 
23
- it 'returns the http status code as a number' do
24
- expect(zc.user_update(args)).to eql(204)
25
- end
26
- end
22
+ it 'requires id param' do
23
+ expect { zc.user_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
24
+ end
27
25
 
28
- describe '#user_update!' do
29
- before :each do
30
- stub_request(
31
- :patch,
32
- zoom_url("/users/#{args[:id]}")
33
- ).to_return(status: 404, body: json_response('error', 'validation'))
26
+ it 'returns the http status code as a number' do
27
+ expect(zc.user_update(args)).to eql(204)
28
+ end
34
29
  end
30
+ context 'with a 4xx response' do
31
+ before :each do
32
+ stub_request(
33
+ :patch,
34
+ zoom_url("/users/#{args[:id]}")
35
+ ).to_return(status: 404,
36
+ body: json_response('error', 'validation'),
37
+ headers: {"Content-Type"=> "application/json"})
38
+ end
35
39
 
36
- it 'raises Zoom::Error exception' do
37
- expect { zc.user_update!(args) }.to raise_error(Zoom::Error)
40
+ it 'raises an error' do
41
+ expect { zc.user_update(args) }.to raise_error(Zoom::Error)
42
+ end
38
43
  end
39
44
  end
40
45
  end
@@ -7,46 +7,48 @@ RSpec.describe Zoom::Actions::Webinar do
7
7
  let(:args) { { host_id: 'test_user_id' } }
8
8
 
9
9
  describe '#webinar_create' do
10
- before :each do
11
- stub_request(
12
- :post,
13
- zoom_url("/users/#{args[:host_id]}/webinars")
14
- ).to_return(body: json_response('webinar', 'create'))
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :post,
14
+ zoom_url("/users/#{args[:host_id]}/webinars")
15
+ ).to_return(body: json_response('webinar', 'create'),
16
+ headers: {"Content-Type"=> "application/json"})
17
+ end
18
+
19
+ it "requires a 'host_id' argument" do
20
+ expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
21
+ end
22
+
23
+ it 'returns a hash' do
24
+ expect(zc.webinar_create(args)).to be_kind_of(Hash)
25
+ end
26
+
27
+ it 'returns the setted params' do
28
+ res = zc.webinar_create(args)
29
+ expect(res['host_id']).to eq(args[:host_id])
30
+ end
31
+
32
+ it "returns 'start_url' and 'join_url'" do
33
+ res = zc.webinar_create(args)
34
+
35
+ expect(res['start_url']).to_not be_nil
36
+ expect(res['join_url']).to_not be_nil
37
+ end
15
38
  end
16
39
 
17
- it "requires a 'host_id' argument" do
18
- expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
19
- end
20
-
21
- it 'returns a hash' do
22
- expect(zc.webinar_create(args)).to be_kind_of(Hash)
23
- end
24
-
25
- it 'returns the setted params' do
26
- res = zc.webinar_create(args)
27
- expect(res['host_id']).to eq(args[:host_id])
28
- end
29
-
30
- it "returns 'start_url' and 'join_url'" do
31
- res = zc.webinar_create(args)
32
-
33
- expect(res['start_url']).to_not be_nil
34
- expect(res['join_url']).to_not be_nil
35
- end
36
- end
37
-
38
- describe '#webinar_create!' do
39
- before :each do
40
- stub_request(
41
- :post,
42
- zoom_url("/users/#{args[:host_id]}/webinars")
43
- ).to_return(body: json_response('error', 'validation'))
44
- end
45
-
46
- it 'raises Zoom::Error exception' do
47
- expect {
48
- zc.webinar_create!(args)
49
- }.to raise_error(Zoom::Error)
40
+ context 'with a 4xx response' do
41
+ before :each do
42
+ stub_request(
43
+ :post,
44
+ zoom_url("/users/#{args[:host_id]}/webinars")
45
+ ).to_return(body: json_response('error', 'validation'),
46
+ headers: {"Content-Type"=> "application/json"})
47
+ end
48
+
49
+ it 'raises Zoom::Error exception' do
50
+ expect { zc.webinar_create(args) }.to raise_error(Zoom::Error)
51
+ end
50
52
  end
51
53
  end
52
54
  end
@@ -7,34 +7,38 @@ describe Zoom::Actions::Webinar do
7
7
  let(:args) { { id: '123456789' } }
8
8
 
9
9
  describe '#webinar_delete' do
10
- before :each do
11
- stub_request(
12
- :delete,
13
- zoom_url("/webinars/#{args[:id]}")
14
- ).to_return(status: 204, body: json_response('webinar', 'delete'))
15
- end
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :delete,
14
+ zoom_url("/webinars/#{args[:id]}")
15
+ ).to_return(status: 204,
16
+ body: json_response('webinar', 'delete'),
17
+ headers: {"Content-Type"=> "application/json"})
18
+ end
16
19
 
17
- it "requires a 'id' argument" do
18
- expect { zc.webinar_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
19
- end
20
+ it "requires a 'id' argument" do
21
+ expect { zc.webinar_delete(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
22
+ end
20
23
 
21
- it 'returns the http status code as a number' do
22
- expect(zc.webinar_delete(args)).to eql(204)
24
+ it 'returns the http status code as a number' do
25
+ expect(zc.webinar_delete(args)).to eql(204)
26
+ end
23
27
  end
24
- end
25
28
 
26
- describe '#webinar_delete!' do
27
- before :each do
28
- stub_request(
29
- :delete,
30
- zoom_url("/webinars/#{args[:id]}")
31
- ).to_return(body: json_response('error', 'validation'))
32
- end
29
+ context 'with a 4xx response' do
30
+ before :each do
31
+ stub_request(
32
+ :delete,
33
+ zoom_url("/webinars/#{args[:id]}")
34
+ ).to_return(status: 404,
35
+ body: json_response('error', 'validation'),
36
+ headers: {"Content-Type"=> "application/json"})
37
+ end
33
38
 
34
- it 'raises Zoom::Error exception' do
35
- expect {
36
- zc.webinar_delete!(args)
37
- }.to raise_error(Zoom::Error)
39
+ it 'raises Zoom::Error exception' do
40
+ expect { zc.webinar_delete(args) }.to raise_error(Zoom::Error)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -17,7 +17,8 @@ xdescribe Zoom::Actions::Webinar do
17
17
  stub_request(
18
18
  :post,
19
19
  zoom_url('/webinar/get')
20
- ).to_return(body: json_response('webinar_get'))
20
+ ).to_return(body: json_response('webinar_get'),
21
+ headers: {"Content-Type"=> "application/json"})
21
22
  end
22
23
 
23
24
  it "requires a 'host_id' argument" do
@@ -7,42 +7,44 @@ RSpec.describe Zoom::Actions::Webinar do
7
7
  let(:args) { { host_id: 'test_user_id' } }
8
8
 
9
9
  describe '#webinar_list' do
10
- before :each do
11
- stub_request(
12
- :get,
13
- zoom_url("/users/#{args[:host_id]}/webinars")
14
- ).to_return(body: json_response('webinar', 'list'))
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/users/#{args[:host_id]}/webinars")
15
+ ).to_return(body: json_response('webinar', 'list'),
16
+ headers: {"Content-Type"=> "application/json"})
17
+ end
18
+
19
+ it "requires a 'host_id' argument" do
20
+ expect { zc.webinar_list }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
21
+ end
22
+
23
+ it 'returns a hash' do
24
+ expect(zc.webinar_list(args)).to be_kind_of(Hash)
25
+ end
26
+
27
+ it "returns 'total_records'" do
28
+ expect(zc.webinar_list(args)['total_records']).to eq(1)
29
+ end
30
+
31
+ it "returns 'webinars' Array" do
32
+ expect(zc.webinar_list(args)['webinars']).to be_kind_of(Array)
33
+ end
15
34
  end
16
35
 
17
- it "requires a 'host_id' argument" do
18
- expect { zc.webinar_list }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
19
- end
20
-
21
- it 'returns a hash' do
22
- expect(zc.webinar_list(args)).to be_kind_of(Hash)
23
- end
24
-
25
- it "returns 'total_records'" do
26
- expect(zc.webinar_list(args)['total_records']).to eq(1)
27
- end
28
-
29
- it "returns 'webinars' Array" do
30
- expect(zc.webinar_list(args)['webinars']).to be_kind_of(Array)
31
- end
32
- end
33
-
34
- describe '#webinar_list! action' do
35
- before :each do
36
- stub_request(
37
- :get,
38
- zoom_url("/users/#{args[:host_id]}/webinars")
39
- ).to_return(body: json_response('error', 'validation'))
40
- end
41
-
42
- it 'raises Zoom::Error exception' do
43
- expect {
44
- zc.webinar_list!(args)
45
- }.to raise_error(Zoom::Error)
36
+ context 'with a 4xx response' do
37
+ before :each do
38
+ stub_request(
39
+ :get,
40
+ zoom_url("/users/#{args[:host_id]}/webinars")
41
+ ).to_return(body: json_response('error', 'validation'),
42
+ headers: {"Content-Type"=> "application/json"})
43
+ end
44
+
45
+ it 'raises Zoom::Error exception' do
46
+ expect { zc.webinar_list(args) }.to raise_error(Zoom::Error)
47
+ end
46
48
  end
47
49
  end
48
50
  end
@@ -10,51 +10,55 @@ RSpec.describe Zoom::Actions::Webinar do
10
10
  email: 'foo@bar.com' } }
11
11
 
12
12
  describe '#webinar_registrant_add' do
13
- before :each do
14
- stub_request(
15
- :post,
16
- zoom_url("/webinars/#{args[:id]}/registrants")
17
- ).to_return(status: 201, body: json_response('webinar', 'registrant', 'add'))
18
- end
13
+ context 'with a valid response' do
14
+ before :each do
15
+ stub_request(
16
+ :post,
17
+ zoom_url("/webinars/#{args[:id]}/registrants")
18
+ ).to_return(status: 201,
19
+ body: json_response('webinar', 'registrant', 'add'),
20
+ headers: {"Content-Type"=> "application/json"})
21
+ end
19
22
 
20
- it "requires a 'id' argument" do
21
- expect { zc.webinar_registrant_add(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
22
- end
23
+ it "requires a 'id' argument" do
24
+ expect { zc.webinar_registrant_add(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
25
+ end
23
26
 
24
- it "requires a 'first_name' argument" do
25
- expect { zc.webinar_registrant_add(filter_key(args, :first_name)) }.to raise_error(Zoom::ParameterMissing, [:first_name].to_s)
26
- end
27
+ it "requires a 'first_name' argument" do
28
+ expect { zc.webinar_registrant_add(filter_key(args, :first_name)) }.to raise_error(Zoom::ParameterMissing, [:first_name].to_s)
29
+ end
27
30
 
28
- it "requires a 'last_name' argument" do
29
- expect { zc.webinar_registrant_add(filter_key(args, :last_name)) }.to raise_error(Zoom::ParameterMissing, [:last_name].to_s)
30
- end
31
+ it "requires a 'last_name' argument" do
32
+ expect { zc.webinar_registrant_add(filter_key(args, :last_name)) }.to raise_error(Zoom::ParameterMissing, [:last_name].to_s)
33
+ end
31
34
 
32
- it "requires a 'email' argument" do
33
- expect { zc.webinar_registrant_add(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s)
34
- end
35
+ it "requires a 'email' argument" do
36
+ expect { zc.webinar_registrant_add(filter_key(args, :email)) }.to raise_error(Zoom::ParameterMissing, [:email].to_s)
37
+ end
35
38
 
36
- it 'returns an Hash' do
37
- expect(zc.webinar_registrant_add(args)).to be_kind_of(Hash)
38
- end
39
+ it 'returns an Hash' do
40
+ expect(zc.webinar_registrant_add(args)).to be_kind_of(Hash)
41
+ end
39
42
 
40
- it 'returns a "join_url"' do
41
- res = zc.webinar_registrant_add(args)
42
- expect(res['join_url']).not_to be nil
43
+ it 'returns a "join_url"' do
44
+ res = zc.webinar_registrant_add(args)
45
+ expect(res['join_url']).not_to be nil
46
+ end
43
47
  end
44
- end
45
48
 
46
- describe '#webinar_registrant_add!' do
47
- before :each do
48
- stub_request(
49
- :post,
50
- zoom_url("/webinars/#{args[:id]}/registrants")
51
- ).to_return(status: 404, body: json_response('error', 'validation'))
52
- end
49
+ context 'with a 4xx response' do
50
+ before :each do
51
+ stub_request(
52
+ :post,
53
+ zoom_url("/webinars/#{args[:id]}/registrants")
54
+ ).to_return(status: 404,
55
+ body: json_response('error', 'not_found'),
56
+ headers: {"Content-Type"=> "application/json"})
57
+ end
53
58
 
54
- it 'raises Zoom::Error exception' do
55
- expect {
56
- zc.webinar_registrant_add!(args)
57
- }.to raise_error(Zoom::Error)
59
+ it 'raises Zoom::Error exception' do
60
+ expect { zc.webinar_registrant_add(args) }.to raise_error(Zoom::Error)
61
+ end
58
62
  end
59
63
  end
60
64
  end
@@ -7,34 +7,37 @@ RSpec.describe Zoom::Actions::Webinar do
7
7
  let(:args) { { id: 'webinar_id' } }
8
8
 
9
9
  describe '#webinar_registrants_list' do
10
- before :each do
11
- stub_request(
12
- :get,
13
- zoom_url("/webinars/#{args[:id]}/registrants")
14
- ).to_return(body: json_response('webinar', 'registrant', 'list'))
15
- end
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/webinars/#{args[:id]}/registrants")
15
+ ).to_return(body: json_response('webinar', 'registrant', 'list'),
16
+ headers: {"Content-Type"=> "application/json"})
17
+ end
16
18
 
17
- it "requires a 'id' argument" do
18
- expect { zc.webinar_registrants_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
19
- end
19
+ it "requires a 'id' argument" do
20
+ expect { zc.webinar_registrants_list(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
21
+ end
20
22
 
21
- it 'returns an Array of registrants' do
22
- expect(zc.webinar_registrants_list(args)['registrants']).to be_kind_of(Array)
23
+ it 'returns an Array of registrants' do
24
+ expect(zc.webinar_registrants_list(args)['registrants']).to be_kind_of(Array)
25
+ end
23
26
  end
24
- end
25
27
 
26
- describe '#webinar_registrants_list!' do
27
- before :each do
28
- stub_request(
29
- :get,
30
- zoom_url("/webinars/#{args[:id]}/registrants")
31
- ).to_return(status: 404, body: json_response('error', 'validation'))
32
- end
28
+ context 'with a 4xx response' do
29
+ before :each do
30
+ stub_request(
31
+ :get,
32
+ zoom_url("/webinars/#{args[:id]}/registrants")
33
+ ).to_return(status: 404,
34
+ body: json_response('error', 'validation'),
35
+ headers: {"Content-Type"=> "application/json"})
36
+ end
33
37
 
34
- it 'raises Zoom::Error exception' do
35
- expect {
36
- zc.webinar_registrants_list!(args)
37
- }.to raise_error(Zoom::Error)
38
+ it 'raises Zoom::Error exception' do
39
+ expect { zc.webinar_registrants_list(args) }.to raise_error(Zoom::Error)
40
+ end
38
41
  end
39
42
  end
40
43
  end
@@ -7,34 +7,38 @@ describe Zoom::Actions::Webinar do
7
7
  let(:args) { { id: '123456789' } }
8
8
 
9
9
  describe '#webinar_update' do
10
- before :each do
11
- stub_request(
12
- :patch,
13
- zoom_url("/webinars/#{args[:id]}")
14
- ).to_return(status: 204, body: json_response('webinar', 'update'))
15
- end
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :patch,
14
+ zoom_url("/webinars/#{args[:id]}")
15
+ ).to_return(status: 204,
16
+ body: json_response('webinar', 'update'),
17
+ headers: {"Content-Type"=> "application/json"})
18
+ end
16
19
 
17
- it "requires a 'id' argument" do
18
- expect { zc.webinar_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
19
- end
20
+ it "requires a 'id' argument" do
21
+ expect { zc.webinar_update(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
22
+ end
20
23
 
21
- it 'returns the http status code as a number' do
22
- expect(zc.webinar_update(args)).to eql(204)
24
+ it 'returns the http status code as a number' do
25
+ expect(zc.webinar_update(args)).to eql(204)
26
+ end
23
27
  end
24
- end
25
28
 
26
- describe '#webinar_update!' do
27
- before :each do
28
- stub_request(
29
- :patch,
30
- zoom_url("/webinars/#{args[:id]}")
31
- ).to_return(status: 404, body: json_response('error', 'validation'))
32
- end
29
+ context 'with a 4xx response' do
30
+ before :each do
31
+ stub_request(
32
+ :patch,
33
+ zoom_url("/webinars/#{args[:id]}")
34
+ ).to_return(status: 404,
35
+ body: json_response('error', 'not_found'),
36
+ headers: {"Content-Type"=> "application/json"})
37
+ end
33
38
 
34
- it 'raises Zoom::Error exception' do
35
- expect {
36
- zc.webinar_update!(args)
37
- }.to raise_error(Zoom::Error)
39
+ it 'raises an error' do
40
+ expect { zc.webinar_update(args) }.to raise_error(Zoom::Error)
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -55,19 +55,4 @@ xdescribe Zoom::Utils do
55
55
  bar: '2000-01-01T20:15:01Z' })
56
56
  end
57
57
  end
58
-
59
- xdescribe '#define_bang_methods' do
60
- before :each do
61
- stub_request(:post, zoom_url('/user/custcreate')).to_timeout
62
- end
63
-
64
- it 'raises Zoom::GatewayTimeout on timeout' do
65
- args = { email: 'foo@bar.com',
66
- first_name: 'Foo',
67
- last_name: 'Bar',
68
- type: 1 }
69
-
70
- expect { zoom_client.user_custcreate!(args) }.to raise_error(Zoom::GatewayTimeout)
71
- end
72
- end
73
58
  end
@@ -25,5 +25,5 @@ Gem::Specification.new do |gem|
25
25
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
26
  gem.name = 'zoom_rb'
27
27
  gem.require_paths = ['lib']
28
- gem.version = '0.8.1'
28
+ gem.version = '0.8.2'
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoom_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Boe
@@ -164,13 +164,15 @@ files:
164
164
  - lib/zoom/actions/user.rb
165
165
  - lib/zoom/actions/webinar.rb
166
166
  - lib/zoom/client.rb
167
- - lib/zoom/defaults.rb
167
+ - lib/zoom/constants.rb
168
168
  - lib/zoom/error.rb
169
169
  - lib/zoom/interface.rb
170
170
  - lib/zoom/params.rb
171
171
  - lib/zoom/utils.rb
172
172
  - spec/fixtures/chat/get.json
173
173
  - spec/fixtures/chat/list.json
174
+ - spec/fixtures/error/already_exists.json
175
+ - spec/fixtures/error/not_found.json
174
176
  - spec/fixtures/error/validation.json
175
177
  - spec/fixtures/mc_recording_list.json
176
178
  - spec/fixtures/meeting/create.json
@@ -340,6 +342,8 @@ summary: zoom.us API wrapper
340
342
  test_files:
341
343
  - spec/fixtures/chat/get.json
342
344
  - spec/fixtures/chat/list.json
345
+ - spec/fixtures/error/already_exists.json
346
+ - spec/fixtures/error/not_found.json
343
347
  - spec/fixtures/error/validation.json
344
348
  - spec/fixtures/mc_recording_list.json
345
349
  - spec/fixtures/meeting/create.json