bandwidth-sdk 10.5.0 → 11.0.0.pre.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (529) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +77 -0
  4. data/README.md +198 -140
  5. data/Rakefile +22 -0
  6. data/bandwidth-sdk.gemspec +40 -0
  7. data/bandwidth.yml +5544 -0
  8. data/docs/AccountStatistics.md +20 -0
  9. data/docs/AnswerCallback.md +44 -0
  10. data/docs/BridgeCompleteCallback.md +48 -0
  11. data/docs/BridgeTargetCompleteCallback.md +42 -0
  12. data/docs/CallDirectionEnum.md +15 -0
  13. data/docs/CallRecordingMetadata.md +52 -0
  14. data/docs/CallState.md +52 -0
  15. data/docs/CallStateEnum.md +15 -0
  16. data/docs/CallbackMethodEnum.md +15 -0
  17. data/docs/CallsApi.md +304 -0
  18. data/docs/CodeRequest.md +28 -0
  19. data/docs/Conference.md +32 -0
  20. data/docs/ConferenceCompletedCallback.md +26 -0
  21. data/docs/ConferenceCreatedCallback.md +26 -0
  22. data/docs/ConferenceMember.md +28 -0
  23. data/docs/ConferenceMemberExitCallback.md +32 -0
  24. data/docs/ConferenceMemberJoinCallback.md +32 -0
  25. data/docs/ConferenceRecordingAvailableCallback.md +44 -0
  26. data/docs/ConferenceRecordingMetadata.md +38 -0
  27. data/docs/ConferenceRedirectCallback.md +26 -0
  28. data/docs/ConferenceStateEnum.md +15 -0
  29. data/docs/ConferencesApi.md +688 -0
  30. data/docs/CreateCall.md +54 -0
  31. data/docs/CreateCallResponse.md +58 -0
  32. data/docs/CreateLookupResponse.md +20 -0
  33. data/docs/CreateMessageRequestError.md +22 -0
  34. data/docs/CreateParticipantRequest.md +24 -0
  35. data/docs/CreateParticipantResponse.md +20 -0
  36. data/docs/DeferredResult.md +20 -0
  37. data/docs/DeviceApiVersionEnum.md +15 -0
  38. data/docs/DisconenctCallback.md +50 -0
  39. data/docs/DisconnectCallback.md +50 -0
  40. data/docs/Diversion.md +30 -0
  41. data/docs/DtmfCallback.md +50 -0
  42. data/docs/FieldError.md +20 -0
  43. data/docs/FileFormatEnum.md +15 -0
  44. data/docs/ForbiddenRequest.md +18 -0
  45. data/docs/GatherCallback.md +52 -0
  46. data/docs/InboundMessageCallback.md +26 -0
  47. data/docs/InboundMessageCallbackMessage.md +40 -0
  48. data/docs/InitiateCallback.md +40 -0
  49. data/docs/ListMessageDirectionEnum.md +15 -0
  50. data/docs/ListMessageItem.md +48 -0
  51. data/docs/LookupRequest.md +18 -0
  52. data/docs/LookupResult.md +34 -0
  53. data/docs/LookupStatus.md +24 -0
  54. data/docs/LookupStatusEnum.md +15 -0
  55. data/docs/MFAApi.md +226 -0
  56. data/docs/MachineDetectionCompleteCallback.md +44 -0
  57. data/docs/MachineDetectionConfiguration.md +46 -0
  58. data/docs/MachineDetectionModeEnum.md +15 -0
  59. data/docs/Media.md +22 -0
  60. data/docs/MediaApi.md +307 -0
  61. data/docs/Message.md +40 -0
  62. data/docs/MessageDeliveredCallback.md +26 -0
  63. data/docs/MessageDeliveredCallbackMessage.md +40 -0
  64. data/docs/MessageDirectionEnum.md +15 -0
  65. data/docs/MessageFailedCallback.md +28 -0
  66. data/docs/MessageFailedCallbackMessage.md +40 -0
  67. data/docs/MessageRequest.md +32 -0
  68. data/docs/MessageSendingCallback.md +26 -0
  69. data/docs/MessageSendingCallbackMessage.md +40 -0
  70. data/docs/MessageStatusEnum.md +15 -0
  71. data/docs/MessageTypeEnum.md +15 -0
  72. data/docs/MessagesApi.md +179 -0
  73. data/docs/MessagesList.md +22 -0
  74. data/docs/MessagingCodeResponse.md +18 -0
  75. data/docs/MessagingRequestError.md +20 -0
  76. data/docs/MfaForbiddenRequestError.md +18 -0
  77. data/docs/MfaRequestError.md +20 -0
  78. data/docs/MfaUnauthorizedRequestError.md +18 -0
  79. data/docs/PageInfo.md +24 -0
  80. data/docs/Participant.md +30 -0
  81. data/docs/ParticipantSubscription.md +20 -0
  82. data/docs/ParticipantsApi.md +227 -0
  83. data/docs/PhoneNumberLookupApi.md +153 -0
  84. data/docs/PriorityEnum.md +15 -0
  85. data/docs/PublishPermissionsEnum.md +15 -0
  86. data/docs/RecordingAvailableCallback.md +60 -0
  87. data/docs/RecordingCompleteCallback.md +60 -0
  88. data/docs/RecordingStateEnum.md +15 -0
  89. data/docs/RecordingsApi.md +758 -0
  90. data/docs/RedirectCallback.md +48 -0
  91. data/docs/RedirectMethodEnum.md +15 -0
  92. data/docs/RequestError.md +20 -0
  93. data/docs/Session.md +20 -0
  94. data/docs/SessionsApi.md +605 -0
  95. data/docs/StatisticsApi.md +78 -0
  96. data/docs/StirShaken.md +22 -0
  97. data/docs/Subscriptions.md +20 -0
  98. data/docs/Tag.md +20 -0
  99. data/docs/TnLookupRequestError.md +18 -0
  100. data/docs/TranscribeRecording.md +28 -0
  101. data/docs/Transcription.md +20 -0
  102. data/docs/TranscriptionAvailableCallback.md +58 -0
  103. data/docs/TranscriptionList.md +18 -0
  104. data/docs/TranscriptionMetadata.md +24 -0
  105. data/docs/TransferAnswerCallback.md +46 -0
  106. data/docs/TransferCompleteCallback.md +52 -0
  107. data/docs/TransferDisconnectCallback.md +56 -0
  108. data/docs/UnauthorizedRequest.md +18 -0
  109. data/docs/UpdateCall.md +36 -0
  110. data/docs/UpdateCallRecording.md +18 -0
  111. data/docs/UpdateConference.md +34 -0
  112. data/docs/UpdateConferenceMember.md +22 -0
  113. data/docs/VerifyCodeRequest.md +24 -0
  114. data/docs/VerifyCodeResponse.md +18 -0
  115. data/docs/VoiceApiError.md +22 -0
  116. data/docs/VoiceCodeResponse.md +18 -0
  117. data/git_push.sh +57 -0
  118. data/lib/bandwidth-sdk/api/calls_api.rb +325 -0
  119. data/lib/bandwidth-sdk/api/conferences_api.rb +717 -0
  120. data/lib/bandwidth-sdk/api/media_api.rb +312 -0
  121. data/lib/bandwidth-sdk/api/messages_api.rb +198 -0
  122. data/lib/bandwidth-sdk/api/mfa_api.rb +244 -0
  123. data/lib/bandwidth-sdk/api/phone_number_lookup_api.rb +165 -0
  124. data/lib/bandwidth-sdk/api/recordings_api.rb +782 -0
  125. data/lib/bandwidth-sdk/api/statistics_api.rb +85 -0
  126. data/lib/bandwidth-sdk/api_client.rb +428 -0
  127. data/lib/bandwidth-sdk/api_error.rb +58 -0
  128. data/lib/bandwidth-sdk/configuration.rb +589 -0
  129. data/lib/bandwidth-sdk/models/account_statistics.rb +230 -0
  130. data/lib/bandwidth-sdk/models/answer_callback.rb +376 -0
  131. data/lib/bandwidth-sdk/models/bridge_complete_callback.rb +397 -0
  132. data/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +365 -0
  133. data/lib/bandwidth-sdk/models/bxml/bxml.rb +13 -0
  134. data/lib/bandwidth-sdk/models/bxml/nestable_verb.rb +50 -0
  135. data/lib/bandwidth-sdk/models/bxml/response.rb +13 -0
  136. data/lib/bandwidth-sdk/models/bxml/root.rb +47 -0
  137. data/lib/bandwidth-sdk/models/bxml/verb.rb +51 -0
  138. data/lib/bandwidth-sdk/models/bxml/verbs/bridge.rb +30 -0
  139. data/lib/bandwidth-sdk/models/bxml/verbs/conference.rb +31 -0
  140. data/lib/bandwidth-sdk/models/bxml/verbs/forward.rb +22 -0
  141. data/lib/bandwidth-sdk/models/bxml/verbs/gather.rb +44 -0
  142. data/lib/bandwidth-sdk/models/bxml/verbs/hangup.rb +12 -0
  143. data/lib/bandwidth-sdk/models/bxml/verbs/pause.rb +17 -0
  144. data/lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb +12 -0
  145. data/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb +28 -0
  146. data/lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb +19 -0
  147. data/lib/bandwidth-sdk/models/bxml/verbs/record.rb +34 -0
  148. data/lib/bandwidth-sdk/models/bxml/verbs/redirect.rb +25 -0
  149. data/lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb +12 -0
  150. data/lib/bandwidth-sdk/models/bxml/verbs/ring.rb +18 -0
  151. data/lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb +19 -0
  152. data/lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb +29 -0
  153. data/lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb +27 -0
  154. data/lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb +21 -0
  155. data/lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb +26 -0
  156. data/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb +30 -0
  157. data/lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb +12 -0
  158. data/lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb +12 -0
  159. data/lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb +17 -0
  160. data/lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb +18 -0
  161. data/lib/bandwidth-sdk/models/bxml/verbs/tag.rb +13 -0
  162. data/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb +36 -0
  163. data/lib/bandwidth-sdk/models/call_direction_enum.rb +40 -0
  164. data/lib/bandwidth-sdk/models/call_recording_metadata.rb +411 -0
  165. data/lib/bandwidth-sdk/models/call_state.rb +423 -0
  166. data/lib/bandwidth-sdk/models/call_state_enum.rb +40 -0
  167. data/lib/bandwidth-sdk/models/callback_method_enum.rb +40 -0
  168. data/lib/bandwidth-sdk/models/code_request.rb +427 -0
  169. data/lib/bandwidth-sdk/models/conference.rb +320 -0
  170. data/lib/bandwidth-sdk/models/conference_completed_callback.rb +262 -0
  171. data/lib/bandwidth-sdk/models/conference_created_callback.rb +262 -0
  172. data/lib/bandwidth-sdk/models/conference_member.rb +273 -0
  173. data/lib/bandwidth-sdk/models/conference_member_exit_callback.rb +292 -0
  174. data/lib/bandwidth-sdk/models/conference_member_join_callback.rb +292 -0
  175. data/lib/bandwidth-sdk/models/conference_recording_available_callback.rb +374 -0
  176. data/lib/bandwidth-sdk/models/conference_recording_metadata.rb +342 -0
  177. data/lib/bandwidth-sdk/models/conference_redirect_callback.rb +262 -0
  178. data/lib/bandwidth-sdk/models/conference_state_enum.rb +40 -0
  179. data/lib/bandwidth-sdk/models/create_call.rb +651 -0
  180. data/lib/bandwidth-sdk/models/create_call_response.rb +552 -0
  181. data/lib/bandwidth-sdk/models/create_lookup_response.rb +252 -0
  182. data/lib/bandwidth-sdk/models/create_message_request_error.rb +249 -0
  183. data/lib/bandwidth-sdk/models/deferred_result.rb +228 -0
  184. data/lib/bandwidth-sdk/models/disconenct_callback.rb +407 -0
  185. data/lib/bandwidth-sdk/models/disconnect_callback.rb +407 -0
  186. data/lib/bandwidth-sdk/models/diversion.rb +280 -0
  187. data/lib/bandwidth-sdk/models/dtmf_callback.rb +405 -0
  188. data/lib/bandwidth-sdk/models/field_error.rb +230 -0
  189. data/lib/bandwidth-sdk/models/file_format_enum.rb +40 -0
  190. data/lib/bandwidth-sdk/models/gather_callback.rb +415 -0
  191. data/lib/bandwidth-sdk/models/inbound_message_callback.rb +281 -0
  192. data/lib/bandwidth-sdk/models/inbound_message_callback_message.rb +399 -0
  193. data/lib/bandwidth-sdk/models/initiate_callback.rb +350 -0
  194. data/lib/bandwidth-sdk/models/list_message_direction_enum.rb +40 -0
  195. data/lib/bandwidth-sdk/models/list_message_item.rb +394 -0
  196. data/lib/bandwidth-sdk/models/lookup_request.rb +227 -0
  197. data/lib/bandwidth-sdk/models/lookup_result.rb +301 -0
  198. data/lib/bandwidth-sdk/models/lookup_status.rb +276 -0
  199. data/lib/bandwidth-sdk/models/lookup_status_enum.rb +42 -0
  200. data/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +376 -0
  201. data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +500 -0
  202. data/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +40 -0
  203. data/lib/bandwidth-sdk/models/media.rb +237 -0
  204. data/lib/bandwidth-sdk/models/message.rb +366 -0
  205. data/lib/bandwidth-sdk/models/message_delivered_callback.rb +281 -0
  206. data/lib/bandwidth-sdk/models/message_delivered_callback_message.rb +404 -0
  207. data/lib/bandwidth-sdk/models/message_direction_enum.rb +40 -0
  208. data/lib/bandwidth-sdk/models/message_failed_callback.rb +295 -0
  209. data/lib/bandwidth-sdk/models/message_failed_callback_message.rb +409 -0
  210. data/lib/bandwidth-sdk/models/message_request.rb +355 -0
  211. data/lib/bandwidth-sdk/models/message_sending_callback.rb +281 -0
  212. data/lib/bandwidth-sdk/models/message_sending_callback_message.rb +409 -0
  213. data/lib/bandwidth-sdk/models/message_status_enum.rb +46 -0
  214. data/lib/bandwidth-sdk/models/message_type_enum.rb +40 -0
  215. data/lib/bandwidth-sdk/models/messages_list.rb +240 -0
  216. data/lib/bandwidth-sdk/models/messaging_code_response.rb +220 -0
  217. data/lib/bandwidth-sdk/models/messaging_request_error.rb +238 -0
  218. data/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +220 -0
  219. data/lib/bandwidth-sdk/models/mfa_request_error.rb +230 -0
  220. data/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +220 -0
  221. data/lib/bandwidth-sdk/models/page_info.rb +250 -0
  222. data/lib/bandwidth-sdk/models/priority_enum.rb +40 -0
  223. data/lib/bandwidth-sdk/models/recording_available_callback.rb +454 -0
  224. data/lib/bandwidth-sdk/models/recording_complete_callback.rb +455 -0
  225. data/lib/bandwidth-sdk/models/recording_state_enum.rb +40 -0
  226. data/lib/bandwidth-sdk/models/redirect_callback.rb +395 -0
  227. data/lib/bandwidth-sdk/models/redirect_method_enum.rb +40 -0
  228. data/lib/bandwidth-sdk/models/stir_shaken.rb +240 -0
  229. data/lib/bandwidth-sdk/models/tag.rb +228 -0
  230. data/lib/bandwidth-sdk/models/tn_lookup_request_error.rb +220 -0
  231. data/lib/bandwidth-sdk/models/transcribe_recording.rb +354 -0
  232. data/lib/bandwidth-sdk/models/transcription.rb +230 -0
  233. data/lib/bandwidth-sdk/models/transcription_available_callback.rb +443 -0
  234. data/lib/bandwidth-sdk/models/transcription_list.rb +221 -0
  235. data/lib/bandwidth-sdk/models/transcription_metadata.rb +251 -0
  236. data/lib/bandwidth-sdk/models/transfer_answer_callback.rb +385 -0
  237. data/lib/bandwidth-sdk/models/transfer_complete_callback.rb +417 -0
  238. data/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +437 -0
  239. data/lib/bandwidth-sdk/models/update_call.rb +411 -0
  240. data/lib/bandwidth-sdk/models/update_call_recording.rb +246 -0
  241. data/lib/bandwidth-sdk/models/update_conference.rb +394 -0
  242. data/lib/bandwidth-sdk/models/update_conference_member.rb +243 -0
  243. data/lib/bandwidth-sdk/models/verify_code_request.rb +342 -0
  244. data/lib/bandwidth-sdk/models/verify_code_response.rb +220 -0
  245. data/lib/bandwidth-sdk/models/voice_api_error.rb +238 -0
  246. data/lib/bandwidth-sdk/models/voice_code_response.rb +220 -0
  247. data/lib/bandwidth-sdk/version.rb +15 -0
  248. data/lib/bandwidth-sdk.rb +166 -0
  249. data/openapi-config.yml +11 -0
  250. data/ruby-notes.md +64 -0
  251. data/spec/call_utils.rb +74 -0
  252. data/spec/fixtures/ruby_cat.jpeg +0 -0
  253. data/spec/integration/calls_api_integration_spec.rb +181 -0
  254. data/spec/integration/conferences_api_integration_spec.rb +163 -0
  255. data/spec/integration/media_api_integration_spec.rb +86 -0
  256. data/spec/integration/messages_api_integration_spec.rb +97 -0
  257. data/spec/integration/mfa_api_integration_spec.rb +109 -0
  258. data/spec/integration/phone_number_lookup_api_integration_spec.rb +92 -0
  259. data/spec/integration/recordings_api_integration_spec.rb +219 -0
  260. data/spec/integration/statistics_api_integration_spec.rb +57 -0
  261. data/spec/spec_helper.rb +154 -0
  262. data/spec/unit/api/calls_api_spec.rb +89 -0
  263. data/spec/unit/api/conferences_api_spec.rb +163 -0
  264. data/spec/unit/api/media_api_spec.rb +90 -0
  265. data/spec/unit/api/messages_api_spec.rb +73 -0
  266. data/spec/unit/api/mfa_api_spec.rb +74 -0
  267. data/spec/unit/api/phone_number_lookup_api_spec.rb +61 -0
  268. data/spec/unit/api/recordings_api_spec.rb +177 -0
  269. data/spec/unit/api/statistics_api_spec.rb +47 -0
  270. data/spec/unit/models/account_statistics_spec.rb +40 -0
  271. data/spec/unit/models/answer_callback_spec.rb +112 -0
  272. data/spec/unit/models/bridge_complete_callback_spec.rb +124 -0
  273. data/spec/unit/models/bridge_target_complete_callback_spec.rb +106 -0
  274. data/spec/unit/models/bxml/bxml_spec.rb +18 -0
  275. data/spec/unit/models/bxml/nestable_verb_spec.rb +13 -0
  276. data/spec/unit/models/bxml/response_spec.rb +18 -0
  277. data/spec/unit/models/bxml/verb_spec.rb +28 -0
  278. data/spec/unit/models/bxml/verbs/bridge_spec.rb +60 -0
  279. data/spec/unit/models/bxml/verbs/conference_spec.rb +60 -0
  280. data/spec/unit/models/bxml/verbs/forward_spec.rb +46 -0
  281. data/spec/unit/models/bxml/verbs/gather_spec.rb +88 -0
  282. data/spec/unit/models/bxml/verbs/hangup_spec.rb +18 -0
  283. data/spec/unit/models/bxml/verbs/pause_recording_spec.rb +18 -0
  284. data/spec/unit/models/bxml/verbs/pause_spec.rb +36 -0
  285. data/spec/unit/models/bxml/verbs/phone_number_spec.rb +56 -0
  286. data/spec/unit/models/bxml/verbs/play_audio_spec.rb +38 -0
  287. data/spec/unit/models/bxml/verbs/record_spec.rb +70 -0
  288. data/spec/unit/models/bxml/verbs/redirect_spec.rb +52 -0
  289. data/spec/unit/models/bxml/verbs/resume_recording_spec.rb +18 -0
  290. data/spec/unit/models/bxml/verbs/ring_spec.rb +38 -0
  291. data/spec/unit/models/bxml/verbs/send_dtmf_spec.rb +38 -0
  292. data/spec/unit/models/bxml/verbs/sip_uri_spec.rb +58 -0
  293. data/spec/unit/models/bxml/verbs/speak_sentence_spec.rb +40 -0
  294. data/spec/unit/models/bxml/verbs/start_gather_spec.rb +44 -0
  295. data/spec/unit/models/bxml/verbs/start_recording_spec.rb +54 -0
  296. data/spec/unit/models/bxml/verbs/start_stream_spec.rb +74 -0
  297. data/spec/unit/models/bxml/verbs/stop_gather_spec.rb +18 -0
  298. data/spec/unit/models/bxml/verbs/stop_recording_spec.rb +18 -0
  299. data/spec/unit/models/bxml/verbs/stop_stream_spec.rb +36 -0
  300. data/spec/unit/models/bxml/verbs/stream_param_spec.rb +38 -0
  301. data/spec/unit/models/bxml/verbs/tag_spec.rb +18 -0
  302. data/spec/unit/models/bxml/verbs/transfer_spec.rb +86 -0
  303. data/spec/unit/models/call_direction_enum_spec.rb +28 -0
  304. data/spec/unit/models/call_recording_metadata_spec.rb +136 -0
  305. data/spec/unit/models/call_state_enum_spec.rb +28 -0
  306. data/spec/unit/models/call_state_spec.rb +136 -0
  307. data/spec/unit/models/callback_method_enum_spec.rb +28 -0
  308. data/spec/unit/models/code_request_spec.rb +64 -0
  309. data/spec/unit/models/conference_completed_callback_spec.rb +58 -0
  310. data/spec/unit/models/conference_created_callback_spec.rb +58 -0
  311. data/spec/unit/models/conference_member_exit_callback_spec.rb +76 -0
  312. data/spec/unit/models/conference_member_join_callback_spec.rb +76 -0
  313. data/spec/unit/models/conference_member_spec.rb +64 -0
  314. data/spec/unit/models/conference_recording_available_callback_spec.rb +112 -0
  315. data/spec/unit/models/conference_recording_metadata_spec.rb +94 -0
  316. data/spec/unit/models/conference_redirect_callback_spec.rb +58 -0
  317. data/spec/unit/models/conference_spec.rb +76 -0
  318. data/spec/unit/models/conference_state_enum_spec.rb +28 -0
  319. data/spec/unit/models/create_call_response_spec.rb +154 -0
  320. data/spec/unit/models/create_call_spec.rb +142 -0
  321. data/spec/unit/models/create_lookup_response_spec.rb +40 -0
  322. data/spec/unit/models/create_message_request_error_spec.rb +46 -0
  323. data/spec/unit/models/deferred_result_spec.rb +40 -0
  324. data/spec/unit/models/disconnect_callback_spec.rb +130 -0
  325. data/spec/unit/models/diversion_spec.rb +70 -0
  326. data/spec/unit/models/dtmf_callback_spec.rb +130 -0
  327. data/spec/unit/models/field_error_spec.rb +40 -0
  328. data/spec/unit/models/file_format_enum_spec.rb +28 -0
  329. data/spec/unit/models/gather_callback_spec.rb +136 -0
  330. data/spec/unit/models/inbound_message_callback_message_spec.rb +100 -0
  331. data/spec/unit/models/inbound_message_callback_spec.rb +58 -0
  332. data/spec/unit/models/initiate_callback_spec.rb +100 -0
  333. data/spec/unit/models/list_message_direction_enum_spec.rb +28 -0
  334. data/spec/unit/models/list_message_item_spec.rb +124 -0
  335. data/spec/unit/models/lookup_request_spec.rb +34 -0
  336. data/spec/unit/models/lookup_result_spec.rb +82 -0
  337. data/spec/unit/models/lookup_status_enum_spec.rb +28 -0
  338. data/spec/unit/models/lookup_status_spec.rb +52 -0
  339. data/spec/unit/models/machine_detection_complete_callback_spec.rb +112 -0
  340. data/spec/unit/models/machine_detection_configuration_spec.rb +118 -0
  341. data/spec/unit/models/machine_detection_mode_enum_spec.rb +28 -0
  342. data/spec/unit/models/media_spec.rb +46 -0
  343. data/spec/unit/models/message_delivered_callback_message_spec.rb +100 -0
  344. data/spec/unit/models/message_delivered_callback_spec.rb +58 -0
  345. data/spec/unit/models/message_direction_enum_spec.rb +28 -0
  346. data/spec/unit/models/message_failed_callback_message_spec.rb +100 -0
  347. data/spec/unit/models/message_failed_callback_spec.rb +64 -0
  348. data/spec/unit/models/message_request_spec.rb +76 -0
  349. data/spec/unit/models/message_sending_callback_message_spec.rb +100 -0
  350. data/spec/unit/models/message_sending_callback_spec.rb +58 -0
  351. data/spec/unit/models/message_spec.rb +100 -0
  352. data/spec/unit/models/message_status_enum_spec.rb +28 -0
  353. data/spec/unit/models/message_type_enum_spec.rb +28 -0
  354. data/spec/unit/models/messages_list_spec.rb +46 -0
  355. data/spec/unit/models/messaging_code_response_spec.rb +34 -0
  356. data/spec/unit/models/messaging_request_error_spec.rb +40 -0
  357. data/spec/unit/models/mfa_forbidden_request_error_spec.rb +34 -0
  358. data/spec/unit/models/mfa_request_error_spec.rb +40 -0
  359. data/spec/unit/models/mfa_unauthorized_request_error_spec.rb +34 -0
  360. data/spec/unit/models/page_info_spec.rb +52 -0
  361. data/spec/unit/models/priority_enum_spec.rb +28 -0
  362. data/spec/unit/models/recording_available_callback_spec.rb +160 -0
  363. data/spec/unit/models/recording_complete_callback_spec.rb +160 -0
  364. data/spec/unit/models/recording_state_enum_spec.rb +28 -0
  365. data/spec/unit/models/redirect_callback_spec.rb +124 -0
  366. data/spec/unit/models/redirect_method_enum_spec.rb +28 -0
  367. data/spec/unit/models/stir_shaken_spec.rb +46 -0
  368. data/spec/unit/models/tag_spec.rb +40 -0
  369. data/spec/unit/models/tn_lookup_request_error_spec.rb +34 -0
  370. data/spec/unit/models/transcribe_recording_spec.rb +64 -0
  371. data/spec/unit/models/transcription_available_callback_spec.rb +154 -0
  372. data/spec/unit/models/transcription_list_spec.rb +34 -0
  373. data/spec/unit/models/transcription_metadata_spec.rb +52 -0
  374. data/spec/unit/models/transcription_spec.rb +40 -0
  375. data/spec/unit/models/transfer_answer_callback_spec.rb +118 -0
  376. data/spec/unit/models/transfer_complete_callback_spec.rb +136 -0
  377. data/spec/unit/models/transfer_disconnect_callback_spec.rb +148 -0
  378. data/spec/unit/models/update_call_recording_spec.rb +34 -0
  379. data/spec/unit/models/update_call_spec.rb +88 -0
  380. data/spec/unit/models/update_conference_member_spec.rb +46 -0
  381. data/spec/unit/models/update_conference_spec.rb +82 -0
  382. data/spec/unit/models/verify_code_request_spec.rb +52 -0
  383. data/spec/unit/models/verify_code_response_spec.rb +34 -0
  384. data/spec/unit/models/voice_api_error_spec.rb +46 -0
  385. data/spec/unit/models/voice_code_response_spec.rb +34 -0
  386. metadata +547 -255
  387. data/LICENSE +0 -28
  388. data/lib/bandwidth/api_helper.rb +0 -280
  389. data/lib/bandwidth/client.rb +0 -75
  390. data/lib/bandwidth/configuration.rb +0 -209
  391. data/lib/bandwidth/exceptions/api_exception.rb +0 -20
  392. data/lib/bandwidth/http/api_response.rb +0 -38
  393. data/lib/bandwidth/http/auth/messaging_basic_auth.rb +0 -22
  394. data/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb +0 -22
  395. data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +0 -22
  396. data/lib/bandwidth/http/auth/voice_basic_auth.rb +0 -22
  397. data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +0 -22
  398. data/lib/bandwidth/http/faraday_client.rb +0 -70
  399. data/lib/bandwidth/http/http_call_back.rb +0 -24
  400. data/lib/bandwidth/http/http_client.rb +0 -104
  401. data/lib/bandwidth/http/http_method_enum.rb +0 -13
  402. data/lib/bandwidth/http/http_request.rb +0 -50
  403. data/lib/bandwidth/http/http_response.rb +0 -29
  404. data/lib/bandwidth/messaging_lib/messaging/client.rb +0 -60
  405. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +0 -491
  406. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +0 -47
  407. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +0 -37
  408. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +0 -100
  409. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +0 -174
  410. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +0 -203
  411. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +0 -79
  412. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +0 -60
  413. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +0 -70
  414. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +0 -122
  415. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +0 -82
  416. data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +0 -19
  417. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +0 -60
  418. data/lib/bandwidth/messaging_lib/messaging.rb +0 -25
  419. data/lib/bandwidth/models/base_model.rb +0 -58
  420. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb +0 -60
  421. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +0 -47
  422. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +0 -214
  423. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +0 -37
  424. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +0 -32
  425. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +0 -32
  426. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +0 -103
  427. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +0 -50
  428. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +0 -50
  429. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +0 -94
  430. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +0 -50
  431. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +0 -23
  432. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +0 -60
  433. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +0 -1553
  434. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +0 -47
  435. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +0 -32
  436. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +0 -50
  437. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +0 -61
  438. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +0 -95
  439. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +0 -132
  440. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +0 -20
  441. data/lib/bandwidth/utilities/date_time_helper.rb +0 -156
  442. data/lib/bandwidth/utilities/file_wrapper.rb +0 -16
  443. data/lib/bandwidth/voice_lib/bxml/bxml.rb +0 -36
  444. data/lib/bandwidth/voice_lib/bxml/response.rb +0 -39
  445. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +0 -28
  446. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +0 -32
  447. data/lib/bandwidth/voice_lib/bxml/verbs/custom_param.rb +0 -17
  448. data/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +0 -18
  449. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +0 -49
  450. data/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +0 -14
  451. data/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +0 -15
  452. data/lib/bandwidth/voice_lib/bxml/verbs/pause_recording.rb +0 -14
  453. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +0 -24
  454. data/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +0 -17
  455. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +0 -34
  456. data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +0 -24
  457. data/lib/bandwidth/voice_lib/bxml/verbs/resume_recording.rb +0 -14
  458. data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +0 -16
  459. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +0 -16
  460. data/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb +0 -25
  461. data/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +0 -18
  462. data/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +0 -20
  463. data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +0 -26
  464. data/lib/bandwidth/voice_lib/bxml/verbs/start_stream.rb +0 -41
  465. data/lib/bandwidth/voice_lib/bxml/verbs/start_transcription.rb +0 -42
  466. data/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +0 -14
  467. data/lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb +0 -14
  468. data/lib/bandwidth/voice_lib/bxml/verbs/stop_stream.rb +0 -16
  469. data/lib/bandwidth/voice_lib/bxml/verbs/stop_transcription.rb +0 -16
  470. data/lib/bandwidth/voice_lib/bxml/verbs/stream_param.rb +0 -17
  471. data/lib/bandwidth/voice_lib/bxml/verbs/tag.rb +0 -13
  472. data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +0 -48
  473. data/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +0 -26
  474. data/lib/bandwidth/voice_lib/voice/client.rb +0 -60
  475. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +0 -1820
  476. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +0 -47
  477. data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +0 -42
  478. data/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +0 -17
  479. data/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +0 -17
  480. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +0 -343
  481. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +0 -250
  482. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +0 -301
  483. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +0 -17
  484. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +0 -211
  485. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +0 -17
  486. data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +0 -103
  487. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +0 -173
  488. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +0 -153
  489. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +0 -236
  490. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +0 -266
  491. data/lib/bandwidth/voice_lib/voice/models/direction_enum.rb +0 -17
  492. data/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +0 -17
  493. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +0 -80
  494. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +0 -17
  495. data/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb +0 -17
  496. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +0 -231
  497. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +0 -20
  498. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +0 -48
  499. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +0 -156
  500. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +0 -144
  501. data/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +0 -17
  502. data/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +0 -17
  503. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +0 -20
  504. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +0 -17
  505. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +0 -17
  506. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +0 -120
  507. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +0 -60
  508. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +0 -80
  509. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +0 -89
  510. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +0 -59
  511. data/lib/bandwidth/voice_lib/voice.rb +0 -48
  512. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +0 -18
  513. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +0 -60
  514. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +0 -703
  515. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +0 -47
  516. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +0 -37
  517. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +0 -62
  518. data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +0 -17
  519. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +0 -115
  520. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +0 -48
  521. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +0 -17
  522. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +0 -60
  523. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +0 -71
  524. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +0 -22
  525. data/lib/bandwidth.rb +0 -72
  526. data/test/controllers/controller_test_base.rb +0 -21
  527. data/test/http_response_catcher.rb +0 -19
  528. data/test/integration/test_integration.rb +0 -851
  529. data/test/test_helper.rb +0 -94
