vonage 7.13.0 → 7.15.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: 7ab386887cbecc55b2e4c2fe915edb4ec7cac9bfc62d7205d577daf2f451b443
4
- data.tar.gz: ba606e264741711abdc23d3109b9a741efd8e6848e0743e48719c7414478d10e
3
+ metadata.gz: fe42d262916665b0528b89b25fc9094ff4009739cea53ec28a416afe2ec232c8
4
+ data.tar.gz: d1bb14fcc3e8c862dedd87a32b80034d9914c0cafcc2c53f071b05a9c640a644
5
5
  SHA512:
6
- metadata.gz: e3d11a57f0782eff2acc885e8edc0243f5acb6f93e27c54dc3ff057a15b3b82c413fb24deda53519e5d3d7b109e22de21244eed798ef8c5cb8abb070117bdac5
7
- data.tar.gz: b199fe7cc3e00eb2a7bb13e62f2448c3cda49dfe7c7b476825872074fe71e89d7f930778d75f83f8b1204c6429155bc363e85468a5c71b89849a8037fb37220a
6
+ metadata.gz: a52f19d149c83ff7cbc2fe73982abaf79901c146fa45d006d19ba9f32b9640bf14065e132362aae591869339109deeafa68e72349a1e6d9f2a6fba173efbf9a6
7
+ data.tar.gz: 38f8d3a78930e5b13e8ed71e3bce0ee37789a506f053e9f31c543bdac10760f574dc976fca097f64f47419f9d99c4b912ce32484b389243b96c52f5fa6e7ef4c
data/lib/vonage/client.rb CHANGED
@@ -61,6 +61,13 @@ module Vonage
61
61
  @files ||= T.let(Files.new(config), T.nilable(Vonage::Files))
62
62
  end
63
63
 
64
+ # @return [Meetings]
65
+ #
66
+ sig { returns(T.nilable(Vonage::Meetings)) }
67
+ def meetings
68
+ @meetings ||= T.let(Meetings.new(config), T.nilable(Vonage::Meetings))
69
+ end
70
+
64
71
  # @return [Messages]
65
72
  #
66
73
  sig { returns(T.nilable(Vonage::Messages)) }
@@ -138,6 +145,13 @@ module Vonage
138
145
  @tfa ||= T.let(TFA.new(config), T.nilable(Vonage::TFA))
139
146
  end
140
147
 
148
+ # @return [Users]
149
+ #
150
+ sig { returns(T.nilable(Vonage::Users)) }
151
+ def users
152
+ @users ||= T.let(Users.new(config), T.nilable(Vonage::Users))
153
+ end
154
+
141
155
  # @return [Verify]
142
156
  #
143
157
  sig { returns(T.nilable(Vonage::Verify)) }
data/lib/vonage/errors.rb CHANGED
@@ -1,14 +1,25 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
- require 'json'
3
+ require "json"
4
4
 
5
5
  module Vonage
6
6
  module Errors
7
7
  extend T::Sig
8
8
 
9
- sig {params(response: T.any(Net::HTTPUnauthorized, Net::HTTPClientError, Net::HTTPServerError, T.untyped)).returns(Vonage::Error)}
9
+ sig do
10
+ params(
11
+ response:
12
+ T.any(
13
+ Net::HTTPUnauthorized,
14
+ Net::HTTPClientError,
15
+ Net::HTTPServerError,
16
+ T.untyped
17
+ )
18
+ ).returns(Vonage::Error)
19
+ end
10
20
  def self.parse(response)
11
- exception_class = case response
21
+ exception_class =
22
+ case response
12
23
  when Net::HTTPUnauthorized
13
24
  AuthenticationError
14
25
  when Net::HTTPClientError
@@ -19,31 +30,34 @@ module Vonage
19
30
  Error
20
31
  end
21
32
 
22
- message = if response.content_type == 'application/json'
23
- hash = ::JSON.parse(response.body)
24
-
25
- if hash.key?('error_title')
26
- hash['error_title']
27
- elsif hash.key?('error-code-label')
28
- hash['error-code-label']
29
- elsif hash.key?('description')
30
- hash['description']
31
- elsif problem_details?(hash)
32
- problem_details_message(hash)
33
+ message =
34
+ if response.content_type == "application/json"
35
+ hash = ::JSON.parse(response.body)
36
+
37
+ if hash.key?("error_title")
38
+ hash["error_title"]
39
+ elsif hash.key?("error-code-label")
40
+ hash["error-code-label"]
41
+ elsif hash.key?("description")
42
+ hash["description"]
43
+ elsif hash.key?("message")
44
+ hash["message"]
45
+ elsif problem_details?(hash)
46
+ problem_details_message(hash)
47
+ end
33
48
  end
34
- end
35
49
 
36
50
  exception_class.new(message)
37
51
  end
38
52
 
39
53
  sig { params(hash: T::Hash[String, T.untyped]).returns(T::Boolean) }
40
54
  def self.problem_details?(hash)
41
- hash.key?('title') && hash.key?('detail') && hash.key?('type')
55
+ hash.key?("title") && hash.key?("detail") && hash.key?("type")
42
56
  end
43
57
 
44
58
  sig { params(hash: T::Hash[String, T.untyped]).returns(String) }
45
59
  def self.problem_details_message(hash)
46
- "#{hash['title']}. #{hash['detail']} See #{hash['type']} for more info, or email support@nexmo.com if you have any questions."
60
+ "#{hash["title"]}. #{hash["detail"]} See #{hash["type"]} for more info, or email support@nexmo.com if you have any questions."
47
61
  end
48
62
  end
49
63
 
