bandwidth-sdk 10.0.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +11 -0
- data/Gemfile.lock +102 -0
- data/README.md +204 -139
- data/Rakefile +30 -0
- data/bandwidth-sdk.gemspec +40 -0
- data/bandwidth.yml +5626 -0
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +9761 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_asc_disabled.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_both.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc.png +0 -0
- data/coverage/assets/0.12.3/DataTables-1.10.20/images/sort_desc_disabled.png +0 -0
- data/coverage/assets/0.12.3/application.css +1 -0
- data/coverage/assets/0.12.3/application.js +7 -0
- data/coverage/assets/0.12.3/colorbox/border.png +0 -0
- data/coverage/assets/0.12.3/colorbox/controls.png +0 -0
- data/coverage/assets/0.12.3/colorbox/loading.gif +0 -0
- data/coverage/assets/0.12.3/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.12.3/favicon_green.png +0 -0
- data/coverage/assets/0.12.3/favicon_red.png +0 -0
- data/coverage/assets/0.12.3/favicon_yellow.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.12.3/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.12.3/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/assets/0.12.3/loading.gif +0 -0
- data/coverage/assets/0.12.3/magnify.png +0 -0
- data/coverage/index.html +108271 -0
- data/custom_templates/Gemfile.mustache +11 -0
- data/custom_templates/README.mustache +173 -0
- data/custom_templates/gem.mustache +99 -0
- data/custom_templates/gemspec.mustache +37 -0
- data/docs/AccountStatistics.md +20 -0
- data/docs/AnswerCallback.md +44 -0
- data/docs/BridgeCompleteCallback.md +48 -0
- data/docs/BridgeTargetCompleteCallback.md +42 -0
- data/docs/CallDirectionEnum.md +15 -0
- data/docs/CallRecordingMetadata.md +52 -0
- data/docs/CallState.md +52 -0
- data/docs/CallStateEnum.md +15 -0
- data/docs/CallbackMethodEnum.md +15 -0
- data/docs/CallsApi.md +304 -0
- data/docs/CodeRequest.md +28 -0
- data/docs/Conference.md +32 -0
- data/docs/ConferenceCompletedCallback.md +26 -0
- data/docs/ConferenceCreatedCallback.md +26 -0
- data/docs/ConferenceMember.md +28 -0
- data/docs/ConferenceMemberExitCallback.md +32 -0
- data/docs/ConferenceMemberJoinCallback.md +32 -0
- data/docs/ConferenceRecordingAvailableCallback.md +44 -0
- data/docs/ConferenceRecordingMetadata.md +38 -0
- data/docs/ConferenceRedirectCallback.md +26 -0
- data/docs/ConferenceStateEnum.md +15 -0
- data/docs/ConferencesApi.md +688 -0
- data/docs/CreateCall.md +56 -0
- data/docs/CreateCallResponse.md +58 -0
- data/docs/CreateLookupResponse.md +20 -0
- data/docs/CreateMessageRequestError.md +22 -0
- data/docs/CreateParticipantRequest.md +24 -0
- data/docs/CreateParticipantResponse.md +20 -0
- data/docs/DeferredResult.md +20 -0
- data/docs/DeviceApiVersionEnum.md +15 -0
- data/docs/DisconenctCallback.md +50 -0
- data/docs/DisconnectCallback.md +50 -0
- data/docs/Diversion.md +30 -0
- data/docs/DtmfCallback.md +50 -0
- data/docs/FieldError.md +20 -0
- data/docs/FileFormatEnum.md +15 -0
- data/docs/ForbiddenRequest.md +18 -0
- data/docs/GatherCallback.md +52 -0
- data/docs/InboundMessageCallback.md +26 -0
- data/docs/InboundMessageCallbackMessage.md +40 -0
- data/docs/InitiateCallback.md +40 -0
- data/docs/ListMessageDirectionEnum.md +15 -0
- data/docs/ListMessageItem.md +50 -0
- data/docs/LookupRequest.md +18 -0
- data/docs/LookupResult.md +34 -0
- data/docs/LookupStatus.md +24 -0
- data/docs/LookupStatusEnum.md +15 -0
- data/docs/MFAApi.md +226 -0
- data/docs/MachineDetectionCompleteCallback.md +44 -0
- data/docs/MachineDetectionConfiguration.md +46 -0
- data/docs/MachineDetectionModeEnum.md +15 -0
- data/docs/MachineDetectionResult.md +20 -0
- data/docs/Media.md +22 -0
- data/docs/MediaApi.md +307 -0
- data/docs/Message.md +42 -0
- data/docs/MessageDeliveredCallback.md +26 -0
- data/docs/MessageDeliveredCallbackMessage.md +40 -0
- data/docs/MessageDirectionEnum.md +15 -0
- data/docs/MessageFailedCallback.md +28 -0
- data/docs/MessageFailedCallbackMessage.md +40 -0
- data/docs/MessageRequest.md +32 -0
- data/docs/MessageSendingCallback.md +26 -0
- data/docs/MessageSendingCallbackMessage.md +40 -0
- data/docs/MessageStatusEnum.md +15 -0
- data/docs/MessageTypeEnum.md +15 -0
- data/docs/MessagesApi.md +183 -0
- data/docs/MessagesList.md +22 -0
- data/docs/MessagingCodeResponse.md +18 -0
- data/docs/MessagingRequestError.md +20 -0
- data/docs/MfaForbiddenRequestError.md +18 -0
- data/docs/MfaRequestError.md +20 -0
- data/docs/MfaUnauthorizedRequestError.md +18 -0
- data/docs/PageInfo.md +24 -0
- data/docs/Participant.md +30 -0
- data/docs/ParticipantSubscription.md +20 -0
- data/docs/ParticipantsApi.md +227 -0
- data/docs/PhoneNumberLookupApi.md +153 -0
- data/docs/PriorityEnum.md +15 -0
- data/docs/PublishPermissionsEnum.md +15 -0
- data/docs/RecordingAvailableCallback.md +60 -0
- data/docs/RecordingCompleteCallback.md +60 -0
- data/docs/RecordingStateEnum.md +15 -0
- data/docs/RecordingsApi.md +758 -0
- data/docs/RedirectCallback.md +48 -0
- data/docs/RedirectMethodEnum.md +15 -0
- data/docs/RequestError.md +20 -0
- data/docs/Session.md +20 -0
- data/docs/SessionsApi.md +605 -0
- data/docs/StatisticsApi.md +78 -0
- data/docs/StirShaken.md +22 -0
- data/docs/Subscriptions.md +20 -0
- data/docs/Tag.md +20 -0
- data/docs/TnLookupRequestError.md +18 -0
- data/docs/TranscribeRecording.md +30 -0
- data/docs/Transcription.md +20 -0
- data/docs/TranscriptionAvailableCallback.md +58 -0
- data/docs/TranscriptionList.md +18 -0
- data/docs/TranscriptionMetadata.md +24 -0
- data/docs/TransferAnswerCallback.md +46 -0
- data/docs/TransferCompleteCallback.md +52 -0
- data/docs/TransferDisconnectCallback.md +56 -0
- data/docs/UnauthorizedRequest.md +18 -0
- data/docs/UpdateCall.md +36 -0
- data/docs/UpdateCallRecording.md +18 -0
- data/docs/UpdateConference.md +34 -0
- data/docs/UpdateConferenceMember.md +22 -0
- data/docs/VerifyCodeRequest.md +24 -0
- data/docs/VerifyCodeResponse.md +18 -0
- data/docs/VoiceApiError.md +22 -0
- data/docs/VoiceCodeResponse.md +18 -0
- data/git_push.sh +57 -0
- data/lib/bandwidth-sdk/api/calls_api.rb +325 -0
- data/lib/bandwidth-sdk/api/conferences_api.rb +717 -0
- data/lib/bandwidth-sdk/api/media_api.rb +312 -0
- data/lib/bandwidth-sdk/api/messages_api.rb +204 -0
- data/lib/bandwidth-sdk/api/mfa_api.rb +244 -0
- data/lib/bandwidth-sdk/api/phone_number_lookup_api.rb +165 -0
- data/lib/bandwidth-sdk/api/recordings_api.rb +782 -0
- data/lib/bandwidth-sdk/api/statistics_api.rb +85 -0
- data/lib/bandwidth-sdk/api_client.rb +428 -0
- data/lib/bandwidth-sdk/api_error.rb +58 -0
- data/lib/bandwidth-sdk/configuration.rb +591 -0
- data/lib/bandwidth-sdk/models/account_statistics.rb +223 -0
- data/lib/bandwidth-sdk/models/answer_callback.rb +368 -0
- data/lib/bandwidth-sdk/models/bridge_complete_callback.rb +390 -0
- data/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +358 -0
- data/lib/bandwidth-sdk/models/bxml/bxml.rb +11 -0
- data/lib/bandwidth-sdk/models/bxml/nestable_verb.rb +46 -0
- data/lib/bandwidth-sdk/models/bxml/response.rb +11 -0
- data/lib/bandwidth-sdk/models/bxml/root.rb +47 -0
- data/lib/bandwidth-sdk/models/bxml/verb.rb +50 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/bridge.rb +28 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/conference.rb +28 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb +16 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/forward.rb +20 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/gather.rb +42 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/hangup.rb +10 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/pause.rb +15 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb +10 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb +26 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb +17 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/record.rb +32 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/redirect.rb +23 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb +10 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/ring.rb +16 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb +17 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb +27 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb +25 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb +19 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb +24 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb +28 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb +29 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb +10 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb +10 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb +15 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb +15 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb +16 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/tag.rb +11 -0
- data/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb +34 -0
- data/lib/bandwidth-sdk/models/call_direction_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/call_recording_metadata.rb +404 -0
- data/lib/bandwidth-sdk/models/call_state.rb +416 -0
- data/lib/bandwidth-sdk/models/call_state_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/callback_method_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/code_request.rb +434 -0
- data/lib/bandwidth-sdk/models/conference.rb +313 -0
- data/lib/bandwidth-sdk/models/conference_completed_callback.rb +255 -0
- data/lib/bandwidth-sdk/models/conference_created_callback.rb +255 -0
- data/lib/bandwidth-sdk/models/conference_member.rb +266 -0
- data/lib/bandwidth-sdk/models/conference_member_exit_callback.rb +285 -0
- data/lib/bandwidth-sdk/models/conference_member_join_callback.rb +285 -0
- data/lib/bandwidth-sdk/models/conference_recording_available_callback.rb +367 -0
- data/lib/bandwidth-sdk/models/conference_recording_metadata.rb +335 -0
- data/lib/bandwidth-sdk/models/conference_redirect_callback.rb +255 -0
- data/lib/bandwidth-sdk/models/conference_state_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/create_call.rb +687 -0
- data/lib/bandwidth-sdk/models/create_call_response.rb +559 -0
- data/lib/bandwidth-sdk/models/create_lookup_response.rb +245 -0
- data/lib/bandwidth-sdk/models/create_message_request_error.rb +246 -0
- data/lib/bandwidth-sdk/models/deferred_result.rb +221 -0
- data/lib/bandwidth-sdk/models/disconenct_callback.rb +405 -0
- data/lib/bandwidth-sdk/models/disconnect_callback.rb +400 -0
- data/lib/bandwidth-sdk/models/diversion.rb +273 -0
- data/lib/bandwidth-sdk/models/dtmf_callback.rb +398 -0
- data/lib/bandwidth-sdk/models/field_error.rb +223 -0
- data/lib/bandwidth-sdk/models/file_format_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/gather_callback.rb +408 -0
- data/lib/bandwidth-sdk/models/inbound_message_callback.rb +284 -0
- data/lib/bandwidth-sdk/models/inbound_message_callback_message.rb +411 -0
- data/lib/bandwidth-sdk/models/initiate_callback.rb +343 -0
- data/lib/bandwidth-sdk/models/list_message_direction_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/list_message_item.rb +398 -0
- data/lib/bandwidth-sdk/models/lookup_request.rb +222 -0
- data/lib/bandwidth-sdk/models/lookup_result.rb +294 -0
- data/lib/bandwidth-sdk/models/lookup_status.rb +269 -0
- data/lib/bandwidth-sdk/models/lookup_status_enum.rb +42 -0
- data/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +368 -0
- data/lib/bandwidth-sdk/models/machine_detection_configuration.rb +493 -0
- data/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/machine_detection_result.rb +224 -0
- data/lib/bandwidth-sdk/models/media.rb +230 -0
- data/lib/bandwidth-sdk/models/message.rb +377 -0
- data/lib/bandwidth-sdk/models/message_delivered_callback.rb +284 -0
- data/lib/bandwidth-sdk/models/message_delivered_callback_message.rb +418 -0
- data/lib/bandwidth-sdk/models/message_direction_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/message_failed_callback.rb +300 -0
- data/lib/bandwidth-sdk/models/message_failed_callback_message.rb +425 -0
- data/lib/bandwidth-sdk/models/message_request.rb +358 -0
- data/lib/bandwidth-sdk/models/message_sending_callback.rb +284 -0
- data/lib/bandwidth-sdk/models/message_sending_callback_message.rb +425 -0
- data/lib/bandwidth-sdk/models/message_status_enum.rb +46 -0
- data/lib/bandwidth-sdk/models/message_type_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/messages_list.rb +233 -0
- data/lib/bandwidth-sdk/models/messaging_code_response.rb +213 -0
- data/lib/bandwidth-sdk/models/messaging_request_error.rb +235 -0
- data/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +213 -0
- data/lib/bandwidth-sdk/models/mfa_request_error.rb +223 -0
- data/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +213 -0
- data/lib/bandwidth-sdk/models/page_info.rb +243 -0
- data/lib/bandwidth-sdk/models/priority_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/recording_available_callback.rb +447 -0
- data/lib/bandwidth-sdk/models/recording_complete_callback.rb +448 -0
- data/lib/bandwidth-sdk/models/recording_state_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/redirect_callback.rb +388 -0
- data/lib/bandwidth-sdk/models/redirect_method_enum.rb +40 -0
- data/lib/bandwidth-sdk/models/stir_shaken.rb +233 -0
- data/lib/bandwidth-sdk/models/tag.rb +221 -0
- data/lib/bandwidth-sdk/models/tn_lookup_request_error.rb +213 -0
- data/lib/bandwidth-sdk/models/transcribe_recording.rb +360 -0
- data/lib/bandwidth-sdk/models/transcription.rb +223 -0
- data/lib/bandwidth-sdk/models/transcription_available_callback.rb +436 -0
- data/lib/bandwidth-sdk/models/transcription_list.rb +214 -0
- data/lib/bandwidth-sdk/models/transcription_metadata.rb +244 -0
- data/lib/bandwidth-sdk/models/transfer_answer_callback.rb +378 -0
- data/lib/bandwidth-sdk/models/transfer_complete_callback.rb +410 -0
- data/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +430 -0
- data/lib/bandwidth-sdk/models/update_call.rb +413 -0
- data/lib/bandwidth-sdk/models/update_call_recording.rb +241 -0
- data/lib/bandwidth-sdk/models/update_conference.rb +387 -0
- data/lib/bandwidth-sdk/models/update_conference_member.rb +236 -0
- data/lib/bandwidth-sdk/models/verify_code_request.rb +341 -0
- data/lib/bandwidth-sdk/models/verify_code_response.rb +213 -0
- data/lib/bandwidth-sdk/models/voice_api_error.rb +231 -0
- data/lib/bandwidth-sdk/models/voice_code_response.rb +213 -0
- data/lib/bandwidth-sdk/version.rb +15 -0
- data/lib/bandwidth-sdk.rb +170 -0
- data/openapi-config.yml +12 -0
- data/openapitools.json +7 -0
- data/spec/api/calls_api_spec.rb +230 -0
- data/spec/api/conferences_api_spec.rb +393 -0
- data/spec/api/media_api_spec.rb +129 -0
- data/spec/api/messages_api_spec.rb +193 -0
- data/spec/api/mfa_api_spec.rb +130 -0
- data/spec/api/phone_number_lookup_api_spec.rb +100 -0
- data/spec/api/recordings_api_spec.rb +395 -0
- data/spec/api/statistics_api_spec.rb +45 -0
- data/spec/api_client_spec.rb +377 -0
- data/spec/api_error_spec.rb +23 -0
- data/spec/call_utils.rb +74 -0
- data/spec/configuration_spec.rb +190 -0
- data/spec/fixtures/ruby_cat.jpeg +0 -0
- data/spec/integration/calls_api_integration_spec.rb +202 -0
- data/spec/integration/conferences_api_integration_spec.rb +169 -0
- data/spec/integration/media_api_integration_spec.rb +92 -0
- data/spec/integration/messages_api_integration_spec.rb +138 -0
- data/spec/integration/mfa_api_integration_spec.rb +117 -0
- data/spec/integration/phone_number_lookup_api_integration_spec.rb +96 -0
- data/spec/integration/recordings_api_integration_spec.rb +226 -0
- data/spec/integration/statistics_api_integration_spec.rb +58 -0
- data/spec/models/bxml/bxml_spec.rb +16 -0
- data/spec/models/bxml/nestable_verb_spec.rb +11 -0
- data/spec/models/bxml/response_spec.rb +16 -0
- data/spec/models/bxml/verb_spec.rb +15 -0
- data/spec/models/bxml/verbs/bridge_spec.rb +58 -0
- data/spec/models/bxml/verbs/conference_spec.rb +58 -0
- data/spec/models/bxml/verbs/custom_param_spec.rb +36 -0
- data/spec/models/bxml/verbs/forward_spec.rb +44 -0
- data/spec/models/bxml/verbs/gather_spec.rb +86 -0
- data/spec/models/bxml/verbs/hangup_spec.rb +16 -0
- data/spec/models/bxml/verbs/pause_recording_spec.rb +16 -0
- data/spec/models/bxml/verbs/pause_spec.rb +34 -0
- data/spec/models/bxml/verbs/phone_number_spec.rb +54 -0
- data/spec/models/bxml/verbs/play_audio_spec.rb +36 -0
- data/spec/models/bxml/verbs/record_spec.rb +68 -0
- data/spec/models/bxml/verbs/redirect_spec.rb +50 -0
- data/spec/models/bxml/verbs/resume_recording_spec.rb +16 -0
- data/spec/models/bxml/verbs/ring_spec.rb +36 -0
- data/spec/models/bxml/verbs/send_dtmf_spec.rb +36 -0
- data/spec/models/bxml/verbs/sip_uri_spec.rb +56 -0
- data/spec/models/bxml/verbs/speak_sentence_spec.rb +38 -0
- data/spec/models/bxml/verbs/start_gather_spec.rb +42 -0
- data/spec/models/bxml/verbs/start_recording_spec.rb +52 -0
- data/spec/models/bxml/verbs/start_stream_spec.rb +72 -0
- data/spec/models/bxml/verbs/start_transcription_spec.rb +74 -0
- data/spec/models/bxml/verbs/stop_gather_spec.rb +16 -0
- data/spec/models/bxml/verbs/stop_recording_spec.rb +16 -0
- data/spec/models/bxml/verbs/stop_stream_spec.rb +34 -0
- data/spec/models/bxml/verbs/stop_transcription_spec.rb +34 -0
- data/spec/models/bxml/verbs/stream_param_spec.rb +36 -0
- data/spec/models/bxml/verbs/tag_spec.rb +16 -0
- data/spec/models/bxml/verbs/transfer_spec.rb +84 -0
- data/spec/models/call_state_enum_spec.rb +16 -0
- data/spec/models/call_state_spec.rb +168 -0
- data/spec/models/deferred_result_spec.rb +74 -0
- data/spec/models/message_spec.rb +138 -0
- data/spec/models/verify_code_request_spec.rb +126 -0
- data/spec/spec_helper.rb +171 -0
- metadata +430 -276
- data/LICENSE +0 -28
- data/lib/bandwidth/api_helper.rb +0 -280
- data/lib/bandwidth/client.rb +0 -75
- data/lib/bandwidth/configuration.rb +0 -209
- data/lib/bandwidth/exceptions/api_exception.rb +0 -20
- data/lib/bandwidth/http/api_response.rb +0 -38
- data/lib/bandwidth/http/auth/messaging_basic_auth.rb +0 -22
- data/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb +0 -22
- data/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +0 -22
- data/lib/bandwidth/http/auth/voice_basic_auth.rb +0 -22
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +0 -22
- data/lib/bandwidth/http/faraday_client.rb +0 -73
- data/lib/bandwidth/http/http_call_back.rb +0 -24
- data/lib/bandwidth/http/http_client.rb +0 -104
- data/lib/bandwidth/http/http_method_enum.rb +0 -13
- data/lib/bandwidth/http/http_request.rb +0 -50
- data/lib/bandwidth/http/http_response.rb +0 -29
- data/lib/bandwidth/messaging_lib/messaging/client.rb +0 -60
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +0 -491
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +0 -47
- data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +0 -37
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +0 -100
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +0 -164
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +0 -203
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +0 -79
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +0 -60
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +0 -70
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +0 -111
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +0 -82
- data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +0 -19
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +0 -60
- data/lib/bandwidth/messaging_lib/messaging.rb +0 -25
- data/lib/bandwidth/models/base_model.rb +0 -58
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb +0 -60
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +0 -47
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +0 -214
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +0 -37
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +0 -32
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +0 -32
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +0 -103
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +0 -50
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +0 -50
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +0 -94
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +0 -50
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +0 -23
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +0 -60
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +0 -1553
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +0 -47
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +0 -32
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +0 -50
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +0 -61
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +0 -95
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +0 -132
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +0 -20
- data/lib/bandwidth/utilities/date_time_helper.rb +0 -156
- data/lib/bandwidth/utilities/file_wrapper.rb +0 -16
- data/lib/bandwidth/voice_lib/bxml/bxml.rb +0 -36
- data/lib/bandwidth/voice_lib/bxml/response.rb +0 -39
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +0 -28
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +0 -32
- data/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +0 -18
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +0 -49
- data/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +0 -14
- data/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +0 -15
- data/lib/bandwidth/voice_lib/bxml/verbs/pause_recording.rb +0 -14
- data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +0 -24
- data/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +0 -17
- data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +0 -33
- data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +0 -24
- data/lib/bandwidth/voice_lib/bxml/verbs/resume_recording.rb +0 -14
- data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +0 -16
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +0 -16
- data/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb +0 -25
- data/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +0 -18
- data/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +0 -20
- data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +0 -25
- data/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +0 -14
- data/lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb +0 -14
- data/lib/bandwidth/voice_lib/bxml/verbs/tag.rb +0 -13
- data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +0 -48
- data/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +0 -26
- data/lib/bandwidth/voice_lib/voice/client.rb +0 -60
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +0 -1820
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +0 -47
- data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +0 -42
- data/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +0 -343
- data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +0 -250
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +0 -301
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +0 -211
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +0 -103
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +0 -173
- data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +0 -153
- data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +0 -236
- data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +0 -266
- data/lib/bandwidth/voice_lib/voice/models/direction_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/diversion.rb +0 -80
- data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +0 -231
- data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +0 -48
- data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +0 -156
- data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +0 -144
- data/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +0 -17
- data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +0 -108
- data/lib/bandwidth/voice_lib/voice/models/transcript.rb +0 -60
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +0 -80
- data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +0 -89
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +0 -59
- data/lib/bandwidth/voice_lib/voice.rb +0 -48
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +0 -18
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +0 -60
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +0 -703
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +0 -47
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +0 -37
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +0 -62
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +0 -17
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +0 -115
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +0 -48
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +0 -17
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +0 -60
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +0 -71
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +0 -22
- data/lib/bandwidth.rb +0 -73
- data/test/controllers/controller_test_base.rb +0 -21
- data/test/http_response_catcher.rb +0 -19
- data/test/integration/test_integration.rb +0 -691
- data/test/test_helper.rb +0 -94
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
# Unit tests for Bandwidth::ApiClient
|
|
2
|
+
describe Bandwidth::ApiClient do
|
|
3
|
+
let(:api_client_default) { Bandwidth::ApiClient.new }
|
|
4
|
+
let(:config) { Bandwidth::Configuration.new }
|
|
5
|
+
let(:faraday_connection) { Faraday::Connection.new }
|
|
6
|
+
let(:api_client) { Bandwidth::ApiClient.new(config) }
|
|
7
|
+
let(:named_media_headers) { { 'content-disposition' => 'filename=test', 'content-type' => 'text/plain' } }
|
|
8
|
+
let(:media_data) { '123456' }
|
|
9
|
+
let(:media_headers) { { 'content-type' => 'text/plain' } }
|
|
10
|
+
let(:json_headers) { { 'content-type' => 'application/json' } }
|
|
11
|
+
let(:multipart_headers) { { 'Content-Type' => 'multipart/form-data' } }
|
|
12
|
+
let(:form_encoded_headers) { { 'Content-Type' => 'application/x-www-form-urlencoded' } }
|
|
13
|
+
let(:error_data) { '{"error": true}' }
|
|
14
|
+
|
|
15
|
+
describe '#call_api' do
|
|
16
|
+
it 'calls api and returns a tempfile with name from content-disposition header' do
|
|
17
|
+
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
|
|
18
|
+
to_return(status: 200, headers: media_headers, body: media_data)
|
|
19
|
+
|
|
20
|
+
opts = {
|
|
21
|
+
operation: :"MediaApi.get_media",
|
|
22
|
+
header_params: {},
|
|
23
|
+
query_params: {},
|
|
24
|
+
form_params: {},
|
|
25
|
+
body: nil,
|
|
26
|
+
auth_names: ['Basic'],
|
|
27
|
+
return_type: 'File'
|
|
28
|
+
}
|
|
29
|
+
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
|
|
30
|
+
|
|
31
|
+
expect(status_code).to eq(200)
|
|
32
|
+
expect(headers).to eq(media_headers)
|
|
33
|
+
expect(data).to be_a(Tempfile)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'calls api and returns a tempfile' do
|
|
37
|
+
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
|
|
38
|
+
to_return(status: 200, headers: named_media_headers, body: media_data)
|
|
39
|
+
|
|
40
|
+
opts = {
|
|
41
|
+
operation: :"MediaApi.get_media",
|
|
42
|
+
header_params: {},
|
|
43
|
+
query_params: {},
|
|
44
|
+
form_params: {},
|
|
45
|
+
body: nil,
|
|
46
|
+
auth_names: ['Basic'],
|
|
47
|
+
return_type: 'File'
|
|
48
|
+
}
|
|
49
|
+
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
|
|
50
|
+
|
|
51
|
+
expect(status_code).to eq(200)
|
|
52
|
+
expect(headers).to eq(named_media_headers)
|
|
53
|
+
expect(data).to be_a(Tempfile)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'calls api and returns binary data' do
|
|
57
|
+
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
|
|
58
|
+
to_return(status: 200, headers: media_headers, body: media_data)
|
|
59
|
+
|
|
60
|
+
api_client.config.return_binary_data = true
|
|
61
|
+
api_client.config.debugging = true
|
|
62
|
+
|
|
63
|
+
opts = {
|
|
64
|
+
operation: :"MediaApi.get_media",
|
|
65
|
+
header_params: {},
|
|
66
|
+
query_params: {},
|
|
67
|
+
form_params: {},
|
|
68
|
+
body: nil,
|
|
69
|
+
auth_names: ['Basic'],
|
|
70
|
+
return_type: 'File'
|
|
71
|
+
}
|
|
72
|
+
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
|
|
73
|
+
|
|
74
|
+
expect(status_code).to eq(200)
|
|
75
|
+
expect(headers).to eq(media_headers)
|
|
76
|
+
expect(data).to eq(media_data)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
it 'calls api and returns a hash' do
|
|
80
|
+
stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path').
|
|
81
|
+
to_return(status: 200, headers: json_headers, body: '{"id": 1}')
|
|
82
|
+
|
|
83
|
+
opts = {
|
|
84
|
+
operation: :"MessagesApi.list_messages",
|
|
85
|
+
header_params: {},
|
|
86
|
+
query_params: {},
|
|
87
|
+
form_params: {},
|
|
88
|
+
body: nil,
|
|
89
|
+
auth_names: ['Basic'],
|
|
90
|
+
return_type: 'Hash<String, Integer>'
|
|
91
|
+
}
|
|
92
|
+
data, status_code, headers = api_client.call_api(:GET, 'path', opts)
|
|
93
|
+
|
|
94
|
+
expect(status_code).to eq(200)
|
|
95
|
+
expect(headers).to eq(json_headers)
|
|
96
|
+
expect(data).to eq({ id: 1 })
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it 'posts data and returns nothing' do
|
|
100
|
+
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
|
|
101
|
+
to_return(status: 204)
|
|
102
|
+
|
|
103
|
+
api_client.config.debugging = true
|
|
104
|
+
|
|
105
|
+
opts = {
|
|
106
|
+
operation: :"MediaApi.upload_media",
|
|
107
|
+
header_params: {},
|
|
108
|
+
query_params: {},
|
|
109
|
+
form_params: {},
|
|
110
|
+
body: { id: 1 },
|
|
111
|
+
auth_names: ['Basic'],
|
|
112
|
+
return_type: nil
|
|
113
|
+
}
|
|
114
|
+
data, status_code, headers = api_client.call_api(:POST, 'path', opts)
|
|
115
|
+
|
|
116
|
+
expect(status_code).to eq(204)
|
|
117
|
+
expect(data).to be nil
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'posts multipart/form-data and returns nothing' do
|
|
121
|
+
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
|
|
122
|
+
to_return(status: 204)
|
|
123
|
+
|
|
124
|
+
opts = {
|
|
125
|
+
operation: :"MediaApi.upload_media",
|
|
126
|
+
header_params: multipart_headers,
|
|
127
|
+
query_params: {},
|
|
128
|
+
form_params: { file: Tempfile.new('filename'), array: [1, 2, 3], string: '123' },
|
|
129
|
+
body: nil,
|
|
130
|
+
auth_names: ['Basic'],
|
|
131
|
+
return_type: nil
|
|
132
|
+
}
|
|
133
|
+
data, status_code, headers = api_client.call_api(:POST, 'path', opts)
|
|
134
|
+
|
|
135
|
+
expect(status_code).to eq(204)
|
|
136
|
+
expect(data).to be nil
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it 'calls api and handles HTTP error' do
|
|
140
|
+
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
|
|
141
|
+
to_return(status: 400, headers: json_headers, body: error_data)
|
|
142
|
+
|
|
143
|
+
opts = {
|
|
144
|
+
operation: :"MediaApi.upload_media",
|
|
145
|
+
header_params: {},
|
|
146
|
+
query_params: {},
|
|
147
|
+
form_params: {},
|
|
148
|
+
body: { id: 1 },
|
|
149
|
+
auth_names: ['Basic'],
|
|
150
|
+
return_type: nil
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
expect {
|
|
154
|
+
api_client.call_api(:POST, 'path', opts)
|
|
155
|
+
}.to raise_error { |e|
|
|
156
|
+
expect(e).to be_instance_of(Bandwidth::ApiError)
|
|
157
|
+
expect(e.code).to eq(400)
|
|
158
|
+
expect(e.response_headers).to eq(json_headers)
|
|
159
|
+
expect(e.response_body).to eq('{"error": true}')
|
|
160
|
+
}
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'calls api and handles timeout error' do
|
|
164
|
+
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
|
|
165
|
+
to_raise(Faraday::TimeoutError)
|
|
166
|
+
|
|
167
|
+
opts = {
|
|
168
|
+
operation: :"MediaApi.upload_media",
|
|
169
|
+
header_params: {},
|
|
170
|
+
query_params: {},
|
|
171
|
+
form_params: {},
|
|
172
|
+
body: { id: 1 },
|
|
173
|
+
auth_names: ['Basic'],
|
|
174
|
+
return_type: nil
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
expect {
|
|
178
|
+
api_client.call_api(:POST, 'path', opts)
|
|
179
|
+
}.to raise_error { |e|
|
|
180
|
+
expect(e).to be_instance_of(Bandwidth::ApiError)
|
|
181
|
+
expect(e.message).to eq('Connection timed out')
|
|
182
|
+
}
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'calls api and handles connection error' do
|
|
186
|
+
stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path').
|
|
187
|
+
to_raise(Faraday::ConnectionFailed)
|
|
188
|
+
|
|
189
|
+
opts = {
|
|
190
|
+
operation: :"MediaApi.upload_media",
|
|
191
|
+
header_params: {},
|
|
192
|
+
query_params: {},
|
|
193
|
+
form_params: {},
|
|
194
|
+
body: { id: 1 },
|
|
195
|
+
auth_names: ['Basic'],
|
|
196
|
+
return_type: nil
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
expect {
|
|
200
|
+
api_client.call_api(:POST, 'path', opts)
|
|
201
|
+
}.to raise_error { |e|
|
|
202
|
+
expect(e).to be_instance_of(Bandwidth::ApiError)
|
|
203
|
+
expect(e.message).to eq('Connection failed')
|
|
204
|
+
}
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
describe '#build_request_body' do
|
|
209
|
+
it 'builds application/x-www-form-urlencoded' do
|
|
210
|
+
expect(api_client_default.build_request_body(form_encoded_headers, { id: 1 }, nil)).to eq('id=1')
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it 'builds empty body' do
|
|
214
|
+
expect(api_client_default.build_request_body({}, {}, nil)).to be nil
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
describe '#deserialize' do
|
|
219
|
+
it 'throws on invalid JSON when expecting JSON' do
|
|
220
|
+
headers = { 'Content-Type' => 'application/json' }
|
|
221
|
+
response = double('response', headers: headers, body: '{id 1}')
|
|
222
|
+
expect {
|
|
223
|
+
api_client_default.deserialize(response, 'Hash<String, Integer>')
|
|
224
|
+
}.to raise_error(JSON::ParserError, 'unexpected token at \'{id 1}]\'')
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
it 'rescues invalid JSON when expecting non-JSON' do
|
|
228
|
+
headers = { 'Content-Type' => 'application/json' }
|
|
229
|
+
response = double('response', headers: headers, body: '2022-06-16')
|
|
230
|
+
data = api_client_default.deserialize(response, 'Date')
|
|
231
|
+
expect(data).to eq(Date.parse('2022-06-16'))
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
describe '#basic_auth' do
|
|
236
|
+
it 'sets basic auth for the connection' do
|
|
237
|
+
api_client.config.username = 'username'
|
|
238
|
+
api_client.config.password = 'password'
|
|
239
|
+
api_client.basic_auth(faraday_connection)
|
|
240
|
+
expect(api_client.config.username).to eq('username')
|
|
241
|
+
expect(api_client.config.password).to eq('password')
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
describe '#json_mime?' do
|
|
246
|
+
it 'checks if the given MIME is a JSON MIME' do
|
|
247
|
+
expect(api_client_default.json_mime?(nil)).to eq false
|
|
248
|
+
expect(api_client_default.json_mime?('')).to eq false
|
|
249
|
+
|
|
250
|
+
expect(api_client_default.json_mime?('application/json')).to eq true
|
|
251
|
+
expect(api_client_default.json_mime?('application/json; charset=UTF8')).to eq true
|
|
252
|
+
expect(api_client_default.json_mime?('APPLICATION/JSON')).to eq true
|
|
253
|
+
|
|
254
|
+
expect(api_client_default.json_mime?('application/xml')).to eq false
|
|
255
|
+
expect(api_client_default.json_mime?('text/plain')).to eq false
|
|
256
|
+
expect(api_client_default.json_mime?('application/jsonp')).to eq false
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
describe '#convert_to_type' do
|
|
261
|
+
it 'conversts data to the given return type' do
|
|
262
|
+
expect(api_client_default.convert_to_type(1, 'String')).to eq('1')
|
|
263
|
+
expect(api_client_default.convert_to_type('1', 'Integer')).to eq(1)
|
|
264
|
+
expect(api_client_default.convert_to_type('1', 'Float')).to eq(1.0)
|
|
265
|
+
expect(api_client_default.convert_to_type(1, 'Boolean')).to be false
|
|
266
|
+
expect(api_client_default.convert_to_type('2022-06-16T13:15:07.160Z', 'Time')).to eq(Time.parse('2022-06-16T13:15:07.160Z'))
|
|
267
|
+
expect(api_client_default.convert_to_type('2022-06-16', 'Date')).to eq(Date.parse('2022-06-16'))
|
|
268
|
+
expect(api_client_default.convert_to_type({ id: 1 }, 'Object')).to eq({ id: 1 })
|
|
269
|
+
expect(api_client_default.convert_to_type([[12, 34], [56]], 'Array<Array<Integer>>')).to eq([[12, 34], [56]])
|
|
270
|
+
expect(api_client_default.convert_to_type({ "id": 'test' }, 'Hash<String, String>')).to eq({ id: 'test' })
|
|
271
|
+
expect(api_client_default.convert_to_type({ set_or_expired: true }, 'DeferredResult')).to be_instance_of(Bandwidth::DeferredResult)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
describe '#sanitize_filename' do
|
|
276
|
+
it 'sanitizes a filename by removing the path' do
|
|
277
|
+
expect(api_client_default.sanitize_filename('sun')).to eq('sun')
|
|
278
|
+
expect(api_client_default.sanitize_filename('sun.gif')).to eq('sun.gif')
|
|
279
|
+
expect(api_client_default.sanitize_filename('../sun.gif')).to eq('sun.gif')
|
|
280
|
+
expect(api_client_default.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
|
|
281
|
+
expect(api_client_default.sanitize_filename('./sun.gif')).to eq('sun.gif')
|
|
282
|
+
expect(api_client_default.sanitize_filename('..\sun.gif')).to eq('sun.gif')
|
|
283
|
+
expect(api_client_default.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
|
|
284
|
+
expect(api_client_default.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
|
|
285
|
+
expect(api_client_default.sanitize_filename('.\sun.gif')).to eq('sun.gif')
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
describe '#build_request_url' do
|
|
290
|
+
it 'adds leading and trailing slashes to path' do
|
|
291
|
+
expect(api_client_default.build_request_url('test/path')).to eq('http://localhost/test/path')
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
describe '#update_params_for_auth' do
|
|
296
|
+
it 'updates header and query params based on authentication settings' do
|
|
297
|
+
|
|
298
|
+
end
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
describe '#user_agent=' do
|
|
302
|
+
it 'sets user agent in HTTP header' do
|
|
303
|
+
api_client_default.user_agent = 'test-user-agent'
|
|
304
|
+
expect(api_client_default.default_headers['User-Agent']).to eq('test-user-agent')
|
|
305
|
+
end
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
describe '#select_header_accept' do
|
|
309
|
+
it 'returns Accept header based on an array of accepts provided' do
|
|
310
|
+
expect(api_client_default.select_header_accept(nil)).to be_nil
|
|
311
|
+
expect(api_client_default.select_header_accept([])).to be_nil
|
|
312
|
+
|
|
313
|
+
expect(api_client_default.select_header_accept(['application/json'])).to eq('application/json')
|
|
314
|
+
expect(api_client_default.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
|
315
|
+
expect(api_client_default.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
|
316
|
+
|
|
317
|
+
expect(api_client_default.select_header_accept(['application/xml'])).to eq('application/xml')
|
|
318
|
+
expect(api_client_default.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
describe '#select_header_content_type' do
|
|
323
|
+
it 'returns Content-Type header based on an array of content types provided' do
|
|
324
|
+
expect(api_client_default.select_header_content_type(nil)).to be_nil
|
|
325
|
+
expect(api_client_default.select_header_content_type([])).to be_nil
|
|
326
|
+
|
|
327
|
+
expect(api_client_default.select_header_content_type(['application/json'])).to eq('application/json')
|
|
328
|
+
expect(api_client_default.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
|
|
329
|
+
expect(api_client_default.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
|
|
330
|
+
expect(api_client_default.select_header_content_type(['application/xml'])).to eq('application/xml')
|
|
331
|
+
expect(api_client_default.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
describe '#object_to_http_body' do
|
|
336
|
+
it 'converts array to JSON string' do
|
|
337
|
+
model = [1, 2, 3]
|
|
338
|
+
expect(api_client_default.object_to_http_body(model)).to eq('[1,2,3]')
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
it 'converts hash to JSON string' do
|
|
342
|
+
model = { id: 1 }
|
|
343
|
+
expect(api_client_default.object_to_http_body(model)).to eq('{"id":1}')
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
describe '#object_to_hash' do
|
|
348
|
+
it 'returns object when object cannot be converted to hash' do
|
|
349
|
+
model = Object.new
|
|
350
|
+
model.instance_variable_set(:@id, 1)
|
|
351
|
+
expect(api_client_default.object_to_hash(model)).to be_instance_of(Object)
|
|
352
|
+
expect(api_client_default.object_to_hash(model).instance_variable_get('@id')).to eq(1)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
it 'returns hash when object can be converted to hash' do
|
|
356
|
+
model = Bandwidth::DeferredResult.new({
|
|
357
|
+
set_or_expired: true
|
|
358
|
+
})
|
|
359
|
+
expected = { setOrExpired: true }
|
|
360
|
+
expect(api_client_default.object_to_hash(model)).to eq(expected)
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
describe '#build_collection_param' do
|
|
365
|
+
it 'builds parameter value according to the given collection format' do
|
|
366
|
+
param = ['aa', 'bb', 'cc']
|
|
367
|
+
expect(api_client_default.build_collection_param(param, :csv)).to eq('aa,bb,cc')
|
|
368
|
+
expect(api_client_default.build_collection_param(param, :ssv)).to eq('aa bb cc')
|
|
369
|
+
expect(api_client_default.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
|
|
370
|
+
expect(api_client_default.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
|
|
371
|
+
expect(api_client_default.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
|
|
372
|
+
expect {
|
|
373
|
+
api_client_default.build_collection_param(param, :INVALID)
|
|
374
|
+
}.to raise_error(RuntimeError, 'unknown collection format: :INVALID')
|
|
375
|
+
end
|
|
376
|
+
end
|
|
377
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Unit tests for Bandwidth::ApiError
|
|
2
|
+
describe Bandwidth::ApiError do
|
|
3
|
+
describe '#initialize' do
|
|
4
|
+
it 'initializes an instance of ApiError with message' do
|
|
5
|
+
api_error = Bandwidth::ApiError.new({ message: 'test' })
|
|
6
|
+
expect(api_error.message).to eq('test')
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe '#to_s' do
|
|
11
|
+
it 'returns message when to_s is called' do
|
|
12
|
+
api_error = Bandwidth::ApiError.new('test')
|
|
13
|
+
expect(api_error.to_s).to eq('test')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe '#message' do
|
|
18
|
+
it 'returns default error message when none supplied' do
|
|
19
|
+
api_error = Bandwidth::ApiError.new
|
|
20
|
+
expect(api_error.message).to eq('Error message: the server returns an error')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/spec/call_utils.rb
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Helper functions for voice calls
|
|
2
|
+
# These are reused in multiple tests
|
|
3
|
+
|
|
4
|
+
def setup_manteca(type)
|
|
5
|
+
manteca_body = {
|
|
6
|
+
os: OPERATING_SYSTEM,
|
|
7
|
+
language: RUBY_VERSION,
|
|
8
|
+
type: type
|
|
9
|
+
}
|
|
10
|
+
manteca_test_url = URI(MANTECA_BASE_URL + '/tests')
|
|
11
|
+
manteca_header = { 'Content-Type': 'application/json' }
|
|
12
|
+
|
|
13
|
+
begin
|
|
14
|
+
test_id = Net::HTTP.post(manteca_test_url, manteca_body.to_json, manteca_header)
|
|
15
|
+
test_id.body.to_s
|
|
16
|
+
rescue => e
|
|
17
|
+
puts e.inspect
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create_manteca_call(tag = 'ruby', answer_path = '/bxml/pause', calls_api)
|
|
22
|
+
manteca_call_body = Bandwidth::CreateCall.new(
|
|
23
|
+
application_id: MANTECA_APPLICATION_ID,
|
|
24
|
+
to: MANTECA_IDLE_NUMBER,
|
|
25
|
+
from: MANTECA_ACTIVE_NUMBER,
|
|
26
|
+
answer_url: MANTECA_BASE_URL + answer_path,
|
|
27
|
+
tag: tag
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
response = calls_api.create_call(BW_ACCOUNT_ID, manteca_call_body)
|
|
31
|
+
$active_calls.append(response.call_id)
|
|
32
|
+
response.call_id
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_manteca_test_status(test_id)
|
|
36
|
+
manteca_status_url = URI(MANTECA_BASE_URL + '/tests/' + test_id)
|
|
37
|
+
response = JSON.parse(Net::HTTP.get(manteca_status_url))
|
|
38
|
+
response
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def cleanup_calls(calls, calls_api)
|
|
42
|
+
attempts = 0
|
|
43
|
+
|
|
44
|
+
while (calls.length > 0 && attempts < 10)
|
|
45
|
+
calls.delete_if { |call_id| call_ended(call_id, calls_api) }
|
|
46
|
+
sleep(SLEEP_TIME_S)
|
|
47
|
+
attempts += 1
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if (calls.length > 0)
|
|
51
|
+
error_message = 'Failed to terminate all calls' + calls.to_s
|
|
52
|
+
raise StandardError.new error_message
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def call_ended(call_id, calls_api)
|
|
57
|
+
begin
|
|
58
|
+
response = calls_api.get_call_state(BW_ACCOUNT_ID, call_id)
|
|
59
|
+
rescue Bandwidth::ApiError
|
|
60
|
+
return false
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if !(response.state == 'disconnected')
|
|
64
|
+
begin
|
|
65
|
+
calls_api.update_call(BW_ACCOUNT_ID, call_id, $complete_call_body)
|
|
66
|
+
return true
|
|
67
|
+
rescue Bandwidth::ApiError
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
return true
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
false
|
|
74
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
|
|
3
|
+
# Unit tests for Bandwidth::Configuration
|
|
4
|
+
describe Bandwidth::Configuration do
|
|
5
|
+
let(:config) { Bandwidth::Configuration.new }
|
|
6
|
+
let(:faraday_connection) { Faraday::Connection.new }
|
|
7
|
+
let(:uri) { URI.parse(BASE_CALLBACK_URL + '/path') }
|
|
8
|
+
let(:token) { 'abcd1234' }
|
|
9
|
+
let(:server) { [
|
|
10
|
+
{
|
|
11
|
+
url: 'https://voice.bandwidth.com/api/{enum_var}/{default_var}',
|
|
12
|
+
description: 'Production',
|
|
13
|
+
variables: {
|
|
14
|
+
enum_var: {
|
|
15
|
+
enum_values: ['v1', 'v2', 'v3'],
|
|
16
|
+
default_value: 'v2'
|
|
17
|
+
},
|
|
18
|
+
default_var: {
|
|
19
|
+
default_value: 'default_value'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
] }
|
|
24
|
+
|
|
25
|
+
describe '#configure' do
|
|
26
|
+
it 'configures a Configuration instance using a a block' do
|
|
27
|
+
config.configure do |c|
|
|
28
|
+
c.scheme = uri.scheme
|
|
29
|
+
c.host = uri.host
|
|
30
|
+
c.base_path = uri.path
|
|
31
|
+
end
|
|
32
|
+
expect(config.scheme).to eq(uri.scheme)
|
|
33
|
+
expect(config.host).to eq(uri.host)
|
|
34
|
+
expect(config.base_path).to eq(uri.path)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe 'custom attribute writers' do
|
|
39
|
+
it '#scheme=' do
|
|
40
|
+
config.scheme = 'scheme://'
|
|
41
|
+
expect(config.scheme).to eq('scheme')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it '#host=' do
|
|
45
|
+
config.host = 'https://hostname'
|
|
46
|
+
expect(config.host).to eq('hostname')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it '#base_path=' do
|
|
50
|
+
config.base_path = 'basepath'
|
|
51
|
+
expect(config.base_path).to eq('/basepath')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe '#base_url' do
|
|
56
|
+
it 'returns default value when invalid operation is passed' do
|
|
57
|
+
expect(config.base_url('invalid_operation')).to eq('http://localhost')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it 'returns proper base URL when server index is set' do
|
|
61
|
+
operation, server = config.operation_server_settings.first
|
|
62
|
+
expect(config.base_url(operation)).to eq(server[0][:url])
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should have the default value' do
|
|
66
|
+
expect(config.base_url).to eq('http://localhost')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'returns default value when invalid operation is passed' do
|
|
70
|
+
expect(config.base_url('invalid_operation')).to eq('http://localhost')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'throws argument error when attempting to use a server index that is out of bounds' do
|
|
74
|
+
config.server_operation_index = {
|
|
75
|
+
:'MediaApi.upload_media' => 10
|
|
76
|
+
}
|
|
77
|
+
expect {
|
|
78
|
+
config.base_url(:'MediaApi.upload_media')
|
|
79
|
+
}.to raise_error(ArgumentError, 'Invalid index 10 when selecting the server. Must not be nil and must be less than 1')
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
describe '#api_key_with_prefix' do
|
|
84
|
+
it 'gets API key without prefix' do
|
|
85
|
+
config.api_key['Authorization'] = token
|
|
86
|
+
expect(config.api_key_with_prefix('Authorization')).to eq(token)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it 'gets API key wit prefix' do
|
|
90
|
+
config.api_key_prefix['Authorization'] = 'Token'
|
|
91
|
+
config.api_key['Authorization'] = token
|
|
92
|
+
expect(config.api_key_with_prefix('Authorization')).to eq("Token #{token}")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe '#access_token_with_refresh' do
|
|
97
|
+
it 'gets the static access_token when no access_token_getter is defined' do
|
|
98
|
+
config.access_token = token
|
|
99
|
+
expect(config.access_token_with_refresh).to eq(token)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'gets access_token using access_token_getter' do
|
|
103
|
+
config.access_token_getter = proc { token }
|
|
104
|
+
expect(config.access_token_with_refresh).to eq(token)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe '#basic_auth_token' do
|
|
109
|
+
it 'gets Basic Auth token string' do
|
|
110
|
+
config.username = 'username'
|
|
111
|
+
config.password = 'password'
|
|
112
|
+
expect(config.basic_auth_token).to eq('Basic dXNlcm5hbWU6cGFzc3dvcmQ=')
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '#auth_settings' do
|
|
117
|
+
it 'returns Auth Settings hash for api client' do
|
|
118
|
+
basic_auth = config.auth_settings['Basic']
|
|
119
|
+
expect(basic_auth[:type]).to eq('basic')
|
|
120
|
+
expect(basic_auth[:in]).to eq('header')
|
|
121
|
+
expect(basic_auth[:key]).to eq('Authorization')
|
|
122
|
+
expect(basic_auth[:value]).to eq('Basic Og==')
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
describe '#server_url' do
|
|
127
|
+
it 'returns URL with enum variable substitued' do
|
|
128
|
+
expect(config.server_url(0, { enum_var: 'v3' }, server)).to eq('https://voice.bandwidth.com/api/v3/default_value')
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'causes an ArgumentError by passing an invalid index' do
|
|
132
|
+
expect {
|
|
133
|
+
config.server_url(100)
|
|
134
|
+
}.to raise_error(ArgumentError)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'causes an ArgumentError by passing an invalid value to an enum variable' do
|
|
138
|
+
expect {
|
|
139
|
+
config.server_url(0, { enum_var: 'v4' }, server)
|
|
140
|
+
}.to raise_error(ArgumentError)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe 'configure faraday connection' do
|
|
145
|
+
it '#configure_faraday_connection #configure_connection' do
|
|
146
|
+
config.configure_faraday_connection do |c|
|
|
147
|
+
config.username = 'username'
|
|
148
|
+
end
|
|
149
|
+
config.configure_connection(faraday_connection)
|
|
150
|
+
expect(config.username).to eq('username')
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
describe '#set_faraday_middleware' do
|
|
155
|
+
it '#use' do
|
|
156
|
+
config.use(Faraday::Request::UrlEncoded)
|
|
157
|
+
expect(config.instance_variable_get('@middlewares')[:use]).to eq([[Faraday::Request::UrlEncoded, [], nil]])
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it '#request' do
|
|
161
|
+
config.request(:retry, max: 3, methods: [:get, :post], retry_statuses: [503])
|
|
162
|
+
expect(config.instance_variable_get('@middlewares')[:request]).to eq([[:retry, [{ :max => 3, :methods => [:get, :post], :retry_statuses => [503] }], nil]])
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
it '#response' do
|
|
166
|
+
config.response(:logger, nil, { bodies: true, log_level: :debug })
|
|
167
|
+
expect(config.instance_variable_get('@middlewares')[:response]).to eq([[:logger, [nil, { :bodies => true, :log_level => :debug }], nil]])
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'causes an ArgumentError by passing an invalid middleware operation' do
|
|
171
|
+
expect {
|
|
172
|
+
config.set_faraday_middleware(:invalid_operation, Faraday::Request::UrlEncoded)
|
|
173
|
+
}.to raise_error(ArgumentError)
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
describe '#configure_middleware' do
|
|
178
|
+
it 'builds connection using supplied response middleware' do
|
|
179
|
+
config.response(:logger)
|
|
180
|
+
config.configure_middleware(faraday_connection)
|
|
181
|
+
expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
it 'builds connection using deleted middleware' do
|
|
185
|
+
config.set_faraday_middleware(:delete, Faraday::Request::UrlEncoded)
|
|
186
|
+
config.configure_middleware(faraday_connection)
|
|
187
|
+
expect(faraday_connection.builder.handlers).to eq([])
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
Binary file
|