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.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Gemfile.lock +13 -22
  4. data/README.md +3 -1
  5. data/Rakefile +4 -12
  6. data/bandwidth-sdk.gemspec +3 -1
  7. data/bandwidth.yml +48 -33
  8. data/coverage/.last_run.json +1 -1
  9. data/coverage/.resultset.json +1333 -1598
  10. data/coverage/index.html +6890 -9805
  11. data/custom_templates/Gemfile.mustache +1 -2
  12. data/custom_templates/gemspec.mustache +2 -0
  13. data/docs/AnswerCallback.md +2 -2
  14. data/docs/BridgeCompleteCallback.md +2 -2
  15. data/docs/BridgeTargetCompleteCallback.md +2 -2
  16. data/docs/CallRecordingMetadata.md +4 -4
  17. data/docs/CallState.md +1 -1
  18. data/docs/CallTranscription.md +6 -6
  19. data/docs/CallTranscriptionDetectedLanguageEnum.md +15 -0
  20. data/docs/CallTranscriptionResponse.md +2 -2
  21. data/docs/CallTranscriptionTrackEnum.md +15 -0
  22. data/docs/CallsApi.md +1 -1
  23. data/docs/ConferenceMemberExitCallback.md +1 -1
  24. data/docs/ConferenceMemberJoinCallback.md +1 -1
  25. data/docs/ConferenceRecordingAvailableCallback.md +1 -1
  26. data/docs/ConferenceRecordingMetadata.md +1 -1
  27. data/docs/CreateCall.md +5 -3
  28. data/docs/DisconnectCallback.md +2 -2
  29. data/docs/DtmfCallback.md +4 -4
  30. data/docs/GatherCallback.md +4 -4
  31. data/docs/InitiateCallback.md +2 -2
  32. data/docs/MachineDetectionCompleteCallback.md +2 -2
  33. data/docs/MessagingCodeResponse.md +1 -1
  34. data/docs/RecordingAvailableCallback.md +4 -4
  35. data/docs/RecordingCompleteCallback.md +4 -4
  36. data/docs/RecordingTranscriptionMetadata.md +1 -1
  37. data/docs/RedirectCallback.md +4 -4
  38. data/docs/TranscriptionAvailableCallback.md +4 -4
  39. data/docs/TranscriptionsApi.md +1 -1
  40. data/docs/TransferAnswerCallback.md +4 -4
  41. data/docs/TransferCompleteCallback.md +4 -4
  42. data/docs/TransferDisconnectCallback.md +4 -4
  43. data/lib/bandwidth-sdk/api/calls_api.rb +1 -1
  44. data/lib/bandwidth-sdk/api/conferences_api.rb +1 -1
  45. data/lib/bandwidth-sdk/api/media_api.rb +1 -1
  46. data/lib/bandwidth-sdk/api/messages_api.rb +1 -1
  47. data/lib/bandwidth-sdk/api/mfa_api.rb +1 -1
  48. data/lib/bandwidth-sdk/api/phone_number_lookup_api.rb +1 -1
  49. data/lib/bandwidth-sdk/api/recordings_api.rb +1 -1
  50. data/lib/bandwidth-sdk/api/statistics_api.rb +1 -1
  51. data/lib/bandwidth-sdk/api/transcriptions_api.rb +3 -3
  52. data/lib/bandwidth-sdk/api_client.rb +44 -41
  53. data/lib/bandwidth-sdk/api_error.rb +1 -1
  54. data/lib/bandwidth-sdk/configuration.rb +11 -1
  55. data/lib/bandwidth-sdk/models/account_statistics.rb +2 -2
  56. data/lib/bandwidth-sdk/models/answer_callback.rb +3 -3
  57. data/lib/bandwidth-sdk/models/bridge_complete_callback.rb +3 -3
  58. data/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +3 -3
  59. data/lib/bandwidth-sdk/models/bxml/root.rb +0 -6
  60. data/lib/bandwidth-sdk/models/bxml/verbs/gather.rb +0 -6
  61. data/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb +0 -6
  62. data/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb +0 -6
  63. data/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb +0 -6
  64. data/lib/bandwidth-sdk/models/call_direction_enum.rb +1 -1
  65. data/lib/bandwidth-sdk/models/call_recording_metadata.rb +4 -4
  66. data/lib/bandwidth-sdk/models/call_state.rb +2 -2
  67. data/lib/bandwidth-sdk/models/call_state_enum.rb +1 -1
  68. data/lib/bandwidth-sdk/models/call_transcription.rb +11 -37
  69. data/lib/bandwidth-sdk/models/call_transcription_detected_language_enum.rb +41 -0
  70. data/lib/bandwidth-sdk/models/call_transcription_metadata.rb +2 -2
  71. data/lib/bandwidth-sdk/models/call_transcription_response.rb +2 -2
  72. data/lib/bandwidth-sdk/models/call_transcription_track_enum.rb +40 -0
  73. data/lib/bandwidth-sdk/models/callback_method_enum.rb +1 -1
  74. data/lib/bandwidth-sdk/models/code_request.rb +2 -2
  75. data/lib/bandwidth-sdk/models/conference.rb +2 -2
  76. data/lib/bandwidth-sdk/models/conference_completed_callback.rb +2 -2
  77. data/lib/bandwidth-sdk/models/conference_created_callback.rb +2 -2
  78. data/lib/bandwidth-sdk/models/conference_member.rb +2 -2
  79. data/lib/bandwidth-sdk/models/conference_member_exit_callback.rb +3 -3
  80. data/lib/bandwidth-sdk/models/conference_member_join_callback.rb +3 -3
  81. data/lib/bandwidth-sdk/models/conference_recording_available_callback.rb +2 -2
  82. data/lib/bandwidth-sdk/models/conference_recording_metadata.rb +2 -2
  83. data/lib/bandwidth-sdk/models/conference_redirect_callback.rb +2 -2
  84. data/lib/bandwidth-sdk/models/conference_state_enum.rb +1 -1
  85. data/lib/bandwidth-sdk/models/create_call.rb +16 -5
  86. data/lib/bandwidth-sdk/models/create_call_response.rb +2 -2
  87. data/lib/bandwidth-sdk/models/create_lookup_response.rb +2 -2
  88. data/lib/bandwidth-sdk/models/create_message_request_error.rb +2 -2
  89. data/lib/bandwidth-sdk/models/deferred_result.rb +2 -2
  90. data/lib/bandwidth-sdk/models/disconnect_callback.rb +3 -3
  91. data/lib/bandwidth-sdk/models/diversion.rb +2 -2
  92. data/lib/bandwidth-sdk/models/dtmf_callback.rb +4 -4
  93. data/lib/bandwidth-sdk/models/field_error.rb +2 -2
  94. data/lib/bandwidth-sdk/models/file_format_enum.rb +1 -1
  95. data/lib/bandwidth-sdk/models/gather_callback.rb +4 -4
  96. data/lib/bandwidth-sdk/models/inbound_message_callback.rb +2 -2
  97. data/lib/bandwidth-sdk/models/inbound_message_callback_message.rb +2 -2
  98. data/lib/bandwidth-sdk/models/initiate_callback.rb +3 -3
  99. data/lib/bandwidth-sdk/models/list_message_direction_enum.rb +1 -1
  100. data/lib/bandwidth-sdk/models/list_message_item.rb +2 -2
  101. data/lib/bandwidth-sdk/models/lookup_request.rb +2 -2
  102. data/lib/bandwidth-sdk/models/lookup_result.rb +2 -2
  103. data/lib/bandwidth-sdk/models/lookup_status.rb +2 -2
  104. data/lib/bandwidth-sdk/models/lookup_status_enum.rb +1 -1
  105. data/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +3 -3
  106. data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +3 -3
  107. data/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +1 -1
  108. data/lib/bandwidth-sdk/models/machine_detection_result.rb +2 -2
  109. data/lib/bandwidth-sdk/models/media.rb +2 -2
  110. data/lib/bandwidth-sdk/models/message.rb +2 -2
  111. data/lib/bandwidth-sdk/models/message_delivered_callback.rb +2 -2
  112. data/lib/bandwidth-sdk/models/message_delivered_callback_message.rb +2 -2
  113. data/lib/bandwidth-sdk/models/message_direction_enum.rb +1 -1
  114. data/lib/bandwidth-sdk/models/message_failed_callback.rb +2 -2
  115. data/lib/bandwidth-sdk/models/message_failed_callback_message.rb +2 -2
  116. data/lib/bandwidth-sdk/models/message_request.rb +2 -2
  117. data/lib/bandwidth-sdk/models/message_sending_callback.rb +2 -2
  118. data/lib/bandwidth-sdk/models/message_sending_callback_message.rb +2 -2
  119. data/lib/bandwidth-sdk/models/message_status_enum.rb +1 -1
  120. data/lib/bandwidth-sdk/models/message_type_enum.rb +1 -1
  121. data/lib/bandwidth-sdk/models/messages_list.rb +2 -2
  122. data/lib/bandwidth-sdk/models/messaging_code_response.rb +2 -2
  123. data/lib/bandwidth-sdk/models/messaging_request_error.rb +2 -2
  124. data/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +2 -2
  125. data/lib/bandwidth-sdk/models/mfa_request_error.rb +2 -2
  126. data/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +2 -2
  127. data/lib/bandwidth-sdk/models/page_info.rb +2 -2
  128. data/lib/bandwidth-sdk/models/priority_enum.rb +1 -1
  129. data/lib/bandwidth-sdk/models/recording_available_callback.rb +4 -4
  130. data/lib/bandwidth-sdk/models/recording_complete_callback.rb +4 -4
  131. data/lib/bandwidth-sdk/models/recording_state_enum.rb +1 -1
  132. data/lib/bandwidth-sdk/models/recording_transcription_metadata.rb +3 -3
  133. data/lib/bandwidth-sdk/models/recording_transcriptions.rb +2 -2
  134. data/lib/bandwidth-sdk/models/redirect_callback.rb +4 -4
  135. data/lib/bandwidth-sdk/models/redirect_method_enum.rb +1 -1
  136. data/lib/bandwidth-sdk/models/stir_shaken.rb +2 -2
  137. data/lib/bandwidth-sdk/models/tag.rb +2 -2
  138. data/lib/bandwidth-sdk/models/tn_lookup_request_error.rb +2 -2
  139. data/lib/bandwidth-sdk/models/transcribe_recording.rb +2 -2
  140. data/lib/bandwidth-sdk/models/transcription.rb +2 -2
  141. data/lib/bandwidth-sdk/models/transcription_available_callback.rb +4 -4
  142. data/lib/bandwidth-sdk/models/transfer_answer_callback.rb +4 -4
  143. data/lib/bandwidth-sdk/models/transfer_complete_callback.rb +4 -4
  144. data/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +4 -4
  145. data/lib/bandwidth-sdk/models/update_call.rb +2 -2
  146. data/lib/bandwidth-sdk/models/update_call_recording.rb +2 -2
  147. data/lib/bandwidth-sdk/models/update_conference.rb +2 -2
  148. data/lib/bandwidth-sdk/models/update_conference_member.rb +2 -2
  149. data/lib/bandwidth-sdk/models/verify_code_request.rb +2 -2
  150. data/lib/bandwidth-sdk/models/verify_code_response.rb +2 -2
  151. data/lib/bandwidth-sdk/models/voice_api_error.rb +2 -2
  152. data/lib/bandwidth-sdk/models/voice_code_response.rb +2 -2
  153. data/lib/bandwidth-sdk/version.rb +2 -2
  154. data/lib/bandwidth-sdk.rb +3 -1
  155. data/openapitools.json +1 -1
  156. data/spec/call_utils.rb +1 -1
  157. data/spec/{integration/calls_api_integration_spec.rb → smoke/calls_api_spec.rb} +3 -6
  158. data/spec/{integration/conferences_api_integration_spec.rb → smoke/conferences_api_spec.rb} +0 -5
  159. data/spec/{integration/media_api_integration_spec.rb → smoke/media_api_spec.rb} +0 -5
  160. data/spec/{integration/messages_api_integration_spec.rb → smoke/messages_api_spec.rb} +0 -5
  161. data/spec/{integration/mfa_api_integration_spec.rb → smoke/mfa_api_spec.rb} +0 -5
  162. data/spec/{integration/phone_number_lookup_api_integration_spec.rb → smoke/phone_number_lookup_api_spec.rb} +0 -5
  163. data/spec/{integration/recordings_api_integration_spec.rb → smoke/recordings_api_spec.rb} +0 -5
  164. data/spec/{integration/statistics_api_integration_spec.rb → smoke/statistics_api_spec.rb} +0 -5
  165. data/spec/{integration/transcriptions_api_integration_spec.rb → smoke/transcriptions_api_spec.rb} +0 -5
  166. data/spec/spec_helper.rb +13 -6
  167. data/spec/unit/api/calls_api_spec.rb +233 -0
  168. data/spec/unit/api/conferences_api_spec.rb +330 -0
  169. data/spec/{api → unit/api}/media_api_spec.rb +17 -32
  170. data/spec/unit/api/messages_api_spec.rb +103 -0
  171. data/spec/{api → unit/api}/mfa_api_spec.rb +8 -24
  172. data/spec/unit/api/phone_number_lookup_api_spec.rb +86 -0
  173. data/spec/{api → unit/api}/recordings_api_spec.rb +83 -110
  174. data/spec/unit/api/statistics_api_spec.rb +37 -0
  175. data/spec/{api → unit/api}/transcriptions_api_spec.rb +18 -37
  176. data/spec/{api_client_spec.rb → unit/client/api_client_spec.rb} +4 -4
  177. metadata +136 -118
  178. data/spec/api/calls_api_spec.rb +0 -261
  179. data/spec/api/conferences_api_spec.rb +0 -393
  180. data/spec/api/messages_api_spec.rb +0 -193
  181. data/spec/api/phone_number_lookup_api_spec.rb +0 -100
  182. data/spec/api/statistics_api_spec.rb +0 -45
  183. /data/spec/{api_error_spec.rb → unit/client/api_error_spec.rb} +0 -0
  184. /data/spec/{configuration_spec.rb → unit/client/configuration_spec.rb} +0 -0
  185. /data/spec/{models → unit/models}/bxml/bxml_spec.rb +0 -0
  186. /data/spec/{models → unit/models}/bxml/nestable_verb_spec.rb +0 -0
  187. /data/spec/{models → unit/models}/bxml/response_spec.rb +0 -0
  188. /data/spec/{models → unit/models}/bxml/verb_spec.rb +0 -0
  189. /data/spec/{models → unit/models}/bxml/verbs/bridge_spec.rb +0 -0
  190. /data/spec/{models → unit/models}/bxml/verbs/conference_spec.rb +0 -0
  191. /data/spec/{models → unit/models}/bxml/verbs/custom_param_spec.rb +0 -0
  192. /data/spec/{models → unit/models}/bxml/verbs/forward_spec.rb +0 -0
  193. /data/spec/{models → unit/models}/bxml/verbs/gather_spec.rb +0 -0
  194. /data/spec/{models → unit/models}/bxml/verbs/hangup_spec.rb +0 -0
  195. /data/spec/{models → unit/models}/bxml/verbs/pause_recording_spec.rb +0 -0
  196. /data/spec/{models → unit/models}/bxml/verbs/pause_spec.rb +0 -0
  197. /data/spec/{models → unit/models}/bxml/verbs/phone_number_spec.rb +0 -0
  198. /data/spec/{models → unit/models}/bxml/verbs/play_audio_spec.rb +0 -0
  199. /data/spec/{models → unit/models}/bxml/verbs/record_spec.rb +0 -0
  200. /data/spec/{models → unit/models}/bxml/verbs/redirect_spec.rb +0 -0
  201. /data/spec/{models → unit/models}/bxml/verbs/resume_recording_spec.rb +0 -0
  202. /data/spec/{models → unit/models}/bxml/verbs/ring_spec.rb +0 -0
  203. /data/spec/{models → unit/models}/bxml/verbs/send_dtmf_spec.rb +0 -0
  204. /data/spec/{models → unit/models}/bxml/verbs/sip_uri_spec.rb +0 -0
  205. /data/spec/{models → unit/models}/bxml/verbs/speak_sentence_spec.rb +0 -0
  206. /data/spec/{models → unit/models}/bxml/verbs/start_gather_spec.rb +0 -0
  207. /data/spec/{models → unit/models}/bxml/verbs/start_recording_spec.rb +0 -0
  208. /data/spec/{models → unit/models}/bxml/verbs/start_stream_spec.rb +0 -0
  209. /data/spec/{models → unit/models}/bxml/verbs/start_transcription_spec.rb +0 -0
  210. /data/spec/{models → unit/models}/bxml/verbs/stop_gather_spec.rb +0 -0
  211. /data/spec/{models → unit/models}/bxml/verbs/stop_recording_spec.rb +0 -0
  212. /data/spec/{models → unit/models}/bxml/verbs/stop_stream_spec.rb +0 -0
  213. /data/spec/{models → unit/models}/bxml/verbs/stop_transcription_spec.rb +0 -0
  214. /data/spec/{models → unit/models}/bxml/verbs/stream_param_spec.rb +0 -0
  215. /data/spec/{models → unit/models}/bxml/verbs/tag_spec.rb +0 -0
  216. /data/spec/{models → unit/models}/bxml/verbs/transfer_spec.rb +0 -0
  217. /data/spec/{models → unit/models}/call_state_enum_spec.rb +0 -0
  218. /data/spec/{models → unit/models}/call_state_spec.rb +0 -0
  219. /data/spec/{models → unit/models}/deferred_result_spec.rb +0 -0
  220. /data/spec/{models → unit/models}/message_spec.rb +0 -0
  221. /data/spec/{models → unit/models}/verify_code_request_spec.rb +0 -0
