bandwidth-sdk 2.2.2 → 3.4.0

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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth.rb +2 -1
  3. data/lib/bandwidth/client.rb +9 -0
  4. data/lib/bandwidth/configuration.rb +22 -4
  5. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  6. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +4 -0
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +30 -83
  9. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  10. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  11. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +19 -0
  12. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +44 -0
  13. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +129 -0
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +62 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +71 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  20. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  21. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  22. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +2 -1
  23. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  24. data/lib/bandwidth/voice_lib/voice.rb +2 -0
  25. data/lib/bandwidth/voice_lib/voice/client.rb +4 -0
  26. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +145 -78
  27. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  28. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  29. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  30. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
  31. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
  32. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
  33. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  34. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
  35. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
  36. metadata +18 -7
  37. data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +0 -49
  38. data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +0 -44
@@ -13,7 +13,7 @@ module Bandwidth
13
13
  @http_call_back = http_call_back
14
14
 
15
15
  @global_headers = {
16
- 'user-agent' => 'APIMATIC 2.0'
16
+ 'user-agent' => 'ruby-sdk-refs/tags/ruby3.4.0'
17
17
  }
18
18
  end
19
19
 
@@ -4,8 +4,8 @@
4
4
  # ( https://apimatic.io ).
5
5
 
6
6
  module Bandwidth
7
- # GenericClientException class.
8
- class GenericClientException < APIException
7
+ # MessagingException class.
8
+ class MessagingException < APIException
9
9
  # TODO: Write general description for this method
10
10
  # @return [String]
11
11
  attr_accessor :type
@@ -14,10 +14,6 @@ module Bandwidth
14
14
  # @return [String]
15
15
  attr_accessor :description
16
16
 
17
- # TODO: Write general description for this method
18
- # @return [List of FieldError]
19
- attr_accessor :field_errors
20
-
21
17
  # The constructor.
22
18
  # @param [String] The reason for raising an exception.
23
19
  # @param [HttpResponse] The HttpReponse of the API call.
@@ -33,14 +29,6 @@ module Bandwidth
33
29
  def unbox(hash)
34
30
  @type = hash['type']
35
31
  @description = hash['description']
36
- # Parameter is an array, so we need to iterate through it
37
- @field_errors = nil
38
- unless hash['fieldErrors'].nil?
39
- @field_errors = []
40
- hash['fieldErrors'].each do |structure|
41
- @field_errors << (FieldError.from_hash(structure) if structure)
42
- end
43
- end
44
32
  end
45
33
  end
46
34
  end
