zoom_rb 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad16279c225cd1874a9923203eafd25dce7b8f122cb9f5abf2cb5126e2792ef6
4
- data.tar.gz: 34fbf4d1a4a4d5dbf02c32cc994ea6eaacdee90b613f70a29d573d9b451e3d3a
3
+ metadata.gz: efbf20752dce2d7796dd85203549f9147fb81f74c98b5f3317a2d2e3dde68ebb
4
+ data.tar.gz: 7e71b22ccbe081f63521fea457a010c0ea48d53cbf307fee8d63e9df716b9500
5
5
  SHA512:
6
- metadata.gz: f392deada6b8e9e7ff03007d295ec97981958a14a1ca6b45cfd4ade5ce6cf7445c6603e899a548d3aef5ff904f02e91138a4bd28ea47da7dd892f3fff9a6d566
7
- data.tar.gz: 18f7a36b1f5af0073a87cf66ddfb5ee03bb5bfe1b1be6635a39cd493ec6d82b775e14d6979bbd0aa02c20065bfc70b42575ce944e786ae3cf3bbb68ab4b3b317
6
+ metadata.gz: f56ec4c5410d86eaa83a10c89ccd29e5d5732effa3203a79c1b3506ffd532abda14090f704f09ded594b5c14c33015a0a786304b8a243b6f561e4e584d2808a5
7
+ data.tar.gz: 3d213b942fd24614dd323d4d2c45076b80cc6dfff483560cbc376630e8c046cfd443c7cfb2b86c7c6d6e04554496dfa6d92c0db565dc8335a17a5888bbc9d8ea
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zoom_rb (0.8.7)
4
+ zoom_rb (0.10.0)
5
5
  httparty (~> 0.13)
6
6
  json (>= 1.8)
7
7
  jwt
@@ -21,12 +21,16 @@ GEM
21
21
  hint-rubocop_style (0.2.5)
22
22
  rubocop (>= 0.50.0)
23
23
  rubocop-rspec (>= 1.17.0)
24
- httparty (0.16.2)
24
+ httparty (0.17.1)
25
+ mime-types (~> 3.0)
25
26
  multi_xml (>= 0.5.2)
26
27
  jaro_winkler (1.5.1)
27
28
  json (2.1.0)
28
- jwt (2.1.0)
29
+ jwt (2.2.1)
29
30
  method_source (0.9.0)
31
+ mime-types (3.3)
32
+ mime-types-data (~> 3.2015)
33
+ mime-types-data (3.2019.1009)
30
34
  multi_xml (0.6.0)
31
35
  parallel (1.12.1)
32
36
  parser (2.5.3.0)
@@ -88,4 +92,4 @@ DEPENDENCIES
88
92
  zoom_rb!
89
93
 
90
94
  BUNDLED WITH