@@ -0,0 +1,25 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::Applications < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Update an existing application.
15
+ #
16
+ # @param [required, String] :default_theme_id The id of the theme to set as application default theme
17
+ #
18
+ # @return [Response]
19
+ #
20
+ # @see https://developer.vonage.com/en/api/meetings#updateApplication
21
+ def update(default_theme_id:)
22
+ request("/meetings/applications", params: {update_details: {default_theme_id: default_theme_id}}, type: Patch)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Meetings::DialInNumbers::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::DialInNumbers < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Get numbers that can be used to dial into a meeting.
15
+ #
16
+ # @return [ListResponse]
17
+ #
18
+ # @see https://developer.vonage.com/en/api/meetings#getDialInNumbers
19
+ def list
20
+ request("/meetings/dial-in-numbers", response_class: ListResponse)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,36 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::Recordings < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Return information for specified recording.
15
+ #
16
+ # @param [required, String] recording_id The id of the recoring for which the info should be returned
17
+ #
18
+ # @return [Response]
19
+ #
20
+ # @see https://developer.vonage.com/en/api/meetings#getRecording
21
+ def info(recording_id:)
22
+ request("/meetings/recordings/" + recording_id)
23
+ end
24
+
25
+ # Delete a specified recording.
26
+ #
27
+ # @param [required, String] recording_id The id of the recoring to be deleted
28
+ #
29
+ # @return [Response]
30
+ #
31
+ # @see https://developer.vonage.com/en/api/meetings#deleteRecording
32
+ def delete(recording_id:)
33
+ request("/meetings/recordings/" + recording_id, type: Delete)
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Meetings::Rooms::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,155 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::Rooms < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Get a list of rooms associated with the Vonage application.
15
+ #
16
+ # @param [optional, Integer] :start_id
17
+ #
18
+ # @param [optional, Integer] :end_id
19
+ #
20
+ # @param [optional, Integer] :page_size
21
+ #
22
+ # @return [ListResponse]
23
+ #
24
+ # @see https://developer.vonage.com/en/api/meetings#getRooms
25
+ def list(**params)
26
+ path = "/meetings/rooms"
27
+ path += "?#{Params.encode(params)}" unless params.empty?
28
+
29
+ request(path, response_class: ListResponse)
30
+ end
31
+
32
+ # Return information for specified room.
33
+ #
34
+ # @param [required, String] room_id
35
+ # The id of the room for which the info should be returned
36
+ #
37
+ # @return [Response]
38
+ #
39
+ # @see https://developer.vonage.com/en/api/meetings#getRoom
40
+ def info(room_id:)
41
+ request("/meetings/rooms/" + room_id)
42
+ end
43
+
44
+ # Create a new room.
45
+ #
46
+ # @param [required, String] :display_name
47
+ #
48
+ # @param [optional, String] :metadata
49
+ # Free text that can be attached to a room. This will be passed in the form of a header in events related to this room.
50
+ #
51
+ # @param [optional, String] :type
52
+ # The type of room. Must be one of `instant` (the default) or `long_term`.
53
+ #
54
+ # @param [String(date)] :expires_at
55
+ # The time for when the room will be expired, expressed in ISO 8601 format.
56
+ # The value must be greater than 10 minutes from now.
57
+ # Must be set if `type` is `long_term`. Should not be set if `type` is `instant`
58
+ #
59
+ # @param [optional, Boolean] :expire_after_use
60
+ # Close the room after a session ends. Only relevant for rooms where the `type` is `long_term`
61
+ #
62
+ # @param [optional, string(uuid)] :theme_id
63
+ # When specified, the meeting room will use the theme indicated by the ID.
64
+ #
65
+ # @param [optional, String] :join_approval_level
66
+ # The level of approval needed to join the meeting in the room. Must be one of: `none`, `after_owner_only`, `explicit_approval`
67
+ #
68
+ # @param [optional, Hash] :recording_options
69
+ # @option :recording_options [Boolean] :auto_record Automatically record all sessions in this room. Recording cannot be stopped when this is set to `true`.
70
+ # @option :recording_options [Boolean] :record_only_owner Record only the owner screen or any share screen of the video.
71
+ #
72
+ # @param [optional, Hash] :initial_join_options
73
+ # @option :initial_join_options [String] :microphone_state
74
+ # Set the default microphone option for users in the pre-join screen of this room.
75
+ # Must be one of: `on`, `off`, `default`
76
+ #
77
+ # @param [optional, Hash] :callback_urls Provides callback URLs to listen to events. If specified, over-rides the callback URLs specified at Application-level
78
+ # @option :callback_urls [String] :rooms_callback_url Callback url for rooms events
79
+ # @option :callback_urls [String] :sessions_callback_url Callback url for sessions events
80
+ # @option :callback_urls [String] :recordings_callback_url Callback url for recordings events
81
+ #
82
+ # @param [optional, Hash] :available_features
83
+ # @option :available_features [Boolean] :is_recording_available Determine if recording feature is available in the UI (default `true`)
84
+ # @option :available_features [Boolean] :is_chat_available Determine if chat feature is available in the UI (default `true`)
85
+ # @option :available_features [Boolean] :is_whiteboard_available Determine if whiteboard feature is available in the UI (default `true`)
86
+ # @option :available_features [Boolean] :is_locale_switcher_available Determine if locale switche feature is available in the UI (default `true`)
87
+ # @option :available_features [Boolean] :is_captions_available Determine if captions feature is available in the UI
88
+ #
89
+ # @param [optional, Hash] :ui_settings Provides options to customize the user interface
90
+ # @option :ui_settings [String] :language
91
+ # The desired language of the UI. The default is `en` (English).
92
+ # Must be one of: `en`, `fr`, `de`, `es`, `pt`, `ca`, `he`
93
+ #
94
+ # @return [Response]
95
+ #
96
+ # @see https://developer.vonage.com/en/api/meetings#createRoom
97
+ def create(display_name:, **params)
98
+ request(
99
+ "/meetings/rooms",
100
+ params: params.merge({ display_name: display_name }),
101
+ type: Post
102
+ )
103
+ end
104
+
105
+ # Update an existing room.
106
+ # Although paramaters (other than `room_id`) are optional, at least one other parameter must be provided or an error
107
+ # response will be received.
108
+ #
109
+ # @param [required, String] room_id The ID of the Room to be updated
110
+ #
111
+ # @param [optional, String(date)] :expires_at
112
+ # The time for when the room will be expired, expressed in ISO 8601 format.
113
+ # Only relevant for rooms where the `type` is `long_term``
114
+ #
115
+ # @param [optional, Boolean] :expire_after_use
116
+ # Close the room after a session ends. Only relevant for rooms where the `type` is `long_term`
117
+ #
118
+ # @param [optional, string(uuid)] :theme_id
119
+ # When specified, the meeting room will use the theme indicated by the ID.
120
+ #
121
+ # @param [optional, String] :join_approval_level
122
+ # The level of approval needed to join the meeting in the room. Must be one of: `none`, `after_owner_only`, `explicit_approval`
123
+ #
124
+ # @param [optional, Hash] :initial_join_options
125
+ # @option :initial_join_options [String] :microphone_state
126
+ # Set the default microphone option for users in the pre-join screen of this room.
127
+ # Must be one of: `on`, `off`, `default`
128
+ #
129
+ # @param [optional, Hash] :callback_urls Provides callback URLs to listen to events. If specified, over-rides the callback URLs specified at Application-level
130
+ # @option :callback_urls [String] :rooms_callback_url Callback url for rooms events
131
+ # @option :callback_urls [String] :sessions_callback_url Callback url for sessions events
132
+ # @option :callback_urls [String] :recordings_callback_url Callback url for recordings events
133
+ #
134
+ # @param [optional, Hash] :available_features
135
+ # @option :available_features [Boolean] :is_recording_available Determine if recording feature is available in the UI (default `true`)
136
+ # @option :available_features [Boolean] :is_chat_available Determine if chat feature is available in the UI (default `true`)
137
+ # @option :available_features [Boolean] :is_whiteboard_available Determine if whiteboard feature is available in the UI (default `true`)
138
+ # @option :available_features [Boolean] :is_locale_switcher_available Determine if locale switche feature is available in the UI (default `true`)
139
+ # @option :available_features [Boolean] :is_captions_available Determine if captions feature is available in the UI
140
+ #
141
+ # @return [Response]
142
+ #
143
+ # @see https://developer.vonage.com/en/api/meetings#updateRoom
144
+ def update(room_id:, **params)
145
+ raise ArgumentError, 'must provide at least one other param in addition to :room_id' if params.empty?
146
+ request(
147
+ "/meetings/rooms/" + room_id,
148
+ params: {
149
+ update_details: params
150
+ },
151
+ type: Patch
152
+ )
153
+ end
154
+ end
155
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Meetings::Sessions::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,28 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::Sessions < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Return a list of recordings for a specified session.
15
+ #
16
+ # @param [required, String] session_id The id of the session for which the recordings list should be returned
17
+ #
18
+ # @return [ListResponse]
19
+ #
20
+ # @see https://developer.vonage.com/en/api/meetings#getSessionRecordings
21
+ def list_recordings(session_id:)
22
+ request(
23
+ "/meetings/sessions/" + session_id + "/recordings",
24
+ response_class: ListResponse
25
+ )
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Meetings::Themes::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,218 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings::Themes < Namespace
6
+ extend T::Sig
7
+
8
+ self.authentication = BearerToken
9
+
10
+ self.request_body = JSON
11
+
12
+ self.host = :vonage_host
13
+
14
+ # Get a list of themes associated with the Vonage application.
15
+ #
16
+ # @return [ListResponse]
17
+ #
18
+ # @see https://developer.vonage.com/en/api/meetings#getThemes
19
+ def list
20
+ request("/meetings/themes", response_class: ListResponse)
21
+ end
22
+
23
+ # Return information for specified theme.
24
+ #
25
+ # @param [required, String] theme_id The id of the theme for which the info should be returned
26
+ #
27
+ # @return [Response]
28
+ #
29
+ # @see https://developer.vonage.com/en/api/meetings#getThemeById
30
+ def info(theme_id:)
31
+ request("/meetings/themes/" + theme_id)
32
+ end
33
+
34
+ # Create a new theme.
35
+ #
36
+ # @param [required, String] :main_color
37
+ # The main color that will be used for the meeting room.
38
+ #
39
+ # @param [required, String] :brand_text
40
+ # The text that will appear on the meeting homepage, in the case that there is no brand image
41
+ #
42
+ # @param [optional, String] :theme_name
43
+ # The name of the theme (must be unique). If null, a UUID will automatically be generated
44
+ #
45
+ # @param [optional, String] :short_company_url
46
+ # The URL that will represent every meeting room with this theme. The value must be unique across Vonage
47
+ #
48
+ # @return [Response]
49
+ #
50
+ # @see https://developer.vonage.com/en/api/meetings#createTheme
51
+ def create(main_color:, brand_text:, **params)
52
+ request(
53
+ "/meetings/themes",
54
+ params: params.merge(main_color: main_color, brand_text: brand_text),
55
+ type: Post
56
+ )
57
+ end
58
+
59
+ # Update an existing theme.
60
+ #
61
+ # @param [required, String] theme_id The id of the theme to be updated
62
+ #
63
+ # @param [required, String] :main_color
64
+ # The main color that will be used for the meeting room.
65
+ #
66
+ # @param [required, String] :brand_text
67
+ # The text that will appear on the meeting homepage, in the case that there is no brand image
68
+ #
69
+ # @param [optional, String] :theme_name
70
+ # The name of the theme (must be unique). If null, a UUID will automatically be generated
71
+ #
72
+ # @param [optional, String] :short_company_url
73
+ # The URL that will represent every meeting room with this theme. The value must be unique across Vonage
74
+ #
75
+ # @return [Response]
76
+ #
77
+ # @see https://developer.vonage.com/en/api/meetings#updateTheme
78
+ def update(theme_id:, **params)
79
+ request(
80
+ "/meetings/themes/" + theme_id,
81
+ params: {
82
+ update_details: params
83
+ },
84
+ type: Patch
85
+ )
86
+ end
87
+
88
+ # Delete an existing theme.
89
+ #
90
+ # @param [required, String] :theme_id The id of the theme to be deleted
91
+ #
92
+ # @param [optional, Boolean] :force. Set to `true` to force delete a theme currently being used for a room, or as
93
+ # a default theme. (Defaults to `false`)
94
+ #
95
+ # @return [Response]
96
+ #
97
+ # @see https://developer.vonage.com/en/api/meetings#deleteTheme
98
+ def delete(theme_id:, force: false)
99
+ request(
100
+ "/meetings/themes/" + theme_id + "?force=#{force}",
101
+ type: Delete
102
+ )
103
+ end
104
+
105
+ # Get a list of rooms that are associated with a theme id.
106
+ #
107
+ # @param [required, String] theme_id THe ID of the theme to search for rooms associated with.
108
+ #
109
+ # @param [optional, Integer] :start_id
110
+ #
111
+ # @param [optional, Integer] :end_id
112
+ #
113
+ # @param [optional, Integer] :page_size
114
+ #
115
+ # @return [Response]
116
+ #
117
+ # @see https://developer.vonage.com/en/api/meetings#getRoomsByThemeId
118
+ def list_rooms(theme_id:, **params)
119
+ path = "/meetings/themes/" + theme_id + "/rooms"
120
+ path += "?#{Params.encode(params)}" unless params.empty?
121
+
122
+ request(path, response_class: Meetings::Rooms::ListResponse)
123
+ end
124
+
125
+ # Set a logo for a theme.
126
+ #
127
+ # @param [required, String] :theme_id The ID of the theme for which the logo should be set
128
+ #
129
+ # @param [required, String] :filepath
130
+ # The filepath of the logo file. Logo files must conform to the following requirements:
131
+ # - Format: PNG
132
+ # - Maximum size: 1MB
133
+ # - Background must be transparent
134
+ # - Dimensions:
135
+ # - 1 px - 300 px (`white` and `colored` logos)
136
+ # - 16 x 16 - 32 x 32 and must be square (favicon)
137
+ #
138
+ # @param [required, String] :logo_type
139
+ # The type of logo to be set. Must be one of `white`, `colored`, `favicon`
140
+ #
141
+ # @return [Response]
142
+ #
143
+ # @see https://developer.vonage.com/en/meetings/guides/theme-management#uploading-icons-and-logos
144
+ # @see https://developer.vonage.com/en/api/meetings#getUploadUrlsForTheme
145
+ # @see https://developer.vonage.com/en/api/meetings#finalizeLogosForTheme
146
+ #
147
+ # TODO: add type signature
148
+ def set_logo(theme_id:, filepath:, logo_type:)
149
+ pn = Pathname.new(filepath)
150
+ valid_logo_types = ['white', 'colored', 'favicon']
151
+ raise ArgumentError, ':filepath not for a file' unless pn.file?
152
+ raise ArgumentError, 'file at :filepath not readable' unless pn.readable?
153
+ raise ArgumentError, "logo_type: must be one of #{valid_logo_types}" unless valid_logo_types.include?(logo_type)
154
+
155
+ logo_upload_credentials = get_logo_upload_credentials
156
+
157
+ filtered_logo_upload_credentials = logo_upload_credentials.select {|cred| cred.fields.logo_type == logo_type }.first
158
+
159
+ upload_logo_file(filepath: filepath, credentials: filtered_logo_upload_credentials)
160
+
161
+ finalize_logos(theme_id: theme_id, keys: [filtered_logo_upload_credentials.fields.key])
162
+ end
163
+
164
+ private
165
+
166
+ def get_logo_upload_credentials
167
+ request("/meetings/themes/logos-upload-urls", response_class: ListResponse)
168
+ end
169
+
170
+ def upload_logo_file(filepath:, credentials:)
171
+ pn = Pathname.new(filepath)
172
+
173
+ params = format_s3_upload_credentials(credentials)
174
+
175
+ multipart_post_request(
176
+ nil,
177
+ filepath: filepath,
178
+ file_name: pn.basename,
179
+ mime_type: credentials.fields.content_type,
180
+ params: params,
181
+ override_uri: credentials.url,
182
+ no_auth: true
183
+ )
184
+ end
185
+
186
+ def finalize_logos(theme_id:, keys: [])
187
+ request(
188
+ "/meetings/themes/" + theme_id + "/finalizeLogos",
189
+ params: {
190
+ keys: keys
191
+ },
192
+ type: Put
193
+ )
194
+ end
195
+
196
+ def format_s3_upload_credentials(credentials)
197
+ credentials_key_map = {
198
+ content_type: "Content-Type",
199
+ logo_type: "logoType",
200
+ x_amz_algorithm: "X-Amz-Algorithm",
201
+ x_amz_credential: "X-Amz-Credential",
202
+ x_amz_date: "X-Amz-Date",
203
+ x_amz_security_token: "X-Amz-Security-Token",
204
+ policy: "Policy",
205
+ x_amz_signature: "X-Amz-Signature"
206
+ }
207
+
208
+ params = credentials.fields.attributes
209
+ params.transform_keys do |k|
210
+ if credentials_key_map.keys.include?(k)
211
+ credentials_key_map[k]
212
+ else
213
+ k.to_s
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,38 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Meetings < Namespace
6
+ extend T::Sig
7
+
8
+ sig { returns(T.nilable(Vonage::Meetings::Rooms)) }
9
+ def rooms
10
+ @rooms ||= Rooms.new(@config)
11
+ end
12
+
13
+ sig { returns(T.nilable(Vonage::Meetings::Recordings)) }
14
+ def recordings
15
+ @recordings ||= Recordings.new(@config)
16
+ end
17
+
18
+ sig { returns(T.nilable(Vonage::Meetings::Sessions)) }
19
+ def sessions
20
+ @sessions ||= Sessions.new(@config)
21
+ end
22
+
23
+ sig { returns(T.nilable(Vonage::Meetings::Themes)) }
24
+ def themes
25
+ @themes ||= Themes.new(@config)
26
+ end
27
+
28
+ sig { returns(T.nilable(Vonage::Meetings::Applications)) }
29
+ def applications
30
+ @applications ||= Applications.new(@config)
31
+ end
32
+
33
+ sig { returns(T.nilable(Vonage::Meetings::DialInNumbers)) }
34
+ def dial_in_numbers
35
+ @dial_in_numbers ||= DialInNumbers.new(@config)
36
+ end
37
+ end
38
+ end
@@ -1,5 +1,6 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
+
3
4
  require 'net/http'
