bandwidth-sdk 12.0.0 → 13.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +13 -22
- data/README.md +3 -1
- data/Rakefile +4 -12
- data/bandwidth-sdk.gemspec +3 -1
- data/bandwidth.yml +48 -33
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +1333 -1598
- data/coverage/index.html +6890 -9805
- data/custom_templates/Gemfile.mustache +1 -2
- data/custom_templates/gemspec.mustache +2 -0
- data/docs/AnswerCallback.md +2 -2
- data/docs/BridgeCompleteCallback.md +2 -2
- data/docs/BridgeTargetCompleteCallback.md +2 -2
- data/docs/CallRecordingMetadata.md +4 -4
- data/docs/CallState.md +1 -1
- data/docs/CallTranscription.md +6 -6
- data/docs/CallTranscriptionDetectedLanguageEnum.md +15 -0
- data/docs/CallTranscriptionResponse.md +2 -2
- data/docs/CallTranscriptionTrackEnum.md +15 -0
- data/docs/CallsApi.md +1 -1
- data/docs/ConferenceMemberExitCallback.md +1 -1
- data/docs/ConferenceMemberJoinCallback.md +1 -1
- data/docs/ConferenceRecordingAvailableCallback.md +1 -1
- data/docs/ConferenceRecordingMetadata.md +1 -1
- data/docs/CreateCall.md +5 -3
- data/docs/DisconnectCallback.md +2 -2
- data/docs/DtmfCallback.md +4 -4
- data/docs/GatherCallback.md +4 -4
- data/docs/InitiateCallback.md +2 -2
- data/docs/MachineDetectionCompleteCallback.md +2 -2
- data/docs/MessagingCodeResponse.md +1 -1
- data/docs/RecordingAvailableCallback.md +4 -4
- data/docs/RecordingCompleteCallback.md +4 -4
- data/docs/RecordingTranscriptionMetadata.md +1 -1
- data/docs/RedirectCallback.md +4 -4
- data/docs/TranscriptionAvailableCallback.md +4 -4
- data/docs/TranscriptionsApi.md +1 -1
- data/docs/TransferAnswerCallback.md +4 -4
- data/docs/TransferCompleteCallback.md +4 -4
- data/docs/TransferDisconnectCallback.md +4 -4
- data/lib/bandwidth-sdk/api/calls_api.rb +1 -1
- data/lib/bandwidth-sdk/api/conferences_api.rb +1 -1
- data/lib/bandwidth-sdk/api/media_api.rb +1 -1
- data/lib/bandwidth-sdk/api/messages_api.rb +1 -1
- data/lib/bandwidth-sdk/api/mfa_api.rb +1 -1
- data/lib/bandwidth-sdk/api/phone_number_lookup_api.rb +1 -1
- data/lib/bandwidth-sdk/api/recordings_api.rb +1 -1
- data/lib/bandwidth-sdk/api/statistics_api.rb +1 -1
- data/lib/bandwidth-sdk/api/transcriptions_api.rb +3 -3
- data/lib/bandwidth-sdk/api_client.rb +44 -41
- data/lib/bandwidth-sdk/api_error.rb +1 -1
- data/lib/bandwidth-sdk/configuration.rb +11 -1
- data/lib/bandwidth-sdk/models/account_statistics.rb +2 -2
- data/lib/bandwidth-sdk/models/answer_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/bridge_complete_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/bxml/root.rb +0 -6
- data/lib/bandwidth-sdk/models/bxml/verbs/gather.rb +0 -6
- data/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb +0 -6
- data/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb +0 -6
- data/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb +0 -6
- data/lib/bandwidth-sdk/models/call_direction_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/call_recording_metadata.rb +4 -4
- data/lib/bandwidth-sdk/models/call_state.rb +2 -2
- data/lib/bandwidth-sdk/models/call_state_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/call_transcription.rb +11 -37
- data/lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb +41 -0
- data/lib/bandwidth-sdk/models/call_transcription_metadata.rb +2 -2
- data/lib/bandwidth-sdk/models/call_transcription_response.rb +2 -2
- data/lib/bandwidth-sdk/models/call_transcription_track_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/callback_method_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/code_request.rb +2 -2
- data/lib/bandwidth-sdk/models/conference.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_completed_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_created_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_member.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_member_exit_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/conference_member_join_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/conference_recording_available_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_recording_metadata.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_redirect_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/conference_state_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/create_call.rb +16 -5
- data/lib/bandwidth-sdk/models/create_call_response.rb +2 -2
- data/lib/bandwidth-sdk/models/create_lookup_response.rb +2 -2
- data/lib/bandwidth-sdk/models/create_message_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/deferred_result.rb +2 -2
- data/lib/bandwidth-sdk/models/disconnect_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/diversion.rb +2 -2
- data/lib/bandwidth-sdk/models/dtmf_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/field_error.rb +2 -2
- data/lib/bandwidth-sdk/models/file_format_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/gather_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/inbound_message_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/inbound_message_callback_message.rb +2 -2
- data/lib/bandwidth-sdk/models/initiate_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/list_message_direction_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/list_message_item.rb +2 -2
- data/lib/bandwidth-sdk/models/lookup_request.rb +2 -2
- data/lib/bandwidth-sdk/models/lookup_result.rb +2 -2
- data/lib/bandwidth-sdk/models/lookup_status.rb +2 -2
- data/lib/bandwidth-sdk/models/lookup_status_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +3 -3
- data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +3 -3
- data/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/machine_detection_result.rb +2 -2
- data/lib/bandwidth-sdk/models/media.rb +2 -2
- data/lib/bandwidth-sdk/models/message.rb +2 -2
- data/lib/bandwidth-sdk/models/message_delivered_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/message_delivered_callback_message.rb +2 -2
- data/lib/bandwidth-sdk/models/message_direction_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/message_failed_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/message_failed_callback_message.rb +2 -2
- data/lib/bandwidth-sdk/models/message_request.rb +2 -2
- data/lib/bandwidth-sdk/models/message_sending_callback.rb +2 -2
- data/lib/bandwidth-sdk/models/message_sending_callback_message.rb +2 -2
- data/lib/bandwidth-sdk/models/message_status_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/message_type_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/messages_list.rb +2 -2
- data/lib/bandwidth-sdk/models/messaging_code_response.rb +2 -2
- data/lib/bandwidth-sdk/models/messaging_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/mfa_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/page_info.rb +2 -2
- data/lib/bandwidth-sdk/models/priority_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/recording_available_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/recording_complete_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/recording_state_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/recording_transcription_metadata.rb +3 -3
- data/lib/bandwidth-sdk/models/recording_transcriptions.rb +2 -2
- data/lib/bandwidth-sdk/models/redirect_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/redirect_method_enum.rb +1 -1
- data/lib/bandwidth-sdk/models/stir_shaken.rb +2 -2
- data/lib/bandwidth-sdk/models/tag.rb +2 -2
- data/lib/bandwidth-sdk/models/tn_lookup_request_error.rb +2 -2
- data/lib/bandwidth-sdk/models/transcribe_recording.rb +2 -2
- data/lib/bandwidth-sdk/models/transcription.rb +2 -2
- data/lib/bandwidth-sdk/models/transcription_available_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/transfer_answer_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/transfer_complete_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +4 -4
- data/lib/bandwidth-sdk/models/update_call.rb +2 -2
- data/lib/bandwidth-sdk/models/update_call_recording.rb +2 -2
- data/lib/bandwidth-sdk/models/update_conference.rb +2 -2
- data/lib/bandwidth-sdk/models/update_conference_member.rb +2 -2
- data/lib/bandwidth-sdk/models/verify_code_request.rb +2 -2
- data/lib/bandwidth-sdk/models/verify_code_response.rb +2 -2
- data/lib/bandwidth-sdk/models/voice_api_error.rb +2 -2
- data/lib/bandwidth-sdk/models/voice_code_response.rb +2 -2
- data/lib/bandwidth-sdk/version.rb +2 -2
- data/lib/bandwidth-sdk.rb +3 -1
- data/openapitools.json +1 -1
- data/spec/call_utils.rb +1 -1
- data/spec/{integration/calls_api_integration_spec.rb → smoke/calls_api_spec.rb} +3 -6
- data/spec/{integration/conferences_api_integration_spec.rb → smoke/conferences_api_spec.rb} +0 -5
- data/spec/{integration/media_api_integration_spec.rb → smoke/media_api_spec.rb} +0 -5
- data/spec/{integration/messages_api_integration_spec.rb → smoke/messages_api_spec.rb} +0 -5
- data/spec/{integration/mfa_api_integration_spec.rb → smoke/mfa_api_spec.rb} +0 -5
- data/spec/{integration/phone_number_lookup_api_integration_spec.rb → smoke/phone_number_lookup_api_spec.rb} +0 -5
- data/spec/{integration/recordings_api_integration_spec.rb → smoke/recordings_api_spec.rb} +0 -5
- data/spec/{integration/statistics_api_integration_spec.rb → smoke/statistics_api_spec.rb} +0 -5
- data/spec/{integration/transcriptions_api_integration_spec.rb → smoke/transcriptions_api_spec.rb} +0 -5
- data/spec/spec_helper.rb +13 -6
- data/spec/unit/api/calls_api_spec.rb +233 -0
- data/spec/unit/api/conferences_api_spec.rb +330 -0
- data/spec/{api → unit/api}/media_api_spec.rb +17 -32
- data/spec/unit/api/messages_api_spec.rb +103 -0
- data/spec/{api → unit/api}/mfa_api_spec.rb +8 -24
- data/spec/unit/api/phone_number_lookup_api_spec.rb +86 -0
- data/spec/{api → unit/api}/recordings_api_spec.rb +83 -110
- data/spec/unit/api/statistics_api_spec.rb +37 -0
- data/spec/{api → unit/api}/transcriptions_api_spec.rb +18 -37
- data/spec/{api_client_spec.rb → unit/client/api_client_spec.rb} +4 -4
- metadata +136 -118
- data/spec/api/calls_api_spec.rb +0 -261
- data/spec/api/conferences_api_spec.rb +0 -393
- data/spec/api/messages_api_spec.rb +0 -193
- data/spec/api/phone_number_lookup_api_spec.rb +0 -100
- data/spec/api/statistics_api_spec.rb +0 -45
- /data/spec/{api_error_spec.rb → unit/client/api_error_spec.rb} +0 -0
- /data/spec/{configuration_spec.rb → unit/client/configuration_spec.rb} +0 -0
- /data/spec/{models → unit/models}/bxml/bxml_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/nestable_verb_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/response_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verb_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/bridge_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/conference_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/custom_param_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/forward_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/gather_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/hangup_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/pause_recording_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/pause_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/phone_number_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/play_audio_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/record_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/redirect_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/resume_recording_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/ring_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/send_dtmf_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/sip_uri_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/speak_sentence_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/start_gather_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/start_recording_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/start_stream_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/start_transcription_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/stop_gather_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/stop_recording_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/stop_stream_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/stop_transcription_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/stream_param_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/tag_spec.rb +0 -0
- /data/spec/{models → unit/models}/bxml/verbs/transfer_spec.rb +0 -0
- /data/spec/{models → unit/models}/call_state_enum_spec.rb +0 -0
- /data/spec/{models → unit/models}/call_state_spec.rb +0 -0
- /data/spec/{models → unit/models}/deferred_result_spec.rb +0 -0
- /data/spec/{models → unit/models}/message_spec.rb +0 -0
- /data/spec/{models → unit/models}/verify_code_request_spec.rb +0 -0
@@ -1,393 +0,0 @@
|
|
1
|
-
# Unit tests for Bandwidth::ConferencesApi
|
2
|
-
describe 'ConferencesApi' do
|
3
|
-
# conference info
|
4
|
-
let(:test_id) { 'ruby-3.1.3_macOS_conference_1687791527' }
|
5
|
-
let(:conference_id) { 'conf-3f758f24-6711b6d2-0d44-495d-afc8-2555c3ce5f4f' }
|
6
|
-
let(:created_time) { '2023-06-26T14:58:49.471Z' }
|
7
|
-
let(:conference_event_url) { 'https://amazonaws.com/prod/conferenceEvents' }
|
8
|
-
let(:conference_event_method) { 'POST' }
|
9
|
-
let(:call_id) { 'c-3f758f24-cd77b08f-97c2-4311-965a-a1ac8ed8f340' }
|
10
|
-
let(:recording_id) { 'r-fbe05094-7bf4b314-91fe-4bdd-a39b-500cdc873d3a' }
|
11
|
-
let(:start_time) { '2023-06-26T14:58:51.195Z' }
|
12
|
-
let(:end_time) { '2023-06-26T14:58:57.502Z' }
|
13
|
-
let(:duration) { 'PT6.3S' }
|
14
|
-
let(:channels) { 1 }
|
15
|
-
let(:file_format) { Bandwidth::FileFormatEnum::WAV }
|
16
|
-
let(:status) { 'complete' }
|
17
|
-
let(:member_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}" }
|
18
|
-
let(:media_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media" }
|
19
|
-
let(:active_members) { "[{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}]" }
|
20
|
-
|
21
|
-
# stubs
|
22
|
-
let(:list_conferences_headers_stub) { { 'content-type' => 'application/json' } }
|
23
|
-
let(:list_conferences_body_stub) { "[{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\"}]" }
|
24
|
-
let(:get_conference_headers_stub) { { 'content-type' => 'application/json' } }
|
25
|
-
let(:get_conference_body_stub) { "{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\",\"activeMembers\":#{active_members}}" }
|
26
|
-
let(:get_conference_member_headers_stub) { { 'content-type' => 'application/json' } }
|
27
|
-
let(:get_conference_member_body_stub) { "{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}" }
|
28
|
-
let(:list_conference_recordings_headers_stub) { { 'content-type' => 'application/json' } }
|
29
|
-
let(:list_conference_recordings_body_stub) { "[{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" }
|
30
|
-
let(:get_conference_recording_headers_stub) { { 'content-type' => 'application/json' } }
|
31
|
-
let(:get_conference_recording_body_stub) { "{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}" }
|
32
|
-
let(:download_conference_recording_body_stub) { 'RIFFWAVEfmtLISTINFOISFTLavf58.45.100data' }
|
33
|
-
let(:download_conference_recording_headers_stub) { { 'content-type' => 'audio/vnd.wave', 'content-length' => "#{download_conference_recording_body_stub.length}" } }
|
34
|
-
|
35
|
-
before(:all) do
|
36
|
-
Bandwidth.configure do |config|
|
37
|
-
config.return_binary_data = true
|
38
|
-
config.debugging = true
|
39
|
-
end
|
40
|
-
@conferences_api_instance = Bandwidth::ConferencesApi.new
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'test an instance of ConferencesApi' do
|
44
|
-
it 'should create an instance of ConferencesApi' do
|
45
|
-
expect(@conferences_api_instance).to be_instance_of(Bandwidth::ConferencesApi)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Download Conference Recording
|
50
|
-
describe 'download_conference_recording test' do
|
51
|
-
it 'should work' do
|
52
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media").
|
53
|
-
to_return(status: 200, headers: download_conference_recording_headers_stub, body: download_conference_recording_body_stub)
|
54
|
-
|
55
|
-
data, status_code, headers = @conferences_api_instance.download_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
|
56
|
-
|
57
|
-
expect(status_code).to eq(200)
|
58
|
-
expect(headers).to eq(download_conference_recording_headers_stub)
|
59
|
-
expect(data).to eq(download_conference_recording_body_stub)
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'causes an ArgumentError for a missing account_id' do
|
63
|
-
expect {
|
64
|
-
@conferences_api_instance.download_conference_recording(nil, '', '')
|
65
|
-
}.to raise_error(ArgumentError)
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
69
|
-
expect {
|
70
|
-
@conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, nil, '')
|
71
|
-
}.to raise_error(ArgumentError)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'causes an ArgumentError for a missing recording_id' do
|
75
|
-
expect {
|
76
|
-
@conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, '', nil)
|
77
|
-
}.to raise_error(ArgumentError)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# Get Conference Information
|
82
|
-
describe 'get_conference' do
|
83
|
-
it 'get a conference by id' do
|
84
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}").
|
85
|
-
to_return(status: 200, headers: get_conference_headers_stub, body: get_conference_body_stub)
|
86
|
-
|
87
|
-
data, status_code, headers = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, conference_id)
|
88
|
-
|
89
|
-
expect(status_code).to eq(200)
|
90
|
-
expect(headers).to eq(get_conference_headers_stub)
|
91
|
-
expect(data).to be_instance_of(Bandwidth::Conference)
|
92
|
-
expect(data.id).to eq(conference_id)
|
93
|
-
expect(data.name).to eq(test_id)
|
94
|
-
expect(data.tag).to eq(test_id)
|
95
|
-
expect(data.created_time).to eq(Time.parse(created_time))
|
96
|
-
expect(data.conference_event_url).to eq(conference_event_url)
|
97
|
-
expect(data.conference_event_method).to eq(conference_event_method)
|
98
|
-
expect(data.active_members).to be_instance_of(Array)
|
99
|
-
expect(data.active_members[0]).to be_instance_of(Bandwidth::ConferenceMember)
|
100
|
-
expect(data.active_members[0].call_id).to eq(call_id)
|
101
|
-
expect(data.active_members[0].conference_id).to eq(conference_id)
|
102
|
-
expect(data.active_members[0].member_url).to eq(member_url)
|
103
|
-
expect(data.active_members[0].mute).to be false
|
104
|
-
expect(data.active_members[0].hold).to be false
|
105
|
-
expect(data.active_members[0].call_ids_to_coach).to eq([])
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'causes an ArgumentError for a missing account_id' do
|
109
|
-
expect {
|
110
|
-
@conferences_api_instance.get_conference(nil, '')
|
111
|
-
}.to raise_error(ArgumentError)
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
115
|
-
expect {
|
116
|
-
@conferences_api_instance.get_conference(BW_ACCOUNT_ID, nil)
|
117
|
-
}.to raise_error(ArgumentError)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
# Get Conference Member
|
122
|
-
describe 'get_conference_member' do
|
123
|
-
it 'gets a conference member by call id' do
|
124
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}").
|
125
|
-
to_return(status: 200, headers: get_conference_member_headers_stub, body: get_conference_member_body_stub)
|
126
|
-
|
127
|
-
data, status_code, headers = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id)
|
128
|
-
|
129
|
-
expect(status_code).to eq(200)
|
130
|
-
expect(headers).to eq(get_conference_member_headers_stub)
|
131
|
-
expect(data).to be_instance_of(Bandwidth::ConferenceMember)
|
132
|
-
expect(data.conference_id).to eq(conference_id)
|
133
|
-
expect(data.call_id).to eq(call_id)
|
134
|
-
expect(data.member_url).to eq(member_url)
|
135
|
-
expect(data.mute).to be false
|
136
|
-
expect(data.hold).to be false
|
137
|
-
expect(data.call_ids_to_coach).to eq([])
|
138
|
-
end
|
139
|
-
|
140
|
-
it 'causes an ArgumentError for a missing account_id' do
|
141
|
-
expect {
|
142
|
-
@conferences_api_instance.get_conference_member(nil, '', '')
|
143
|
-
}.to raise_error(ArgumentError)
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
147
|
-
expect {
|
148
|
-
@conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, nil, '')
|
149
|
-
}.to raise_error(ArgumentError)
|
150
|
-
end
|
151
|
-
|
152
|
-
it 'causes an ArgumentError for a missing member_id' do
|
153
|
-
expect {
|
154
|
-
@conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, '', nil)
|
155
|
-
}.to raise_error(ArgumentError)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
# Get Conference Recording Information
|
160
|
-
describe 'get_conference_recording' do
|
161
|
-
it 'gets a conference recording by id' do
|
162
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}").
|
163
|
-
to_return(status: 200, headers: get_conference_recording_headers_stub, body: get_conference_recording_body_stub)
|
164
|
-
|
165
|
-
data, status_code, headers = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
|
166
|
-
|
167
|
-
expect(status_code).to eq(200)
|
168
|
-
expect(headers).to eq(get_conference_recording_headers_stub)
|
169
|
-
expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
|
170
|
-
expect(data.account_id).to eq(BW_ACCOUNT_ID)
|
171
|
-
expect(data.conference_id).to eq(conference_id)
|
172
|
-
expect(data.name).to eq(test_id)
|
173
|
-
expect(data.recording_id).to eq(recording_id)
|
174
|
-
expect(data.duration).to eq(duration)
|
175
|
-
expect(data.channels).to eq(channels)
|
176
|
-
expect(data.start_time).to eq(Time.parse(start_time))
|
177
|
-
expect(data.end_time).to eq(Time.parse(end_time))
|
178
|
-
expect(data.file_format).to eq(Bandwidth::FileFormatEnum::WAV)
|
179
|
-
expect(data.status).to eq('complete')
|
180
|
-
expect(data.media_url).to eq(media_url)
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'causes an ArgumentError for a missing account_id' do
|
184
|
-
expect {
|
185
|
-
@conferences_api_instance.get_conference_recording(nil, '', '')
|
186
|
-
}.to raise_error(ArgumentError)
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
190
|
-
expect {
|
191
|
-
@conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, nil, '')
|
192
|
-
}.to raise_error(ArgumentError)
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'causes an ArgumentError for a missing recording_id' do
|
196
|
-
expect {
|
197
|
-
@conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, '', nil)
|
198
|
-
}.to raise_error(ArgumentError)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
# Get Conference Recordings
|
203
|
-
describe 'list_conference_recordings' do
|
204
|
-
it 'lists recordings for a conference' do
|
205
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings").
|
206
|
-
to_return(status: 200, headers: list_conference_recordings_headers_stub, body: list_conference_recordings_body_stub)
|
207
|
-
|
208
|
-
data, status_code, headers = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, conference_id)
|
209
|
-
|
210
|
-
expect(status_code).to eq(200)
|
211
|
-
expect(headers).to eq(list_conference_recordings_headers_stub)
|
212
|
-
expect(data).to be_instance_of(Array)
|
213
|
-
expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
|
214
|
-
expect(data[0].account_id).to eq(BW_ACCOUNT_ID)
|
215
|
-
expect(data[0].conference_id).to eq(conference_id)
|
216
|
-
expect(data[0].name).to eq(test_id)
|
217
|
-
expect(data[0].recording_id).to eq(recording_id)
|
218
|
-
expect(data[0].duration).to eq(duration)
|
219
|
-
expect(data[0].channels).to eq(channels)
|
220
|
-
expect(data[0].start_time).to eq(Time.parse(start_time))
|
221
|
-
expect(data[0].end_time).to eq(Time.parse(end_time))
|
222
|
-
expect(data[0].file_format).to eq(Bandwidth::FileFormatEnum::WAV)
|
223
|
-
expect(data[0].status).to eq('complete')
|
224
|
-
expect(data[0].media_url).to eq(media_url)
|
225
|
-
end
|
226
|
-
|
227
|
-
it 'causes an ArgumentError for a missing account_id' do
|
228
|
-
expect {
|
229
|
-
@conferences_api_instance.list_conference_recordings(nil, '')
|
230
|
-
}.to raise_error(ArgumentError)
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
234
|
-
expect {
|
235
|
-
@conferences_api_instance.list_conference_recordings(BW_ACCOUNT_ID, nil)
|
236
|
-
}.to raise_error(ArgumentError)
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
# Get Conferences
|
241
|
-
describe 'list_conferences' do
|
242
|
-
it 'list all conferences' do
|
243
|
-
stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences?name=#{test_id}").
|
244
|
-
to_return(status: 200, headers: list_conferences_headers_stub, body: list_conferences_body_stub)
|
245
|
-
|
246
|
-
conference_opts = {
|
247
|
-
name: test_id
|
248
|
-
}
|
249
|
-
|
250
|
-
data, status_code, headers = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts)
|
251
|
-
|
252
|
-
expect(status_code).to eq(200)
|
253
|
-
expect(headers).to eq(list_conferences_headers_stub)
|
254
|
-
expect(data).to be_instance_of(Array)
|
255
|
-
expect(data[0]).to be_instance_of(Bandwidth::Conference)
|
256
|
-
expect(data[0].id).to eq(conference_id)
|
257
|
-
expect(data[0].name).to eq(test_id)
|
258
|
-
expect(data[0].tag).to eq(test_id)
|
259
|
-
expect(data[0].created_time).to eq(Time.parse(created_time))
|
260
|
-
expect(data[0].conference_event_url).to eq(conference_event_url)
|
261
|
-
expect(data[0].conference_event_method).to eq(conference_event_method)
|
262
|
-
end
|
263
|
-
|
264
|
-
it 'causes an ArgumentError for a missing account_id' do
|
265
|
-
expect {
|
266
|
-
@conferences_api_instance.list_conferences(nil, {})
|
267
|
-
}.to raise_error(ArgumentError)
|
268
|
-
end
|
269
|
-
|
270
|
-
it 'causes an ArgumentError for an invalid page_size' do
|
271
|
-
expect {
|
272
|
-
@conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 1001 })
|
273
|
-
}.to raise_error(ArgumentError)
|
274
|
-
end
|
275
|
-
|
276
|
-
it 'causes an ArgumentError for an invalid page_size' do
|
277
|
-
expect {
|
278
|
-
@conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 0 })
|
279
|
-
}.to raise_error(ArgumentError)
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
# Update Conference
|
284
|
-
describe 'update_conference' do
|
285
|
-
it 'updates a conference' do
|
286
|
-
stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}").
|
287
|
-
to_return(status: 204)
|
288
|
-
|
289
|
-
update_conference_body = Bandwidth::UpdateConference.new(
|
290
|
-
status: Bandwidth::ConferenceStateEnum::ACTIVE,
|
291
|
-
redirect_url: BASE_CALLBACK_URL + '/bxml/pause',
|
292
|
-
redirect_method: Bandwidth::RedirectMethodEnum::POST,
|
293
|
-
username: 'username',
|
294
|
-
password: 'password',
|
295
|
-
redirect_fallback_url: BASE_CALLBACK_URL + '/bxml/pause',
|
296
|
-
redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST,
|
297
|
-
fallback_username: 'username',
|
298
|
-
fallback_password: 'password'
|
299
|
-
)
|
300
|
-
|
301
|
-
_data, status_code = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, conference_id, update_conference_body)
|
302
|
-
expect(status_code).to eq(204)
|
303
|
-
end
|
304
|
-
|
305
|
-
it 'causes an ArgumentError for a missing account_id' do
|
306
|
-
expect {
|
307
|
-
@conferences_api_instance.update_conference(nil, '', '')
|
308
|
-
}.to raise_error(ArgumentError)
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
312
|
-
expect {
|
313
|
-
@conferences_api_instance.update_conference(BW_ACCOUNT_ID, nil, '')
|
314
|
-
}.to raise_error(ArgumentError)
|
315
|
-
end
|
316
|
-
|
317
|
-
it 'causes an ArgumentError for a missing update_conference' do
|
318
|
-
expect {
|
319
|
-
@conferences_api_instance.update_conference(BW_ACCOUNT_ID, '', nil)
|
320
|
-
}.to raise_error(ArgumentError)
|
321
|
-
end
|
322
|
-
end
|
323
|
-
|
324
|
-
# Update Conference BXML
|
325
|
-
describe 'update_conference_bxml' do
|
326
|
-
it 'updates a conference using bxml' do
|
327
|
-
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/bxml").
|
328
|
-
to_return(status: 204)
|
329
|
-
|
330
|
-
update_bxml = '<?xml version="1.0" encoding="UTF-8"?><Bxml><StartRecording/><SpeakSentence locale="en_US" gender="female" voice="susan">This should be a conference recording.</SpeakSentence><StopRecording/></Bxml>'
|
331
|
-
|
332
|
-
_data, status_code = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, conference_id, update_bxml)
|
333
|
-
expect(status_code).to eq(204)
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'causes an ArgumentError for a missing account_id' do
|
337
|
-
expect {
|
338
|
-
@conferences_api_instance.update_conference_bxml(nil, '', '')
|
339
|
-
}.to raise_error(ArgumentError)
|
340
|
-
end
|
341
|
-
|
342
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
343
|
-
expect {
|
344
|
-
@conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, nil, '')
|
345
|
-
}.to raise_error(ArgumentError)
|
346
|
-
end
|
347
|
-
|
348
|
-
it 'causes an ArgumentError for a missing body' do
|
349
|
-
expect {
|
350
|
-
@conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, '', nil)
|
351
|
-
}.to raise_error(ArgumentError)
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
# Update Conference Member
|
356
|
-
describe 'update_conference_member' do
|
357
|
-
it 'updates a conference member by call id' do
|
358
|
-
stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}").
|
359
|
-
to_return(status: 204)
|
360
|
-
|
361
|
-
update_conference_member = Bandwidth::UpdateConferenceMember.new(
|
362
|
-
mute: false
|
363
|
-
)
|
364
|
-
|
365
|
-
_data, status_code = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id, update_conference_member)
|
366
|
-
expect(status_code).to eq(204)
|
367
|
-
end
|
368
|
-
|
369
|
-
it 'causes an ArgumentError for a missing account_id' do
|
370
|
-
expect {
|
371
|
-
@conferences_api_instance.update_conference_member(nil, '', '', {})
|
372
|
-
}.to raise_error(ArgumentError)
|
373
|
-
end
|
374
|
-
|
375
|
-
it 'causes an ArgumentError for a missing conference_id' do
|
376
|
-
expect {
|
377
|
-
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, nil, '', {})
|
378
|
-
}.to raise_error(ArgumentError)
|
379
|
-
end
|
380
|
-
|
381
|
-
it 'causes an ArgumentError for a missing member_id' do
|
382
|
-
expect {
|
383
|
-
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', nil, {})
|
384
|
-
}.to raise_error(ArgumentError)
|
385
|
-
end
|
386
|
-
|
387
|
-
it 'causes an ArgumentError for a missing update_conference_member' do
|
388
|
-
expect {
|
389
|
-
@conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', '', nil)
|
390
|
-
}.to raise_error(ArgumentError)
|
391
|
-
end
|
392
|
-
end
|
393
|
-
end
|
@@ -1,193 +0,0 @@
|
|
1
|
-
# Unit tests for Bandwidth::MessagesApi
|
2
|
-
describe 'MessagesApi' do
|
3
|
-
# message info
|
4
|
-
let(:mms_id) { '1687899647358cu2t57tczmbzcu2s' }
|
5
|
-
let(:sms_id) { '1687899647634s46mhdt7ifq5hnjl' }
|
6
|
-
let(:time) { '2023-06-27T21:00:47.358063Z' }
|
7
|
-
let(:segment_count) { 1 }
|
8
|
-
let(:direction) { Bandwidth::MessageDirectionEnum::OUT }
|
9
|
-
let(:text) { 'test text' }
|
10
|
-
let(:media_url) { 'https://cdn2.thecatapi.com/images/MTY3ODIyMQ.jpg' }
|
11
|
-
let(:tag) { 'test tag' }
|
12
|
-
let(:priority) { Bandwidth::PriorityEnum::HIGH }
|
13
|
-
let(:expiration_time) { (Time.now + 60).round.to_datetime.rfc3339 }
|
14
|
-
let(:total_count) { 2 }
|
15
|
-
let(:next_page_token) { 'YWZ0ZXI9MTAwJmxpbWl0PTEwMA' }
|
16
|
-
let(:list_message_direction) { Bandwidth::ListMessageDirectionEnum::OUTBOUND }
|
17
|
-
let(:list_message_status) { Bandwidth::MessageStatusEnum::SENT }
|
18
|
-
let(:list_message_type_mms) { Bandwidth::MessageTypeEnum::MMS }
|
19
|
-
let(:list_message_type_sms) { Bandwidth::MessageTypeEnum::SMS }
|
20
|
-
let(:mms_length) { 45151 }
|
21
|
-
let(:attachment_count) { 1 }
|
22
|
-
let(:recipient_count) { 1 }
|
23
|
-
let(:mms_error_code) { 0 }
|
24
|
-
let(:sms_error_code) { 4720 }
|
25
|
-
let(:carrier_name) { 'Other' }
|
26
|
-
let(:next_page_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}&pageToken=#{next_page_token}" }
|
27
|
-
|
28
|
-
# stubs
|
29
|
-
let(:create_message_mms_headers_stub) { { 'content-type' => 'application/json' } }
|
30
|
-
let(:create_message_mms_body_stub) { "{\"id\":\"#{mms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"media\":[\"#{media_url}\"],\"tag\":\"#{tag}\"}" }
|
31
|
-
let(:create_message_sms_headers_stub) { { 'content-type' => 'application/json' } }
|
32
|
-
let(:create_message_sms_body_stub) { "{\"id\":\"#{sms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"tag\":\"#{tag}\",\"priority\":\"#{priority}\",\"expiration\":\"#{expiration_time}\"}" }
|
33
|
-
let(:list_messages_body_stub) { "{\"totalCount\":#{total_count},\"pageInfo\":{\"nextPage\":\"#{next_page_url}\",\"nextPageToken\":\"#{next_page_token}\"},\"messages\":[{\"messageId\":\"#{mms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_mms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{mms_length},\"messageSize\":#{mms_length},\"attachmentCount\":#{attachment_count},\"recipientCount\":#{recipient_count},\"errorCode\":#{mms_error_code},\"carrierName\":null,\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"},{\"messageId\":\"#{sms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_sms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{text.length},\"messageSize\":null,\"attachmentCount\":null,\"recipientCount\":null,\"errorCode\":#{sms_error_code},\"carrierName\":\"#{carrier_name}\",\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"}]}" }
|
34
|
-
let(:list_messages_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{list_messages_body_stub.length}" } }
|
35
|
-
|
36
|
-
before(:all) do
|
37
|
-
Bandwidth.configure do |config|
|
38
|
-
config.debugging = true
|
39
|
-
end
|
40
|
-
@messaging_api_instance = Bandwidth::MessagesApi.new
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'test an instance of MessagesApi' do
|
44
|
-
it 'should create an instance of MessagesApi' do
|
45
|
-
expect(@messaging_api_instance).to be_instance_of(Bandwidth::MessagesApi)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Create Message
|
50
|
-
describe 'create_message' do
|
51
|
-
it 'creates an mms message' do
|
52
|
-
stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages").
|
53
|
-
to_return(status: 202, headers: create_message_mms_headers_stub, body: create_message_mms_body_stub)
|
54
|
-
|
55
|
-
message_request = Bandwidth::MessageRequest.new(
|
56
|
-
application_id: BW_MESSAGING_APPLICATION_ID,
|
57
|
-
to: [USER_NUMBER],
|
58
|
-
from: BW_NUMBER,
|
59
|
-
text: text,
|
60
|
-
media: [media_url],
|
61
|
-
tag: tag
|
62
|
-
)
|
63
|
-
|
64
|
-
data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
|
65
|
-
|
66
|
-
expect(status_code).to eq(202)
|
67
|
-
expect(headers).to eq(create_message_mms_headers_stub)
|
68
|
-
expect(data).to be_instance_of(Bandwidth::Message)
|
69
|
-
expect(data.id).to eq(mms_id)
|
70
|
-
expect(data.owner).to eq(BW_NUMBER)
|
71
|
-
expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID)
|
72
|
-
expect(data.time).to eq(Time.parse(time))
|
73
|
-
expect(data.segment_count).to eq(segment_count)
|
74
|
-
expect(data.direction).to eq(direction)
|
75
|
-
expect(data.to).to eq([USER_NUMBER])
|
76
|
-
expect(data.from).to eq(BW_NUMBER)
|
77
|
-
expect(data.text).to eq(text)
|
78
|
-
expect(data.media).to eq([media_url])
|
79
|
-
expect(data.tag).to eq(tag)
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'creates an sms message' do
|
83
|
-
stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages").
|
84
|
-
to_return(status: 202, headers: create_message_sms_headers_stub, body: create_message_sms_body_stub)
|
85
|
-
|
86
|
-
message_request = Bandwidth::MessageRequest.new(
|
87
|
-
application_id: BW_MESSAGING_APPLICATION_ID,
|
88
|
-
to: [USER_NUMBER],
|
89
|
-
from: BW_NUMBER,
|
90
|
-
text: text,
|
91
|
-
tag: tag,
|
92
|
-
priority: priority,
|
93
|
-
expiration: expiration_time
|
94
|
-
)
|
95
|
-
|
96
|
-
data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
|
97
|
-
|
98
|
-
expect(status_code).to eq(202)
|
99
|
-
expect(headers).to eq(create_message_sms_headers_stub)
|
100
|
-
expect(data).to be_instance_of(Bandwidth::Message)
|
101
|
-
expect(data.id).to eq(sms_id)
|
102
|
-
expect(data.owner).to eq(BW_NUMBER)
|
103
|
-
expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID)
|
104
|
-
expect(data.time).to eq(Time.parse(time))
|
105
|
-
expect(data.segment_count).to eq(segment_count)
|
106
|
-
expect(data.direction).to eq(direction)
|
107
|
-
expect(data.to).to eq([USER_NUMBER])
|
108
|
-
expect(data.from).to eq(BW_NUMBER)
|
109
|
-
expect(data.text).to eq(text)
|
110
|
-
expect(data.tag).to eq(tag)
|
111
|
-
expect(data.priority).to eq(priority)
|
112
|
-
expect(data.expiration).to eq(Time.parse(expiration_time))
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'causes an ArgumentError for a missing account_id' do
|
116
|
-
expect {
|
117
|
-
@messaging_api_instance.create_message(nil, {})
|
118
|
-
}.to raise_error(ArgumentError)
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'causes an ArgumentError for a missing message_request' do
|
122
|
-
expect {
|
123
|
-
@messaging_api_instance.create_message(BW_ACCOUNT_ID, nil)
|
124
|
-
}.to raise_error(ArgumentError)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
# List Messages
|
129
|
-
describe 'list_messages' do
|
130
|
-
it 'lists messages' do
|
131
|
-
stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}").
|
132
|
-
to_return(status: 200, headers: list_messages_headers_stub, body: list_messages_body_stub)
|
133
|
-
|
134
|
-
get_opts = {
|
135
|
-
:source_tn => BW_NUMBER,
|
136
|
-
:message_direction => list_message_direction
|
137
|
-
}
|
138
|
-
|
139
|
-
data, status_code, headers = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID, get_opts)
|
140
|
-
|
141
|
-
expect(status_code).to eq(200)
|
142
|
-
expect(headers).to eq(list_messages_headers_stub)
|
143
|
-
expect(data).to be_instance_of(Bandwidth::MessagesList)
|
144
|
-
expect(data.total_count).to eq(total_count)
|
145
|
-
expect(data.page_info.next_page).to eq(next_page_url)
|
146
|
-
expect(data.page_info.next_page_token).to eq(next_page_token)
|
147
|
-
expect(data.messages.length).to eq(total_count)
|
148
|
-
expect(data.messages).to be_instance_of(Array)
|
149
|
-
expect(data.messages[0]).to be_instance_of(Bandwidth::ListMessageItem)
|
150
|
-
expect(data.messages[0].message_id).to eq(mms_id)
|
151
|
-
expect(data.messages[0].account_id).to eq(BW_ACCOUNT_ID)
|
152
|
-
expect(data.messages[0].source_tn).to eq(BW_NUMBER)
|
153
|
-
expect(data.messages[0].destination_tn).to eq(USER_NUMBER)
|
154
|
-
expect(data.messages[0].message_status).to eq(list_message_status)
|
155
|
-
expect(data.messages[0].message_direction).to eq(list_message_direction)
|
156
|
-
expect(data.messages[0].message_type).to eq(list_message_type_mms)
|
157
|
-
expect(data.messages[0].segment_count).to eq(segment_count)
|
158
|
-
expect(data.messages[0].error_code).to eq(mms_error_code)
|
159
|
-
expect(data.messages[0].receive_time).to eq(Time.parse(time))
|
160
|
-
expect(data.messages[0].carrier_name).to eq(nil)
|
161
|
-
expect(data.messages[0].message_size).to eq(mms_length)
|
162
|
-
expect(data.messages[0].message_length).to eq(mms_length)
|
163
|
-
expect(data.messages[0].attachment_count).to eq(attachment_count)
|
164
|
-
expect(data.messages[0].recipient_count).to eq(recipient_count)
|
165
|
-
expect(data.messages[0].campaign_class).to eq(nil)
|
166
|
-
expect(data.messages[0].campaign_id).to eq(nil)
|
167
|
-
expect(data.messages[1]).to be_instance_of(Bandwidth::ListMessageItem)
|
168
|
-
expect(data.messages[1].message_id).to eq(sms_id)
|
169
|
-
expect(data.messages[1].account_id).to eq(BW_ACCOUNT_ID)
|
170
|
-
expect(data.messages[1].source_tn).to eq(BW_NUMBER)
|
171
|
-
expect(data.messages[1].destination_tn).to eq(USER_NUMBER)
|
172
|
-
expect(data.messages[1].message_status).to eq(list_message_status)
|
173
|
-
expect(data.messages[1].message_direction).to eq(list_message_direction)
|
174
|
-
expect(data.messages[1].message_type).to eq(list_message_type_sms)
|
175
|
-
expect(data.messages[1].segment_count).to eq(segment_count)
|
176
|
-
expect(data.messages[1].error_code).to eq(sms_error_code)
|
177
|
-
expect(data.messages[1].receive_time).to eq(Time.parse(time))
|
178
|
-
expect(data.messages[1].carrier_name).to eq(carrier_name)
|
179
|
-
expect(data.messages[1].message_size).to eq(nil)
|
180
|
-
expect(data.messages[1].message_length).to eq(text.length)
|
181
|
-
expect(data.messages[1].attachment_count).to eq(nil)
|
182
|
-
expect(data.messages[1].recipient_count).to eq(nil)
|
183
|
-
expect(data.messages[1].campaign_class).to eq(nil)
|
184
|
-
expect(data.messages[1].campaign_id).to eq(nil)
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'causes an ArgumentError for a missing account_id' do
|
188
|
-
expect {
|
189
|
-
@messaging_api_instance.list_messages(nil)
|
190
|
-
}.to raise_error(ArgumentError)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|