91
- 1.17.1
95
+ 1.17.2
data/README.md CHANGED
@@ -18,6 +18,8 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ The Zoom API uses OAuth or JWT to [Authenticate](https://marketplace.zoom.us/docs/api-reference/Authentication) API request. By defaut, a JWT client will be used.
22
+
21
23
  ```ruby
22
24
  require 'zoom'
23
25
 
@@ -27,7 +29,19 @@ Zoom.configure do |c|
27
29
  end
28
30
 
29
31
  zoom_client = Zoom.new
32
+ ```
33
+
34
+ To create an OAuth client, create the client directly
35
+
36
+ ```ruby
37
+ require 'zoom'
38
+
39
+ zoom_client = Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15)
40
+ ```
30
41
 
42
+ With the client, access the API
43
+
44
+ ```ruby
31
45
  user_list = zoom_client.user_list
32
46
  user_list['users'].each do |user|
33
47
  user_id = user['id']
@@ -26,7 +26,7 @@ module Zoom
26
26
 
27
27
  def new
28
28
  @configuration ||= Configuration.new
29
- Zoom::Client.new(
29
+ Zoom::Client::JWT.new(
30
30
  api_key: @configuration.api_key,
31
31
  api_secret: @configuration.api_secret,
32
32
  timeout: @configuration.timeout
@@ -40,10 +40,11 @@ module Zoom
40
40
  end
41
41
 
42
42
  class Configuration
43
- attr_accessor :api_key, :api_secret, :timeout
43
+ attr_accessor :api_key, :api_secret, :timeout, :access_token
44
44
 
45
45
  def initialize
46
46
  @api_key = @api_secret = 'xxx'
47
+ @access_token = nil
47
48
  @timeout = 15
48
49
  end
49
50
  end
@@ -4,9 +4,9 @@ module Zoom
4
4
  module Actions
5
5
  module Account
6
6
  def account_list(*args)
7
- # TODO: implement accounts_list
8
- # options = Utils.extract_options!(args)
9
- raise Zoom::NotImplemented, 'accounts_list is not yet implemented'
7
+ params = Zoom::Params.new(Utils.extract_options!(args))
8
+ params.permit(:page_size, :page_number)
9
+ Utils.parse_response self.class.get("/accounts", query: params, headers: request_headers)
10
10
  end
11
11
 
12
12
  def account_create(*args)
@@ -34,9 +34,9 @@ module Zoom
34
34
  end
35
35
 
36
36
  def account_settings_get(*args)
37
- # TODO: implement account_settings_get
38
- # options = Utils.extract_options!(args)
39
- raise Zoom::NotImplemented, 'account_settings_get is not yet implemented'
37
+ params = Zoom::Params.new(Utils.extract_options!(args))
38
+ params.require(:id)
39
+ Utils.parse_response self.class.get("/accounts/#{params[:id]}/settings", query: params.except(:id), headers: request_headers)
40
40
  end
41
41
 
42
42
  def account_settings_update(*args)
@@ -7,7 +7,7 @@ module Zoom
7
7
  # Get chat messages for a specified period.
8
8
  def chat_get(*args)
9
9
  options = Utils.extract_options!(args)
10
- Utils.require_params(%i[access_token session_id from to], options)
10
+ Zoom::Params.new(options).require(:access_token, :session_id, :from, :to)
11
11
  # TODO handle date format for `from` and `to` params
12
12
  # TODO implement `next_page_token`, will be returned whenever the set of available chat history list exceeds 100. The expiration period is 30 minutes.
13
13
  Utils.parse_response self.class.post('/chat/get', query: options)
@@ -16,7 +16,7 @@ module Zoom
16
16
  # Get chat history list for a specified time period.
17
17
  def chat_list(*args)
18
18
  options = Utils.extract_options!(args)
19
- Utils.require_params(%i[access_token from to], options)
19
+ Zoom::Params.new(options).require(:access_token, :from, :to)
20
20
  # TODO handle date format for `from` and `to` params
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)
@@ -5,21 +5,21 @@ module Zoom
5
5
  module Metrics
6
6
  def metrics_crc(*args)
7
7
  options = Utils.extract_options!(args)
8
- Utils.require_params(%i[from to], options)
8
+ Zoom::Params.new(options).require(:from, :to)
9
9
  Utils.process_datetime_params!(%i[from to], options)
10
10
  Utils.parse_response self.class.post('/metrics/crc', query: options)
11
11
  end
12
12
 
13
13
  def metrics_meetings(*args)
14
14
  options = Utils.extract_options!(args)
15
- Utils.require_params(%i[from to type], options)
15
+ Zoom::Params.new(options).require(:from, :to, :type)
16
16
  Utils.process_datetime_params!(%i[from to], options)
17
17
  Utils.parse_response self.class.post('/metrics/meetings', query: options)
18
18
  end
19
19
 
20
20
  def metrics_meetingdetail(*args)
21
21
  options = Utils.extract_options!(args)
22
- Utils.require_params(%i[meeting_id type], options)
22
+ Zoom::Params.new(options).require(:meeting_id, :type)
23
23
  Utils.parse_response self.class.post('/metrics/meetingdetail', query: options)
24
24
  end
25
25
  end
@@ -5,27 +5,27 @@ module Zoom
5
5
  module Recording
6
6
  def recording_list(*args)
7
7
  options = Utils.extract_options!(args)
8
- Utils.require_params([:host_id], options)
8
+ Zoom::Params.new(options).require(:host_id)
9
9
  Utils.process_datetime_params!(%i[from to], options)
10
10
  Utils.parse_response self.class.post('/recording/list', query: options)
11
11
  end
12
12
 
13
13
  def mc_recording_list(*args)
14
14
  options = Utils.extract_options!(args)
15
- Utils.require_params([:host_id], options)
15
+ Zoom::Params.new(options).require(:host_id)
16
16
  Utils.process_datetime_params!(%i[from to], options)
17
17
  Utils.parse_response self.class.post('/mc/recording/list', query: options)
18
18
  end
19
19
 
20
20
  def recording_get(*args)
21
21
  options = Utils.extract_options!(args)
22
- Utils.require_params([:meeting_id], options)
22
+ Zoom::Params.new(options).require(:meeting_id)
23
23
  Utils.parse_response self.class.post('/recording/get', query: options)
24
24
  end
25
25
 
26
26
  def recording_delete(*args)
27
27
  options = Utils.extract_options!(args)
28
- Utils.require_params([:meeting_id], options)
28
+ Zoom::Params.new(options).require(:meeting_id)
29
29
  Utils.parse_response self.class.post('/recording/delete', query: options)
30
30
  end
31
31
  end
@@ -6,7 +6,7 @@ module Zoom
6
6
  def daily_report(*args)
7
7
  params = Zoom::Params.new(Utils.extract_options!(args))
8
8
  params.permit(:year, :month)
9
- Utils.parse_response self.class.get('/report/daily', query: params)
9
+ Utils.parse_response self.class.get('/report/daily', query: params, headers: request_headers)
10
10
  end
11
11
 
12
12
  def hosts_report(*args)
@@ -41,7 +41,6 @@ module Zoom
41
41
  raise Zoom::NotImplemented, 'user_assistants_list is not yet implemented'
42
42
  # TODO: implement user_assistants_list
43
43
  # options = Utils.extract_options!(args)
44
- # Utils.require_params([:user_id], options)
45
44
  Utils.parse_response self.class.get("/users/#{options.slice!(:id)}/assistants", query: options, headers: request_headers)
46
45
  end
47
46
 
@@ -90,9 +89,9 @@ module Zoom
90
89
  end
91
90
 
92
91
  def user_settings_get(*args)
93
- # TODO: implement user_settings_get
94
- # options = Utils.extract_options!(args)
95
- raise Zoom::NotImplemented, 'user_settings_get is not yet implemented'
92
+ params = Zoom::Params.new(Utils.extract_options!(args))
93
+ params.require(:id).permit(:login_type)
94
+ Utils.parse_response self.class.get("/users/#{params[:id]}/settings", query: params.except(:id), headers: request_headers)
96
95
  end
97
96
 
98
97
  def user_settings_update(*args)
@@ -104,6 +104,12 @@ module Zoom
104
104
  params.require(:id)
105
105
  Utils.parse_response self.class.get("/past_webinars/#{params[:id]}/instances", headers: request_headers)
106
106
  end
107
+
108
+ def webinar_registrant_get(*args)
109
+ params = Zoom::Params.new(Utils.extract_options!(args))
110
+ params.require(:webinar_id, :id).permit(:occurrence_id)
111
+ Utils.parse_response self.class.get("/webinars/#{params[:webinar_id]}/registrants/#{params[:id]}", query: params.except(:webinar_id, :id), headers: request_headers)
112
+ end
107
113
  end
108
114
  end
109
115
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'httparty'
4
- require 'json'
5
- require 'jwt'
6
4
 
7
5
  module Zoom
8
6
  class Client
@@ -23,12 +21,6 @@ module Zoom
23
21
  headers 'Accept' => 'application/json'
24
22
  headers 'Content-Type' => 'application/json'
25
23
 
26
- def initialize(config)
27
- Utils.require_params(%i[api_key api_secret], config)
28
- config.each { |k, v| instance_variable_set("@#{k}", v) }
29
- self.class.default_timeout(@timeout)
30
- end
31
-
32
24
  def request_headers
33
25
  {
34
26
  'Accept' => 'application/json',
@@ -36,9 +28,8 @@ module Zoom
36
28
  'Authorization' => "Bearer #{access_token}"
37
29
  }
38
30
  end
39
-
40
- def access_token
41
- JWT.encode({ iss: @api_key, exp: Time.now.to_i + @timeout }, @api_secret, 'HS256', { typ: 'JWT' })
42
- end
43
31
  end
44
32
  end
33
+
34
+ require 'zoom/clients/jwt'
35
+ require 'zoom/clients/oauth'
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'jwt'
3
+
4
+ module Zoom
5
+ class Client
6
+ class JWT < Zoom::Client
7
+
8
+ def initialize(config)
9
+ Zoom::Params.new(config).require(:api_key, :api_secret)
10
+ config.each { |k, v| instance_variable_set("@#{k}", v) }
11
+ self.class.default_timeout(@timeout || 20)
12
+ end
13
+
14
+ def access_token
15
+ ::JWT.encode({ iss: @api_key, exp: Time.now.to_i + @timeout }, @api_secret, 'HS256', { typ: 'JWT' })
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+
22
+
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Zoom
4
+ class Client
5
+ class OAuth < Zoom::Client
6
+ def initialize(config)
7
+ Zoom::Params.new(config).require(:access_token)
8
+ config.each { |k, v| instance_variable_set("@#{k}", v) }
9
+ self.class.default_timeout(@timeout || 20)
10
+ end
11
+
12
+ def access_token
13
+ @access_token
14
+ end
15
+ end
16
+ end
17
+ end
@@ -95,8 +95,8 @@ module Zoom
95
95
 
96
96
  USER_CREATE_TYPES = {
97
97
  'create' => 'User will get an email sent from Zoom. There is a confirmation link in this email. User will then need to click this link to activate their account to the Zoom service. The user can set or change their password in Zoom.',
98
- 'custCreate' => 'This action is provided for enterprise customer who has a managed domain. This feature is disabled by default because of the security risk involved in creating a user who does not belong to your domain without notifying the user.',
99
- 'autoCreate' => 'This action is provided for API partner only. User created in this way has no password and is not able to log into the Zoom web site or client.',
98
+ 'autoCreate' => 'This action is provided for enterprise customer who has a managed domain. This feature is disabled by default because of the security risk involved in creating a user who does not belong to your domain without notifying the user.',
99
+ 'custCreate' => 'This action is provided for API partner only. User created in this way has no password and is not able to log into the Zoom web site or client.',
100
100
  'ssoCreate' => 'This action is provided for enabled “Pre-provisioning SSO User” option. User created in this way has no password. If it is not a basic user, will generate a Personal Vanity URL using user name (no domain) of the provisioning email. If user name or pmi is invalid or occupied, will use random number/random personal vanity URL.'
101
101
  }.freeze # no default
102
102
  end
@@ -26,30 +26,6 @@ module Zoom
26
26
  raise_if_error!(http_response.parsed_response) || http_response.code
27
27
  end
28
28
 
29
- def require_params(params, options)
30
- params = [params] unless params.is_a? Array
31
- params.each do |param|
32
- raise argument_error(param.to_s) unless options[param]
33
- end
34
- end
35
-
36
- def permit_params(params, options)
37
- params = [params] unless params.is_a? Array
38
- options.keys.each do |key|
39
- raise exclude_argument_error(key.to_s) unless params.include?(key)
40
- end
41
- end
42
-
43
- # Dynamically defines bang methods for Actions modules
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
52
-
53
29
  def extract_options!(array)
54
30
  array.last.is_a?(::Hash) ? array.pop : {}
55
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zoom
4
- VERSION = '0.9.1'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -0,0 +1,18 @@
1
+ {
2
+ "page_count": 1,
3
+ "page_number": 1,
4
+ "page_size": 10,
5
+ "total_records": 1,
6
+ "accounts": [
7
+ {
8
+ "id": "string [uuid]",
9
+ "account_name": "string",
10
+ "owner_email": "string",
11
+ "account_type": "string",
12
+ "seats": "integer",
13
+ "subscription_start_time": "string [date-time]",
14
+ "subscription_end_time": "string [date-time]",
15
+ "created_at": "string [date-time]"
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "schedule_meting": {
3
+ "host_video": false,
4
+ "participant_video": false,
5
+ "audio_type": "both",
6
+ "join_before_host": false,
7
+ "use_pmi_for_scheduled_meetings": false,
8
+ "use_pmi_for_instant_meetings": false,
9
+ "enforce_login": false,
10
+ "enforce_login_with_domains": false,
11
+ "enforce_login_domains": "example.com",
12
+ "not_store_meeting_topic": false,
13
+ "force_pmi_jbh_password": false
14
+ },
15
+ "in_meeting": {
16
+ "e2e_encryption": false,
17
+ "chat": false,
18
+ "private_chat": false,
19
+ "auto_saving_chat": false,
20
+ "entry_exit_chime": "host",
21
+ "record_play_own_voice": false,
22
+ "file_transfer": false,
23
+ "feedback": false,
24
+ "post_meeting_feedback": false,
25
+ "co_host": false,
26
+ "polling": false,
27
+ "attendee_on_hold": false,
28
+ "show_meeting_control_toolbar": false,
29
+ "allow_show_zoom_windows": false,
30
+ "annotation": false,
31
+ "whiteboard": false,
32
+ "webinar_question_answer": false,
33
+ "anonymous_question_answer": false,
34
+ "breakout_room": false,
35
+ "closed_caption": false,
36
+ "far_end_camera_control": false,
37
+ "group_hd": false,
38
+ "virtual_background": false,
39
+ "watermark": false,
40
+ "alert_guest_join": false,
41
+ "auto_answer": false,
42
+ "p2p_connetion": false,
43
+ "p2p_ports": false,
44
+ "ports_range": "55,56",
45
+ "sending_default_email_invites": false,
46
+ "use_html_format_email": false,
47
+ "dscp_marking": false,
48
+ "dscp_audio": 42,
49
+ "dscp_video": 43,
50
+ "stereo_audio": false,
51
+ "original_audio": false,
52
+ "screen_sharing": false,
53
+ "remote_control": false,
54
+ "attention_tracking": false
55
+ },
56
+ "email_notification": {
57
+ "cloud_recording_avaliable_reminder": false,
58
+ "jbh_reminder": false,
59
+ "cancel_meeting_reminder": false,
60
+ "low_host_count_reminder": false,
61
+ "alternative_host_reminder": false,
62
+ "schedule_for_reminder": false
63
+ },
64
+ "zoom_rooms": {
65
+ "upcoming_meeting_alert": false,
66
+ "start_airplay_manually": false,
67
+ "weekly_system_restart": false,
68
+ "list_meetings_with_calendar": false,
69
+ "zr_post_meeting_feedback": false,
70
+ "ultrasonic": false,
71
+ "force_private_meeting": false,
72
+ "hide_host_information": false,
73
+ "cmr_for_instant_meeting": false,
74
+ "auto_start_stop_scheduled_meetings": false
75
+ },
76
+ "security": {
77
+ "admin_change_name_pic": false,
78
+ "import_photos_from_devices": false,
79
+ "hide_billing_info": false
80
+ },
81
+ "recording": {
82
+ "local_recording": false,
83
+ "cloud_recording": false,
84
+ "record_speaker_view": false,
85
+ "record_gallery_view": false,
86
+ "record_audio_file": false,
87
+ "save_chat_text": false,
88
+ "show_timestamp": false,
89
+ "recording_audio_transcript": false,
90
+ "auto_recording": "local",
91
+ "cloud_recording_download": false,
92
+ "cloud_recording_download_host": false,
93
+ "account_user_access_recording": false,
94
+ "auto_delete_cmr": false,
95
+ "auto_delete_cmr_days": 60
96
+ },
97
+ "telephony": {
98
+ "third_party_audio": false,
99
+ "audio_conference_info": "Magic third party auto conference info"
100
+ },
101
+ "tsp": {
102
+ "call_out": false,
103
+ "call_out_countries": [
104
+ "US"
105
+ ],
106
+ "show_international_numbers_link": false,
107
+ "display_toll_free_numbers": false
108
+ },
109
+ "integration": {
110
+ "google_calendar": false,
111
+ "google_drive": false,
112
+ "dropbox": false,
113
+ "box": false,
114
+ "microsoft_one_drive": false,
115
+ "kubi": false
116
+ },
117
+ "feature": {
118
+ "meeting_capacity": 500
119
+ }
120
+ }
@@ -0,0 +1,74 @@
1
+ {
2
+ "scheduled_meeting": {
3
+ "host_video": true,
4
+ "participants_video": true,
5
+ "audio_type": "cloud",
6
+ "join_before_host": true,
7
+ "use_pmi_for_scheduled_meetings": true,
8
+ "use_pmi_for_instant_meetings": true,
9
+ "enforce_login": true,
10
+ "not_store_meeting_topic": true,
11
+ "force_pmi_jbh_password": true,
12
+ "pstn_password_protected": true
13
+ },
14
+ "in_meeting": {
15
+ "e2e_encryption": true,
16
+ "chat": true,
17
+ "private_chat": true,
18
+ "auto_saving_chat": true,
19
+ "entry_exit_chime": "all",
20
+ "record_play_voice": true,
21
+ "file_transfer": true,
22
+ "feedback": true,
23
+ "co_host": true,
24
+ "polling": true,
25
+ "attendee_on_hold": true,
26
+ "annotation": true,
27
+ "remote_control": true,
28
+ "non_verbal_feedback": true,
29
+ "breakout_room": true,
30
+ "remote_support": true,
31
+ "closed_caption": true,
32
+ "group_hd": true,
33
+ "virtual_background": true,
34
+ "far_end_camera_control": true,
35
+ "share_dual_camera": true,
36
+ "attention_tracking": true,
37
+ "waiting_room": true,
38
+ "allow_live_streaming": true
39
+ },
40
+ "email_notification": {
41
+ "jbh_reminder": true,
42
+ "cancel_meeting_reminder": true,
43
+ "alternative_host_reminder": true
44
+ },
45
+ "recording": {
46
+ "local_recording": true,
47
+ "cloud_recording": true,
48
+ "record_speaker_view": true,
49
+ "record_gallery_view": true,
50
+ "record_audio_file": true,
51
+ "save_chat_text": true,
52
+ "show_timestamp": true,
53
+ "recording_audio_transcript": true,
54
+ "auto_recording": "cloud",
55
+ "auto_delete_cmr": true,
56
+ "auto_delete_cmr_days": 42
57
+ },
58
+ "telephony": {
59
+ "third_party_audio": true,
60
+ "audio_conference_info": "Third party audio conference info",
61
+ "show_international_numbers_link": true
62
+ },
63
+ "tsp": {},
64
+ "feature": {
65
+ "meeting_capacity": 100,
66
+ "large_meeting": true,
67
+ "large_meeting_capacity": 1000,
68
+ "webinar": true,
69
+ "webinar_capacity": 500,
70
+ "cn_meeting": true,
71
+ "in_meeting": true,
72
+ "zoom_phone": true
73
+ }
74
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "id": "FAKE",
3
+ "first_name": "Bobby",
4
+ "last_name": "Tables",
5
+ "email": "bobby_tables@example.org",
6
+ "address": "",
7
+ "city": "",
8
+ "country": "",
9
+ "zip": "",
10
+ "state": "",
11
+ "phone": "",
12
+ "industry": "",
13
+ "org": "",
14
+ "job_title": "",
15
+ "purchasing_time_frame": "",
16
+ "role_in_purchase_process": "",
17
+ "no_of_employees": "",
18
+ "comments": "",
19
+ "custom_questions": [
20
+
21
+ ],
22
+ "status": "approved",
23
+ "create_time": "2019-06-26T10:45:56Z",
24
+ "join_url": "https://zoom.us/w/FAKE"
25
+ }
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Account do
6
+ let(:zc) { zoom_client }
7
+ let(:args) {
8
+ {}
9
+ }
10
+ describe '#account_list action' do
11
+ context 'with a valid response' do
12
+ before :each do
13
+ stub_request(
14
+ :get,
15
+ zoom_url('/accounts')
16
+ ).to_return(body: json_response('account', 'list'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it 'returns a hash' do
21
+ expect(zc.account_list(args)).to be_kind_of(Hash)
22
+ end
23
+
24
+ it "allows 'page_size and page_numbers" do
25
+ args[:page_number] = 1
26
+ args[:page_size] = 30
27
+ expect(zc.account_list(args)).to be_kind_of(Hash)
28
+ end
29
+
30
+ it "returns 'total_records" do
31
+ expect(zc.account_list(args)['total_records']).to eq(1)
32
+ end
33
+
34
+ it "returns 'accounts' Array" do
35
+ expect(zc.account_list(args)['accounts']).to be_kind_of(Array)
36
+ end
37
+
38
+ it 'raises an error when passed an invalid option' do
39
+ expect { zc.account_list(foo: 'bar') }.to raise_error(Zoom::ParameterNotPermitted, [:foo].to_s)
40
+ end
41
+ end
42
+
43
+ context 'with a 4xx response' do
44
+ before :each do
45
+ stub_request(
46
+ :get,
47
+ zoom_url('/accounts')
48
+ ).to_return(status: 404,
49
+ body: json_response('error', 'not_found'),
50
+ headers: { 'Content-Type' => 'application/json' })
51
+ end
52
+
53
+ it 'raises Zoom::Error exception' do
54
+ expect { zc.account_list }.to raise_error(Zoom::Error)
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::Account do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { id: 'ufR9342pRyf8ePFN92dttQ' } }
8
+
9
+ describe '#settings_get action' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/accounts/#{args[:id]}/settings")
15
+ ).to_return(status: 200,
16
+ body: json_response('account', 'settings_get'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it 'requires id param' do
21
+ expect { zc.account_settings_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]')
22
+ end
23
+
24
+ it 'returns a hash' do
25
+ expect(zc.account_settings_get(args)).to be_kind_of(Hash)
26
+ end
27
+
28
+ it 'returns same params' do
29
+ res = zc.account_settings_get(args)
30
+
31
+ expect(res.keys).to match_array(["email_notification", "feature", "in_meeting", "integration", "recording", "schedule_meting", "security", "telephony", "tsp", "zoom_rooms"])
32
+ end
33
+ end
34
+
35
+ context 'with a 4xx response' do
36
+ before :each do
37
+ stub_request(
38
+ :get,
39
+ zoom_url("/accounts/#{args[:id]}/settings")
40
+ ).to_return(status: 404,
41
+ body: json_response('error', 'validation'),
42
+ headers: { 'Content-Type' => 'application/json' })
43
+ end
44
+
45
+ it 'raises Zoom::Error exception' do
46
+ expect { zc.account_settings_get(args) }.to raise_error(Zoom::Error)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Zoom::Actions::User do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { id: 'ufR9342pRyf8ePFN92dttQ' } }
8
+
9
+ describe '#settings_get action' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/users/#{args[:id]}/settings")
15
+ ).to_return(status: 200,
16
+ body: json_response('user', 'settings_get'),
17
+ headers: { 'Content-Type' => 'application/json' })
18
+ end
19
+
20
+ it 'requires id param' do
21
+ expect { zc.user_settings_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, '[:id]')
22
+ end
23
+
24
+ it 'allowes login_type' do
25
+ args[:login_type] = 0
26
+ expect { zc.user_settings_get(args) }.not_to raise_error
27
+ end
28
+
29
+
30
+ it 'returns a hash' do
31
+ expect(zc.user_settings_get(args)).to be_kind_of(Hash)
32
+ end
33
+
34
+ it 'returns same params' do
35
+ res = zc.user_settings_get(args)
36
+
37
+ expect(res.keys).to match_array(['scheduled_meeting', 'in_meeting', 'email_notification', 'recording', 'telephony', 'tsp', 'feature'])
38
+ end
39
+ end
40
+
41
+ context 'with a 4xx response' do
42
+ before :each do
43
+ stub_request(
44
+ :get,
45
+ zoom_url("/users/#{args[:id]}/settings")
46
+ ).to_return(status: 404,
47
+ body: json_response('error', 'validation'),
48
+ headers: { 'Content-Type' => 'application/json' })
49
+ end
50
+
51
+ it 'raises Zoom::Error exception' do
52
+ expect { zc.user_settings_get(args) }.to raise_error(Zoom::Error)
53
+ end
54
+ end
55
+ end
56
+ end
@@ -3,51 +3,56 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Zoom::Actions::Webinar do
6
- let(:zc) { zoom_client }
7
- let(:args) { { host_id: 'test_user_id' } }
8
-
9
- describe '#webinar_create' do
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
38
- end
39
-
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
6
 
49
- it 'raises Zoom::Error exception' do
50
- expect { zc.webinar_create(args) }.to raise_error(Zoom::Error)
7
+ [:jwt_client, :oauth_client].each do |client|
8
+ describe "#{client}" do
9
+ let(:zc) { send(client) }
10
+ let(:args) { { host_id: 'test_user_id' } }
11
+
12
+ describe '#webinar_create' do
13
+ context 'with a valid response' do
14
+ before :each do
15
+ stub_request(
16
+ :post,
17
+ zoom_url("/users/#{args[:host_id]}/webinars")
18
+ ).to_return(body: json_response('webinar', 'create'),
19
+ headers: { 'Content-Type' => 'application/json' })
20
+ end
21
+
22
+ it "requires a 'host_id' argument" do
23
+ expect { zc.webinar_create(filter_key(args, :host_id)) }.to raise_error(Zoom::ParameterMissing, [:host_id].to_s)
24
+ end
25
+
26
+ it 'returns a hash' do
27
+ expect(zc.webinar_create(args)).to be_kind_of(Hash)
28
+ end
29
+
30
+ it 'returns the setted params' do
31
+ res = zc.webinar_create(args)
32
+ expect(res['host_id']).to eq(args[:host_id])
33
+ end
34
+
35
+ it "returns 'start_url' and 'join_url'" do
36
+ res = zc.webinar_create(args)
37
+
38
+ expect(res['start_url']).to_not be_nil
39
+ expect(res['join_url']).to_not be_nil
40
+ end
41
+ end
42
+
43
+ context 'with a 4xx response' do
44
+ before :each do
45
+ stub_request(
46
+ :post,
47
+ zoom_url("/users/#{args[:host_id]}/webinars")
48
+ ).to_return(body: json_response('error', 'validation'),
49
+ headers: { 'Content-Type' => 'application/json' })
50
+ end
51
+
52
+ it 'raises Zoom::Error exception' do
53
+ expect { zc.webinar_create(args) }.to raise_error(Zoom::Error)
54
+ end
55
+ end
51
56
  end
52
57
  end
53
58
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Zoom::Actions::Webinar do
6
+ let(:zc) { zoom_client }
7
+ let(:args) { { webinar_id: 'webinar_id', id: 'registrant_id' } }
8
+
9
+ describe '#webinar_registrant_get' do
10
+ context 'with a valid response' do
11
+ before :each do
12
+ stub_request(
13
+ :get,
14
+ zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}")
15
+ ).to_return(body: json_response('webinar', 'registrant', 'get'),
16
+ headers: { 'Content-Type' => 'application/json' })
17
+ end
18
+
19
+ it "requires a 'webinar_id' argument" do
20
+ expect { zc.webinar_registrant_get(filter_key(args, :webinar_id)) }.to raise_error(Zoom::ParameterMissing, [:webinar_id].to_s)
21
+ end
22
+ it "requires a 'id' argument" do
23
+ expect { zc.webinar_registrant_get(filter_key(args, :id)) }.to raise_error(Zoom::ParameterMissing, [:id].to_s)
24
+ end
25
+ it "allows occurrence_id" do
26
+ expect { zc.webinar_registrant_get(args.merge(:occurrence_id => '5')) }.not_to raise_error
27
+ end
28
+
29
+ it 'returns an Hash' do
30
+ expect(zc.webinar_registrant_get(args)).to be_kind_of(Hash)
31
+ end
32
+ end
33
+
34
+ context 'with a 4xx response' do
35
+ before :each do
36
+ stub_request(
37
+ :get,
38
+ zoom_url("/webinars/#{args[:webinar_id]}/registrants/#{args[:id]}")
39
+ ).to_return(status: 404,
40
+ body: json_response('error', 'validation'),
41
+ headers: { 'Content-Type' => 'application/json' })
42
+ end
43
+
44
+ it 'raises Zoom::Error exception' do
45
+ expect { zc.webinar_registrant_get(args) }.to raise_error(Zoom::Error)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -2,11 +2,12 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- xdescribe Zoom::Client do
5
+ describe Zoom::Client do
6
6
 
7
- xdescribe 'default attributes' do
7
+ describe 'default attributes' do
8
8
  it 'must include httparty methods' do
9
9
  expect(Zoom::Client).to include(HTTParty)
10
+ expect(Zoom::Client::JWT).to include(HTTParty)
10
11
  end
11
12
 
12
13
  it 'must have the base url set to Zoom API endpoint' do
@@ -19,7 +20,7 @@ xdescribe Zoom::Client do
19
20
  config.api_secret = 'xxx'
20
21
  end
21
22
  Zoom.new
22
- expect(Zoom::Client.default_options[:timeout]).to eq(15)
23
+ expect(Zoom::Client::JWT.default_options[:timeout]).to eq(15)
23
24
  end
24
25
 
25
26
  it 'must get the timeout from the configuration' do
@@ -29,17 +30,47 @@ xdescribe Zoom::Client do
29
30
  config.timeout = 20
30
31
  end
31
32
  Zoom.new
32
- expect(Zoom::Client.default_options[:timeout]).to eq(20)
33
+ expect(Zoom::Client::JWT.default_options[:timeout]).to eq(20)
33
34
  end
34
35
  end
35
36
 
36
- xdescribe 'constructor' do
37
+ describe 'JWT client' do
38
+ let(:client) {
39
+ Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx', timeout: 15)
40
+ }
37
41
  it 'requires api_key and api_secret for a new instance' do
38
- expect { Zoom::Client.new(api_key: 'xxx') }.to raise_error(ArgumentError)
42
+ expect { Zoom::Client::JWT.new(api_key: 'xxx') }.to raise_error(Zoom::ParameterMissing)
43
+ expect { Zoom::Client::JWT.new(api_key: 'xxx', api_secret: 'xxx') }.not_to raise_error
39
44
  end
40
45
 
41
46
  it 'creates instance of Zoom::Client if api_key and api_secret is provided' do
42
- expect(Zoom::Client.new(api_key: 'xxx', api_secret: 'xxx', timeout: 15)).to be_an_instance_of(Zoom::Client)
47
+ expect(client).to be_kind_of(Zoom::Client)
48
+ end
49
+
50
+ it 'has the bearer token in the auth header' do
51
+ fake_token = 'NotTheRealToken'
52
+ allow(client).to receive(:access_token) {fake_token}
53
+ expect(client.request_headers['Authorization']).to eq("Bearer #{fake_token}")
54
+ end
55
+
56
+ end
57
+
58
+ describe 'OAuth client' do
59
+ let(:access_token) {'xxx'}
60
+ let(:client) {
61
+ Zoom::Client::OAuth.new(access_token: access_token, timeout: 30)
62
+ }
63
+ it 'requires an access token' do
64
+ expect { Zoom::Client::OAuth.new(timeout: 30) }.to raise_error(Zoom::ParameterMissing)
65
+ expect { Zoom::Client::OAuth.new(access_token: access_token) }.not_to raise_error
66
+ end
67
+
68
+ it 'creates instance of Zoom::Client if api_key and api_secret is provided' do
69
+ expect(client).to be_kind_of(Zoom::Client)
70
+ end
71
+
72
+ it 'has the bearer token in the auth header' do
73
+ expect(client.request_headers['Authorization']).to eq("Bearer #{access_token}")
43
74
  end
44
75
  end
45
76
  end
@@ -26,16 +26,6 @@ xdescribe Zoom::Utils do
26
26
  end
27
27
  end
28
28
 
29
- xdescribe '#require_params' do
30
- it 'raises ArgumentError if the param is not present' do
31
- expect { Utils.require_params(:foo, { bar: 'bar' }) }.to raise_error(ArgumentError)
32
- end
33
-
34
- it 'does not raise ArgumentError if the param is present' do
35
- expect { Utils.require_params(:foo, { foo: 'foo' }) }.to_not raise_error
36
- end
37
- end
38
-
39
29
  xdescribe '#extract_options!' do
40
30
  it 'converts array to hash options' do
41
31
  args = [{ foo: 'foo' }, { bar: 'bar' }, { zemba: 'zemba' }]
@@ -24,10 +24,18 @@ def zoom_url(url)
24
24
  /https:\/\/api.zoom.us\/v2#{url}.*/
25
25
  end
26
26
 
27
- def zoom_client
27
+ def jwt_client
28
28
  Zoom.new
29
29
  end
30
30
 
31
+ def oauth_client
32
+ Zoom::Client::OAuth.new(access_token: 'xxx', timeout: 15)
33
+ end
34
+
35
+ def zoom_client
36
+ jwt_client
37
+ end
38
+
31
39
  def filter_key(hash, key)
32
40
  copy = hash.dup
33
41
  copy.delete(key)
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: 0.9.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Boe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -163,12 +163,16 @@ files:
163
163
  - lib/zoom/actions/user.rb
164
164
  - lib/zoom/actions/webinar.rb
165
165
  - lib/zoom/client.rb
166
+ - lib/zoom/clients/jwt.rb
167
+ - lib/zoom/clients/oauth.rb
166
168
  - lib/zoom/constants.rb
167
169
  - lib/zoom/error.rb
168
170
  - lib/zoom/interface.rb
169
171
  - lib/zoom/params.rb
170
172
  - lib/zoom/utils.rb
171
173
  - lib/zoom/version.rb
174
+ - spec/fixtures/account/list.json
175
+ - spec/fixtures/account/settings_get.json
172
176
  - spec/fixtures/chat/get.json
173
177
  - spec/fixtures/chat/list.json
174
178
  - spec/fixtures/error/already_exists.json
@@ -206,18 +210,22 @@ files:
206
210
  - spec/fixtures/user/list.json
207
211
  - spec/fixtures/user/pending.json
208
212
  - spec/fixtures/user/permanent_delete.json
213
+ - spec/fixtures/user/settings_get.json
209
214
  - spec/fixtures/user/update.json
210
215
  - spec/fixtures/webinar/create.json
211
216
  - spec/fixtures/webinar/delete.json
212
217
  - spec/fixtures/webinar/list.json
213
218
  - spec/fixtures/webinar/past_webinar_list.json
214
219
  - spec/fixtures/webinar/registrant/add.json
220
+ - spec/fixtures/webinar/registrant/get.json
215
221
  - spec/fixtures/webinar/registrant/list.json
216
222
  - spec/fixtures/webinar/update.json
217
223
  - spec/fixtures/webinar_delete.json
218
224
  - spec/fixtures/webinar_end.json
219
225
  - spec/fixtures/webinar_get.json
220
226
  - spec/fixtures/webinar_update.json
227
+ - spec/lib/zoom/actions/account/list_spec.rb
228
+ - spec/lib/zoom/actions/account/settings_get_spec.rb
221
229
  - spec/lib/zoom/actions/group/create_spec.rb
222
230
  - spec/lib/zoom/actions/group/delete_spec.rb
223
231
  - spec/lib/zoom/actions/group/edit_spec.rb
@@ -296,6 +304,7 @@ files:
296
304
  - spec/lib/zoom/actions/user/getbyemail_spec.rb
297
305
  - spec/lib/zoom/actions/user/list_spec.rb
298
306
  - spec/lib/zoom/actions/user/revoketoken_spec.rb
307
+ - spec/lib/zoom/actions/user/settings_get_spec.rb
299
308
  - spec/lib/zoom/actions/user/update_spec.rb
300
309
  - spec/lib/zoom/actions/user/updatepassword_spec.rb
301
310
  - spec/lib/zoom/actions/webinar/attendees_list_spec.rb
@@ -311,6 +320,7 @@ files:
311
320
  - spec/lib/zoom/actions/webinar/questions_spec.rb
312
321
  - spec/lib/zoom/actions/webinar/register_spec.rb
313
322
  - spec/lib/zoom/actions/webinar/registrants/add_spec.rb
323
+ - spec/lib/zoom/actions/webinar/registrants/get_spec.rb
314
324
  - spec/lib/zoom/actions/webinar/registrants/list_spec.rb
315
325
  - spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb
316
326
  - spec/lib/zoom/actions/webinar/registration_cancel_spec.rb
@@ -346,6 +356,8 @@ signing_key:
346
356
  specification_version: 4
347
357
  summary: zoom.us API wrapper
348
358
  test_files:
359
+ - spec/fixtures/account/list.json
360
+ - spec/fixtures/account/settings_get.json
349
361
  - spec/fixtures/chat/get.json
350
362
  - spec/fixtures/chat/list.json
351
363
  - spec/fixtures/error/already_exists.json
@@ -383,18 +395,22 @@ test_files:
383
395
  - spec/fixtures/user/list.json
384
396
  - spec/fixtures/user/pending.json
385
397
  - spec/fixtures/user/permanent_delete.json
398
+ - spec/fixtures/user/settings_get.json
386
399
  - spec/fixtures/user/update.json
387
400
  - spec/fixtures/webinar/create.json
388
401
  - spec/fixtures/webinar/delete.json
389
402
  - spec/fixtures/webinar/list.json
390
403
  - spec/fixtures/webinar/past_webinar_list.json
391
404
  - spec/fixtures/webinar/registrant/add.json
405
+ - spec/fixtures/webinar/registrant/get.json
392
406
  - spec/fixtures/webinar/registrant/list.json
393
407
  - spec/fixtures/webinar/update.json
394
408
  - spec/fixtures/webinar_delete.json
395
409
  - spec/fixtures/webinar_end.json
396
410
  - spec/fixtures/webinar_get.json
397
411
  - spec/fixtures/webinar_update.json
412
+ - spec/lib/zoom/actions/account/list_spec.rb
413
+ - spec/lib/zoom/actions/account/settings_get_spec.rb
398
414
  - spec/lib/zoom/actions/group/create_spec.rb
399
415
  - spec/lib/zoom/actions/group/delete_spec.rb
400
416
  - spec/lib/zoom/actions/group/edit_spec.rb
@@ -473,6 +489,7 @@ test_files:
473
489
  - spec/lib/zoom/actions/user/getbyemail_spec.rb
474
490
  - spec/lib/zoom/actions/user/list_spec.rb
475
491
  - spec/lib/zoom/actions/user/revoketoken_spec.rb
492
+ - spec/lib/zoom/actions/user/settings_get_spec.rb
476
493
  - spec/lib/zoom/actions/user/update_spec.rb
477
494
  - spec/lib/zoom/actions/user/updatepassword_spec.rb
478
495
  - spec/lib/zoom/actions/webinar/attendees_list_spec.rb
@@ -488,6 +505,7 @@ test_files:
488
505
  - spec/lib/zoom/actions/webinar/questions_spec.rb
489
506
  - spec/lib/zoom/actions/webinar/register_spec.rb
490
507
  - spec/lib/zoom/actions/webinar/registrants/add_spec.rb
508
+ - spec/lib/zoom/actions/webinar/registrants/get_spec.rb
491
509
  - spec/lib/zoom/actions/webinar/registrants/list_spec.rb
492
510
  - spec/lib/zoom/actions/webinar/registrants/update_status_spec.rb
493
511
  - spec/lib/zoom/actions/webinar/registration_cancel_spec.rb