@@ -0,0 +1,330 @@
1
+ # Unit tests for Bandwidth::ConferencesApi
2
+ describe 'ConferencesApi' do
3
+ let(:call_id) { 'c-1234' }
4
+ let(:conference_id) { 'c-4321' }
5
+ let(:recording_id) { 'r-1234' }
6
+
7
+ before(:all) do
8
+ Bandwidth.configure do |config|
9
+ config.debugging = true
10
+ config.username = BW_USERNAME
11
+ config.password = BW_PASSWORD
12
+ config.ignore_operation_servers = true
13
+ config.host = '127.0.0.1:4010'
14
+ end
15
+ @conferences_api_instance = Bandwidth::ConferencesApi.new
16
+ end
17
+
18
+ describe 'test an instance of ConferencesApi' do
19
+ it 'should create an instance of ConferencesApi' do
20
+ expect(@conferences_api_instance).to be_instance_of(Bandwidth::ConferencesApi)
21
+ end
22
+ end
23
+
24
+ # Download Conference Recording
25
+ describe 'download_conference_recording test' do
26
+ it 'download a conference recording' do
27
+ data, status_code = @conferences_api_instance.download_conference_recording_with_http_info(
28
+ BW_ACCOUNT_ID, conference_id, recording_id, { header_params: { 'Accept' => 'audio/vnd.wave' } })
29
+
30
+ expect(status_code).to eq(200)
31
+ # expect(data).to be_instance_of(String)
32
+ end if false # skip for now due to an issue with setting the Accept header
33
+
34
+ it 'causes an ArgumentError for a missing account_id' do
35
+ expect {
36
+ @conferences_api_instance.download_conference_recording(nil, '', '')
37
+ }.to raise_error(ArgumentError)
38
+ end
39
+
40
+ it 'causes an ArgumentError for a missing conference_id' do
41
+ expect {
42
+ @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, nil, '')
43
+ }.to raise_error(ArgumentError)
44
+ end
45
+
46
+ it 'causes an ArgumentError for a missing recording_id' do
47
+ expect {
48
+ @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, '', nil)
49
+ }.to raise_error(ArgumentError)
50
+ end
51
+ end
52
+
53
+ # Get Conference Information
54
+ describe 'get_conference' do
55
+ it 'get a conference by id' do
56
+ data, status_code = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, conference_id)
57
+
58
+ expect(status_code).to eq(200)
59
+ expect(data).to be_instance_of(Bandwidth::Conference)
60
+ expect(data.id.length).to eq(50)
61
+ expect(data.name).to be_instance_of(String)
62
+ expect(data.created_time).to be_instance_of(Time)
63
+ expect(data.completed_time).to be_instance_of(Time)
64
+ expect(data.conference_event_url).to start_with('http')
65
+ expect(data.conference_event_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
66
+ expect(data.tag).to be_instance_of(String)
67
+ end
68
+
69
+ it 'causes an ArgumentError for a missing account_id' do
70
+ expect {
71
+ @conferences_api_instance.get_conference(nil, '')
72
+ }.to raise_error(ArgumentError)
73
+ end
74
+
75
+ it 'causes an ArgumentError for a missing conference_id' do
76
+ expect {
77
+ @conferences_api_instance.get_conference(BW_ACCOUNT_ID, nil)
78
+ }.to raise_error(ArgumentError)
79
+ end
80
+ end
81
+
82
+ # Get Conference Member
83
+ describe 'get_conference_member' do
84
+ it 'gets a conference member by call id' do
85
+ data, status_code = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id)
86
+
87
+ expect(status_code).to eq(200)
88
+ expect(data).to be_instance_of(Bandwidth::ConferenceMember)
89
+ expect(data.call_id.length).to eq(47)
90
+ expect(data.conference_id.length).to eq(50)
91
+ expect(data.member_url).to start_with('http')
92
+ expect(data.mute).to be_one_of([true, false])
93
+ expect(data.hold).to be_one_of([true, false])
94
+ expect(data.call_ids_to_coach).to be_instance_of(Array)
95
+ end
96
+
97
+ it 'causes an ArgumentError for a missing account_id' do
98
+ expect {
99
+ @conferences_api_instance.get_conference_member(nil, '', '')
100
+ }.to raise_error(ArgumentError)
101
+ end
102
+
103
+ it 'causes an ArgumentError for a missing conference_id' do
104
+ expect {
105
+ @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, nil, '')
106
+ }.to raise_error(ArgumentError)
107
+ end
108
+
109
+ it 'causes an ArgumentError for a missing member_id' do
110
+ expect {
111
+ @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, '', nil)
112
+ }.to raise_error(ArgumentError)
113
+ end
114
+ end
115
+
116
+ # Get Conference Recording Information
117
+ describe 'get_conference_recording' do
118
+ it 'gets a conference recording by id' do
119
+ data, status_code = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id)
120
+
121
+ expect(status_code).to eq(200)
122
+ expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
123
+ expect(data.account_id.length).to eq(7)
124
+ expect(data.conference_id.length).to eq(50)
125
+ expect(data.name).to be_instance_of(String)
126
+ expect(data.recording_id.length).to eq(47)
127
+ expect(data.duration).to start_with('PT')
128
+ expect(data.channels).to be_instance_of(Integer)
129
+ expect(data.start_time).to be_instance_of(Time)
130
+ expect(data.end_time).to be_instance_of(Time)
131
+ expect(data.file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
132
+ expect(data.status).to be_instance_of(String)
133
+ expect(data.media_url).to start_with('http')
134
+ end
135
+
136
+ it 'causes an ArgumentError for a missing account_id' do
137
+ expect {
138
+ @conferences_api_instance.get_conference_recording(nil, '', '')
139
+ }.to raise_error(ArgumentError)
140
+ end
141
+
142
+ it 'causes an ArgumentError for a missing conference_id' do
143
+ expect {
144
+ @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, nil, '')
145
+ }.to raise_error(ArgumentError)
146
+ end
147
+
148
+ it 'causes an ArgumentError for a missing recording_id' do
149
+ expect {
150
+ @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, '', nil)
151
+ }.to raise_error(ArgumentError)
152
+ end
153
+ end
154
+
155
+ # List Conference Recordings
156
+ describe 'list_conference_recordings' do
157
+ it 'lists recordings for a conference' do
158
+ data, status_code = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, conference_id)
159
+
160
+ expect(status_code).to eq(200)
161
+ expect(data).to be_instance_of(Array)
162
+ expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata)
163
+ expect(data[0].account_id.length).to eq(7)
164
+ expect(data[0].conference_id.length).to eq(50)
165
+ expect(data[0].name).to be_instance_of(String)
166
+ expect(data[0].recording_id.length).to eq(47)
167
+ expect(data[0].duration).to start_with('PT')
168
+ expect(data[0].channels).to be_instance_of(Integer)
169
+ expect(data[0].start_time).to be_instance_of(Time)
170
+ expect(data[0].end_time).to be_instance_of(Time)
171
+ expect(data[0].file_format).to be_one_of(Bandwidth::FileFormatEnum.all_vars)
172
+ expect(data[0].status).to be_instance_of(String)
173
+ expect(data[0].media_url).to start_with('http')
174
+ end
175
+
176
+ it 'causes an ArgumentError for a missing account_id' do
177
+ expect {
178
+ @conferences_api_instance.list_conference_recordings(nil, '')
179
+ }.to raise_error(ArgumentError)
180
+ end
181
+
182
+ it 'causes an ArgumentError for a missing conference_id' do
183
+ expect {
184
+ @conferences_api_instance.list_conference_recordings(BW_ACCOUNT_ID, nil)
185
+ }.to raise_error(ArgumentError)
186
+ end
187
+ end
188
+
189
+ # List Conferences
190
+ describe 'list_conferences' do
191
+ it 'list all conferences' do
192
+ conference_opts = {
193
+ name: call_id
194
+ }
195
+
196
+ data, status_code = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts)
197
+
198
+ expect(status_code).to eq(200)
199
+ expect(data).to be_instance_of(Array)
200
+ expect(data[0]).to be_instance_of(Bandwidth::Conference)
201
+ expect(data[0].id.length).to eq(50)
202
+ expect(data[0].name).to be_instance_of(String)
203
+ expect(data[0].created_time).to be_instance_of(Time)
204
+ expect(data[0].completed_time).to be_instance_of(Time)
205
+ expect(data[0].conference_event_url).to start_with('http')
206
+ expect(data[0].conference_event_method).to be_one_of(Bandwidth::CallbackMethodEnum.all_vars)
207
+ expect(data[0].tag).to be_instance_of(String)
208
+ end
209
+
210
+ it 'causes an ArgumentError for a missing account_id' do
211
+ expect {
212
+ @conferences_api_instance.list_conferences(nil, {})
213
+ }.to raise_error(ArgumentError)
214
+ end
215
+
216
+ it 'causes an ArgumentError for an invalid page_size' do
217
+ expect {
218
+ @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 1001 })
219
+ }.to raise_error(ArgumentError)
220
+ end
221
+
222
+ it 'causes an ArgumentError for an invalid page_size' do
223
+ expect {
224
+ @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 0 })
225
+ }.to raise_error(ArgumentError)
226
+ end
227
+ end
228
+
229
+ # Update Conference
230
+ describe 'update_conference' do
231
+ it 'updates a conference' do
232
+ update_conference_body = Bandwidth::UpdateConference.new(
233
+ status: Bandwidth::ConferenceStateEnum::ACTIVE,
234
+ redirect_url: BASE_CALLBACK_URL + '/bxml/pause',
235
+ redirect_method: Bandwidth::RedirectMethodEnum::POST,
236
+ username: 'username',
237
+ password: 'password',
238
+ redirect_fallback_url: BASE_CALLBACK_URL + '/bxml/pause',
239
+ redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST,
240
+ fallback_username: 'username',
241
+ fallback_password: 'password'
242
+ )
243
+
244
+ _data, status_code = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, conference_id, update_conference_body)
245
+ expect(status_code).to eq(204)
246
+ end
247
+
248
+ it 'causes an ArgumentError for a missing account_id' do
249
+ expect {
250
+ @conferences_api_instance.update_conference(nil, '', '')
251
+ }.to raise_error(ArgumentError)
252
+ end
253
+
254
+ it 'causes an ArgumentError for a missing conference_id' do
255
+ expect {
256
+ @conferences_api_instance.update_conference(BW_ACCOUNT_ID, nil, '')
257
+ }.to raise_error(ArgumentError)
258
+ end
259
+
260
+ it 'causes an ArgumentError for a missing update_conference' do
261
+ expect {
262
+ @conferences_api_instance.update_conference(BW_ACCOUNT_ID, '', nil)
263
+ }.to raise_error(ArgumentError)
264
+ end
265
+ end
266
+
267
+ # Update Conference BXML
268
+ describe 'update_conference_bxml' do
269
+ it 'updates a conference using bxml' do
270
+ 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>'
271
+
272
+ _data, status_code = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, conference_id, update_bxml)
273
+ expect(status_code).to eq(204)
274
+ end
275
+
276
+ it 'causes an ArgumentError for a missing account_id' do
277
+ expect {
278
+ @conferences_api_instance.update_conference_bxml(nil, '', '')
279
+ }.to raise_error(ArgumentError)
280
+ end
281
+
282
+ it 'causes an ArgumentError for a missing conference_id' do
283
+ expect {
284
+ @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, nil, '')
285
+ }.to raise_error(ArgumentError)
286
+ end
287
+
288
+ it 'causes an ArgumentError for a missing body' do
289
+ expect {
290
+ @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, '', nil)
291
+ }.to raise_error(ArgumentError)
292
+ end
293
+ end
294
+
295
+ # Update Conference Member
296
+ describe 'update_conference_member' do
297
+ it 'updates a conference member by call id' do
298
+ update_conference_member = Bandwidth::UpdateConferenceMember.new(
299
+ mute: false
300
+ )
301
+
302
+ _data, status_code = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id, update_conference_member)
303
+ expect(status_code).to eq(204)
304
+ end
305
+
306
+ it 'causes an ArgumentError for a missing account_id' do
307
+ expect {
308
+ @conferences_api_instance.update_conference_member(nil, '', '', {})
309
+ }.to raise_error(ArgumentError)
310
+ end
311
+
312
+ it 'causes an ArgumentError for a missing conference_id' do
313
+ expect {
314
+ @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, nil, '', {})
315
+ }.to raise_error(ArgumentError)
316
+ end
317
+
318
+ it 'causes an ArgumentError for a missing member_id' do
319
+ expect {
320
+ @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', nil, {})
321
+ }.to raise_error(ArgumentError)
322
+ end
323
+
324
+ it 'causes an ArgumentError for a missing update_conference_member' do
325
+ expect {
326
+ @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', '', nil)
327
+ }.to raise_error(ArgumentError)
328
+ end
329
+ end
330
+ end
@@ -1,19 +1,16 @@
1
1
  # Unit tests for Bandwidth::MediaApi