@@ -0,0 +1,19 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+
7
+ require_relative 'two_factor_auth/client.rb'
8
+
9
+ # Models
10
+ require_relative 'two_factor_auth/models/two_factor_code_request_schema.rb'
11
+ require_relative 'two_factor_auth/models/two_factor_voice_response.rb'
12
+ require_relative 'two_factor_auth/models/two_factor_messaging_response.rb'
13
+ require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb'
14
+ require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb'
15
+
16
+ # Exceptions
17
+ # Controllers
18
+ require_relative 'two_factor_auth/controllers/base_controller.rb'
19
+ require_relative 'two_factor_auth/controllers/api_controller.rb'
@@ -0,0 +1,44 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ module TwoFactorAuth
8
+ # bandwidth client class.
9
+ class Client
10
+ attr_reader :config
11
+
12
+ # Access to client controller.
13
+ # @return [APIController] Returns the controller instance.
14
+ def client
15
+ @client ||= APIController.new config
16
+ end
17
+
18
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
19
+ backoff_factor: 1, environment: Environment::PRODUCTION,
20
+ messaging_basic_auth_user_name: 'TODO: Replace',
21
+ messaging_basic_auth_password: 'TODO: Replace',
22
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
24
+ voice_basic_auth_user_name: 'TODO: Replace',
25
+ voice_basic_auth_password: 'TODO: Replace', config: nil)
26
+ @config = if config.nil?
27
+ Configuration.new(timeout: timeout,
28
+ 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
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
35
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
36
+ voice_basic_auth_user_name: voice_basic_auth_user_name,
37
+ voice_basic_auth_password: voice_basic_auth_password)
38
+ else
39
+ config
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,129 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ module TwoFactorAuth
8
+ # APIController
9
+ class APIController < BaseController
10
+ def initialize(config, http_call_back: nil)
11
+ super(config, http_call_back: http_call_back)
12
+ end
13
+
14
+ # Two-Factor authentication with Bandwidth Voice services
15
+ # @param [String] account_id Required parameter: Bandwidth Account ID with
16
+ # Voice service enabled
17
+ # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
18
+ # @return [TwoFactorVoiceResponse] response from the API call
19
+ def create_voice_two_factor(account_id,
20
+ body)
21
+ # Prepare query url.
22
+ _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
23
+ _query_builder << '/accounts/{accountId}/code/voice'
24
+ _query_builder = APIHelper.append_url_with_template_parameters(
25
+ _query_builder,
26
+ 'accountId' => account_id
27
+ )
28
+ _query_url = APIHelper.clean_url _query_builder
29
+
30
+ # Prepare headers.
31
+ _headers = {
32
+ 'accept' => 'application/json',
33
+ 'content-type' => 'application/json; charset=utf-8'
34
+ }
35
+
36
+ # Prepare and execute HttpRequest.
37
+ _request = config.http_client.post(
38
+ _query_url,
39
+ headers: _headers,
40
+ parameters: body.to_json
41
+ )
42
+ TwoFactorAuthBasicAuth.apply(config, _request)
43
+ _response = execute_request(_request)
44
+ validate_response(_response)
45
+
46
+ # Return appropriate response type.
47
+ decoded = APIHelper.json_deserialize(_response.raw_body)
48
+ ApiResponse.new(_response,
49
+ data: TwoFactorVoiceResponse.from_hash(decoded))
50
+ end
51
+
52
+ # Two-Factor authentication with Bandwidth messaging services
53
+ # @param [String] account_id Required parameter: Bandwidth Account ID with
54
+ # Messaging service enabled
55
+ # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
56
+ # @return [TwoFactorMessagingResponse] response from the API call
57
+ def create_messaging_two_factor(account_id,
58
+ body)
59
+ # Prepare query url.
60
+ _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
61
+ _query_builder << '/accounts/{accountId}/code/messaging'
62
+ _query_builder = APIHelper.append_url_with_template_parameters(
63
+ _query_builder,
64
+ 'accountId' => account_id
65
+ )
66
+ _query_url = APIHelper.clean_url _query_builder
67
+
68
+ # Prepare headers.
69
+ _headers = {
70
+ 'accept' => 'application/json',
71
+ 'content-type' => 'application/json; charset=utf-8'
72
+ }
73
+
74
+ # Prepare and execute HttpRequest.
75
+ _request = config.http_client.post(
76
+ _query_url,
77
+ headers: _headers,
78
+ parameters: body.to_json
79
+ )
80
+ TwoFactorAuthBasicAuth.apply(config, _request)
81
+ _response = execute_request(_request)
82
+ validate_response(_response)
83
+
84
+ # Return appropriate response type.
85
+ decoded = APIHelper.json_deserialize(_response.raw_body)
86
+ ApiResponse.new(_response,
87
+ data: TwoFactorMessagingResponse.from_hash(decoded))
88
+ end
89
+
90
+ # Verify a previously sent two-factor authentication code
91
+ # @param [String] account_id Required parameter: Bandwidth Account ID with
92
+ # Two-Factor enabled
93
+ # @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
94
+ # @return [TwoFactorVerifyCodeResponse] response from the API call
95
+ def create_verify_two_factor(account_id,
96
+ body)
97
+ # Prepare query url.
98
+ _query_builder = config.get_base_uri(Server::TWOFACTORAUTHDEFAULT)
99
+ _query_builder << '/accounts/{accountId}/code/verify'
100
+ _query_builder = APIHelper.append_url_with_template_parameters(
101
+ _query_builder,
102
+ 'accountId' => account_id
103
+ )
104
+ _query_url = APIHelper.clean_url _query_builder
105
+
106
+ # Prepare headers.
107
+ _headers = {
108
+ 'accept' => 'application/json',
109
+ 'content-type' => 'application/json; charset=utf-8'
110
+ }
111
+
112
+ # Prepare and execute HttpRequest.
113
+ _request = config.http_client.post(
114
+ _query_url,
115
+ headers: _headers,
116
+ parameters: body.to_json
117
+ )
118
+ TwoFactorAuthBasicAuth.apply(config, _request)
119
+ _response = execute_request(_request)
120
+ validate_response(_response)
121
+
122
+ # Return appropriate response type.
123
+ decoded = APIHelper.json_deserialize(_response.raw_body)
124
+ ApiResponse.new(_response,
125
+ data: TwoFactorVerifyCodeResponse.from_hash(decoded))
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,49 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # BaseController.
8
+ class BaseController
9
+ attr_accessor :config, :http_call_back
10
+
11
+ def initialize(config, http_call_back: nil)
12
+ @config = config
13
+ @http_call_back = http_call_back
14
+
15
+ @global_headers = {
16
+ 'user-agent' => 'ruby-sdk-refs/tags/ruby3.4.0'
17
+ }
18
+ end
19
+
20
+ def validate_parameters(args)
21
+ args.each do |_name, value|
22
+ if value.nil?
23
+ raise ArgumentError, "Required parameter #{_name} cannot be nil."
24
+ end
25
+ end
26
+ end
27
+
28
+ def execute_request(request, binary: false)
29
+ @http_call_back.on_before_request(request) if @http_call_back
30
+
31
+ APIHelper.clean_hash(request.headers)
32
+ request.headers.merge!(@global_headers)
33
+
34
+ response = if binary
35
+ config.http_client.execute_as_binary(request)
36
+ else
37
+ config.http_client.execute_as_string(request)
38
+ end
39
+ @http_call_back.on_after_response(response) if @http_call_back
40
+
41
+ response
42
+ end
43
+
44
+ def validate_response(response)
45
+ raise APIException.new 'HTTP Response Not OK', response unless
46
+ response.status_code.between?(200, 208) # [200,208] = HTTP OK
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,62 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # TwoFactorCodeRequestSchema Model.
8
+ class TwoFactorCodeRequestSchema < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [String]
11
+ attr_accessor :to
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [String]
15
+ attr_accessor :from
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [String]
19
+ attr_accessor :application_id
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [String]
23
+ attr_accessor :scope
24
+
25
+ # A mapping from model property names to API property names.
26
+ def self.names
27
+ @_hash = {} if @_hash.nil?
28
+ @_hash['to'] = 'to'
29
+ @_hash['from'] = 'from'
30
+ @_hash['application_id'] = 'applicationId'
31
+ @_hash['scope'] = 'scope'
32
+ @_hash
33
+ end
34
+
35
+ def initialize(to = nil,
36
+ from = nil,
37
+ application_id = nil,
38
+ scope = nil)
39
+ @to = to
40
+ @from = from
41
+ @application_id = application_id
42
+ @scope = scope
43
+ end
44
+
45
+ # Creates an instance of the object from a hash.
46
+ def self.from_hash(hash)
47
+ return nil unless hash
48
+
49
+ # Extract variables from the hash.
50
+ to = hash['to']
51
+ from = hash['from']
52
+ application_id = hash['applicationId']
53
+ scope = hash['scope']
54
+
55
+ # Create object from extracted values.
56
+ TwoFactorCodeRequestSchema.new(to,
57
+ from,
58
+ application_id,
59
+ scope)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,35 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # TwoFactorMessagingResponse Model.
8
+ class TwoFactorMessagingResponse < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [String]
11
+ attr_accessor :message_id
12
+
13
+ # A mapping from model property names to API property names.
14
+ def self.names
15
+ @_hash = {} if @_hash.nil?
16
+ @_hash['message_id'] = 'messageId'
17
+ @_hash
18
+ end
19
+
20
+ def initialize(message_id = nil)
21
+ @message_id = message_id
22
+ end
23
+
24
+ # Creates an instance of the object from a hash.
25
+ def self.from_hash(hash)
26
+ return nil unless hash
27
+
28
+ # Extract variables from the hash.
29
+ message_id = hash['messageId']
30
+
31
+ # Create object from extracted values.
32
+ TwoFactorMessagingResponse.new(message_id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # TwoFactorVerifyCodeResponse Model.
8
+ class TwoFactorVerifyCodeResponse < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [Boolean]
11
+ attr_accessor :valid
12
+
13
+ # A mapping from model property names to API property names.
14
+ def self.names
15
+ @_hash = {} if @_hash.nil?
16
+ @_hash['valid'] = 'valid'
17
+ @_hash
18
+ end
19
+
20
+ def initialize(valid = nil)
21
+ @valid = valid
22
+ end
23
+
24
+ # Creates an instance of the object from a hash.
25
+ def self.from_hash(hash)
26
+ return nil unless hash
27
+
28
+ # Extract variables from the hash.
29
+ valid = hash['valid']
30
+
31
+ # Create object from extracted values.
32
+ TwoFactorVerifyCodeResponse.new(valid)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,71 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # TwoFactorVerifyRequestSchema Model.
8
+ class TwoFactorVerifyRequestSchema < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [String]
11
+ attr_accessor :to
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [String]
15
+ attr_accessor :from
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [String]
19
+ attr_accessor :application_id
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [String]
23
+ attr_accessor :scope
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [String]
27
+ attr_accessor :code
28
+
29
+ # A mapping from model property names to API property names.
30
+ def self.names
31
+ @_hash = {} if @_hash.nil?
32
+ @_hash['to'] = 'to'
33
+ @_hash['from'] = 'from'
34
+ @_hash['application_id'] = 'applicationId'
35
+ @_hash['scope'] = 'scope'
36
+ @_hash['code'] = 'code'
37
+ @_hash
38
+ end
39
+
40
+ def initialize(to = nil,
41
+ from = nil,
42
+ application_id = nil,
43
+ scope = nil,
44
+ code = nil)
45
+ @to = to
46
+ @from = from
47
+ @application_id = application_id
48
+ @scope = scope
49
+ @code = code
50
+ end
51
+
52
+ # Creates an instance of the object from a hash.
53
+ def self.from_hash(hash)
54
+ return nil unless hash
55
+
56
+ # Extract variables from the hash.
57
+ to = hash['to']
58
+ from = hash['from']
59
+ application_id = hash['applicationId']
60
+ scope = hash['scope']
61
+ code = hash['code']
62
+
63
+ # Create object from extracted values.
64
+ TwoFactorVerifyRequestSchema.new(to,
65
+ from,
66
+ application_id,
67
+ scope,
68
+ code)
69
+ end
70
+ end
71
+ end