bandwidth-sdk 6.2.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bandwidth.rb +3 -2
- data/lib/bandwidth/api_helper.rb +0 -12
- data/lib/bandwidth/client.rb +8 -8
- data/lib/bandwidth/configuration.rb +15 -15
- data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
- data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +25 -29
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +47 -2
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +5 -75
- data/lib/bandwidth/models/base_model.rb +19 -8
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +7 -7
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +0 -0
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +0 -0
- data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
- data/lib/bandwidth/voice_lib/voice.rb +14 -18
- data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +248 -230
- data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +2 -2
- data/lib/bandwidth/voice_lib/voice/models/{recording_metadata_response.rb → call_recording_metadata.rb} +47 -28
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +232 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{conference_recording_metadata_response.rb → conference_recording_metadata.rb} +34 -18
- data/lib/bandwidth/voice_lib/voice/models/{conference_detail.rb → conference_state.rb} +22 -14
- data/lib/bandwidth/voice_lib/voice/models/{api_create_call_request.rb → create_call_request.rb} +35 -59
- data/lib/bandwidth/voice_lib/voice/models/{api_call_response.rb → create_call_response.rb} +28 -23
- data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +4 -4
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_call_request.rb → modify_call_request.rb} +25 -25
- data/lib/bandwidth/voice_lib/voice/models/{api_modify_conference_request.rb → modify_conference_request.rb} +11 -11
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/{api_transcribe_recording_request.rb → transcribe_recording_request.rb} +8 -8
- data/lib/bandwidth/voice_lib/voice/models/{transcription.rb → transcription_metadata.rb} +19 -10
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +4 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +14 -14
- data/test/integration/test_integration.rb +13 -13
- metadata +29 -32
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b67b83b111ec3185ce0614d96b9f46ea31270db7e0b44a069cc8d87e16bf2bd5
|
4
|
+
data.tar.gz: b4c1575cda3afab5b3a17ccf70883ddd68815ec9e3e55c162d778cc7667dd8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7de5c586dc71cc06134c42008931b6508e5fca4a7baecd02dd94b5d9c5d1e26f10c6266c020ef6c91429a0e50e10678a32803e07c2af30e74833fe0a55ea7f65
|
7
|
+
data.tar.gz: 61b41ff9f216fee03ff287270a13666575006b870ecdc38c9edf8b4de93e7db0a4d45d37becf2b11bd52cfba399058739b3e9bea48d086d71d01983ef2da28f7
|
data/lib/bandwidth.rb
CHANGED
@@ -14,6 +14,7 @@ require_relative 'bandwidth/client.rb'
|
|
14
14
|
|
15
15
|
# Utilities
|
16
16
|
require_relative 'bandwidth/utilities/file_wrapper.rb'
|
17
|
+
require_relative 'bandwidth/utilities/date_time_helper.rb'
|
17
18
|
|
18
19
|
# Http
|
19
20
|
require_relative 'bandwidth/http/api_response.rb'
|
@@ -35,8 +36,8 @@ require_relative 'bandwidth/configuration.rb'
|
|
35
36
|
# Namespaces
|
36
37
|
require_relative 'bandwidth/messaging_lib/messaging'
|
37
38
|
require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
|
38
|
-
require_relative 'bandwidth/
|
39
|
-
require_relative 'bandwidth/http/auth/
|
39
|
+
require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth'
|
40
|
+
require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth.rb'
|
40
41
|
require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup'
|
41
42
|
require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth.rb'
|
42
43
|
require_relative 'bandwidth/voice_lib/voice'
|
data/lib/bandwidth/api_helper.rb
CHANGED
@@ -273,17 +273,5 @@ module Bandwidth
|
|
273
273
|
end
|
274
274
|
val
|
275
275
|
end
|
276
|
-
|
277
|
-
# Safely converts a string into an rfc3339 DateTime object
|
278
|
-
# @param [String] The datetime string
|
279
|
-
# @return [DateTime] A DateTime object of rfc3339 format
|
280
|
-
def self.rfc3339(date_time)
|
281
|
-
# missing timezone information
|
282
|
-
if date_time.end_with?('Z') || date_time.index('+')
|
283
|
-
DateTime.rfc3339(date_time)
|
284
|
-
else
|
285
|
-
DateTime.rfc3339(date_time + 'Z')
|
286
|
-
end
|
287
|
-
end
|
288
276
|
end
|
289
277
|
end
|
data/lib/bandwidth/client.rb
CHANGED
@@ -12,10 +12,10 @@ module Bandwidth
|
|
12
12
|
def messaging_client
|
13
13
|
@messaging_client ||= Messaging::Client.new(config: config)
|
14
14
|
end
|
15
|
-
# Access to
|
16
|
-
# @return [
|
17
|
-
def
|
18
|
-
@
|
15
|
+
# Access to multi_factor_auth_client controller.
|
16
|
+
# @return [MultiFactorAuth::Client] Returns the client instance.
|
17
|
+
def multi_factor_auth_client
|
18
|
+
@multi_factor_auth_client ||= MultiFactorAuth::Client.new(config: config)
|
19
19
|
end
|
20
20
|
# Access to phone_number_lookup_client controller.
|
21
21
|
# @return [PhoneNumberLookup::Client] Returns the client instance.
|
@@ -41,8 +41,8 @@ module Bandwidth
|
|
41
41
|
base_url: 'https://www.example.com',
|
42
42
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
43
43
|
messaging_basic_auth_password: 'TODO: Replace',
|
44
|
-
|
45
|
-
|
44
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
45
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
46
46
|
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
47
47
|
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
48
48
|
voice_basic_auth_user_name: 'TODO: Replace',
|
@@ -59,8 +59,8 @@ module Bandwidth
|
|
59
59
|
base_url: base_url,
|
60
60
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
61
61
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
62
|
-
|
63
|
-
|
62
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
63
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
64
64
|
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
65
65
|
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
66
66
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
@@ -17,7 +17,7 @@ module Bandwidth
|
|
17
17
|
SERVER = [
|
18
18
|
DEFAULT = 'default'.freeze,
|
19
19
|
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
|
20
|
-
|
20
|
+
MULTIFACTORAUTHDEFAULT = 'MultiFactorAuthDefault'.freeze,
|
21
21
|
PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze,
|
22
22
|
VOICEDEFAULT = 'VoiceDefault'.freeze,
|
23
23
|
WEBRTCDEFAULT = 'WebRtcDefault'.freeze
|
@@ -39,8 +39,8 @@ module Bandwidth
|
|
39
39
|
attr_reader :base_url
|
40
40
|
attr_reader :messaging_basic_auth_user_name
|
41
41
|
attr_reader :messaging_basic_auth_password
|
42
|
-
attr_reader :
|
43
|
-
attr_reader :
|
42
|
+
attr_reader :multi_factor_auth_basic_auth_user_name
|
43
|
+
attr_reader :multi_factor_auth_basic_auth_password
|
44
44
|
attr_reader :phone_number_lookup_basic_auth_user_name
|
45
45
|
attr_reader :phone_number_lookup_basic_auth_password
|
46
46
|
attr_reader :voice_basic_auth_user_name
|
@@ -60,8 +60,8 @@ module Bandwidth
|
|
60
60
|
base_url: 'https://www.example.com',
|
61
61
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
62
62
|
messaging_basic_auth_password: 'TODO: Replace',
|
63
|
-
|
64
|
-
|
63
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
64
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
65
65
|
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
66
66
|
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
67
67
|
voice_basic_auth_user_name: 'TODO: Replace',
|
@@ -100,10 +100,10 @@ module Bandwidth
|
|
100
100
|
@messaging_basic_auth_password = messaging_basic_auth_password
|
101
101
|
|
102
102
|
# The username to use with basic authentication
|
103
|
-
@
|
103
|
+
@multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name
|
104
104
|
|
105
105
|
# The password to use with basic authentication
|
106
|
-
@
|
106
|
+
@multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password
|
107
107
|
|
108
108
|
# The username to use with basic authentication
|
109
109
|
@phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name
|
@@ -132,8 +132,8 @@ module Bandwidth
|
|
132
132
|
environment: nil, base_url: nil,
|
133
133
|
messaging_basic_auth_user_name: nil,
|
134
134
|
messaging_basic_auth_password: nil,
|
135
|
-
|
136
|
-
|
135
|
+
multi_factor_auth_basic_auth_user_name: nil,
|
136
|
+
multi_factor_auth_basic_auth_password: nil,
|
137
137
|
phone_number_lookup_basic_auth_user_name: nil,
|
138
138
|
phone_number_lookup_basic_auth_password: nil,
|
139
139
|
voice_basic_auth_user_name: nil,
|
@@ -150,8 +150,8 @@ module Bandwidth
|
|
150
150
|
base_url ||= self.base_url
|
151
151
|
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
|
152
152
|
messaging_basic_auth_password ||= self.messaging_basic_auth_password
|
153
|
-
|
154
|
-
|
153
|
+
multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name
|
154
|
+
multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password
|
155
155
|
phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name
|
156
156
|
phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password
|
157
157
|
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
|
@@ -166,8 +166,8 @@ module Bandwidth
|
|
166
166
|
environment: environment, base_url: base_url,
|
167
167
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
168
168
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
169
|
-
|
170
|
-
|
169
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
170
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
171
171
|
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
172
172
|
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
173
173
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
@@ -190,7 +190,7 @@ module Bandwidth
|
|
190
190
|
Environment::PRODUCTION => {
|
191
191
|
Server::DEFAULT => 'api.bandwidth.com',
|
192
192
|
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
|
193
|
-
Server::
|
193
|
+
Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1',
|
194
194
|
Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1',
|
195
195
|
Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
|
196
196
|
Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
|
@@ -198,7 +198,7 @@ module Bandwidth
|
|
198
198
|
Environment::CUSTOM => {
|
199
199
|
Server::DEFAULT => '{base_url}',
|
200
200
|
Server::MESSAGINGDEFAULT => '{base_url}',
|
201
|
-
Server::
|
201
|
+
Server::MULTIFACTORAUTHDEFAULT => '{base_url}',
|
202
202
|
Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}',
|
203
203
|
Server::VOICEDEFAULT => '{base_url}',
|
204
204
|
Server::WEBRTCDEFAULT => '{base_url}'
|
data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb}
RENAMED
@@ -7,13 +7,13 @@ require 'base64'
|
|
7
7
|
|
8
8
|
module Bandwidth
|
9
9
|
# Utility class for basic authorization.
|
10
|
-
class
|
10
|
+
class MultiFactorAuthBasicAuth
|
11
11
|
# Add basic authentication to the request.
|
12
12
|
# @param [HttpRequest] The HttpRequest object to which authentication will
|
13
13
|
# be added.
|
14
14
|
def self.apply(config, http_request)
|
15
|
-
username = config.
|
16
|
-
password = config.
|
15
|
+
username = config.multi_factor_auth_basic_auth_user_name
|
16
|
+
password = config.multi_factor_auth_basic_auth_password
|
17
17
|
value = Base64.strict_encode64("#{username}:#{password}")
|
18
18
|
header_value = "Basic #{value}"
|
19
19
|
http_request.headers['Authorization'] = header_value
|
@@ -16,12 +16,17 @@ module Bandwidth
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
19
|
-
backoff_factor:
|
19
|
+
backoff_factor: 2,
|
20
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
|
+
retry_methods: %i[get put get put],
|
22
|
+
environment: Environment::PRODUCTION,
|
20
23
|
base_url: 'https://www.example.com',
|
21
24
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
22
25
|
messaging_basic_auth_password: 'TODO: Replace',
|
23
|
-
|
24
|
-
|
26
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
27
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
28
|
+
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
29
|
+
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
25
30
|
voice_basic_auth_user_name: 'TODO: Replace',
|
26
31
|
voice_basic_auth_password: 'TODO: Replace',
|
27
32
|
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
@@ -32,12 +37,16 @@ module Bandwidth
|
|
32
37
|
max_retries: max_retries,
|
33
38
|
retry_interval: retry_interval,
|
34
39
|
backoff_factor: backoff_factor,
|
40
|
+
retry_statuses: retry_statuses,
|
41
|
+
retry_methods: retry_methods,
|
35
42
|
environment: environment,
|
36
43
|
base_url: base_url,
|
37
44
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
38
45
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
39
|
-
|
40
|
-
|
46
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
47
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
48
|
+
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
49
|
+
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
41
50
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
42
51
|
voice_basic_auth_password: voice_basic_auth_password,
|
43
52
|
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
@@ -12,18 +12,18 @@ module Messaging
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# listMedia
|
15
|
-
# @param [String]
|
15
|
+
# @param [String] account_id Required parameter: User's account ID
|
16
16
|
# @param [String] continuation_token Optional parameter: Continuation token
|
17
17
|
# used to retrieve subsequent media.
|
18
18
|
# @return [List of Media] response from the API call
|
19
|
-
def list_media(
|
19
|
+
def list_media(account_id,
|
20
20
|
continuation_token: nil)
|
21
21
|
# Prepare query url.
|
22
22
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
23
|
-
_query_builder << '/users/{
|
23
|
+
_query_builder << '/users/{accountId}/media'
|
24
24
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
25
25
|
_query_builder,
|
26
|
-
'
|
26
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
27
27
|
)
|
28
28
|
_query_url = APIHelper.clean_url _query_builder
|
29
29
|
|
@@ -84,17 +84,17 @@ module Messaging
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# getMedia
|
87
|
-
# @param [String]
|
87
|
+
# @param [String] account_id Required parameter: User's account ID
|
88
88
|
# @param [String] media_id Required parameter: Media ID to retrieve
|
89
89
|
# @return [Binary] response from the API call
|
90
|
-
def get_media(
|
90
|
+
def get_media(account_id,
|
91
91
|
media_id)
|
92
92
|
# Prepare query url.
|
93
93
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
94
|
-
_query_builder << '/users/{
|
94
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
95
95
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
96
96
|
_query_builder,
|
97
|
-
'
|
97
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
98
98
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
99
99
|
)
|
100
100
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -147,11 +147,9 @@ module Messaging
|
|
147
147
|
end
|
148
148
|
|
149
149
|
# uploadMedia
|
150
|
-
# @param [String]
|
150
|
+
# @param [String] account_id Required parameter: User's account ID
|
151
151
|
# @param [String] media_id Required parameter: The user supplied custom
|
152
152
|
# media ID
|
153
|
-
# @param [Long] content_length Required parameter: The size of the
|
154
|
-
# entity-body
|
155
153
|
# @param [File | UploadIO] body Required parameter: Example:
|
156
154
|
# @param [String] content_type Optional parameter: The media type of the
|
157
155
|
# entity-body
|
@@ -159,18 +157,17 @@ module Messaging
|
|
159
157
|
# used to specify directives that MUST be obeyed by all caching mechanisms
|
160
158
|
# along the request/response chain.
|
161
159
|
# @return [void] response from the API call
|
162
|
-
def upload_media(
|
160
|
+
def upload_media(account_id,
|
163
161
|
media_id,
|
164
|
-
content_length,
|
165
162
|
body,
|
166
163
|
content_type: 'application/octet-stream',
|
167
164
|
cache_control: nil)
|
168
165
|
# Prepare query url.
|
169
166
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
170
|
-
_query_builder << '/users/{
|
167
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
171
168
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
172
169
|
_query_builder,
|
173
|
-
'
|
170
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
174
171
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
175
172
|
)
|
176
173
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -187,7 +184,6 @@ module Messaging
|
|
187
184
|
_headers = {
|
188
185
|
'content-type' => body_content_type,
|
189
186
|
'content-length' => body_wrapper.size.to_s,
|
190
|
-
'Content-Length' => content_length,
|
191
187
|
'Cache-Control' => cache_control
|
192
188
|
}
|
193
189
|
|
@@ -239,17 +235,17 @@ module Messaging
|
|
239
235
|
end
|
240
236
|
|
241
237
|
# deleteMedia
|
242
|
-
# @param [String]
|
238
|
+
# @param [String] account_id Required parameter: User's account ID
|
243
239
|
# @param [String] media_id Required parameter: The media ID to delete
|
244
240
|
# @return [void] response from the API call
|
245
|
-
def delete_media(
|
241
|
+
def delete_media(account_id,
|
246
242
|
media_id)
|
247
243
|
# Prepare query url.
|
248
244
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
249
|
-
_query_builder << '/users/{
|
245
|
+
_query_builder << '/users/{accountId}/media/{mediaId}'
|
250
246
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
251
247
|
_query_builder,
|
252
|
-
'
|
248
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
253
249
|
'mediaId' => { 'value' => media_id, 'encode' => false }
|
254
250
|
)
|
255
251
|
_query_url = APIHelper.clean_url _query_builder
|
@@ -300,7 +296,7 @@ module Messaging
|
|
300
296
|
end
|
301
297
|
|
302
298
|
# getMessages
|
303
|
-
# @param [String]
|
299
|
+
# @param [String] account_id Required parameter: User's account ID
|
304
300
|
# @param [String] message_id Optional parameter: The ID of the message to
|
305
301
|
# search for. Special characters need to be encoded using URL encoding
|
306
302
|
# @param [String] source_tn Optional parameter: The phone number that sent
|
@@ -309,7 +305,7 @@ module Messaging
|
|
309
305
|
# received the message
|
310
306
|
# @param [String] message_status Optional parameter: The status of the
|
311
307
|
# message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED,
|
312
|
-
#
|
308
|
+
# ACCEPTED, UNDELIVERED
|
313
309
|
# @param [Integer] error_code Optional parameter: The error code of the
|
314
310
|
# message
|
315
311
|
# @param [String] from_date_time Optional parameter: The start of the date
|
@@ -324,7 +320,7 @@ module Messaging
|
|
324
320
|
# in search result. Default 100. The sum of limit and after cannot be more
|
325
321
|
# than 10000
|
326
322
|
# @return [BandwidthMessagesList] response from the API call
|
327
|
-
def get_messages(
|
323
|
+
def get_messages(account_id,
|
328
324
|
message_id: nil,
|
329
325
|
source_tn: nil,
|
330
326
|
destination_tn: nil,
|
@@ -336,10 +332,10 @@ module Messaging
|
|
336
332
|
limit: nil)
|
337
333
|
# Prepare query url.
|
338
334
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
339
|
-
_query_builder << '/users/{
|
335
|
+
_query_builder << '/users/{accountId}/messages'
|
340
336
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
341
337
|
_query_builder,
|
342
|
-
'
|
338
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
343
339
|
)
|
344
340
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
345
341
|
_query_builder,
|
@@ -410,17 +406,17 @@ module Messaging
|
|
410
406
|
end
|
411
407
|
|
412
408
|
# createMessage
|
413
|
-
# @param [String]
|
409
|
+
# @param [String] account_id Required parameter: User's account ID
|
414
410
|
# @param [MessageRequest] body Required parameter: Example:
|
415
411
|
# @return [BandwidthMessage] response from the API call
|
416
|
-
def create_message(
|
412
|
+
def create_message(account_id,
|
417
413
|
body)
|
418
414
|
# Prepare query url.
|
419
415
|
_query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
|
420
|
-
_query_builder << '/users/{
|
416
|
+
_query_builder << '/users/{accountId}/messages'
|
421
417
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
422
418
|
_query_builder,
|
423
|
-
'
|
419
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
424
420
|
)
|
425
421
|
_query_url = APIHelper.clean_url _query_builder
|
426
422
|
|
@@ -50,6 +50,26 @@ module Bandwidth
|
|
50
50
|
# @return [String]
|
51
51
|
attr_accessor :carrier_name
|
52
52
|
|
53
|
+
# The size of the message including message content and headers
|
54
|
+
# @return [Integer]
|
55
|
+
attr_accessor :message_size
|
56
|
+
|
57
|
+
# The length of the message content
|
58
|
+
# @return [Integer]
|
59
|
+
attr_accessor :message_length
|
60
|
+
|
61
|
+
# The number of attachments the message has
|
62
|
+
# @return [Integer]
|
63
|
+
attr_accessor :attachment_count
|
64
|
+
|
65
|
+
# The number of recipients the message has
|
66
|
+
# @return [Integer]
|
67
|
+
attr_accessor :recipient_count
|
68
|
+
|
69
|
+
# The campaign class of the message, if it has one
|
70
|
+
# @return [String]
|
71
|
+
attr_accessor :campaign_class
|
72
|
+
|
53
73
|
# A mapping from model property names to API property names.
|
54
74
|
def self.names
|
55
75
|
@_hash = {} if @_hash.nil?
|
@@ -64,6 +84,11 @@ module Bandwidth
|
|
64
84
|
@_hash['error_code'] = 'errorCode'
|
65
85
|
@_hash['receive_time'] = 'receiveTime'
|
66
86
|
@_hash['carrier_name'] = 'carrierName'
|
87
|
+
@_hash['message_size'] = 'messageSize'
|
88
|
+
@_hash['message_length'] = 'messageLength'
|
89
|
+
@_hash['attachment_count'] = 'attachmentCount'
|
90
|
+
@_hash['recipient_count'] = 'recipientCount'
|
91
|
+
@_hash['campaign_class'] = 'campaignClass'
|
67
92
|
@_hash
|
68
93
|
end
|
69
94
|
|
@@ -77,7 +102,12 @@ module Bandwidth
|
|
77
102
|
segment_count = nil,
|
78
103
|
error_code = nil,
|
79
104
|
receive_time = nil,
|
80
|
-
carrier_name = nil
|
105
|
+
carrier_name = nil,
|
106
|
+
message_size = nil,
|
107
|
+
message_length = nil,
|
108
|
+
attachment_count = nil,
|
109
|
+
recipient_count = nil,
|
110
|
+
campaign_class = nil)
|
81
111
|
@message_id = message_id
|
82
112
|
@account_id = account_id
|
83
113
|
@source_tn = source_tn
|
@@ -89,6 +119,11 @@ module Bandwidth
|
|
89
119
|
@error_code = error_code
|
90
120
|
@receive_time = receive_time
|
91
121
|
@carrier_name = carrier_name
|
122
|
+
@message_size = message_size
|
123
|
+
@message_length = message_length
|
124
|
+
@attachment_count = attachment_count
|
125
|
+
@recipient_count = recipient_count
|
126
|
+
@campaign_class = campaign_class
|
92
127
|
end
|
93
128
|
|
94
129
|
# Creates an instance of the object from a hash.
|
@@ -107,6 +142,11 @@ module Bandwidth
|
|
107
142
|
error_code = hash['errorCode']
|
108
143
|
receive_time = hash['receiveTime']
|
109
144
|
carrier_name = hash['carrierName']
|
145
|
+
message_size = hash['messageSize']
|
146
|
+
message_length = hash['messageLength']
|
147
|
+
attachment_count = hash['attachmentCount']
|
148
|
+
recipient_count = hash['recipientCount']
|
149
|
+
campaign_class = hash['campaignClass']
|
110
150
|
|
111
151
|
# Create object from extracted values.
|
112
152
|
BandwidthMessageItem.new(message_id,
|
@@ -119,7 +159,12 @@ module Bandwidth
|
|
119
159
|
segment_count,
|
120
160
|
error_code,
|
121
161
|
receive_time,
|
122
|
-
carrier_name
|
162
|
+
carrier_name,
|
163
|
+
message_size,
|
164
|
+
message_length,
|
165
|
+
attachment_count,
|
166
|
+
recipient_count,
|
167
|
+
campaign_class)
|
123
168
|
end
|
124
169
|
end
|
125
170
|
end
|