bandwidth-sdk 6.1.0 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +89 -12
  3. data/lib/bandwidth.rb +5 -2
  4. data/lib/bandwidth/api_helper.rb +5 -17
  5. data/lib/bandwidth/client.rb +23 -9
  6. data/lib/bandwidth/configuration.rb +54 -18
  7. data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
  8. data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +22 -0
  9. data/lib/bandwidth/http/faraday_client.rb +5 -2
  10. data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
  11. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +25 -29
  12. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +47 -2
  13. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +5 -75
  14. data/lib/bandwidth/models/base_model.rb +19 -8
  15. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
  16. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
  17. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +0 -0
  18. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +7 -7
  19. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +0 -0
  20. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +0 -0
  21. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +0 -0
  22. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +0 -0
  23. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +0 -0
  24. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +0 -0
  25. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +0 -0
  26. data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +0 -0
  27. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +20 -0
  28. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +60 -0
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +1551 -0
  30. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +49 -0
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +29 -0
  32. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +35 -0
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +45 -0
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +74 -0
  35. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +107 -0
  36. data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
  37. data/lib/bandwidth/voice_lib/voice.rb +14 -18
  38. data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +248 -230
  40. data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +2 -2
  41. data/lib/bandwidth/voice_lib/voice/models/{recording_metadata_response.rb → call_recording_metadata.rb} +47 -28
  42. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +232 -0
  43. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
  44. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
  45. data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +8 -8
  46. data/lib/bandwidth/voice_lib/voice/models/{conference_recording_metadata_response.rb → conference_recording_metadata.rb} +34 -18
  47. data/lib/bandwidth/voice_lib/voice/models/{conference_detail.rb → conference_state.rb} +22 -14
  48. data/lib/bandwidth/voice_lib/voice/models/{api_create_call_request.rb → create_call_request.rb} +35 -59
  49. data/lib/bandwidth/voice_lib/voice/models/{api_call_response.rb → create_call_response.rb} +28 -23
  50. data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +4 -4
  51. data/lib/bandwidth/voice_lib/voice/models/{api_modify_call_request.rb → modify_call_request.rb} +25 -25
  52. data/lib/bandwidth/voice_lib/voice/models/{api_modify_conference_request.rb → modify_conference_request.rb} +11 -11
  53. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
  54. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
  55. data/lib/bandwidth/voice_lib/voice/models/{api_transcribe_recording_request.rb → transcribe_recording_request.rb} +8 -8
  56. data/lib/bandwidth/voice_lib/voice/models/{transcription.rb → transcription_metadata.rb} +19 -10
  57. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
  58. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +14 -5
  59. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +14 -14
  60. data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +2 -2
  61. data/test/controllers/controller_test_base.rb +21 -0
  62. data/test/http_response_catcher.rb +19 -0
  63. data/test/integration/test_integration.rb +39 -13
  64. data/test/test_helper.rb +94 -0
  65. metadata +47 -37
  66. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
  67. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
  68. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
  69. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
  70. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
  71. data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
@@ -4,8 +4,8 @@
4
4
  # ( https://apimatic.io ).
5
5
 
6
6
  module Bandwidth
7
- # ApiModifyConferenceRequest Model.
8
- class ApiModifyConferenceRequest < BaseModel
7
+ # ModifyConferenceRequest Model.
8
+ class ModifyConferenceRequest < BaseModel
9
9
  # TODO: Write general description for this method
10
10
  # @return [StatusEnum]
11
11
  attr_accessor :status
@@ -93,15 +93,15 @@ module Bandwidth
93
93
  fallback_password = hash['fallbackPassword']
94
94
 
95
95
  # Create object from extracted values.
96
- ApiModifyConferenceRequest.new(status,
97
- redirect_url,
98
- redirect_fallback_url,
99
- redirect_method,
100
- redirect_fallback_method,
101
- username,
102
- password,
103
- fallback_username,
104
- fallback_password)
96
+ ModifyConferenceRequest.new(status,
97
+ redirect_url,
98
+ redirect_fallback_url,
99
+ redirect_method,
100
+ redirect_fallback_method,
101
+ username,
102
+ password,
103
+ fallback_username,
104
+ fallback_password)
105
105
  end
106
106
  end
107
107
  end
@@ -7,11 +7,14 @@ module Bandwidth
7
7
  # State1.
8
8
  class State1Enum