4
5
  require 'net/http/post/multipart'
5
6
  require 'json'
@@ -9,7 +10,6 @@ module Vonage
9
10
  def initialize(config)
10
11
  @config = config
11
12
 
12
- # @host = self.class.host == :api_host ? @config.api_host : @config.rest_host
13
13
  @host = set_host
14
14
 
15
15
  @http = Net::HTTP.new(@host, Net::HTTP.https_default_port, p_addr = nil)
@@ -49,6 +49,7 @@ module Vonage
49
49
  end
50
50
 
51
51
  protected
52
+
52
53
  # :nocov:
53
54
 
54
55
  Get = Net::HTTP::Get
@@ -61,7 +62,7 @@ module Vonage
61
62
  authentication = self.class.authentication.new(@config)
62
63
  authentication.update(params)
63
64
 
64
- uri = URI('https://' + @host + path)
65
+ uri = URI("https://" + @host + path)
65
66
  unless type.const_get(:REQUEST_HAS_BODY) || params.empty?
66
67
  uri.query = Params.encode(params)
67
68
  end
@@ -73,17 +74,20 @@ module Vonage
73
74
  request = type.new(uri)
74
75
 
75
76
  # set headers
76
- request['User-Agent'] = UserAgent.string(@config.app_name, @config.app_version)
77
- request['Accept'] = 'application/json'
78
- self.class.request_headers.each do |key, value|
79
- request[key] = value
80
- end
77
+ request["User-Agent"] = UserAgent.string(
78
+ @config.app_name,
79
+ @config.app_version
80
+ )
81
+ request["Accept"] = "application/json"
82
+ self.class.request_headers.each { |key, value| request[key] = value }
81
83
 