@@ -1,851 +0,0 @@
1
- # test_integration.rb
2
- #
3
- # A simple integration test against Bandwidth's APIs
4
-
5
- require 'test/unit'
6
- require 'securerandom'
7
- require_relative '../../lib/bandwidth.rb'
8
-
9
- include Bandwidth
10
- include Bandwidth::Voice
11
- include Bandwidth::Messaging
12
- include Bandwidth::MultiFactorAuth
13
- include Bandwidth::WebRtc
14
-
15
- begin
16
- BW_USERNAME = ENV.fetch("BW_USERNAME")
17
- BW_PASSWORD = ENV.fetch("BW_PASSWORD")
18
- BW_ACCOUNT_ID = ENV.fetch("BW_ACCOUNT_ID")
19
- BW_VOICE_APPLICATION_ID = ENV.fetch("BW_VOICE_APPLICATION_ID")
20
- BW_MESSAGING_APPLICATION_ID = ENV.fetch("BW_MESSAGING_APPLICATION_ID")
21
- BASE_CALLBACK_URL = ENV.fetch("BASE_CALLBACK_URL")
22
- BW_NUMBER = ENV.fetch("BW_NUMBER")
23
- USER_NUMBER = ENV.fetch("USER_NUMBER")
24
- rescue
25
- puts "Environmental variables not found"
26
- exit(-1)
27
- end
28
-
29
- class IntegrationTest < Test::Unit::TestCase
30
- def setup
31
- @bandwidth_client = Bandwidth::Client.new(
32
- voice_basic_auth_user_name: BW_USERNAME,
33
- voice_basic_auth_password: BW_PASSWORD,
34
- messaging_basic_auth_user_name: BW_USERNAME,
35
- messaging_basic_auth_password: BW_PASSWORD,
36
- multi_factor_auth_basic_auth_user_name: BW_USERNAME,
37
- multi_factor_auth_basic_auth_password: BW_PASSWORD,
38
- phone_number_lookup_basic_auth_user_name: BW_USERNAME,
39
- phone_number_lookup_basic_auth_password: BW_PASSWORD
40
- )
41
-
42
- @bandwidth_client_invalid_auth = Bandwidth::Client.new(
43
- voice_basic_auth_user_name: "bad_username",
44
- voice_basic_auth_password: "bad_password",
45
- messaging_basic_auth_user_name: "bad_username",
46
- messaging_basic_auth_password: "bad_password",
47
- multi_factor_auth_basic_auth_user_name: "bad_username",
48
- multi_factor_auth_basic_auth_password: "bad_password",
49
- phone_number_lookup_basic_auth_user_name: "bad_username",
50
- phone_number_lookup_basic_auth_password: "bad_password"
51
- )
52
- end
53
-
54
- def test_create_message
55
- body = MessageRequest.new
56
- body.application_id = BW_MESSAGING_APPLICATION_ID
57
- body.to = [USER_NUMBER]
58
- body.from = BW_NUMBER
59
- body.text = "Ruby Integration"
60
- body.priority = "high"
61
- body.expiration = "2091-02-01T11:29:18-05:00"
62
- response = @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
63
- assert(response.data.to == [USER_NUMBER])
64
- assert(response.data.from == BW_NUMBER)
65
- assert(response.data.text == "Ruby Integration")
66
- assert(response.data.priority == "high")
67
- assert(response.data.expiration == "2091-02-01T11:29:18-05:00")
68
- assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
69
- end
70
-
71
- def test_create_message_invalid_phone_number
72
- body = MessageRequest.new
73
- body.application_id = BW_MESSAGING_APPLICATION_ID
74
- body.to = ["+1invalid"]
75
- body.from = BW_NUMBER
76
- body.text = "Ruby Integration"
77
- begin
78
- @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body)
79
- #workaround to make sure that if the above error is not raised, the build will fail
80
- assert(false, "Expected exception not raised")
81
- rescue MessagingException => e
82
- assert(e.description.length > 0, "description value not set")
83
- end
84
- end
85
-
86
- def test_upload_download_media
87
- #define constants for upload media and download media
88
- media_id = "text-media-id-" + SecureRandom.uuid
89
- media = "Hello world"
90
-
91
- #media upload
92
- @bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID, media_id, media, :content_type => "text/plain", :cache_control => "no-cache")
93
-
94
- #media download
95
- downloaded_media = @bandwidth_client.messaging_client.client.get_media(BW_ACCOUNT_ID, media_id).data
96
-
97
- assert_equal(downloaded_media, media, "Downloaded media file not equal to upload")
98
- end
99
-
100
- def test_get_message
101
- # Send a successful request to the GET messages API
102
- response = @bandwidth_client.messaging_client.client.get_messages(BW_ACCOUNT_ID, :message_id => "abc123")
103
- assert_equal(response.status_code, 200, "API did not return a 200 OK")
104
- end
105
-
106
- def test_get_message_invalid_auth
107
- # Send an unsuccessful request to the GET messages API
108
- assert_raise MessagingException do
109
- response = @bandwidth_client_invalid_auth.messaging_client.client.get_messages(BW_ACCOUNT_ID)
110
- end
111
- end
112
-
113
- def test_create_call_and_get_call_state
114
- body = CreateCallRequest.new
115
- body.from = BW_NUMBER
116
- body.to = USER_NUMBER
117
- body.application_id = BW_VOICE_APPLICATION_ID
118
- body.answer_url = BASE_CALLBACK_URL
119
- response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
120
- assert(response.data.call_id.length > 0, "call_id value not set")
121
- assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
122
- assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
123
-
124
- #Get phone call information
125
- sleep(2)
126
- begin
127
- response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
128
- assert(response.data.state.length > 0, "state value not set")
129
- assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
130
- assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
131
- rescue ApiErrorException => e
132
- if e.response_code != 404
133
- raise StandardError, "Unexpected HTTP Response: " + e.message
134
- end
135
- end
136
-
137
- end
138
-
139
- def test_create_call_with_amd_and_get_call_state
140
- machine_detection = MachineDetectionConfiguration.new
141
- machine_detection.mode = 'async'
142
- machine_detection.detection_timeout = 5.0
143
- machine_detection.silence_timeout = 5.0
144
- machine_detection.speech_threshold = 5.0
145
- machine_detection.speech_end_threshold = 5.0
146
- machine_detection.delay_result = true
147
- machine_detection.callback_url = BASE_CALLBACK_URL + '/machineDetection'
148
- machine_detection.callback_method = 'POST'
149
- machine_detection.machine_speech_end_threshold = 3.2
150
-
151
- body = CreateCallRequest.new
152
- body.from = BW_NUMBER
153
- body.to = USER_NUMBER
154
- body.application_id = BW_VOICE_APPLICATION_ID
155
- body.answer_url = BASE_CALLBACK_URL
156
- body.machine_detection = machine_detection
157
- response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
158
- assert(response.data.call_id.length > 0, "call_id value not set")
159
-
160
- #Get phone call information
161
- sleep(2)
162
- begin
163
- response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
164
- assert(response.data.state.length > 0, "state value not set")
165
- rescue ApiErrorException => e
166
- if e.response_code != 404
167
- raise StandardError, "Unexpected HTTP Response: " + e.message
168
- end
169
- end
170
- end
171
-
172
- def test_create_call_with_priority
173
- body = CreateCallRequest.new
174
- body.from = BW_NUMBER
175
- body.to = USER_NUMBER
176
- body.application_id = BW_VOICE_APPLICATION_ID
177
- body.answer_url = BASE_CALLBACK_URL
178
- body.priority = 1
179
-
180
- response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
181
- assert(response.data.call_id.length > 0, "call_id value not set")
182
- assert(response.data.priority == 1, "priority not set")
183
- end
184
-
185
- def test_create_call_invalid_phone_number
186
- body = CreateCallRequest.new
187
- body.from = BW_NUMBER
188
- body.to = "+1invalid"
189
- body.application_id = BW_VOICE_APPLICATION_ID
190
- body.answer_url = BASE_CALLBACK_URL
191
-
192
- begin
193
- @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, :body => body)
194
- #workaround to make sure that if the above error is not raised, the build will fail
195
- assert(false, "Expected exception not raised")
196
- rescue ApiErrorException => e
197
- assert(e.description.length > 0, "description value not set")
198
- end
199
- end
200
-
201
- def test_forward
202
- forward = Bandwidth::Voice::Forward.new({
203
- :to => "+15554443333",
204
- :from => "+13334445555",
205
- :call_timeout => 25,
206
- :diversion_treatment => "none",
207
- :diversion_reason => "away"
208
- })
209
-
210
- response = Bandwidth::Voice::Response.new()
211
- response.push(forward)
212
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Forward to="+15554443333" from="+13334445555" callTimeout="25" diversionTreatment="none" diversionReason="away"/></Response>'
213
- actual = response.to_bxml()
214
- assert_equal(expected, actual)
215
- end
216
-
217
- def test_gather
218
- gather = Bandwidth::Voice::Gather.new({
219
- :gather_url => "https://test.com",
220
- :gather_method => "POST",
221
- :username => "user",
222
- :password => "pass",
223
- :tag => "tag",
224
- :terminating_digits => "#",
225
- :max_digits => 3,
226
- :inter_digit_timeout => 5,
227
- :first_digit_timeout => "10",
228
- :repeat_count => 1,
229
- :gather_fallback_url => "https://test.com",
230
- :gather_fallback_method => "GET",
231
- :fallback_username => "fuser",
232
- :fallback_password => "fpass"
233
- })
234
-
235
- response = Bandwidth::Voice::Response.new()
236
- response.push(gather)
237
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather gatherUrl="https://test.com" gatherMethod="POST" terminatingDigits="#" tag="tag" maxDigits="3" interDigitTimeout="5" username="user" password="pass" firstDigitTimeout="10" repeatCount="1" gatherFallbackUrl="https://test.com" gatherFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"></Gather></Response>'
238
- actual = response.to_bxml()
239
- assert_equal(expected, actual)
240
- end
241
-
242
- def test_gather_nested_speak_sentence
243
- speak_sentence = Bandwidth::Voice::SpeakSentence.new({
244
- :sentence => "test"
245
- })
246
- gather = Bandwidth::Voice::Gather.new({
247
- :speak_sentence => speak_sentence
248
- })
249
-
250
- response = Bandwidth::Voice::Response.new()
251
- response.push(gather)
252
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><SpeakSentence>test</SpeakSentence></Gather></Response>'
253
- actual = response.to_bxml()
254
- assert_equal(expected, actual)
255
- end
256
-
257
- def test_gather_nested_play_audio
258
- play_audio = Bandwidth::Voice::PlayAudio.new({
259
- :url => "https://test.com"
260
- })
261
- gather = Bandwidth::Voice::Gather.new({
262
- :play_audio => play_audio
263
- })
264
-
265
- response = Bandwidth::Voice::Response.new()
266
- response.push(gather)
267
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio></Gather></Response>'
268
- actual = response.to_bxml()
269
- assert_equal(expected, actual)
270
- end
271
-
272
- def test_gather_multiple_nested_verbs
273
- play_audio = Bandwidth::Voice::PlayAudio.new({
274
- :url => "https://test.com"
275
- })
276
- speak_sentence = Bandwidth::Voice::SpeakSentence.new({
277
- :sentence => "test"
278
- })
279
- gather = Bandwidth::Voice::Gather.new({
280
- :nested_verbs => [play_audio, speak_sentence]
281
- })
282
-
283
- response = Bandwidth::Voice::Response.new()
284
- response.push(gather)
285
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio><SpeakSentence>test</SpeakSentence></Gather></Response>'
286
- actual = response.to_bxml()
287
- assert_equal(expected, actual)
288
- end
289
-
290
- def test_empty_bxml_verb
291
- bxml = Bandwidth::Voice::Bxml.new()
292
-
293
- expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml></Bxml>'
294
- actual = bxml.to_bxml()
295
- assert_equal(expected, actual)
296
- end
297
-
298
- def test_speak_sentence_pause
299
- bxml = Bandwidth::Voice::Bxml.new()
300
-
301
- speak_sentence = Bandwidth::Voice::SpeakSentence.new({
302
- :sentence => "new modify call bxml is pog",
303
- :voice => "Julie"
304
- })
305
-
306
- pause = Bandwidth::Voice::Pause.new({
307
- :duration => 6
308
- })
309
-
310
- bxml.push(speak_sentence)
311
- bxml.push(pause)
312
-
313
- expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence voice="Julie">new modify call bxml is pog</SpeakSentence><Pause duration="6"/></Bxml>'
314
- actual = bxml.to_bxml()
315
- assert_equal(expected, actual)
316
- end
317
-
318
- def test_hangup
319
- hangup = Bandwidth::Voice::Hangup.new()
320
-
321
- response = Bandwidth::Voice::Response.new()
322
- response.push(hangup)
323
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>'
324
- actual = response.to_bxml()
325
- assert_equal(expected, actual)
326
- end
327
-
328
- def test_pause
329
- pause = Bandwidth::Voice::Pause.new({
330
- :duration => 2
331
- })
332
-
333
- response = Bandwidth::Voice::Response.new()
334
- response.push(pause)
335
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Pause duration="2"/></Response>'
336
- actual = response.to_bxml()
337
- assert_equal(expected, actual)
338
- end
339
-
340
- def test_pause_recording
341
- pause_recording = Bandwidth::Voice::PauseRecording.new()
342
-
343
- response = Bandwidth::Voice::Response.new()
344
- response.push(pause_recording)
345
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>'
346
- actual = response.to_bxml()
347
- assert_equal(expected, actual)
348
- end
349
-
350
- def test_play_audio
351
- play_audio = Bandwidth::Voice::PlayAudio.new({
352
- :url => "https://test.com",
353
- :username => "user",
354
- :password => "pass"
355
- })
356
-
357
- response = Bandwidth::Voice::Response.new()
358
- response.push(play_audio)
359
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PlayAudio username="user" password="pass">https://test.com</PlayAudio></Response>'
360
- actual = response.to_bxml()
361
- assert_equal(expected, actual)
362
- end
363
-
364
- def test_record
365
- record = Bandwidth::Voice::Record.new({
366
- :record_complete_url => "https://complete.com",
367
- :record_complete_method => "POST",
368
- :recording_available_url => "https://available.com",
369
- :recording_available_method => "GET",
370
- :transcribe => false,
371
- :detect_language=> true,
372
- :transcription_available_url => "https://transcribe.com",
373
- :transcription_available_method => "POST",
374
- :username => "user",
375
- :password => "pass",
376
- :tag => "tag",
377
- :terminating_digits => "#",
378
- :max_duration => 3,
379
- :silence_timeout => 5,
380
- :file_format => "wav",
381
- :record_complete_fallback_url => "https://test.com",
382
- :record_complete_fallback_method => "GET",
383
- :fallback_username => "fuser",
384
- :fallback_password => "fpass"
385
- })
386
-
387
- response = Bandwidth::Voice::Response.new()
388
- response.push(record)
389
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Record tag="tag" username="user" password="pass" recordCompleteUrl="https://complete.com" recordCompleteMethod="POST" recordingAvailableUrl="https://available.com" recordingAvailableMethod="GET" terminatingDigits="#" maxDuration="3" fileFormat="wav" transcribe="false" detectLanguage="true" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="POST" silenceTimeout="5" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
390
- actual = response.to_bxml()
391
- assert_equal(expected, actual)
392
- end
393
-
394
- def test_redirect
395
- redirect = Bandwidth::Voice::Redirect.new({
396
- :redirect_url => "https://redirect.com",
397
- :redirect_method => "GET",
398
- :username => "user",
399
- :password => "pass",
400
- :tag => "tag",
401
- :redirect_fallback_url => "https://test.com",
402
- :redirect_fallback_method => "GET",
403
- :fallback_username => "fuser",
404
- :fallback_password => "fpass"
405
- })
406
-
407
- response = Bandwidth::Voice::Response.new()
408
- response.push(redirect)
409
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect redirectUrl="https://redirect.com" redirectMethod="GET" tag="tag" username="user" password="pass" redirectFallbackUrl="https://test.com" redirectFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
410
- actual = response.to_bxml()
411
- assert_equal(expected, actual)
412
- end
413
-
414
- def test_resume_recording
415
- resume_recording = Bandwidth::Voice::ResumeRecording.new()
416
-
417
- response = Bandwidth::Voice::Response.new()
418
- response.push(resume_recording)
419
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><ResumeRecording/></Response>'
420
- actual = response.to_bxml()
421
- assert_equal(expected, actual)
422
- end
423
-
424
- def test_send_dtmf
425
- send_dtmf = Bandwidth::Voice::SendDtmf.new({
426
- :dtmf => "12w34",
427
- :tone_duration => 75,
428
- :tone_interval => 65
429
- })
430
-
431
- response = Bandwidth::Voice::Response.new()
432
- response.push(send_dtmf)
433
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SendDtmf toneDuration="75" toneInterval="65">12w34</SendDtmf></Response>'
434
- actual = response.to_bxml()
435
- assert_equal(expected, actual)
436
- end
437
-
438
- def test_speak_sentence
439
- speak_sentence = Bandwidth::Voice::SpeakSentence.new({
440
- :sentence => "test",
441
- :voice => "julie",
442
- :gender => "female",
443
- :locale => "en_US"
444
- })
445
-
446
- response = Bandwidth::Voice::Response.new()
447
- response.push(speak_sentence)
448
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence voice="julie" locale="en_US" gender="female">test</SpeakSentence></Response>'
449
- actual = response.to_bxml()
450
- assert_equal(expected, actual)
451
- end
452
-
453
- def test_speak_sentence_ssml
454
- speak_sentence = Bandwidth::Voice::SpeakSentence.new({
455
- :sentence => 'Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.',
456
- })
457
-
458
- response = Bandwidth::Voice::Response.new()
459
- response.push(speak_sentence)
460
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence>Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.</SpeakSentence></Response>'
461
- actual = response.to_bxml()
462
- assert_equal(expected, actual)
463
- end
464
-
465
- def test_start_recording
466
- start_recording = Bandwidth::Voice::StartRecording.new({
467
- :recording_available_url => "https://available.com",
468
- :recording_available_method => "POST",
469
- :transcribe => false,
470
- :transcription_available_url => "https://transcribe.com",
471
- :transcription_available_method => "GET",
472
- :username => "user",
473
- :password => "pass",
474
- :tag => "tag",
475
- :file_format => "mp3",
476
- :multi_channel => true
477
- })
478
-
479
- response = Bandwidth::Voice::Response.new()
480
- response.push(start_recording)
481
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartRecording tag="tag" username="user" password="pass" recordingAvailableUrl="https://available.com" recordingAvailableMethod="POST" fileFormat="mp3" multiChannel="true" transcribe="false" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="GET"/></Response>'
482
- actual = response.to_bxml()
483
- assert_equal(expected, actual)
484
- end
485
-
486
- def test_stop_recording
487
- stop_recording = Bandwidth::Voice::StopRecording.new()
488
-
489
- response = Bandwidth::Voice::Response.new()
490
- response.push(stop_recording)
491
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopRecording/></Response>'
492
- actual = response.to_bxml()
493
- assert_equal(expected, actual)
494
- end
495
-
496
- def test_transfer
497
- phone_number = Bandwidth::Voice::PhoneNumber.new({
498
- :number => "+15554443333",
499
- :transfer_answer_url => "https://phoneanswer.com",
500
- :transfer_answer_method => "GET",
501
- :transfer_disconnect_url => "https://phonedisconnect.com",
502
- :transfer_disconnect_method => "POST",
503
- :username => "phoneuser",
504
- :password => "phonepassword",
505
- :tag => "phonetag",
506
- :transfer_answer_fallback_url => "https://test.com",
507
- :transfer_answer_fallback_method => "GET",
508
- :fallback_username => "fuser",
509
- :fallback_password => "fpass"
510
- })
511
- transfer = Bandwidth::Voice::Transfer.new({
512
- :transfer_caller_id => "+13334445555",
513
- :call_timeout => 3,
514
- :transfer_complete_url => "https://transfercomplete.com",
515
- :transfer_complete_method => "POST",
516
- :username => "transferuser",
517
- :password => "transferpass",
518
- :tag => "transfertag",
519
- :diversion_treatment => "none",
520
- :diversion_reason => "away",
521
- :phone_numbers => [phone_number],
522
- :transfer_complete_fallback_url => "https://test.com",
523
- :transfer_complete_fallback_method => "GET",
524
- :fallback_username => "fusern",
525
- :fallback_password => "fpassw"
526
- })
527
-
528
- response = Bandwidth::Voice::Response.new()
529
- response.push(transfer)
530
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer transferCallerId="+13334445555" callTimeout="3" tag="transfertag" transferCompleteUrl="https://transfercomplete.com" transferCompleteMethod="POST" username="transferuser" password="transferpass" diversionTreatment="none" diversionReason="away" transferCompleteFallbackUrl="https://test.com" transferCompleteFallbackMethod="GET" fallbackUsername="fusern" fallbackPassword="fpassw"><PhoneNumber transferAnswerUrl="https://phoneanswer.com" transferAnswerMethod="GET" transferDisconnectUrl="https://phonedisconnect.com" transferDisconnectMethod="POST" username="phoneuser" password="phonepassword" tag="phonetag" transferAnswerFallbackUrl="https://test.com" transferAnswerFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass">+15554443333</PhoneNumber></Transfer></Response>'
531
- actual = response.to_bxml()
532
- assert_equal(expected, actual)
533
- end
534
-
535
- def test_conference
536
- conference = Bandwidth::Voice::Conference.new({
537
- :conference_name => 'my-conference',
538
- :mute => false,
539
- :hold => true,
540
- :call_ids_to_coach => "c-123,c-234",
541
- :conference_event_url => "https://test.com",
542
- :conference_event_method => "POST",
543
- :username => "user",
544
- :password => "pass",
545
- :tag => "tag",
546
- :conference_event_fallback_url => "https://test2.com",
547
- :conference_event_fallback_method => "POST",
548
- :fallback_username => "fuser",
549
- :fallback_password => "fpass"
550
- })
551
- response = Bandwidth::Voice::Response.new()
552
- response.push(conference)
553
-
554
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference mute="false" hold="true" callIdsToCoach="c-123,c-234" conferenceEventUrl="https://test.com" conferenceEventMethod="POST" username="user" password="pass" tag="tag" conferenceEventFallbackUrl="https://test2.com" conferenceEventFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">my-conference</Conference></Response>'
555
- actual = response.to_bxml()
556
- assert_equal(expected, actual)
557
- end
558
-
559
- def test_conference_coach_ids_array
560
- conference = Bandwidth::Voice::Conference.new({
561
- :conference_name => 'my-conference',
562
- :call_ids_to_coach => ["c-123", "c-234"],
563
- })
564
- response = Bandwidth::Voice::Response.new()
565
- response.push(conference)
566
-
567
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference callIdsToCoach="c-123,c-234">my-conference</Conference></Response>'
568
- actual = response.to_bxml()
569
- assert_equal(expected, actual)
570
- end
571
-
572
- def test_conference_no_coach
573
- conference = Bandwidth::Voice::Conference.new({
574
- :conference_name => 'my-conference'
575
- })
576
- response = Bandwidth::Voice::Response.new()
577
- response.push(conference)
578
-
579
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference>my-conference</Conference></Response>'
580
- actual = response.to_bxml()
581
- assert_equal(expected, actual)
582
- end
583
-
584
- def test_mfa_messaging
585
- body = TwoFactorCodeRequestSchema.new
586
- body.from = BW_NUMBER
587
- body.to = USER_NUMBER
588
- body.application_id = BW_MESSAGING_APPLICATION_ID
589
- body.scope = "scope"
590
- body.digits = 6
591
- body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
592
-
593
- response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(BW_ACCOUNT_ID, body)
594
- assert(response.data.message_id.length > 0, "message id value not set")
595
- end
596
-
597
- def test_mfa_voice
598
- body = TwoFactorCodeRequestSchema.new
599
- body.from = BW_NUMBER
600
- body.to = USER_NUMBER
601
- body.application_id = BW_VOICE_APPLICATION_ID
602
- body.scope = "scope"
603
- body.digits = 6
604
- body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
605
-
606
- response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(BW_ACCOUNT_ID, body)
607
- assert(response.data.call_id.length > 0, "call id value not set")
608
- end
609
-
610
- def test_mfa_verify
611
- body = TwoFactorVerifyRequestSchema.new
612
- body.to = "+1000" + rand(1111111..9999999).to_s
613
- body.application_id = BW_VOICE_APPLICATION_ID
614
- body.scope = "scope"
615
- body.code = "123456"
616
- body.expiration_time_in_minutes = 3
617
- response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(BW_ACCOUNT_ID, body)
618
- #Ruby has no check to see if variables are of type boolean
619
- #An explicit true/false check is required
620
- assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
621
- end
622
-
623
- def test_bridge
624
- bridge = Bandwidth::Voice::Bridge.new({
625
- :call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
626
- :bridge_complete_url => "https://test.com",
627
- :bridge_complete_method => "POST",
628
- :bridge_target_complete_url => "https://test2.com",
629
- :bridge_target_complete_method => "GET",
630
- :username => "user",
631
- :password => "pass",
632
- :tag => "custom tag",
633
- :bridge_complete_fallback_url => "https://test3.com",
634
- :bridge_complete_fallback_method => "GET",
635
- :bridge_target_complete_fallback_url => "https://test4.com",
636
- :bridge_target_complete_fallback_method => "POST",
637
- :fallback_username => "fuser",
638
- :fallback_password => "fpass"
639
- })
640
-
641
- response = Bandwidth::Voice::Response.new()
642
- response.push(bridge)
643
-
644
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Bridge bridgeCompleteUrl="https://test.com" bridgeCompleteMethod="POST" bridgeTargetCompleteUrl="https://test2.com" bridgeTargetCompleteMethod="GET" username="user" password="pass" tag="custom tag" bridgeCompleteFallbackUrl="https://test3.com" bridgeCompleteFallbackMethod="GET" bridgeTargetCompleteFallbackUrl="https://test4.com" bridgeTargetCompleteFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge></Response>'
645
- actual = response.to_bxml()
646
- assert_equal(expected, actual)
647
- end
648
-
649
- def test_ring
650
- ring = Bandwidth::Voice::Ring.new({
651
- :duration => 5,
652
- :answer_call => false
653
- })
654
-
655
- response = Bandwidth::Voice::Response.new()
656
- response.push(ring)
657
-
658
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5" answerCall="false"/></Response>'
659
- actual = response.to_bxml()
660
- assert_equal(expected, actual)
661
- end
662
-
663
- def test_start_gather
664
- start_gather = Bandwidth::Voice::StartGather.new({
665
- :username => "user",
666
- :password => "pass",
667
- :tag => "custom tag",
668
- :dtmf_url => "https://test.com",
669
- :dtmf_method => "GET"
670
- })
671
-
672
- response = Bandwidth::Voice::Response.new()
673
- response.push(start_gather)
674
-
675
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartGather username="user" password="pass" tag="custom tag" dtmfUrl="https://test.com" dtmfMethod="GET"/></Response>'
676
- actual = response.to_bxml()
677
- assert_equal(expected, actual)
678
- end
679
-
680
- def test_stop_gather
681
- stop_gather = Bandwidth::Voice::StopGather.new()
682
-
683
- response = Bandwidth::Voice::Response.new()
684
- response.push(stop_gather)
685
-
686
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopGather/></Response>'
687
- actual = response.to_bxml()
688
- assert_equal(expected, actual)
689
- end
690
-
691
- def test_tn_lookup
692
- body = OrderRequest.new
693
- body.tns = [BW_NUMBER]
694
- create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(BW_ACCOUNT_ID, body)
695
- assert(create_response.data.request_id.length > 0, "request_id value not set")
696
-
697
- request_id = create_response.data.request_id
698
- get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(BW_ACCOUNT_ID, request_id)
699
- assert(get_response.data.status.length > 0, "status value not set")
700
- end
701
-
702
- def test_webrtc_generate_bxml
703
- 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>'
704
- actual = Bandwidth::WebRtc.generate_bxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
705
- assert_equal(expected, actual)
706
- end
707
-
708
- def test_webrtc_generate_transfer_bxml_verb
709
- expected = '<Transfer><SipUri uui="93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt">sip:sipx.webrtc.bandwidth.com:5060</SipUri></Transfer>'
710
- actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
711
- assert_equal(expected, actual)
712
- end
713
-
714
- def test_start_stream_bxml_verb
715
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www.test.com/stream" name="test_stream" tracks="inbound" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"><StreamParam name="name1" value="value1"/></StartStream></Response>'
716
- response = Bandwidth::Voice::Response.new()
717
-
718
- stream_param1 = Bandwidth::Voice::StreamParam.new({
719
- :name => "name1",
720
- :value => "value1"
721
- })
722
-
723
- start_stream = Bandwidth::Voice::StartStream.new({
724
- :destination => "https://www.test.com/stream",
725
- :name => "test_stream",
726
- :tracks => "inbound",
727
- :streamEventUrl => "https://www.test.com/event",
728
- :streamEventMethod => "POST",
729
- :username => "username",
730
- :password => "password",
731
- :stream_params => stream_param1
732
- })
733
-
734
- response.push(start_stream)
735
- actual = response.to_bxml()
736
-
737
- assert_equal(expected, actual)
738
- end
739
-
740
- def test_start_stream_multiple_nested_stream_params
741
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www.test.com/stream" name="test_stream" tracks="inbound" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"><StreamParam name="name1" value="value1"/><StreamParam name="name2" value="value2"/></StartStream></Response>'
742
- response = Bandwidth::Voice::Response.new()
743
-
744
- stream_param1 = Bandwidth::Voice::StreamParam.new({
745
- :name => "name1",
746
- :value => "value1"
747
- })
748
-
749
- stream_param2 = Bandwidth::Voice::StreamParam.new({
750
- :name => "name2",
751
- :value => "value2"
752
- })
753
-
754
- start_stream = Bandwidth::Voice::StartStream.new({
755
- :destination => "https://www.test.com/stream",
756
- :name => "test_stream",
757
- :tracks => "inbound",
758
- :streamEventUrl => "https://www.test.com/event",
759
- :streamEventMethod => "POST",
760
- :username => "username",
761
- :password => "password",
762
- :nested_verbs => [stream_param1, stream_param2]
763
- })
764
-
765
- response.push(start_stream)
766
- actual = response.to_bxml()
767
-
768
- assert_equal(expected, actual)
769
- end
770
-
771
- def test_stop_stream_bxml_verb
772
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopStream name="test_stream"/></Response>'
773
- response = Bandwidth::Voice::Response.new()
774
- stop_stream = Bandwidth::Voice::StopStream.new({
775
- :name => "test_stream"
776
- })
777
- response.push(stop_stream)
778
- actual = response.to_bxml()
779
-
780
- assert_equal(expected, actual)
781
- end
782
-
783
- def test_start_transcription_bxml_verb
784
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartTranscription name="test_transcription" tracks="inbound" transcriptionEventUrl="https://www.test.com/event" transcriptionEventMethod="POST" username="username" password="password" destination="https://www.test.com/transcription"><CustomParam name="name1" value="value1"/></StartTranscription></Response>'
785
- response = Bandwidth::Voice::Response.new()
786
-
787
- custom_param1 = Bandwidth::Voice::CustomParam.new({
788
- :name => "name1",
789
- :value => "value1"
790
- })
791
-
792
- start_transcription = Bandwidth::Voice::StartTranscription.new({
793
- :name => "test_transcription",
794
- :tracks => "inbound",
795
- :transcriptionEventUrl => "https://www.test.com/event",
796
- :transcriptionEventMethod => "POST",
797
- :username => "username",
798
- :password => "password",
799
- :destination => "https://www.test.com/transcription",
800
- :custom_params => custom_param1
801
- })
802
-
803
- response.push(start_transcription)
804
- actual = response.to_bxml()
805
-
806
- assert_equal(expected, actual)
807
- end
808
-
809
- def test_start_transcription_multiple_nested_custom_params
810
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartTranscription name="test_transcription" tracks="inbound" transcriptionEventUrl="https://www.test.com/event" transcriptionEventMethod="POST" username="username" password="password" destination="https://www.test.com/transcription"><CustomParam name="name1" value="value1"/><CustomParam name="name2" value="value2"/></StartTranscription></Response>'
811
- response = Bandwidth::Voice::Response.new()
812
-
813
- custom_param1 = Bandwidth::Voice::CustomParam.new({
814
- :name => "name1",
815
- :value => "value1"
816
- })
817
-
818
- custom_param2 = Bandwidth::Voice::CustomParam.new({
819
- :name => "name2",
820
- :value => "value2"
821
- })
822
-
823
- start_transcription = Bandwidth::Voice::StartTranscription.new({
824
- :destination => "https://www.test.com/transcription",
825
- :name => "test_transcription",
826
- :tracks => "inbound",
827
- :transcriptionEventUrl => "https://www.test.com/event",
828
- :transcriptionEventMethod => "POST",
829
- :username => "username",
830
- :password => "password",
831
- :nested_verbs => [custom_param1, custom_param2]
832
- })
833
-
834
- response.push(start_transcription)
835
- actual = response.to_bxml()
836
-
837
- assert_equal(expected, actual)
838
- end
839
-
840
- def test_stop_transcription_bxml_verb
841
- expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopTranscription name="test_transcription"/></Response>'
842
- response = Bandwidth::Voice::Response.new()
843
- stop_transcription = Bandwidth::Voice::StopTranscription.new({
844
- :name => "test_transcription"
845
- })
846
- response.push(stop_transcription)
847
- actual = response.to_bxml()
848
-
849
- assert_equal(expected, actual)
850
- end
851
- end