9
9
  STATE1_ENUM = [
10
- # TODO: Write general description for ACTIVE
11
- ACTIVE = 'active'.freeze,
10
+ # TODO: Write general description for NOT_RECORDING
11
+ NOT_RECORDING = 'NOT_RECORDING'.freeze,
12
12
 
13
- # TODO: Write general description for COMPLETED
14
- COMPLETED = 'completed'.freeze
13
+ # TODO: Write general description for PAUSED
14
+ PAUSED = 'PAUSED'.freeze,
15
+
16
+ # TODO: Write general description for RECORDING
17
+ RECORDING = 'RECORDING'.freeze
15
18
  ].freeze
16
19
  end
17
20
  end
@@ -7,14 +7,11 @@ module Bandwidth
7
7
  # State.
8
8
  class StateEnum
9
9
  STATE_ENUM = [
10
- # TODO: Write general description for DISCONNECTED
11
- DISCONNECTED = 'DISCONNECTED'.freeze,
10
+ # TODO: Write general description for ACTIVE
11
+ ACTIVE = 'active'.freeze,
12
12
 
13
- # TODO: Write general description for ANSWERED
14
- ANSWERED = 'ANSWERED'.freeze,
15
-
16
- # TODO: Write general description for INITIATED
17
- INITIATED = 'INITIATED'.freeze
13
+ # TODO: Write general description for COMPLETED
14
+ COMPLETED = 'completed'.freeze
18
15
  ].freeze
19
16
  end
20
17
  end
@@ -4,8 +4,8 @@
4
4
  # ( https://apimatic.io ).
5
5
 
6
6
  module Bandwidth
7
- # ApiTranscribeRecordingRequest Model.
8
- class ApiTranscribeRecordingRequest < BaseModel
7
+ # TranscribeRecordingRequest Model.
8
+ class TranscribeRecordingRequest < BaseModel
9
9
  # TODO: Write general description for this method
10
10
  # @return [String]
11
11
  attr_accessor :callback_url
@@ -69,12 +69,12 @@ module Bandwidth
69
69
  callback_timeout = hash['callbackTimeout']
70
70
 
71
71
  # Create object from extracted values.
72
- ApiTranscribeRecordingRequest.new(callback_url,
73
- callback_method,
74
- username,
75
- password,
76
- tag,
77
- callback_timeout)
72
+ TranscribeRecordingRequest.new(callback_url,
73
+ callback_method,
74
+ username,
75
+ password,
76
+ tag,
77
+ callback_timeout)
78
78
  end
79
79
  end
80
80
  end
@@ -4,21 +4,30 @@
4
4
  # ( https://apimatic.io ).
5
5
 
6
6
  module Bandwidth
7
- # Transcription Model.
8
- class Transcription < BaseModel
7
+ # TranscriptionMetadata Model.
8
+ class TranscriptionMetadata < BaseModel
9
9
  # TODO: Write general description for this method
10
10
  # @return [String]
11
11
  attr_accessor :id
12
12
 
13
- # TODO: Write general description for this method
14
- # @return [Status3Enum]
13
+ # The current status of the transcription. Current values are 'none',
14
+ # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and
15
+ # 'file-size-too-small'. Additional states may be added in the future, so
16
+ # your application must be tolerant of unknown values.
17
+ # @return [String]
15
18
  attr_accessor :status
16
19
 
17
- # TODO: Write general description for this method
20
+ # The current status of the transcription. Current values are 'none',
21
+ # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and
22
+ # 'file-size-too-small'. Additional states may be added in the future, so
23
+ # your application must be tolerant of unknown values.
18
24
  # @return [String]
19
25
  attr_accessor :completed_time
20
26
 
21
- # TODO: Write general description for this method
27
+ # The current status of the transcription. Current values are 'none',
28
+ # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and
29
+ # 'file-size-too-small'. Additional states may be added in the future, so
30
+ # your application must be tolerant of unknown values.
22
31
  # @return [String]
23
32
  attr_accessor :url
24
33
 
@@ -53,10 +62,10 @@ module Bandwidth
53
62
  url = hash['url']
54
63
 
55
64
  # Create object from extracted values.
56
- Transcription.new(id,
57
- status,
58
- completed_time,
59
- url)
65
+ TranscriptionMetadata.new(id,
66
+ status,
67
+ completed_time,
68
+ url)
60
69
  end
61
70
  end
62
71
  end
@@ -6,8 +6,13 @@
6
6
 
7
7
  module Bandwidth
8
8
  module WebRtc