82
84
  # Set BearerToken if needed
83
85
  authentication.update(request)
84
86
 
85
87
  # set body
86
- self.class.request_body.update(request, params) if type.const_get(:REQUEST_HAS_BODY)
88
+ if type.const_get(:REQUEST_HAS_BODY)
89
+ self.class.request_body.update(request, params)
90
+ end
87
91
 
88
92
  request
89
93
  end
@@ -103,16 +107,31 @@ module Vonage
103
107
  end
104
108
 
105
109
  def request(path, params: nil, type: Get, response_class: Response, &block)
106
- auto_advance = !params.nil? && params.key?(:auto_advance) ? params[:auto_advance] : false
110
+ auto_advance =
111
+ (
112
+ if !params.nil? && params.key?(:auto_advance)
113
+ params[:auto_advance]
114
+ else
115
+ false
116
+ end
117
+ )
107
118
 
108
- params = params.tap { |params| params.delete(:auto_advance) } if !params.nil? && params.key?(:auto_advance)
119
+ params =
120
+ params.tap { |params| params.delete(:auto_advance) } if !params.nil? &&
121
+ params.key?(:auto_advance)
109
122
 
110
123
  request = build_request(path: path, params: params || {}, type: type)
111
124
 
112
125
  response = make_request!(request, &block)
