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.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +27 -27
  3. data/README.md +115 -1
  4. data/lib/bandwidth.rb +39 -37
  5. data/lib/bandwidth/api_helper.rb +280 -280
  6. data/lib/bandwidth/client.rb +41 -32
  7. data/lib/bandwidth/configuration.rb +130 -111
  8. data/lib/bandwidth/exceptions/api_exception.rb +20 -20
  9. data/lib/bandwidth/http/api_response.rb +36 -36
  10. data/lib/bandwidth/http/auth/messaging_basic_auth.rb +22 -0
  11. data/lib/bandwidth/http/auth/voice_basic_auth.rb +22 -22
  12. data/lib/bandwidth/http/faraday_client.rb +64 -64
  13. data/lib/bandwidth/http/http_call_back.rb +24 -24
  14. data/lib/bandwidth/http/http_client.rb +104 -104
  15. data/lib/bandwidth/http/http_method_enum.rb +13 -13
  16. data/lib/bandwidth/http/http_request.rb +50 -50
  17. data/lib/bandwidth/http/http_response.rb +29 -29
  18. data/lib/bandwidth/messaging_lib/messaging.rb +23 -0
  19. data/lib/bandwidth/messaging_lib/messaging/client.rb +40 -0
  20. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +406 -0
  21. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +49 -0
  22. data/lib/bandwidth/messaging_lib/messaging/exceptions/generic_client_exception.rb +46 -0
  23. data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +49 -0
  24. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +80 -0
  25. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +125 -0
  26. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +44 -0
  27. data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +44 -0
  28. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +123 -0
  29. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +80 -0
  30. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +44 -0
  31. data/lib/bandwidth/models/base_model.rb +36 -36
  32. data/lib/bandwidth/voice_lib/bxml/bxml.rb +40 -0
  33. data/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +19 -0
  34. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +38 -0
  35. data/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +15 -0
  36. data/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +16 -0
  37. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +19 -0
  38. data/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +18 -0
  39. data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +21 -0
  40. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +14 -0
  41. data/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +19 -0
  42. data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +38 -0
  43. data/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +27 -0
  44. data/lib/bandwidth/voice_lib/voice.rb +27 -23
  45. data/lib/bandwidth/voice_lib/voice/client.rb +40 -36
  46. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +184 -0
  47. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +49 -49
  48. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb +51 -0
  49. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_not_found_exception.rb +49 -0
  50. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_rate_limit_error_exception.rb +56 -0
  51. data/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +35 -35
  52. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +116 -116
  53. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +125 -125
  54. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +80 -80
  55. data/lib/bandwidth/voice_lib/voice/models/bandwidth_callback_message_voice.rb +98 -98
  56. data/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +35 -35
  57. data/lib/bandwidth/voice_lib/voice/models/field_error.rb +44 -0
  58. data/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +35 -35
  59. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +17 -17
  60. metadata +36 -47
  61. data/lib/bandwidth/voice_lib/voice/bxml/bxml.rb +0 -36
  62. data/lib/bandwidth/voice_lib/voice/bxml/verbs/forward.rb +0 -19
  63. data/lib/bandwidth/voice_lib/voice/bxml/verbs/gather.rb +0 -37
  64. data/lib/bandwidth/voice_lib/voice/bxml/verbs/hangup.rb +0 -14
  65. data/lib/bandwidth/voice_lib/voice/bxml/verbs/pause.rb +0 -15
  66. data/lib/bandwidth/voice_lib/voice/bxml/verbs/phone_number.rb +0 -18
  67. data/lib/bandwidth/voice_lib/voice/bxml/verbs/play_audio.rb +0 -17
  68. data/lib/bandwidth/voice_lib/voice/bxml/verbs/redirect.rb +0 -20
  69. data/lib/bandwidth/voice_lib/voice/bxml/verbs/send_dtmf.rb +0 -12
  70. data/lib/bandwidth/voice_lib/voice/bxml/verbs/speak_sentence.rb +0 -18
  71. data/lib/bandwidth/voice_lib/voice/bxml/verbs/transfer.rb +0 -37
  72. data/lib/bandwidth/voice_lib/voice/bxml/verbs/xml_verb.rb +0 -26
  73. data/lib/bandwidth/voice_lib/voice/controllers/calls_controller.rb +0 -88