9
- def generate_bxml(device_token, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
10
- return '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="%s;encoding=jwt">%s</SipUri></Transfer></Response>' % [device_token, sip_uri]
9
+ def generate_bxml(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
10
+ return '<?xml version="1.0" encoding="UTF-8"?><Response>' + generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri) + '</Response>'
11
+ end
12
+
13
+ def generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
14
+ voice_call_id = voice_call_id.split("-", 2).last.split("-").join()
15
+ return '<Transfer><SipUri uui="%s;encoding=base64,%s;encoding=jwt">%s</SipUri></Transfer>' % [voice_call_id, device_token, sip_uri]
11
16
  end
12
17
  end
13
18
  end
@@ -16,12 +16,17 @@ module Bandwidth
16
16
  end
17
17
 
18
18
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
19
- backoff_factor: 1, environment: Environment::PRODUCTION,
19
+ backoff_factor: 2,
20
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
21
+ retry_methods: %i[get put get put],
22
+ environment: Environment::PRODUCTION,
20
23
  base_url: 'https://www.example.com',
21
24
  messaging_basic_auth_user_name: 'TODO: Replace',
22
25
  messaging_basic_auth_password: 'TODO: Replace',
23
- two_factor_auth_basic_auth_user_name: 'TODO: Replace',
24
- two_factor_auth_basic_auth_password: 'TODO: Replace',
26
+ multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
27
+ multi_factor_auth_basic_auth_password: 'TODO: Replace',
28
+ phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
29
+ phone_number_lookup_basic_auth_password: 'TODO: Replace',
25
30
  voice_basic_auth_user_name: 'TODO: Replace',
26
31
  voice_basic_auth_password: 'TODO: Replace',
27
32
  web_rtc_basic_auth_user_name: 'TODO: Replace',
@@ -32,12 +37,16 @@ module Bandwidth
32
37
  max_retries: max_retries,
33
38
  retry_interval: retry_interval,
34
39
  backoff_factor: backoff_factor,
40
+ retry_statuses: retry_statuses,
41
+ retry_methods: retry_methods,
35
42
  environment: environment,
36
43
  base_url: base_url,
37
44
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
38
45
  messaging_basic_auth_password: messaging_basic_auth_password,
39
- two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
40
- two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
46
+ multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
47
+ multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
48
+ phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
49
+ phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
41
50
  voice_basic_auth_user_name: voice_basic_auth_user_name,
42
51
  voice_basic_auth_password: voice_basic_auth_password,
43
52
  web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
@@ -498,20 +498,20 @@ module WebRtc
498
498
  # This will automatically remove any subscriptions the participant has
499
499
  # associated with this session
500
500
  # @param [String] account_id Required parameter: Account ID
501
- # @param [String] participant_id Required parameter: Participant ID
502
501
  # @param [String] session_id Required parameter: Session ID
502
+ # @param [String] participant_id Required parameter: Participant ID
503
503
  # @return [void] response from the API call
504
504
  def remove_participant_from_session(account_id,
505
- participant_id,
506
- session_id)
505
+ session_id,
506
+ participant_id)
507
507
  # Prepare query url.
508
508
  _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
509
509
  _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
510
510
  _query_builder = APIHelper.append_url_with_template_parameters(
511
511
  _query_builder,
512
512
  'accountId' => { 'value' => account_id, 'encode' => false },
513
- 'participantId' => { 'value' => participant_id, 'encode' => false },
514
- 'sessionId' => { 'value' => session_id, 'encode' => false }
513
+ 'sessionId' => { 'value' => session_id, 'encode' => false },
514
+ 'participantId' => { 'value' => participant_id, 'encode' => false }
515
515
  )
516
516
  _query_url = APIHelper.clean_url _query_builder
517
517
 
@@ -553,20 +553,20 @@ module WebRtc
553
553
 
554
554
  # Get a participant's subscriptions
555
555
  # @param [String] account_id Required parameter: Account ID
556
- # @param [String] participant_id Required parameter: Participant ID
557
556
  # @param [String] session_id Required parameter: Session ID
557
+ # @param [String] participant_id Required parameter: Participant ID
558
558
  # @return [Subscriptions] response from the API call
559
559
  def get_participant_subscriptions(account_id,
560
- participant_id,
561
- session_id)
560
+ session_id,
561
+ participant_id)
562
562
  # Prepare query url.
563
563
  _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
564
564
  _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