113
126
 
114
127
  if auto_advance
115
- iterable_request(path, response: response, response_class: response_class, params: params, &block)
128
+ iterable_request(
129
+ path,
130
+ response: response,
131
+ response_class: response_class,
132
+ params: params,
133
+ &block
134
+ )
116
135
  else
117
136
  return if block
118
137
 
@@ -120,25 +139,29 @@ module Vonage
120
139
  end
121
140
  end
122
141
 
123
- def multipart_post_request(path, filepath:, file_name:, mime_type:, response_class: Response, &block)
124
- authentication = self.class.authentication.new(@config)
142
+ def multipart_post_request(path, filepath:, file_name:, mime_type:, params: {}, override_uri: nil, no_auth: false, response_class: Response, &block)
143
+ authentication = self.class.authentication.new(@config) unless no_auth
125
144
 
126
- uri = URI('https://' + @host + path)
145
+ uri = override_uri ? URI(override_uri) : URI('https://' + @host + path)
146
+
147
+ http = override_uri ? Net::HTTP.new(uri.host, Net::HTTP.https_default_port, p_addr = nil) : @http
148
+ http.use_ssl = true
149
+ http.set_debug_output($stdout)
127
150
 
128
151
  response = File.open(filepath) do |file|
129
152
  request = Net::HTTP::Post::Multipart.new(
130
153
  uri,
131
- {file: Multipart::Post::UploadIO.new(file, mime_type, file_name)}
154
+ params.merge(file: Multipart::Post::UploadIO.new(file, mime_type, file_name))
132
155
  )