2
2
  describe 'MediaApi' do
3
3
  # media info
4
- let(:media_name) { 'ruby_binary_media' + SecureRandom.uuid }
5
- let(:media_data) { '123456' }
6
- let(:content_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}" }
7
-
8
- # stubs
9
- let(:get_media_headers_stub) { { 'content-type' => 'application/json' } }
10
- let(:list_media_body_stub) { "[{\"contentLength\":#{media_data.length},\"mediaName\":\"#{media_name}\",\"content\":\"#{content_url}\"}]" }
11
- let(:list_media_headers_stub) { { 'content-type' => 'application/json' } }
4
+ let(:media_name) { 'ruby_media.jpeg' }
5
+ let(:media_file_data) { File.open('spec/fixtures/ruby_cat.jpeg').read }
12
6
 
13
7
  before(:all) do
14
8
  Bandwidth.configure do |config|
15
- config.return_binary_data = true
16
9
  config.debugging = true
10
+ config.username = BW_USERNAME
11
+ config.password = BW_PASSWORD
12
+ config.ignore_operation_servers = true
13
+ config.host = '127.0.0.1:4010'
17
14
  end
18
15
  @media_api_instance = Bandwidth::MediaApi.new
19
16
  end
@@ -27,9 +24,6 @@ describe 'MediaApi' do
27
24
  # Delete Media
