bandwidth-sdk 0.1.0 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
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,22 +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 VoiceBasicAuth
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.voice_basic_auth_user_name
16
- password = config.voice_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
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 VoiceBasicAuth
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.voice_basic_auth_user_name
16
+ password = config.voice_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
@@ -1,64 +1,64 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- require 'faraday/http_cache'
7
- require 'faraday_middleware'
8
-
9
- module Bandwidth
10
- # An implementation of HttpClient.
11
- class FaradayClient < HttpClient
12
- # The constructor.
13
- def initialize(timeout:, max_retries:, retry_interval:,
14
- backoff_factor:, cache: false, verify: true)
15
- @connection = Faraday.new do |faraday|
16
- faraday.use Faraday::HttpCache, serializer: Marshal if cache
17
- faraday.use FaradayMiddleware::FollowRedirects
18
- faraday.request :multipart
19
- faraday.request :url_encoded
20
- faraday.ssl[:ca_file] = Certifi.where
21
- faraday.ssl[:verify] = verify
22
- faraday.request :retry, max: max_retries, interval: retry_interval,
23
- backoff_factor: backoff_factor
24
- faraday.adapter Faraday.default_adapter
25
- faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
26
- faraday.options[:timeout] = timeout if timeout > 0
27
- end
28
- end
29
-
30
- # Method overridden from HttpClient.
31
- def execute_as_string(http_request)
32
- response = @connection.send(
33
- http_request.http_method.downcase,
34
- http_request.query_url
35
- ) do |request|
36
- request.headers = http_request.headers
37
- unless http_request.parameters.empty?
38
- request.body = http_request.parameters
39
- end
40
- end
41
- convert_response(response, http_request)
42
- end
43
-
44
- # Method overridden from HttpClient.
45
- def execute_as_binary(http_request)
46
- response = @connection.send(
47
- http_request.http_method.downcase,
48
- http_request.query_url
49
- ) do |request|
50
- request.headers = http_request.headers
51
- unless http_request.parameters.empty?
52
- request.body = http_request.parameters
53
- end
54
- end
55
- convert_response(response, http_request)
56
- end
57
-
58
- # Method overridden from HttpClient.
59
- def convert_response(response, http_request)
60
- HttpResponse.new(response.status, response.reason_phrase,
61
- response.headers, response.body, http_request)
62
- end
63
- end
64
- end
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'faraday/http_cache'
7
+ require 'faraday_middleware'
8
+
9
+ module Bandwidth
10
+ # An implementation of HttpClient.
11
+ class FaradayClient < HttpClient
12
+ # The constructor.
13
+ def initialize(timeout:, max_retries:, retry_interval:,
14
+ backoff_factor:, cache: false, verify: true)
15
+ @connection = Faraday.new do |faraday|
16
+ faraday.use Faraday::HttpCache, serializer: Marshal if cache
17
+ faraday.use FaradayMiddleware::FollowRedirects
18
+ faraday.request :multipart
19
+ faraday.request :url_encoded
20
+ faraday.ssl[:ca_file] = Certifi.where
21
+ faraday.ssl[:verify] = verify
22
+ faraday.request :retry, max: max_retries, interval: retry_interval,
23
+ backoff_factor: backoff_factor
24
+ faraday.adapter Faraday.default_adapter
25
+ faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
26
+ faraday.options[:timeout] = timeout if timeout > 0
27
+ end
28
+ end
29
+
30
+ # Method overridden from HttpClient.
31
+ def execute_as_string(http_request)
32
+ response = @connection.send(
33
+ http_request.http_method.downcase,
34
+ http_request.query_url
35
+ ) do |request|
36
+ request.headers = http_request.headers
37
+ unless http_request.parameters.empty?
38
+ request.body = http_request.parameters
39
+ end
40
+ end
41
+ convert_response(response, http_request)
42
+ end
43
+
44
+ # Method overridden from HttpClient.
45
+ def execute_as_binary(http_request)
46
+ response = @connection.send(
47
+ http_request.http_method.downcase,
48
+ http_request.query_url
49
+ ) do |request|
50
+ request.headers = http_request.headers
51
+ unless http_request.parameters.empty?
52
+ request.body = http_request.parameters
53
+ end
54
+ end
55
+ convert_response(response, http_request)
56
+ end
57
+
58
+ # Method overridden from HttpClient.
59
+ def convert_response(response, http_request)
60
+ HttpResponse.new(response.status, response.reason_phrase,
61
+ response.headers, response.body, http_request)
62
+ end
63
+ end
64
+ end
@@ -1,24 +1,24 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Bandwidth
7
- # HttpCallBack allows defining callables for pre and post API calls.
8
- class HttpCallBack
9
- # A controller will call this method before making an HTTP Request.
10
- # @param [HttpRequest] The HttpRequest object which the HttpClient
11
- # will execute.
12
- def on_before_request(_http_request)
13
- raise NotImplementedError, 'This method needs
14
- to be implemented in a child class.'
15
- end
16
-
17
- # A controller will call this method after making an HTTP Request.
18
- # @param [HttpResponse] The HttpReponse of the API call.
19
- def on_after_response(_http_response)
20
- raise NotImplementedError, 'This method needs
21
- to be implemented in a child class.'
22
- end
23
- end
24
- end
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack
9
+ # A controller will call this method before making an HTTP Request.
10
+ # @param [HttpRequest] The HttpRequest object which the HttpClient
11
+ # will execute.
12
+ def on_before_request(_http_request)
13
+ raise NotImplementedError, 'This method needs
14
+ to be implemented in a child class.'
15
+ end
16
+
17
+ # A controller will call this method after making an HTTP Request.
18
+ # @param [HttpResponse] The HttpReponse of the API call.
19
+ def on_after_response(_http_response)
20
+ raise NotImplementedError, 'This method needs
21
+ to be implemented in a child class.'
22
+ end
23
+ end
24
+ end
@@ -1,104 +1,104 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Bandwidth
7
- # An interface for the methods that an HTTP Client must implement.
8
- #
9
- # This class should not be instantiated but should be used as a base class
10
- # for HTTP Client classes.
11
- class HttpClient
12
- # Execute an HttpRequest when the response is expected to be a string.
13
- # @param [HttpRequest] The HttpRequest to be executed.
14
- def execute_as_string(_http_request)
15
- raise NotImplementedError, 'This method needs
16
- to be implemented in a child class.'
17
- end
18
-
19
- # Execute an HttpRequest when the response is expected to be binary.
20
- # @param [HttpRequest] The HttpRequest to be executed.
21
- def execute_as_binary(_http_request)
22
- raise NotImplementedError, 'This method needs
23
- to be implemented in a child class.'
24
- end
25
-
26
- # Converts the HTTP Response from the client to an HttpResponse object.
27
- # @param [Dynamic] The response object received from the client.
28
- def convert_response(_response)
29
- raise NotImplementedError, 'This method needs
30
- to be implemented in a child class.'
31
- end
32
-
33
- # Get a GET HttpRequest object.
34
- # @param [String] The URL to send the request to.
35
- # @param [Hash, Optional] The headers for the HTTP Request.
36
- def get(query_url,
37
- headers: {})
38
- HttpRequest.new(HttpMethodEnum::GET,
39
- query_url,
40
- headers: headers)
41
- end
42
-
43
- # Get a HEAD HttpRequest object.
44
- # @param [String] The URL to send the request to.
45
- # @param [Hash, Optional] The headers for the HTTP Request.
46
- def head(query_url,
47
- headers: {})
48
- HttpRequest.new(HttpMethodEnum::HEAD,
49
- query_url,
50
- headers: headers)
51
- end
52
-
53
- # Get a POST HttpRequest object.
54
- # @param [String] The URL to send the request to.
55
- # @param [Hash, Optional] The headers for the HTTP Request.
56
- # @param [Hash, Optional] The parameters for the HTTP Request.
57
- def post(query_url,
58
- headers: {},
59
- parameters: {})
60
- HttpRequest.new(HttpMethodEnum::POST,
61
- query_url,
62
- headers: headers,
63
- parameters: parameters)
64
- end
65
-
66
- # Get a PUT HttpRequest object.
67
- # @param [String] The URL to send the request to.
68
- # @param [Hash, Optional] The headers for the HTTP Request.
69
- # @param [Hash, Optional] The parameters for the HTTP Request.
70
- def put(query_url,
71
- headers: {},
72
- parameters: {})
73
- HttpRequest.new(HttpMethodEnum::PUT,
74
- query_url,
75
- headers: headers,
76
- parameters: parameters)
77
- end
78
-
79
- # Get a PATCH HttpRequest object.
80
- # @param [String] The URL to send the request to.
81
- # @param [Hash, Optional] The headers for the HTTP Request.
82
- # @param [Hash, Optional] The parameters for the HTTP Request.
83
- def patch(query_url,
84
- headers: {},
85
- parameters: {})
86
- HttpRequest.new(HttpMethodEnum::PATCH,
87
- query_url,
88
- headers: headers,
89
- parameters: parameters)
90
- end
91
-
92
- # Get a DELETE HttpRequest object.
93
- # @param [String] The URL to send the request to.
94
- # @param [Hash, Optional] The headers for the HTTP Request.
95
- def delete(query_url,
96
- headers: {},
97
- parameters: {})
98
- HttpRequest.new(HttpMethodEnum::DELETE,
99
- query_url,
100
- headers: headers,
101
- parameters: parameters)
102
- end
103
- end
104
- end
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # An interface for the methods that an HTTP Client must implement.
8
+ #
9
+ # This class should not be instantiated but should be used as a base class
10
+ # for HTTP Client classes.
11
+ class HttpClient
12
+ # Execute an HttpRequest when the response is expected to be a string.
13
+ # @param [HttpRequest] The HttpRequest to be executed.
14
+ def execute_as_string(_http_request)
15
+ raise NotImplementedError, 'This method needs
16
+ to be implemented in a child class.'
17
+ end
18
+
19
+ # Execute an HttpRequest when the response is expected to be binary.
20
+ # @param [HttpRequest] The HttpRequest to be executed.
21
+ def execute_as_binary(_http_request)
22
+ raise NotImplementedError, 'This method needs
23
+ to be implemented in a child class.'
24
+ end
25
+
26
+ # Converts the HTTP Response from the client to an HttpResponse object.
27
+ # @param [Dynamic] The response object received from the client.
28
+ def convert_response(_response)
29
+ raise NotImplementedError, 'This method needs
30
+ to be implemented in a child class.'
31
+ end
32
+
33
+ # Get a GET HttpRequest object.
34
+ # @param [String] The URL to send the request to.
35
+ # @param [Hash, Optional] The headers for the HTTP Request.
36
+ def get(query_url,
37
+ headers: {})
38
+ HttpRequest.new(HttpMethodEnum::GET,
39
+ query_url,
40
+ headers: headers)
41
+ end
42
+
43
+ # Get a HEAD HttpRequest object.
44
+ # @param [String] The URL to send the request to.
45
+ # @param [Hash, Optional] The headers for the HTTP Request.
46
+ def head(query_url,
47
+ headers: {})
48
+ HttpRequest.new(HttpMethodEnum::HEAD,
49
+ query_url,
50
+ headers: headers)
51
+ end
52
+
53
+ # Get a POST HttpRequest object.
54
+ # @param [String] The URL to send the request to.
55
+ # @param [Hash, Optional] The headers for the HTTP Request.
56
+ # @param [Hash, Optional] The parameters for the HTTP Request.
57
+ def post(query_url,
58
+ headers: {},
59
+ parameters: {})
60
+ HttpRequest.new(HttpMethodEnum::POST,
61
+ query_url,
62
+ headers: headers,
63
+ parameters: parameters)
64
+ end
65
+
66
+ # Get a PUT HttpRequest object.
67
+ # @param [String] The URL to send the request to.
68
+ # @param [Hash, Optional] The headers for the HTTP Request.
69
+ # @param [Hash, Optional] The parameters for the HTTP Request.
70
+ def put(query_url,
71
+ headers: {},
72
+ parameters: {})
73
+ HttpRequest.new(HttpMethodEnum::PUT,
74
+ query_url,
75
+ headers: headers,
76
+ parameters: parameters)
77
+ end
78
+
79
+ # Get a PATCH HttpRequest object.
80
+ # @param [String] The URL to send the request to.
81
+ # @param [Hash, Optional] The headers for the HTTP Request.
82
+ # @param [Hash, Optional] The parameters for the HTTP Request.
83
+ def patch(query_url,
84
+ headers: {},
85
+ parameters: {})
86
+ HttpRequest.new(HttpMethodEnum::PATCH,
87
+ query_url,
88
+ headers: headers,
89
+ parameters: parameters)
90
+ end
91
+
92
+ # Get a DELETE HttpRequest object.
93
+ # @param [String] The URL to send the request to.
94
+ # @param [Hash, Optional] The headers for the HTTP Request.
95
+ def delete(query_url,
96
+ headers: {},
97
+ parameters: {})
98
+ HttpRequest.new(HttpMethodEnum::DELETE,
99
+ query_url,
100
+ headers: headers,
101
+ parameters: parameters)
102
+ end
103
+ end
104
+ end
@@ -1,13 +1,13 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Bandwidth
7
- # HTTP Methods Enumeration.
8
- class HttpMethodEnum
9
- HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
- PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
- DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
- end
13
- end
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum
9
+ HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
+ PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
+ DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
+ end
13
+ end