133
156
 
134
157
  request['User-Agent'] = UserAgent.string(@config.app_name, @config.app_version)
135
158
 
136
159
  # Set BearerToken if needed
137
- authentication.update(request)
160
+ authentication.update(request) unless no_auth
138
161
 
139
162
  logger.log_request_info(request)
140
163
 
141
- @http.request(request, &block)
164
+ http.request(request, &block)
142
165
  end
143
166
 
144
167
  logger.log_response_info(response, @host)
@@ -156,16 +179,19 @@ module Vonage
156
179
  remainder = remaining_count(json_response)
157
180
 
158
181
  while remainder > 0
159
- params = { page_size: json_response['page_size'] }
160
-
161
- if json_response['record_index'] && json_response['record_index'] == 0
162
- params[:record_index] = json_response['page_size']
163
- elsif json_response['record_index'] && json_response['record_index'] != 0
164
- params[:record_index] = (json_response['record_index'] + json_response['page_size'])
182
+ params = { page_size: json_response["page_size"] }
183
+
184
+ if json_response["record_index"] && json_response["record_index"] == 0
185
+ params[:record_index] = json_response["page_size"]
186
+ elsif json_response["record_index"] &&
187
+ json_response["record_index"] != 0
188
+ params[:record_index] = (
189
+ json_response["record_index"] + json_response["page_size"]
190
+ )
165
191
  end
166
192
 
167
- if json_response['total_pages']
168
- params[:page] = json_response['page'] + 1
193
+ if json_response["total_pages"]
194
+ params[:page] = json_response["page"] + 1
169
195
  end
170
196
 
171
197
  request = build_request(path: path, type: Get, params: params)
@@ -176,11 +202,15 @@ module Vonage
176
202
  json_response = ::JSON.parse(paginated_response.body)
177
203
  remainder = remaining_count(json_response)
178
204
 
179
- if response.respond_to?('_embedded')
180
- collection_name = collection_name(response['_embedded'])
181
- response['_embedded'][collection_name].push(*next_response['_embedded'][collection_name])
205
+ if response.respond_to?("_embedded")
206
+ collection_name = collection_name(response["_embedded"])
207
+ response["_embedded"][collection_name].push(
208
+ *next_response["_embedded"][collection_name]
209
+ )
182
210
  else
183
- response[collection_name(response)].push(*next_response[collection_name(next_response)])
211
+ response[collection_name(response)].push(
212
+ *next_response[collection_name(next_response)]
213
+ )
184
214
  end
185
215
  end
186
216
 
@@ -188,43 +218,51 @@ module Vonage
188
218
  end
189
219
 
190
220
  def remaining_count(params)
191
- if params.key?('total_pages')
192
- params['total_pages'] - params['page']
193
- elsif params.key?('count')
194
- params['count'] - (params['record_index'] == 0 ? params['page_size'] : (params['record_index'] + params['page_size']))
221
+ if params.key?("total_pages")
222
+ params["total_pages"] - params["page"]
223
+ elsif params.key?("count")
224
+ params["count"] -
225
+ (
226
+ if params["record_index"] == 0
227
+ params["page_size"]
228
+ else
229
+ (params["record_index"] + params["page_size"])
230
+ end
231
+ )
195
232
  else
196
233
  0
197
234
  end
198
235
  end
199
236
 
200
237
  def collection_name(params)
201
- @collection_name ||= case
202
- when params.respond_to?('calls')
203
- 'calls'
204
- when params.respond_to?('users')
205
- 'users'
206
- when params.respond_to?('legs')
207
- 'legs'
208
- when params.respond_to?('data')
209
- 'data'
210
- when params.respond_to?('conversations')
211
- 'conversations'
212
- when params.respond_to?('applications')
213
- 'applications'
214
- when params.respond_to?('records')
215
- 'records'
216
- when params.respond_to?('reports')
217
- 'reports'
218
- when params.respond_to?('networks')
219
- 'networks'
220
- when params.respond_to?('countries')
221
- 'countries'
222
- when params.respond_to?('media')
223
- 'media'
224
- when params.respond_to?('numbers')
225
- 'numbers'
226
- when params.respond_to?('events')
227
- 'events'
238
+ @collection_name ||=
239
+ case
240
+ when params.respond_to?("calls")
241
+ "calls"
242
+ when params.respond_to?("users")
243
+ "users"
244
+ when params.respond_to?("legs")
245
+ "legs"
246
+ when params.respond_to?("data")
247
+ "data"
248
+ when params.respond_to?("conversations")
249
+ "conversations"
250
+ when params.respond_to?("applications")
251
+ "applications"
252
+ when params.respond_to?("records")
253
+ "records"
254
+ when params.respond_to?("reports")
255
+ "reports"
256
+ when params.respond_to?("networks")
257
+ "networks"
258
+ when params.respond_to?("countries")
259
+ "countries"
260
+ when params.respond_to?("media")
261
+ "media"
262
+ when params.respond_to?("numbers")
263
+ "numbers"
264
+ when params.respond_to?("events")
265
+ "events"
228
266
  else
