bandwidth-sdk 2.1.1 → 3.7.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +85 -70
  3. data/lib/bandwidth.rb +7 -1
  4. data/lib/bandwidth/client.rb +20 -2
  5. data/lib/bandwidth/configuration.rb +45 -9
  6. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  7. data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
  8. data/lib/bandwidth/http/faraday_client.rb +2 -6
  9. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  10. data/lib/bandwidth/messaging_lib/messaging/client.rb +11 -2
  11. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +45 -88
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  13. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +20 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +49 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +153 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
  20. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  21. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  22. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +94 -0
  23. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  24. data/lib/bandwidth/utilities/file_wrapper.rb +17 -0
  25. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
  26. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  27. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  28. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +2 -0
  29. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +5 -1
  30. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  31. data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
  32. data/lib/bandwidth/voice_lib/voice.rb +13 -4
  33. data/lib/bandwidth/voice_lib/voice/client.rb +11 -2
  34. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +629 -112
  35. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  36. data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
  37. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +11 -2
  38. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
  39. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  40. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +1 -1
  41. data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +71 -0
  42. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  43. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
  44. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
  45. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
  46. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +35 -25
  47. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
  48. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
  49. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
  50. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +26 -0
  51. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  52. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
  53. data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
  54. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
  55. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
  56. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
  57. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
  58. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +682 -0
  59. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
  60. data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
  61. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
  67. metadata +58 -11
  68. data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
  69. data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
  70. data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