565
565
  _query_builder = APIHelper.append_url_with_template_parameters(
566
566
  _query_builder,
567
567
  'accountId' => { 'value' => account_id, 'encode' => false },
568
- 'participantId' => { 'value' => participant_id, 'encode' => false },
569
- 'sessionId' => { 'value' => session_id, 'encode' => false }
568
+ 'sessionId' => { 'value' => session_id, 'encode' => false },
569
+ 'participantId' => { 'value' => participant_id, 'encode' => false }
570
570
  )
571
571
  _query_url = APIHelper.clean_url _query_builder
572
572
 
@@ -621,13 +621,13 @@ module WebRtc
621
621
  # subscriptions. Call this function with no `Subscriptions` object to remove
622
622
  # all subscriptions
623
623
  # @param [String] account_id Required parameter: Account ID
624
- # @param [String] participant_id Required parameter: Participant ID
625
624
  # @param [String] session_id Required parameter: Session ID
625
+ # @param [String] participant_id Required parameter: Participant ID
626
626
  # @param [Subscriptions] body Optional parameter: Initial state
627
627
  # @return [void] response from the API call
628
628
  def update_participant_subscriptions(account_id,
629
- participant_id,
630
629
  session_id,
630
+ participant_id,
631
631
  body: nil)
632
632
  # Prepare query url.
633
633
  _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
@@ -635,8 +635,8 @@ module WebRtc
635
635
  _query_builder = APIHelper.append_url_with_template_parameters(
636
636
  _query_builder,
637
637
  'accountId' => { 'value' => account_id, 'encode' => false },
638
- 'participantId' => { 'value' => participant_id, 'encode' => false },
639
- 'sessionId' => { 'value' => session_id, 'encode' => false }
638
+ 'sessionId' => { 'value' => session_id, 'encode' => false },
639
+ 'participantId' => { 'value' => participant_id, 'encode' => false }
640
640
  )
641
641
  _query_url = APIHelper.clean_url _query_builder
642
642
 
@@ -8,10 +8,10 @@ module Bandwidth
8
8
  class DeviceApiVersionEnum
9
9
  DEVICE_API_VERSION_ENUM = [
10
10
  # TODO: Write general description for V3
11
- V3 = 'v3'.freeze,
11
+ V3 = 'V3'.freeze,
12
12
 
13
13
  # TODO: Write general description for V2
14
- V2 = 'v2'.freeze
14
+ V2 = 'V2'.freeze
15
15
  ].freeze
16
16
  end
17
17
  end
@@ -0,0 +1,21 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'json'
7
+ require 'minitest/autorun'
8
+ require 'minitest/hell'
9
+ require 'minitest/pride'
10
+ require 'minitest/proveit'
11
+ require 'bandwidth'
12
+ require_relative '../test_helper'
13
+ require_relative '../http_response_catcher'
14
+
15
+ class ControllerTestBase < Minitest::Test
16
+ parallelize_me!
17
+ include Bandwidth
18
+
19
+ # Create configuration and set any test parameters
20
+ CONFIG = Configuration.new
21
+ end
@@ -0,0 +1,19 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ class HttpResponseCatcher < Bandwidth::HttpCallBack
7
+ attr_accessor :response
8
+
9
+ def on_before_request(request)
10
+ end
11
+
12
+ # Catching the response
13
+ def on_after_response(response)
14
+ @response = response
15
+ end
16
+ end
17
+
18
+
19
+
@@ -8,7 +8,8 @@ require_relative '../../lib/bandwidth.rb'
8
8
  include Bandwidth
9
9
  include Bandwidth::Voice
10
10
  include Bandwidth::Messaging
11
- include Bandwidth::TwoFactorAuth
11
+ include Bandwidth::MultiFactorAuth
12
+ include Bandwidth::WebRtc
12
13
 
13
14
  begin
14
15
  USERNAME = ENV.fetch("USERNAME")
@@ -34,8 +35,10 @@ class IntegrationTest < Test::Unit::TestCase
34
35
  voice_basic_auth_password: PASSWORD,
35
36
  messaging_basic_auth_user_name: USERNAME,
36
37
  messaging_basic_auth_password: PASSWORD,
37
- two_factor_auth_basic_auth_user_name: USERNAME,
38
- two_factor_auth_basic_auth_password: PASSWORD
38
+ multi_factor_auth_basic_auth_user_name: USERNAME,
39
+ multi_factor_auth_basic_auth_password: PASSWORD,
40
+ phone_number_lookup_basic_auth_user_name: USERNAME,
41
+ phone_number_lookup_basic_auth_password: PASSWORD
39
42
  )
40
43
  end
41
44
 