229
267
  params.entity.attributes.keys[0].to_s
230
268
  end
@@ -0,0 +1,11 @@
1
+ # typed: true
2
+
3
+ class Vonage::Users::ListResponse < Vonage::Response
4
+ include Enumerable
5
+
6
+ def each
7
+ return enum_for(:each) unless block_given?
8
+
9
+ @entity._embedded.users.each { |item| yield item }
10
+ end
11
+ end
@@ -0,0 +1,156 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Vonage
5
+ class Users < Namespace
6
+ extend T::Sig
7
+ self.authentication = BearerToken
8
+
9
+ self.request_body = JSON
10
+
11
+ # Get a list of Users associated with the Vonage Application.
12
+ #
13
+ # @param [optional, Integer] :page_size
14
+ # Specifies the number of records to be returned in the response.
15
+ #
16
+ # @param [optional, String] :order
17
+ # Specifies the order in which the records should be returned.
18
+ # Must be one of `asc`, `ASC`, `desc`, or `DESC`
19
+ #
20
+ # @param [optional, String] :cursor
21
+ # Specficy a cursor point from which to start returning results, for example the values of the `next` or `prev`
22
+ # `_links` contained in a response.
23
+ #
24
+ # @param [optional, String] :name
25
+ # Specify a user name with which to filter results
26
+ #
27
+ # @return [ListResponse]
28
+ #
29
+ # @see https://developer.vonage.com/en/api/application.v2#getUsers
30
+ #
31
+ def list(**params)
32
+ request('/v1/users', params: params, response_class: ListResponse)
33
+ end
34
+
35
+ # Get a specified User associated with the Vonage Application.
36
+ #
37
+ # @param [required, String] :id
38
+ # The unique ID or name for the user.
39
+ #
40
+ # @return [Vonage::Response]
41
+ #
42
+ # @see https://developer.vonage.com/en/api/application.v2#getUser
43
+ #
44
+ def find(id:)
45
+ request("/v1/users/#{id}")
46
+ end
47
+
48
+ # Create a new User associated with the Vonage Application.
49
+ #
50
+ # @param [optional, String] :name
51
+ # A unique name for the user. If not provided, a name will be auto-generated.
52
+ #
53
+ # @param [optional, String] :display_name
54
+ # A string to be displayed as user name. It does not need to be unique.
55
+ #
56
+ # @param [optional, String] :image_url
57
+ # A publicly accessible URL to an image file for an image to be associated with the user.
58
+ #
59
+ # @param [optional, Hash] :properties A hash defining properties for the User.
60
+ # @option properties [Hash] :custom_data A hash of custom data as key/value pairs.
61
+ #
62
+ # @param [optional, Hash] :channels A hash defining details of various channels.
63
+ # @option channels [Array] :pstn An array containing a Hash which defines data for the pstn channel.
64
+ # @option pstn [Integer] :number The pstn number.
65
+ # @option channels [Array] :sip An array containing a Hash which defines data for the sip channel.
66
+ # @option sip [String] :uri The sip uri.
67
+ # @option sip [String] :username The sip username.
68
+ # @option sip [String] :password The sip password.
69
+ # @option channels [Array] :vbc An array containing a Hash which defines data for the vbc channel.
70
+ # @option vbc [String] :extension The vbc extension.
71
+ # @option channels [Array] :websocket An array containing a Hash which defines data for the websocket channel.
72
+ # @option websocket [String] :uri The websocket uri.
73
+ # @option websocket [String] :content-type The websocket audio type. Must be one of: `audio/l16;rate=8000`, `audio/l16;rate=16000`.
74
+ # @option websocket [Hash] :headers A hash of custom websocket headers provided as key/value pairs.
75
+ # @option channels [Array] :sms An array containing a Hash which defines data for the sms channel.
76
+ # @option sms [Integer] :number The sms number.
77
+ # @option channels [Array] :mms An array containing a Hash which defines data for the mms channel.
78
+ # @option mms [Integer] :number The mms number.
79
+ # @option channels [Array] :whatsapp An array containing a Hash which defines data for the whatsapp channel.
80
+ # @option whatsapp [Integer] :number The whatsapp number.
81
+ # @option channels [Array] :viber An array containing a Hash which defines data for the sms channel.
82
+ # @option viber [Integer] :number The viber number.
83
+ # @option channels [Array] :messenger An array containing a Hash which defines data for the messenger channel.
84
+ # @option messenger [Integer] :id The messenger id.
85
+ #
86
+ # @return [Vonage::Response]
87
+ #
88
+ # @see https://developer.vonage.com/en/api/application.v2#createUser
89
+ #
90
+ def create(**params)
91
+ request('/v1/users', params: params, type: Post)
92
+ end
93
+
94
+ # Update an existing User associated with the Vonage Application.
95
+ #
96
+ # @param [required, String] :id
97
+ # The unique ID or name for the user to be updated.
98
+ #
99
+ # @param [optional, String] :name
100
+ # A unique name for the user.
101
+ #
102
+ # @param [optional, String] :display_name
103
+ # A string to be displayed as user name. It does not need to be unique.
104
+ #
105
+ # @param [optional, String] :image_url
106
+ # A publicly accessible URL to an image file for an image to be associated with the user.
107
+ #
108
+ # @param [optional, Hash] :properties A hash defining properties for the User.
109
+ # @option properties [Hash] :custom_data A hash of custom data as key/value pairs.
110
+ #
111
+ # @param [optional, Hash] :channels A hash defining details of various channels.
112
+ # @option channels [Array] :pstn An array containing a Hash which defines data for the pstn channel.
113
+ # @option pstn [Integer] :number The pstn number.
114
+ # @option channels [Array] :sip An array containing a Hash which defines data for the sip channel.
115
+ # @option sip [String] :uri The sip uri.
116
+ # @option sip [String] :username The sip username.
117
+ # @option sip [String] :password The sip password.
118
+ # @option channels [Array] :vbc An array containing a Hash which defines data for the vbc channel.
119
+ # @option vbc [String] :extension The vbc extension.
120
+ # @option channels [Array] :websocket An array containing a Hash which defines data for the websocket channel.
121
+ # @option websocket [String] :uri The websocket uri.
122
+ # @option websocket [String] :content-type The websocket audio type. Must be one of: `audio/l16;rate=8000`, `audio/l16;rate=16000`.
123
+ # @option websocket [Hash] :headers A hash of custom websocket headers provided as key/value pairs.
124
+ # @option channels [Array] :sms An array containing a Hash which defines data for the sms channel.
125
+ # @option sms [Integer] :number The sms number.
126
+ # @option channels [Array] :mms An array containing a Hash which defines data for the mms channel.
127
+ # @option mms [Integer] :number The mms number.
128
+ # @option channels [Array] :whatsapp An array containing a Hash which defines data for the whatsapp channel.
129
+ # @option whatsapp [Integer] :number The whatsapp number.
130
+ # @option channels [Array] :viber An array containing a Hash which defines data for the sms channel.
131
+ # @option viber [Integer] :number The viber number.
132
+ # @option channels [Array] :messenger An array containing a Hash which defines data for the messenger channel.
133
+ # @option messenger [Integer] :id The messenger id.
134
+ #
135
+ # @return [Vonage::Response]
136
+ #
137
+ # @see https://developer.vonage.com/en/api/application.v2#createUser
138
+ #
139
+ def update(id:, **params)
140
+ request("/v1/users/#{id}", params: params, type: Patch)
141
+ end
142
+
143
+ # Delete a specified User associated with the Vonage Application.
144
+ #
145
+ # @param [required, String] :id
146
+ # The unique ID or name for the user.
147
+ #
148
+ # @return [Vonage::Response]
149
+ #
150
+ # @see https://developer.vonage.com/en/api/application.v2#deleteUser
151
+ #
152
+ def delete(id:)
153
+ request("/v1/users/#{id}", type: Delete)
154
+ end
155
+ end
156
+ end
@@ -28,7 +28,7 @@ module Vonage
28
28
  # @option opts [String] :client_ref Reference to be included in callbacks