28
25
  describe 'delete_media' do
29
26
  it 'deletes the binary media' do
30
- stub_request(:delete, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
31
- to_return(status: 204)
32
-
33
27
  _data, status_code = @media_api_instance.delete_media_with_http_info(BW_ACCOUNT_ID, media_name)
34
28
 
35
29
  expect(status_code).to eq(204)
@@ -51,15 +45,12 @@ describe 'MediaApi' do
51
45
  # Get Media
52
46
  describe 'get_media' do
53
47
  it 'gets uploaded binary media' do
54
- stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
55
- to_return(status: 200, headers: get_media_headers_stub, body: media_data)
56
-
57
- data, status_code, headers = @media_api_instance.get_media_with_http_info(BW_ACCOUNT_ID, media_name)
48
+ data, status_code = @media_api_instance.get_media_with_http_info(
49
+ BW_ACCOUNT_ID, media_name, { header_params: { 'Accept' => 'application/octet-stream' } })
58
50
 
59
51
  expect(status_code).to eq(200)
60
- expect(headers).to eq(get_media_headers_stub)
61
- expect(data).to eq(media_data)
62
- end
52
+ # expect(data).to be_instance_of(String)
53
+ end if false # skip due to Accept header issue
63
54
 
64
55
  it 'causes an ArgumentError for a missing account_id' do
65
56
  expect {
@@ -77,18 +68,14 @@ describe 'MediaApi' do
77
68
  # List Media
78
69
  describe 'list_media' do
79
70
  it 'lists media' do
80
- stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media").
81
- to_return(status: 200, headers: list_media_headers_stub, body: list_media_body_stub)
82
-
83
- data, status_code, headers = @media_api_instance.list_media_with_http_info(BW_ACCOUNT_ID)
71
+ data, status_code = @media_api_instance.list_media_with_http_info(BW_ACCOUNT_ID)
84
72
 
85
73
  expect(status_code).to eq(200)
86
- expect(headers).to eq(list_media_headers_stub)
87
74
  expect(data).to be_instance_of(Array)
88
75
  expect(data[0]).to be_instance_of(Bandwidth::Media)
89
- expect(data[0].content_length).to eq(media_data.length)
90
- expect(data[0].media_name).to eq(media_name)
91
- expect(data[0].content).to eq(content_url)
76
+ expect(data[0].content).to be_instance_of(String)
77
+ expect(data[0].content_length).to be_instance_of(Integer)
78
+ expect(data[0].media_name).to be_instance_of(String)
92
79
  end
93
80
 
94
81
  it 'causes an ArgumentError for a missing account_id' do
@@ -100,11 +87,9 @@ describe 'MediaApi' do
100
87
 
101
88
  # Upload Media
102
89
  describe 'upload_media' do
103
- it 'uploads binary media' do
104
- stub_request(:put, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}").
105
- to_return(status: 204)
106
-
107
- _data, status_code = @media_api_instance.upload_media_with_http_info(BW_ACCOUNT_ID, media_name, media_data)
90
+ it 'uploads media' do
91
+ _data, status_code = @media_api_instance.upload_media_with_http_info(
92
+ BW_ACCOUNT_ID, media_name, media_file_data, { content_type: 'image/jpeg' })
108
93
  expect(status_code).to eq(204)
109
94
  end
110
95
 
@@ -0,0 +1,103 @@
1
+ # Unit tests for Bandwidth::MessagesApi
2
+ describe 'MessagesApi' do
3
+ before(:all) do
4
+ Bandwidth.configure do |config|
5
+ config.debugging = true
6
+ config.username = BW_USERNAME
7
+ config.password = BW_PASSWORD
8
+ config.ignore_operation_servers = true
9
+ config.host = '127.0.0.1:4010'
10
+ end
11
+ @messaging_api_instance = Bandwidth::MessagesApi.new
12
+ end
13
+
14
+ describe 'test an instance of MessagesApi' do
15
+ it 'should create an instance of MessagesApi' do
16
+ expect(@messaging_api_instance).to be_instance_of(Bandwidth::MessagesApi)
17
+ end
18
+ end
19
+
20
+ # Create Message
21
+ describe 'create_message' do
22
+ it 'creates a message' do
23
+ message_request = Bandwidth::MessageRequest.new(
24
+ application_id: BW_MESSAGING_APPLICATION_ID,
25
+ to: [USER_NUMBER],
26
+ from: BW_NUMBER,
27
+ text: 'Hello',
28
+ )
29
+
30
+ data, status_code = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request)
31
+
32
+ expect(status_code).to eq(202)
33
+ expect(data).to be_instance_of(Bandwidth::Message)
34
+ expect(data.id.length).to eq(29)
35
+ expect(data.owner.length).to eq(12)
36
+ expect(data.application_id.length).to eq(36)
37
+ expect(data.time).to be_instance_of(Time)
38
+ expect(data.segment_count).to be_instance_of(Integer)
39
+ expect(data.direction).to be_one_of(Bandwidth::MessageDirectionEnum.all_vars)
40
+ expect(data.to).to be_instance_of(Array)
41
+ expect(data.to[0].length).to eq(12)
42
+ expect(data.from.length).to eq(12)
43
+ expect(data.media).to be_instance_of(Array)
44
+ expect(data.media[0]).to start_with('http')
45
+ expect(data.text).to be_instance_of(String)
46
+ expect(data.tag).to be_instance_of(String)
47
+ expect(data.priority).to be_one_of(Bandwidth::PriorityEnum.all_vars)
48
+ expect(data.expiration).to be_instance_of(Time)
49
+ end
50
+
51
+ it 'causes an ArgumentError for a missing account_id' do
52
+ expect {
53
+ @messaging_api_instance.create_message(nil, {})
54
+ }.to raise_error(ArgumentError)
55
+ end
56
+
57
+ it 'causes an ArgumentError for a missing message_request' do
58
+ expect {
59
+ @messaging_api_instance.create_message(BW_ACCOUNT_ID, nil)
60
+ }.to raise_error(ArgumentError)
61
+ end
62
+ end
63
+
64
+ # List Messages
65
+ describe 'list_messages' do
66
+ it 'lists messages' do
67
+ data, status_code = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID)
68
+
69
+ expect(status_code).to eq(200)
70
+ expect(data).to be_instance_of(Bandwidth::MessagesList)
71
+ expect(data.total_count).to be_instance_of(Integer)
72
+ expect(data.page_info).to be_instance_of(Bandwidth::PageInfo)
73
+ expect(data.page_info.prev_page).to start_with('http')
74
+ expect(data.page_info.next_page).to start_with('http')
75
+ expect(data.page_info.prev_page_token).to be_instance_of(String)
76
+ expect(data.page_info.next_page_token).to be_instance_of(String)
77
+ expect(data.messages).to be_instance_of(Array)
78
+ expect(data.messages[0].message_id.length).to eq(29)
79
+ expect(data.messages[0].account_id.length).to eq(7)
80
+ expect(data.messages[0].source_tn.length).to eq(12)
81
+ expect(data.messages[0].destination_tn.length).to eq(12)
82
+ expect(data.messages[0].message_status).to be_one_of(Bandwidth::MessageStatusEnum.all_vars)
83
+ expect(data.messages[0].message_direction).to be_one_of(Bandwidth::ListMessageDirectionEnum.all_vars)
84
+ expect(data.messages[0].message_type).to be_one_of(Bandwidth::MessageTypeEnum.all_vars)
85
+ expect(data.messages[0].segment_count).to be_instance_of(Integer)
86
+ expect(data.messages[0].error_code).to be_instance_of(Integer)
87
+ expect(data.messages[0].receive_time).to be_instance_of(Time)
88
+ expect(data.messages[0].carrier_name).to be_instance_of(String)
89
+ expect(data.messages[0].message_size).to be_instance_of(Integer)
90
+ expect(data.messages[0].message_length).to be_instance_of(Integer)
91
+ expect(data.messages[0].attachment_count).to be_instance_of(Integer)
92
+ expect(data.messages[0].recipient_count).to be_instance_of(Integer)
93
+ expect(data.messages[0].campaign_class).to be_instance_of(String)
94
+ expect(data.messages[0].campaign_id).to be_instance_of(String)
95
+ end
96
+
97
+ it 'causes an ArgumentError for a missing account_id' do
98
+ expect {
99
+ @messaging_api_instance.list_messages(nil)
100
+ }.to raise_error(ArgumentError)
101
+ end
102
+ end
103
+ end
@@ -1,22 +1,15 @@
1
1
  # Unit tests for Bandwidth::MFAApi