@@ -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 voice_client controller.
11
- # @return [Voice::Client] Returns the client instance.
12
- def voice_client
13
- @voice_client ||= Voice::Client.new(config: config)
14
- end
15
-
16
- def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
17
- backoff_factor: 1, environment: Environment::PRODUCTION,
18
- voice_basic_auth_user_name: 'TODO: Replace',
19
- voice_basic_auth_password: 'TODO: Replace', config: nil)
20
- @config = if config.nil?
21
- Configuration.new(timeout: timeout, max_retries: max_retries,
22
- retry_interval: retry_interval,
23
- backoff_factor: backoff_factor,
24
- environment: environment,
25
- voice_basic_auth_user_name: voice_basic_auth_user_name,
26
- voice_basic_auth_password: voice_basic_auth_password)
27
- else
28
- config
29
- end
30
- end
31
- end
32
- end
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
- VOICEDEFAULT = 'VoiceDefault'.freeze
19
- ].freeze
20
- end
21
-
22
- # All configuration including auth info and base URI for the API access
23
- # are configured in this class.
24
- class Configuration
25
- # The attribute readers for properties.
26
- attr_reader :http_client
27
- attr_reader :timeout
28
- attr_reader :max_retries
29
- attr_reader :retry_interval
30
- attr_reader :backoff_factor
31
- attr_reader :environment
32
- attr_reader :voice_basic_auth_user_name
33
- attr_reader :voice_basic_auth_password
34
-
35
- class << self
36
- attr_reader :environments
37
- end
38
-
39
- def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
40
- backoff_factor: 1, environment: Environment::PRODUCTION,
41
- voice_basic_auth_user_name: 'TODO: Replace',
42
- voice_basic_auth_password: 'TODO: Replace')
43
- # The value to use for connection timeout
44
- @timeout = timeout
45
-
46
- # The number of times to retry an endpoint call if it fails
47
- @max_retries = max_retries
48
-
49
- # Pause in seconds between retries
50
- @retry_interval = retry_interval
51
-
52
- # The amount to multiply each successive retry's interval amount
53
- # by in order to provide backoff
54
- @backoff_factor = backoff_factor
55
-
56
- # Current API environment
57
- @environment = environment
58
-
59
- # The username to use with basic authentication
60
- @voice_basic_auth_user_name = voice_basic_auth_user_name
61
-
62
- # The password to use with basic authentication
63
- @voice_basic_auth_password = voice_basic_auth_password
64
-
65
- # The Http Client to use for making requests.
66
- @http_client = create_http_client
67
- end
68
-
69
- def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
70
- backoff_factor: nil, environment: nil,
71
- voice_basic_auth_user_name: nil,
72
- voice_basic_auth_password: nil)
73
- timeout ||= self.timeout
74
- max_retries ||= self.max_retries
75
- retry_interval ||= self.retry_interval
76
- backoff_factor ||= self.backoff_factor
77
- environment ||= self.environment
78
- voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
79
- voice_basic_auth_password ||= self.voice_basic_auth_password
80
-
81
- Configuration.new(timeout: timeout, max_retries: max_retries,
82
- retry_interval: retry_interval,
83
- backoff_factor: backoff_factor,
84
- environment: environment,
85
- voice_basic_auth_user_name: voice_basic_auth_user_name,
86
- voice_basic_auth_password: voice_basic_auth_password)
87
- end
88
-
89
- def create_http_client
90
- FaradayClient.new(timeout: timeout, max_retries: max_retries,
91
- retry_interval: retry_interval,
92
- backoff_factor: backoff_factor)
93
- end
94
-
95
- # All the environments the SDK can run in.
96
- @environments = {
97
- Environment::PRODUCTION => {
98
- Server::DEFAULT => 'api.bandwidth.com',
99
- Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
100
- }
101
- }
102
-
103
- # Generates the appropriate base URI for the environment and the server.
104
- # @param [Configuration::Server] The server enum for which the base URI is
105
- # required.
106
- # @return [String] The base URI.
107
- def get_base_uri(server = Server::DEFAULT)
108
- self.class.environments[environment][server].clone
109
- end
110
- end
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