bandwidth-sdk 0.1.0 → 1.0.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/LICENSE +27 -27
- data/README.md +115 -1
- data/lib/bandwidth.rb +39 -37
- data/lib/bandwidth/api_helper.rb +280 -280
- data/lib/bandwidth/client.rb +41 -32
- data/lib/bandwidth/configuration.rb +130 -111
- data/lib/bandwidth/exceptions/api_exception.rb +20 -20
- data/lib/bandwidth/http/api_response.rb +36 -36
- data/lib/bandwidth/http/auth/messaging_basic_auth.rb +22 -0
- data/lib/bandwidth/http/auth/voice_basic_auth.rb +22 -22
- data/lib/bandwidth/http/faraday_client.rb +64 -64
- data/lib/bandwidth/http/http_call_back.rb +24 -24
- data/lib/bandwidth/http/http_client.rb +104 -104
- data/lib/bandwidth/http/http_method_enum.rb +13 -13
- data/lib/bandwidth/http/http_request.rb +50 -50
- data/lib/bandwidth/http/http_response.rb +29 -29
- data/lib/bandwidth/messaging_lib/messaging.rb +23 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +40 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +406 -0
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/messaging_lib/messaging/exceptions/generic_client_exception.rb +46 -0
- data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +49 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +80 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +44 -0
- data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +44 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +123 -0
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +80 -0
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +44 -0
- data/lib/bandwidth/models/base_model.rb +36 -36
- data/lib/bandwidth/voice_lib/bxml/bxml.rb +40 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +38 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +15 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +16 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +18 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +21 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +14 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +19 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +38 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +27 -0
- data/lib/bandwidth/voice_lib/voice.rb +27 -23
- data/lib/bandwidth/voice_lib/voice/client.rb +40 -36
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +184 -0
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +49 -49
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb +51 -0
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_not_found_exception.rb +49 -0
- data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_rate_limit_error_exception.rb +56 -0
- data/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +116 -116
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +125 -125
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +80 -80
- data/lib/bandwidth/voice_lib/voice/models/bandwidth_callback_message_voice.rb +98 -98
- data/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/field_error.rb +44 -0
- data/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +35 -35
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +17 -17
- metadata +36 -47
- data/lib/bandwidth/voice_lib/voice/bxml/bxml.rb +0 -36
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/forward.rb +0 -19
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/gather.rb +0 -37
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/hangup.rb +0 -14
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/pause.rb +0 -15
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/phone_number.rb +0 -18
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/play_audio.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/redirect.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/send_dtmf.rb +0 -12
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/speak_sentence.rb +0 -18
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/transfer.rb +0 -37
- data/lib/bandwidth/voice_lib/voice/bxml/verbs/xml_verb.rb +0 -26
- data/lib/bandwidth/voice_lib/voice/controllers/calls_controller.rb +0 -88
data/lib/bandwidth/client.rb
CHANGED
@@ -1,32 +1,41 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# bandwidth client class.
|
8
|
-
class Client
|
9
|
-
attr_reader :config
|
10
|
-
# Access to
|
11
|
-
# @return [
|
12
|
-
def
|
13
|
-
@
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# bandwidth client class.
|
8
|
+
class Client
|
9
|
+
attr_reader :config
|
10
|
+
# Access to messaging_client controller.
|
11
|
+
# @return [Messaging::Client] Returns the client instance.
|
12
|
+
def messaging_client
|
13
|
+
@messaging_client ||= Messaging::Client.new(config: config)
|
14
|
+
end
|
15
|
+
# Access to voice_client controller.
|
16
|
+
# @return [Voice::Client] Returns the client instance.
|
17
|
+
def voice_client
|
18
|
+
@voice_client ||= Voice::Client.new(config: config)
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
|
22
|
+
backoff_factor: 1, environment: Environment::PRODUCTION,
|
23
|
+
messaging_basic_auth_user_name: 'TODO: Replace',
|
24
|
+
messaging_basic_auth_password: 'TODO: Replace',
|
25
|
+
voice_basic_auth_user_name: 'TODO: Replace',
|
26
|
+
voice_basic_auth_password: 'TODO: Replace', config: nil)
|
27
|
+
@config = if config.nil?
|
28
|
+
Configuration.new(timeout: timeout, max_retries: max_retries,
|
29
|
+
retry_interval: retry_interval,
|
30
|
+
backoff_factor: backoff_factor,
|
31
|
+
environment: environment,
|
32
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
33
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
34
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
35
|
+
voice_basic_auth_password: voice_basic_auth_password)
|
36
|
+
else
|
37
|
+
config
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,111 +1,130 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# An enum for SDK environments.
|
8
|
-
class Environment
|
9
|
-
ENVIRONMENT = [
|
10
|
-
PRODUCTION = 'production'.freeze
|
11
|
-
].freeze
|
12
|
-
end
|
13
|
-
|
14
|
-
# An enum for API servers.
|
15
|
-
class Server
|
16
|
-
SERVER = [
|
17
|
-
DEFAULT = 'default'.freeze,
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
class
|
25
|
-
|
26
|
-
|
27
|
-
attr_reader :
|
28
|
-
attr_reader :
|
29
|
-
attr_reader :
|
30
|
-
attr_reader :
|
31
|
-
attr_reader :
|
32
|
-
attr_reader :
|
33
|
-
attr_reader :
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# An enum for SDK environments.
|
8
|
+
class Environment
|
9
|
+
ENVIRONMENT = [
|
10
|
+
PRODUCTION = 'production'.freeze
|
11
|
+
].freeze
|
12
|
+
end
|
13
|
+
|
14
|
+
# An enum for API servers.
|
15
|
+
class Server
|
16
|
+
SERVER = [
|
17
|
+
DEFAULT = 'default'.freeze,
|
18
|
+
MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
|
19
|
+
VOICEDEFAULT = 'VoiceDefault'.freeze
|
20
|
+
].freeze
|
21
|
+
end
|
22
|
+
|
23
|
+
# All configuration including auth info and base URI for the API access
|
24
|
+
# are configured in this class.
|
25
|
+
class Configuration
|
26
|
+
# The attribute readers for properties.
|
27
|
+
attr_reader :http_client
|
28
|
+
attr_reader :timeout
|
29
|
+
attr_reader :max_retries
|
30
|
+
attr_reader :retry_interval
|
31
|
+
attr_reader :backoff_factor
|
32
|
+
attr_reader :environment
|
33
|
+
attr_reader :messaging_basic_auth_user_name
|
34
|
+
attr_reader :messaging_basic_auth_password
|
35
|
+
attr_reader :voice_basic_auth_user_name
|
36
|
+
attr_reader :voice_basic_auth_password
|
37
|
+
|
38
|
+
class << self
|
39
|
+
attr_reader :environments
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
|
43
|
+
backoff_factor: 1, environment: Environment::PRODUCTION,
|
44
|
+
messaging_basic_auth_user_name: 'TODO: Replace',
|
45
|
+
messaging_basic_auth_password: 'TODO: Replace',
|
46
|
+
voice_basic_auth_user_name: 'TODO: Replace',
|
47
|
+
voice_basic_auth_password: 'TODO: Replace')
|
48
|
+
# The value to use for connection timeout
|
49
|
+
@timeout = timeout
|
50
|
+
|
51
|
+
# The number of times to retry an endpoint call if it fails
|
52
|
+
@max_retries = max_retries
|
53
|
+
|
54
|
+
# Pause in seconds between retries
|
55
|
+
@retry_interval = retry_interval
|
56
|
+
|
57
|
+
# The amount to multiply each successive retry's interval amount
|
58
|
+
# by in order to provide backoff
|
59
|
+
@backoff_factor = backoff_factor
|
60
|
+
|
61
|
+
# Current API environment
|
62
|
+
@environment = environment
|
63
|
+
|
64
|
+
# The username to use with basic authentication
|
65
|
+
@messaging_basic_auth_user_name = messaging_basic_auth_user_name
|
66
|
+
|
67
|
+
# The password to use with basic authentication
|
68
|
+
@messaging_basic_auth_password = messaging_basic_auth_password
|
69
|
+
|
70
|
+
# The username to use with basic authentication
|
71
|
+
@voice_basic_auth_user_name = voice_basic_auth_user_name
|
72
|
+
|
73
|
+
# The password to use with basic authentication
|
74
|
+
@voice_basic_auth_password = voice_basic_auth_password
|
75
|
+
|
76
|
+
# The Http Client to use for making requests.
|
77
|
+
@http_client = create_http_client
|
78
|
+
end
|
79
|
+
|
80
|
+
def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
|
81
|
+
backoff_factor: nil, environment: nil,
|
82
|
+
messaging_basic_auth_user_name: nil,
|
83
|
+
messaging_basic_auth_password: nil,
|
84
|
+
voice_basic_auth_user_name: nil,
|
85
|
+
voice_basic_auth_password: nil)
|
86
|
+
timeout ||= self.timeout
|
87
|
+
max_retries ||= self.max_retries
|
88
|
+
retry_interval ||= self.retry_interval
|
89
|
+
backoff_factor ||= self.backoff_factor
|
90
|
+
environment ||= self.environment
|
91
|
+
messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
|
92
|
+
messaging_basic_auth_password ||= self.messaging_basic_auth_password
|
93
|
+
voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
|
94
|
+
voice_basic_auth_password ||= self.voice_basic_auth_password
|
95
|
+
|
96
|
+
Configuration.new(
|
97
|
+
timeout: timeout, max_retries: max_retries,
|
98
|
+
retry_interval: retry_interval, backoff_factor: backoff_factor,
|
99
|
+
environment: environment,
|
100
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
101
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
102
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
103
|
+
voice_basic_auth_password: voice_basic_auth_password
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
def create_http_client
|
108
|
+
FaradayClient.new(timeout: timeout, max_retries: max_retries,
|
109
|
+
retry_interval: retry_interval,
|
110
|
+
backoff_factor: backoff_factor)
|
111
|
+
end
|
112
|
+
|
113
|
+
# All the environments the SDK can run in.
|
114
|
+
@environments = {
|
115
|
+
Environment::PRODUCTION => {
|
116
|
+
Server::DEFAULT => 'api.bandwidth.com',
|
117
|
+
Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
|
118
|
+
Server::VOICEDEFAULT => 'https://voice.bandwidth.com/api/v2/'
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
# Generates the appropriate base URI for the environment and the server.
|
123
|
+
# @param [Configuration::Server] The server enum for which the base URI is
|
124
|
+
# required.
|
125
|
+
# @return [String] The base URI.
|
126
|
+
def get_base_uri(server = Server::DEFAULT)
|
127
|
+
self.class.environments[environment][server].clone
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# Class for exceptions when there is a network error, status code error, etc.
|
8
|
-
class APIException < StandardError
|
9
|
-
attr_reader :response, :response_code
|
10
|
-
|
11
|
-
# The constructor.
|
12
|
-
# @param [String] The reason for raising an exception.
|
13
|
-
# @param [HttpResponse] The HttpReponse of the API call.
|
14
|
-
def initialize(reason, response)
|
15
|
-
super(reason)
|
16
|
-
@response = response
|
17
|
-
@response_code = response.status_code
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Class for exceptions when there is a network error, status code error, etc.
|
8
|
+
class APIException < StandardError
|
9
|
+
attr_reader :response, :response_code
|
10
|
+
|
11
|
+
# The constructor.
|
12
|
+
# @param [String] The reason for raising an exception.
|
13
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
14
|
+
def initialize(reason, response)
|
15
|
+
super(reason)
|
16
|
+
@response = response
|
17
|
+
@response_code = response.status_code
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
# bandwidth
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Bandwidth
|
7
|
-
# Http response received.
|
8
|
-
class ApiResponse
|
9
|
-
attr_reader(:status_code, :reason_phrase, :headers, :raw_body, :request,
|
10
|
-
:data, :errors)
|
11
|
-
|
12
|
-
# The constructor
|
13
|
-
# @param [HttpResponse] The original, raw response from the api.
|
14
|
-
# @param [Object] The data field specified for the response.
|
15
|
-
# @param [Array<String>] Any errors returned by the server.
|
16
|
-
def initialize(http_response,
|
17
|
-
data: nil,
|
18
|
-
errors: nil)
|
19
|
-
@status_code = http_response.status_code
|
20
|
-
@reason_phrase = http_response.reason_phrase
|
21
|
-
@headers = http_response.headers
|
22
|
-
@raw_body = http_response.raw_body
|
23
|
-
@request = http_response.request
|
24
|
-
@data = data
|
25
|
-
@errors = errors
|
26
|
-
end
|
27
|
-
|
28
|
-
def success?
|
29
|
-
status_code >= 200 && status_code < 300
|
30
|
-
end
|
31
|
-
|
32
|
-
def error?
|
33
|
-
status_code >= 400 && status_code < 600
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Http response received.
|
8
|
+
class ApiResponse
|
9
|
+
attr_reader(:status_code, :reason_phrase, :headers, :raw_body, :request,
|
10
|
+
:data, :errors)
|
11
|
+
|
12
|
+
# The constructor
|
13
|
+
# @param [HttpResponse] The original, raw response from the api.
|
14
|
+
# @param [Object] The data field specified for the response.
|
15
|
+
# @param [Array<String>] Any errors returned by the server.
|
16
|
+
def initialize(http_response,
|
17
|
+
data: nil,
|
18
|
+
errors: nil)
|
19
|
+
@status_code = http_response.status_code
|
20
|
+
@reason_phrase = http_response.reason_phrase
|
21
|
+
@headers = http_response.headers
|
22
|
+
@raw_body = http_response.raw_body
|
23
|
+
@request = http_response.request
|
24
|
+
@data = data
|
25
|
+
@errors = errors
|
26
|
+
end
|
27
|
+
|
28
|
+
def success?
|
29
|
+
status_code >= 200 && status_code < 300
|
30
|
+
end
|
31
|
+
|
32
|
+
def error?
|
33
|
+
status_code >= 400 && status_code < 600
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module Bandwidth
|
9
|
+
# Utility class for basic authorization.
|
10
|
+
class MessagingBasicAuth
|
11
|
+
# Add basic authentication to the request.
|
12
|
+
# @param [HttpRequest] The HttpRequest object to which authentication will
|
13
|
+
# be added.
|
14
|
+
def self.apply(config, http_request)
|
15
|
+
username = config.messaging_basic_auth_user_name
|
16
|
+
password = config.messaging_basic_auth_password
|
17
|
+
value = Base64.strict_encode64("#{username}:#{password}")
|
18
|
+
header_value = "Basic #{value}"
|
19
|
+
http_request.headers['Authorization'] = header_value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|