29
29
  # @option opts [Boolean] If used, must be set to `false`. Will bypass a network block for a single Verify V2 request
30
30
  #
31
- # @return Vomage::Response
31
+ # @return Vonage::Response
32
32
  # @see https://developer.vonage.com/en/api/verify.v2#newRequest
33
33
  #
34
34
  def start_verification(brand:, workflow:, **opts)
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = "7.13.0"
4
+ VERSION = "7.15.0"
5
5
  end
data/vonage.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.summary = 'This is the Ruby Server SDK for Vonage APIs. To use it you\'ll need a Vonage account. Sign up for free at https://www.vonage.com'
13
13
  s.files = Dir.glob('lib/**/*.rb') + %w(LICENSE.txt README.md vonage.gemspec)
14
14
  s.required_ruby_version = '>= 2.5.0'
15
- s.add_dependency('vonage-jwt', '~> 0.1.0')
15
+ s.add_dependency('vonage-jwt', '~> 0.1.3')
16
16
  s.add_dependency('zeitwerk', '~> 2', '>= 2.2')
17
17
  s.add_dependency('sorbet-runtime', '~> 0.5')
18
18
  s.add_dependency('multipart-post', '~> 2.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.13.0
4
+ version: 7.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vonage-jwt
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.1.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0
26
+ version: 0.1.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: zeitwerk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +139,17 @@ files:
139
139
  - lib/vonage/key_secret_params.rb
140
140
  - lib/vonage/keys.rb
141
141
  - lib/vonage/logger.rb
142
+ - lib/vonage/meetings.rb
143
+ - lib/vonage/meetings/applications.rb
144
+ - lib/vonage/meetings/dial_in_numbers.rb
145
+ - lib/vonage/meetings/dial_in_numbers/list_response.rb
146
+ - lib/vonage/meetings/recordings.rb
147
+ - lib/vonage/meetings/rooms.rb
148
+ - lib/vonage/meetings/rooms/list_response.rb
149
+ - lib/vonage/meetings/sessions.rb
150
+ - lib/vonage/meetings/sessions/list_response.rb
151
+ - lib/vonage/meetings/themes.rb
152
+ - lib/vonage/meetings/themes/list_response.rb
142
153
  - lib/vonage/messages.rb
143
154
  - lib/vonage/messaging.rb
144
155
  - lib/vonage/messaging/channels/messenger.rb
@@ -179,6 +190,8 @@ files:
179
190
  - lib/vonage/subaccounts/list_response.rb
180
191
  - lib/vonage/tfa.rb
181
192
  - lib/vonage/user_agent.rb
193
+ - lib/vonage/users.rb
194
+ - lib/vonage/users/list_response.rb
182
195
  - lib/vonage/verify.rb
183
196
  - lib/vonage/verify2.rb
184
197
  - lib/vonage/verify2/channels/email.rb