@@ -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.7.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,29 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # InvalidRequest class.
8
+ class InvalidRequestException < APIException
9
+ # An error message pertaining to what the issue could be
10
+ # @return [String]
11
+ attr_accessor :result
12
+
13
+ # The constructor.
14
+ # @param [String] The reason for raising an exception.
15
+ # @param [HttpResponse] The HttpReponse of the API call.
16
+ def initialize(reason, response)
17
+ super(reason, response)
18
+ hash = APIHelper.json_deserialize(@response.raw_body)
19
+ unbox(hash)
20
+ end
21
+
22
+ # Populates this object by extracting properties from a hash.
23
+ # @param [Hash] The deserialized response sent by the server in the
24
+ # response body.
25
+ def unbox(hash)
26
+ @result = hash['result']
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,88 @@
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
+ # The phone number to send the 2fa code to.
10
+ # @return [String]
11
+ attr_accessor :to
12
+
13
+ # The application phone number, the sender of the 2fa code.
14
+ # @return [String]
15
+ attr_accessor :from
16
+
17
+ # The application unique ID, obtained from Bandwidth.
18
+ # @return [String]
19
+ attr_accessor :application_id
20
+
21
+ # An optional field to denote what scope or action the 2fa code is
22
+ # addressing. If not supplied, defaults to "2FA".
23
+ # @return [String]
24
+ attr_accessor :scope
25
+
26
+ # The message format of the 2fa code. There are three values that the
27
+ # system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" and
28
+ # "{NAME} value template are optional, while "{CODE}" must be supplied. As
29
+ # the name would suggest, code will be replace with the actual 2fa code.
30
+ # Name is replaced with the application name, configured during provisioning
31
+ # of 2fa. The scope value is the same value sent during the call and
32
+ # partitioned by the server.
33
+ # @return [String]
34
+ attr_accessor :message
35
+
36
+ # The number of digits for your 2fa code. The valid number ranges from 2 to
37
+ # 8, inclusively.
38
+ # @return [Float]
39
+ attr_accessor :digits
40
+
41
+ # A mapping from model property names to API property names.
42
+ def self.names
43
+ @_hash = {} if @_hash.nil?
44
+ @_hash['to'] = 'to'
45
+ @_hash['from'] = 'from'
46
+ @_hash['application_id'] = 'applicationId'
47
+ @_hash['scope'] = 'scope'
48
+ @_hash['message'] = 'message'
49
+ @_hash['digits'] = 'digits'
50
+ @_hash
51
+ end
52
+
53
+ def initialize(to = nil,
54
+ from = nil,
55
+ application_id = nil,
56
+ message = nil,
57
+ digits = nil,
58
+ scope = nil)
59
+ @to = to
60
+ @from = from
61
+ @application_id = application_id
62
+ @scope = scope
63
+ @message = message
64
+ @digits = digits
65
+ end
66
+
67
+ # Creates an instance of the object from a hash.
68
+ def self.from_hash(hash)
69
+ return nil unless hash
70
+
71
+ # Extract variables from the hash.
72
+ to = hash['to']
73
+ from = hash['from']
74
+ application_id = hash['applicationId']
75
+ message = hash['message']
76
+ digits = hash['digits']
77
+ scope = hash['scope']
78
+
79
+ # Create object from extracted values.
80
+ TwoFactorCodeRequestSchema.new(to,
81
+ from,
82
+ application_id,
83
+ message,
84
+ digits,
85
+ scope)
86
+ end
87
+ end
88
+ 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,94 @@
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
+ # The phone number to send the 2fa code to.
10
+ # @return [String]
11
+ attr_accessor :to
12
+
13
+ # The application phone number, the sender of the 2fa code.
14
+ # @return [String]
15
+ attr_accessor :from
16
+
17
+ # The application unique ID, obtained from Bandwidth.
18
+ # @return [String]
19
+ attr_accessor :application_id
20
+
21
+ # An optional field to denote what scope or action the 2fa code is
22
+ # addressing. If not supplied, defaults to "2FA".
23
+ # @return [String]
24
+ attr_accessor :scope
25
+
26
+ # The number of digits for your 2fa code. The valid number ranges from 2 to
27
+ # 8, inclusively.
28
+ # @return [Float]
29
+ attr_accessor :digits
30
+
31
+ # The time period, in minutes, to validate the 2fa code. By setting this to
32
+ # 3 minutes, it will mean any code generated within the last 3 minutes are
33
+ # still valid. The valid range for expiration time is between 0 and 15
34
+ # minutes, exclusively and inclusively, respectively.
35
+ # @return [Float]
36
+ attr_accessor :expiration_time_in_minutes
37
+
38
+ # The generated 2fa code to check if valid
39
+ # @return [String]
40
+ attr_accessor :code
41
+
42
+ # A mapping from model property names to API property names.
43
+ def self.names
44
+ @_hash = {} if @_hash.nil?
45
+ @_hash['to'] = 'to'
46
+ @_hash['from'] = 'from'
47
+ @_hash['application_id'] = 'applicationId'
48
+ @_hash['scope'] = 'scope'
49
+ @_hash['digits'] = 'digits'
50
+ @_hash['expiration_time_in_minutes'] = 'expirationTimeInMinutes'
51
+ @_hash['code'] = 'code'
52
+ @_hash
53
+ end
54
+
55
+ def initialize(to = nil,
56
+ from = nil,
57
+ application_id = nil,
58
+ digits = nil,
59
+ expiration_time_in_minutes = nil,
60
+ code = nil,
61
+ scope = nil)
62
+ @to = to
63
+ @from = from
64
+ @application_id = application_id
65
+ @scope = scope
66
+ @digits = digits
67
+ @expiration_time_in_minutes = expiration_time_in_minutes
68
+ @code = code
69
+ end
70
+
71
+ # Creates an instance of the object from a hash.
72
+ def self.from_hash(hash)
73
+ return nil unless hash
74
+
75
+ # Extract variables from the hash.
76
+ to = hash['to']
77
+ from = hash['from']
78
+ application_id = hash['applicationId']
79
+ digits = hash['digits']
80
+ expiration_time_in_minutes = hash['expirationTimeInMinutes']
81
+ code = hash['code']
82
+ scope = hash['scope']
83
+
84
+ # Create object from extracted values.
85
+ TwoFactorVerifyRequestSchema.new(to,
86
+ from,
87
+ application_id,
88
+ digits,
89
+ expiration_time_in_minutes,
90
+ code,
91
+ scope)
92
+ end
93
+ end
94
+ 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
+ # TwoFactorVoiceResponse Model.
8
+ class TwoFactorVoiceResponse < BaseModel
9
+ # TODO: Write general description for this method
10
+ # @return [String]
11
+ attr_accessor :call_id
12
+
13
+ # A mapping from model property names to API property names.
14
+ def self.names
15
+ @_hash = {} if @_hash.nil?
16
+ @_hash['call_id'] = 'callId'
17
+ @_hash
18
+ end
19
+
20
+ def initialize(call_id = nil)
21
+ @call_id = call_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
+ call_id = hash['callId']
30
+
31
+ # Create object from extracted values.
32
+ TwoFactorVoiceResponse.new(call_id)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # A utility to allow users to set the content-type for files
8
+ class FileWrapper
9
+ attr_reader :content_type
10
+ attr_reader :file
11
+
12
+ def initialize(file, content_type: 'application/octet-stream')
13
+ @file = file
14
+ @content_type = content_type
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # The Bridge verb allows you to connect 2 calls
6
+ class Bridge
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ xml.Bridge(call_id, compact_hash({
11
+ 'bridgeCompleteUrl' => bridge_complete_url,
12
+ 'bridgeCompleteMethod' => bridge_complete_method,
13
+ 'bridgeTargetCompleteUrl' => bridge_target_complete_url,
14
+ 'bridgeTargetCompleteMethod' => bridge_target_complete_method,
15
+ 'username' => username,
16
+ 'password' => password,
17
+ 'tag' => tag
18
+ }))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,28 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # The Conference verb is used to add callees to conferences
6
+ class Conference
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ if not call_ids_to_coach.nil?
11
+ coach_ids = call_ids_to_coach.instance_of?(String) ? call_ids_to_coach : call_ids_to_coach.join(",")
12
+ else
13
+ coach_ids = nil
14
+ end
15
+ xml.Conference(conference_name, compact_hash({
16
+ 'mute' => mute,
17
+ 'hold' => hold,
18
+ 'callIdsToCoach' => coach_ids,
19
+ 'conferenceEventUrl' => conference_event_url,
20
+ 'conferenceEventMethod' => conference_event_method,
21
+ 'username' => username,
22
+ 'password' => password,
23
+ 'tag' => tag
24
+ }))
25
+ end
26
+ end
27
+ end
28
+ end