2
2
  describe 'MFAApi' do
3
- # mfa info
4
3
  let(:message) { 'Your temporary {NAME} {SCOPE} code is: {CODE}' }
5
- let(:message_id) { '1687965513364hx26ky4mpkll3m5a' }
6
- let(:call_id) { 'c-28bba681-cffc7d67-904e-42c8-85c5-b5589ea583b4' }
7
4
  let(:digits) { 6 }
8
5
 
9
- # stubs
10
- let(:generate_messaging_code_body_stub) { "{\"messageId\": \"#{message_id}\"}" }
11
- let(:generate_messaging_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_messaging_code_body_stub.length}" } }
12
- let(:generate_voice_code_body_stub) { "{\"callId\": \"#{call_id}\"}" }
13
- let(:generate_voice_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_voice_code_body_stub.length}" } }
14
- let(:verify_code_body_stub) { '{"valid": false}' }
15
- let(:verify_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{verify_code_body_stub.length}" } }
16
-
17
6
  before(:all) do
18
7
  Bandwidth.configure do |config|
19
8
  config.debugging = true
9
+ config.username = BW_USERNAME
10
+ config.password = BW_PASSWORD
11
+ config.ignore_operation_servers = true
12
+ config.host = '127.0.0.1:4010'
20
13
  end
21
14
  @mfa_api_instance = Bandwidth::MFAApi.new
22
15
  end
@@ -30,9 +23,6 @@ describe 'MFAApi' do
30
23
  # Messaging Authentication Code
31
24
  describe 'generate_messaging_code' do
32
25
  it 'generates messaging mfa code' do
33
- stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/messaging").
34
- to_return(status: 200, headers: generate_messaging_code_headers_stub, body: generate_messaging_code_body_stub)
35
-
36
26
  req_schema = Bandwidth::CodeRequest.new(
37
27
  to: USER_NUMBER,
38
28
  from: BW_NUMBER,
@@ -45,7 +35,7 @@ describe 'MFAApi' do
45
35
 
46
36
  expect(status_code).to eq(200)
47
37
  expect(data).to be_instance_of(Bandwidth::MessagingCodeResponse)
48
- expect(data.message_id).to eq(message_id)
38
+ expect(data.message_id.length).to eq(29)
49
39
  end
50
40
 
51
41
  it 'causes an ArgumentError for a missing account_id' do
@@ -64,9 +54,6 @@ describe 'MFAApi' do
64
54
  # Voice Authentication Code
65
55
  describe 'generate_voice_code' do
66
56
  it 'generates voice mfa code' do
67
- stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/voice").
68
- to_return(status: 200, headers: generate_voice_code_headers_stub, body: generate_voice_code_body_stub)
69
-
70
57
  req_schema = Bandwidth::CodeRequest.new(
71
58
  to: USER_NUMBER,
72
59
  from: BW_NUMBER,
@@ -79,7 +66,7 @@ describe 'MFAApi' do
79
66
 
80
67
  expect(status_code).to eq(200)
81
68
  expect(data).to be_instance_of(Bandwidth::VoiceCodeResponse)
82
- expect(data.call_id).to eq(call_id)
69
+ expect(data.call_id.length).to eq(47)
83
70
  end
84
71
 
85
72
  it 'causes an ArgumentError for a missing account_id' do
@@ -98,11 +85,8 @@ describe 'MFAApi' do
98
85
  # Verify Authentication Code
99
86
  describe 'verify_code' do
100
87
  it 'verifies mfa code' do
101
- stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/verify").
102
- to_return(status: 200, headers: verify_code_headers_stub, body: verify_code_body_stub)
103
-
104
88
  req_schema = Bandwidth::VerifyCodeRequest.new(
105
- to: '+1000' + rand(1...10000000).to_s,
89
+ to: USER_NUMBER,
106
90
  scope: '2FA',
107
91
  expiration_time_in_minutes: 3,
108
92
  code: '12345'
@@ -112,7 +96,7 @@ describe 'MFAApi' do
112
96
 
113
97
  expect(status_code).to eq(200)
114
98
  expect(data).to be_instance_of(Bandwidth::VerifyCodeResponse)
115
- expect(data.valid).to be false
99
+ expect(data.valid).to be_one_of([true, false])
116
100
  end
117
101
 
118
102
  it 'causes an ArgumentError for a missing account_id' do