@@ -56,7 +59,7 @@ class IntegrationTest < Test::Unit::TestCase
56
59
  body.from = PHONE_NUMBER_OUTBOUND
57
60
  body.text = "Ruby Integration"
58
61
  begin
59
- @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body)
62
+ @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body)
60
63
  #workaround to make sure that if the above error is not raised, the build will fail
61
64
  assert(false, "Expected exception not raised")
62
65
  rescue MessagingException => e
@@ -70,7 +73,7 @@ class IntegrationTest < Test::Unit::TestCase
70
73
  media_file = '12345' #todo: check a binary string
71
74
 
72
75
  #media upload
73
- @bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file.length.to_s, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache")
76
+ @bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache")
74
77
 
75
78
  #media download
76
79
  downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data
@@ -79,21 +82,21 @@ class IntegrationTest < Test::Unit::TestCase
79
82
  end
80
83
 
81
84
  def test_create_call_and_get_call_state
82
- body = ApiCreateCallRequest.new
85
+ body = CreateCallRequest.new
83
86
  body.from = PHONE_NUMBER_OUTBOUND
84
87
  body.to = PHONE_NUMBER_INBOUND
85
88
  body.application_id = VOICE_APPLICATION_ID
86
89
  body.answer_url = CALLBACK_URL
87
- response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
90
+ response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, body)
88
91
  assert(response.data.call_id.length > 0, "call_id value not set")
89
92
 
90
93
  #Get phone call information
91
- response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id)
94
+ response = @bandwidth_client.voice_client.client.get_call(ACCOUNT_ID, response.data.call_id)
92
95
  assert(response.data.state.length > 0, "state value not set")
93
96
  end
94
97
 
95
98
  def test_create_call_invalid_phone_number
96
- body = ApiCreateCallRequest.new
99
+ body = CreateCallRequest.new
97
100
  body.from = PHONE_NUMBER_OUTBOUND
98
101
  body.to = "+1invalid"
99
102
  body.application_id = VOICE_APPLICATION_ID
@@ -103,7 +106,7 @@ class IntegrationTest < Test::Unit::TestCase
103
106
  @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
104
107
  #workaround to make sure that if the above error is not raised, the build will fail
105
108
  assert(false, "Expected exception not raised")
106
- rescue ApiErrorResponseException => e
109
+ rescue ApiErrorException => e
107
110
  assert(e.description.length > 0, "description value not set")
108
111
  end
109
112
  end
@@ -471,7 +474,7 @@ class IntegrationTest < Test::Unit::TestCase
471
474
  body.digits = 6
472
475
  body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
473
476
 
474
- response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
477
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
475
478
  assert(response.data.message_id.length > 0, "message id value not set")
476
479
  end
477
480
 
@@ -484,7 +487,7 @@ class IntegrationTest < Test::Unit::TestCase
484
487
  body.digits = 6
485
488
  body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
486
489
 
487
- response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
490
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
488
491
  assert(response.data.call_id.length > 0, "call id value not set")
489
492
  end
490
493
 
@@ -495,7 +498,7 @@ class IntegrationTest < Test::Unit::TestCase
495
498
  body.scope = "scope"
496
499
  body.code = "123456"
497
500
  body.expiration_time_in_minutes = 3
498
- response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
501
+ response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
499
502
  #Ruby has no check to see if variables are of type boolean
500
503
  #An explicit true/false check is required
501
504
  assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
@@ -567,4 +570,27 @@ class IntegrationTest < Test::Unit::TestCase
567
570
  actual = response.to_bxml()
568
571
  assert_equal(expected, actual)
569
572
  end
573
+
574
+ def test_tn_lookup
575
+ body = OrderRequest.new
576
+ body.tns = [PHONE_NUMBER_OUTBOUND]
577
+ create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(ACCOUNT_ID, body)
578
+ assert(create_response.data.request_id.length > 0, "request_id value not set")
579
+
580
+ request_id = create_response.data.request_id
581
+ get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(ACCOUNT_ID, request_id)
582
+ assert(get_response.data.status.length > 0, "status value not set")
583
+ end
584
+
585
+ def test_webrtc_generate_bxml
586
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer></Response>'
587
+ actual = Bandwidth::WebRtc.generate_bxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
588
+ assert_equal(expected, actual)
589
+ end
590
+
591
+ def test_webrtc_generate_transfer_bxml_verb
592
+ expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>'
593
+ actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
594
+ assert_equal(expected, actual)
595
+ end
570
596
  end