diff --git a/.github/actions/deploy/Dockerfile b/.github/actions/deploy/Dockerfile deleted file mode 100644 index a120746d..00000000 --- a/.github/actions/deploy/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# Container image that runs your code -FROM ruby:latest - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh - -#Make entrypoint.sh exacutable -RUN chmod +x /entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml deleted file mode 100644 index 6b866b4b..00000000 --- a/.github/actions/deploy/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -# action.yml -name: "Deploy" -description: "Deploys the ruby sdk to Rubygems" -runs: - using: "docker" - image: "Dockerfile" diff --git a/.github/actions/deploy/entrypoint.sh b/.github/actions/deploy/entrypoint.sh deleted file mode 100644 index 3fc4ff22..00000000 --- a/.github/actions/deploy/entrypoint.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mkdir ~/.gem #Rubygems needs this directory for auth -echo "---\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials #The file to store rubygems auth. Must be in this format -chmod 0600 ~/.gem/credentials #Rubygems expects this permissions -gem build *.gemspec -gem push *.gem -k rubygems diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 023f6390..747b47d9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,48 +7,7 @@ on: jobs: deploy: - name: Deploy to Rubygems - if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }} - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: "3.0" - - - name: Install Packages - run: bundle install - - - name: Test - env: - BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }} - BW_USERNAME: ${{ secrets.BW_USERNAME }} - BW_PASSWORD: ${{ secrets.BW_PASSWORD }} - BW_VOICE_APPLICATION_ID: ${{ secrets.BW_VOICE_APPLICATION_ID }} - BW_MESSAGING_APPLICATION_ID: ${{ secrets.BW_MESSAGING_APPLICATION_ID }} - BW_NUMBER: ${{ secrets.BW_NUMBER }} - USER_NUMBER: ${{ secrets.USER_NUMBER }} - BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }} - run: rake - - - name: Deploy to Rubygems - uses: ./.github/actions/deploy - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} - - - uses: Bandwidth/build-notify-slack-action@v1.0.0 - if: always() - with: - job-status: ${{ job.status }} - slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} - slack-channel: ${{ secrets.SLACK_CHANNEL }} - - deploy_pre_release: - name: Deploy OpenAPI Generator Client Pre-Release to Rubygems - if: ${{ github.event.release.prerelease && github.event.release.target_commitish == 'feature/openapi-generator-sdk' }} + name: Deploy SDK to Rubygems runs-on: ubuntu-latest env: BW_ACCOUNT_ID: ${{ secrets.BW_ACCOUNT_ID }} @@ -61,49 +20,53 @@ jobs: BW_NUMBER: ${{ secrets.BW_NUMBER }} USER_NUMBER: ${{ secrets.USER_NUMBER }} BASE_CALLBACK_URL: ${{ secrets.BASE_CALLBACK_URL }} - RUBY_VERSION: '3.0' - OPERATING_SYSTEM: 'ubuntu' + RUBY_VERSION: "3.0" + OPERATING_SYSTEM: "ubuntu" MANTECA_ACTIVE_NUMBER: ${{ secrets.MANTECA_ACTIVE_NUMBER }} MANTECA_IDLE_NUMBER: ${{ secrets.MANTECA_IDLE_NUMBER }} MANTECA_BASE_URL: ${{ secrets.MANTECA_BASE_URL }} MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }} BW_NUMBER_PROVIDER: ${{ secrets.BW_NUMBER_PROVIDER }} - + steps: - name: Set Release Version - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV - - - name: Check Release Tag Format run: | - re=[0-9]+\.[0-9]+\.[0-9]+\.pre\.beta\.[0-9]+\.?[0-9]*\.?[0-9]* - if ! [[ $RELEASE_VERSION =~ $re ]]; then - echo 'Tag does not match expected regex pattern for beta releases (v[0-9]+\.[0-9]+\.[0-9]+\.pre\.beta\.[0-9]+\.?[0-9]*\.?[0-9]*)' + RELEASE_VERSION=${GITHUB_REF#refs/tags/v} + re=[0-9]+\.[0-9]+\.[0-9]+ + if [[ $RELEASE_VERSION =~ $re ]]; then + echo "GEM_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV + else + echo "Tag does not match expected semver regex pattern (v$re)" echo $RELEASE_VERSION echo 'Please update your tag to match the expected regex pattern' exit 1 fi - + - name: Checkout uses: actions/checkout@v3 - with: - ref: feature/openapi-generator-sdk - name: Setup Ruby uses: ruby/setup-ruby@v1 with: ruby-version: "3.0" - - name: Install Packages - run: bundle install + - name: Update Gem Version + run: sed -i "s/VERSION = '.*'/VERSION = '$GEM_VERSION'/g" lib/bandwidth-sdk/version.rb + + - name: Install Packages and Test + run: | + bundle install + rake - - name: Test - run: rake - - name: Deploy to Rubygems - uses: ./.github/actions/deploy - env: - RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} - + run: | + mkdir ~/.gem + touch ~/.gem/credentials + chmod 0600 ~/.gem/credentials + printf -- "---\n:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}\n" > ~/.gem/credentials + gem build *.gemspec + gem push *.gem + - uses: Bandwidth/build-notify-slack-action@v1.0.0 if: always() with: diff --git a/.github/workflows/test-nightly.yml b/.github/workflows/test-nightly.yml index b071634c..97a8d317 100644 --- a/.github/workflows/test-nightly.yml +++ b/.github/workflows/test-nightly.yml @@ -1,4 +1,4 @@ -name: Test Main and Feature Branch Nightly +name: Test Main Branch Nightly on: schedule: @@ -31,12 +31,12 @@ jobs: strategy: matrix: os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04] - ruby-version: [2.6, 2.7, 3.0] + ruby-version: [2.7, 3.0, 3.1, 3.2] steps: - name: Checkout uses: actions/checkout@v3 with: - ref: 'main' + ref: "main" - name: Set up Ruby uses: ruby/setup-ruby@v1 @@ -47,37 +47,13 @@ jobs: run: | bundle install rake - - test_feature: - name: Test Feature Branch Nightly - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04] - ruby-version: [2.7, 3.0, 3.1, 3.2] - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: 'feature/openapi-generator-sdk' - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - - - name: Install Packages and Test env: RUBY_VERSION: ${{ matrix.ruby-version }} OPERATING_SYSTEM: ${{ matrix.os }} - GEM_VERSION: "11.0.0" - run: | - bundle install - rake notify_for_failures: name: Notify for Failures - needs: [test_main, test_feature] + needs: [test_main] if: failure() runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml index 58fc5f5c..f9c336ce 100644 --- a/.github/workflows/test-pr.yml +++ b/.github/workflows/test-pr.yml @@ -24,13 +24,13 @@ env: MANTECA_APPLICATION_ID: ${{ secrets.MANTECA_APPLICATION_ID }} jobs: - test_pr_main: + test_pr: name: Test PR runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04] - ruby-version: [2.6, 2.7, 3.0] + ruby-version: [2.7, 3.0, 3.1, 3.2] steps: - name: Checkout uses: actions/checkout@v3 @@ -44,3 +44,6 @@ jobs: run: | bundle install rake + env: + RUBY_VERSION: ${{ matrix.ruby-version }} + OPERATING_SYSTEM: ${{ matrix.os }} diff --git a/.github/workflows/update-sdk.yml b/.github/workflows/update-sdk.yml new file mode 100644 index 00000000..5707747f --- /dev/null +++ b/.github/workflows/update-sdk.yml @@ -0,0 +1,106 @@ +name: Update SDK + +on: + schedule: + - cron: "0 14 * * 2" + workflow_dispatch: + +jobs: + update-sdk: + name: Update SDK if Necessary + runs-on: ubuntu-latest + outputs: + generate: ${{ steps.compare.outputs.generate }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Combine Product Specs + uses: Bandwidth/api-specs-combine-action@v1.0.0 + with: + token: ${{ secrets.DX_GITHUB_TOKEN }} + + - name: Determine if a New SDK is Needed + id: compare + run: | + if cmp -s "bandwidth.yml" "api-specs/bandwidth.yml"; then :; else mv -f api-specs/bandwidth.yml bandwidth.yml; rm -r -f api-specs; echo "generate=true" >> $GITHUB_OUTPUT; fi + + - name: Create JIRA Card for SDK Update + if: ${{ steps.compare.outputs.generate == 'true' }} + id: jira + run: | + JIRA_KEY=$(jq -r '.key' <<< $(curl -s -u $JIRA_USERNAME:$JIRA_TOKEN \ + -X POST https://bandwidth-jira.atlassian.net/rest/api/2/issue \ + -H "Content-Type: application/json" \ + --data-binary @- << EOF + { + "fields": { + "project": { + "key": "SWI" + }, + "summary": "[$LANGUAGE] Update SDK for New Spec Version", + "description": "Prepare the $LANGUAGE SDK for release based on the latest spec changes.", + "issuetype": { + "name": "Story" + }, + "customfield_12108": "$LANGUAGE SDK is ready for release. Tests are created/updated if need be.", + "customfield_10205": "$EPIC", + "components": [{ + "name": "Client SDKs" + }] + } + } + EOF + )) + echo "jira-key=$JIRA_KEY" >> $GITHUB_OUTPUT + env: + LANGUAGE: Ruby + EPIC: SWI-1876 + JIRA_USERNAME: ${{ secrets.JIRA_USERNAME }} + JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }} + + - name: Build SDK + id: build + if: ${{ startsWith(steps.jira.outputs.jira-key, 'SWI') }} + uses: Bandwidth/generate-sdk-action@v3.0.0 + with: + branch-name: ${{ steps.jira.outputs.jira-key }} + token: ${{ secrets.DX_GITHUB_TOKEN }} + openapi-generator-version: 7.0.0 + language: ruby + config: ./openapi-config.yml + + - name: Setup Ruby + if: steps.build.outputs.changes + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.0" + + - name: Clean SDK + if: steps.build.outputs.changes + run: | + bundle install + rubocop -A + git add . + git commit -m "Clean SDK using Rubocop" + git push origin ${{ steps.jira.outputs.jira-key }} + + - name: Open Pull Request + if: steps.build.outputs.changes + run: | + gh pr create -B main -H Bandwidth:${{ steps.jira.outputs.jira-key }} -t '${{ steps.jira.outputs.jira-key }} Update SDK Based on Recent Spec Changes' -b 'Auto-generated by Update SDK Workflow' + env: + GITHUB_TOKEN: ${{ secrets.DX_GITHUB_TOKEN }} + + notify-for-failures: + name: Notify for Failures + needs: [update-sdk] + if: failure() + runs-on: ubuntu-latest + steps: + - name: Notify Slack of Failures + uses: Bandwidth/build-notify-slack-action@v1.0.0 + with: + job-status: failure + slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }} + slack-channel: ${{ secrets.SLACK_CHANNEL }} diff --git a/.gitignore b/.gitignore index eac0157b..1e47cd99 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,41 @@ -Gemfile.lock +# Generated by: https://openapi-generator.tech +# + +*.gem +*.rbc +/.config +/coverage/ +/InstalledFiles +/pkg/ +/spec/reports/ +/spec/examples.txt +/test/tmp/ +/test/version_tmp/ +/tmp/ + +## Specific to RubyMotion: +.dat* +.repl_history +build/ + +## Documentation cache and generated files: +/.yardoc/ +/_yardoc/ +/doc/ +/rdoc/ + +## Environment normalization: +/.bundle/ +/vendor/bundle +/lib/bundler/man/ + +# for a library or gem, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +Gemfile.lock +# .ruby-version +# .ruby-gemset + +# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: +.rvmrc + +.DS_Store diff --git a/.gitkeep b/.gitkeep deleted file mode 100644 index 7804e232..00000000 --- a/.gitkeep +++ /dev/null @@ -1,4 +0,0 @@ -README.md -lib/bandwidth/voice_lib/bxml/* -lib/bandwidth/web_rtc_lib/utils/* -test/integration/* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..3a253c45 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,26 @@ +.ruby: &ruby + variables: + LANG: "C.UTF-8" + before_script: + - ruby -v + - bundle config set --local deployment true + - bundle install -j $(nproc) + parallel: + matrix: + - RUBY_VERSION: ['2.7', '3.0', '3.1'] + image: "ruby:$RUBY_VERSION" + cache: + paths: + - vendor/ruby + key: 'ruby-$RUBY_VERSION' + +gem: + extends: .ruby + script: + - bundle exec rspec + - bundle exec rake build + - bundle exec rake install + artifacts: + paths: + - pkg/*.gem + diff --git a/.openapi-generator-ignore b/.openapi-generator-ignore new file mode 100644 index 00000000..a74a4808 --- /dev/null +++ b/.openapi-generator-ignore @@ -0,0 +1,7 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +/spec/** +Rakefile +.gitignore +.rubocop.yml diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES new file mode 100644 index 00000000..b98a4270 --- /dev/null +++ b/.openapi-generator/FILES @@ -0,0 +1,204 @@ +.gitlab-ci.yml +.rspec +.travis.yml +Gemfile +README.md +bandwidth-sdk.gemspec +docs/AccountStatistics.md +docs/AnswerCallback.md +docs/BridgeCompleteCallback.md +docs/BridgeTargetCompleteCallback.md +docs/CallDirectionEnum.md +docs/CallRecordingMetadata.md +docs/CallState.md +docs/CallStateEnum.md +docs/CallbackMethodEnum.md +docs/CallsApi.md +docs/CodeRequest.md +docs/Conference.md +docs/ConferenceCompletedCallback.md +docs/ConferenceCreatedCallback.md +docs/ConferenceMember.md +docs/ConferenceMemberExitCallback.md +docs/ConferenceMemberJoinCallback.md +docs/ConferenceRecordingAvailableCallback.md +docs/ConferenceRecordingMetadata.md +docs/ConferenceRedirectCallback.md +docs/ConferenceStateEnum.md +docs/ConferencesApi.md +docs/CreateCall.md +docs/CreateCallResponse.md +docs/CreateLookupResponse.md +docs/CreateMessageRequestError.md +docs/DeferredResult.md +docs/DisconnectCallback.md +docs/Diversion.md +docs/DtmfCallback.md +docs/FieldError.md +docs/FileFormatEnum.md +docs/GatherCallback.md +docs/InboundMessageCallback.md +docs/InboundMessageCallbackMessage.md +docs/InitiateCallback.md +docs/ListMessageDirectionEnum.md +docs/ListMessageItem.md +docs/LookupRequest.md +docs/LookupResult.md +docs/LookupStatus.md +docs/LookupStatusEnum.md +docs/MFAApi.md +docs/MachineDetectionCompleteCallback.md +docs/MachineDetectionConfiguration.md +docs/MachineDetectionModeEnum.md +docs/MachineDetectionResult.md +docs/Media.md +docs/MediaApi.md +docs/Message.md +docs/MessageDeliveredCallback.md +docs/MessageDeliveredCallbackMessage.md +docs/MessageDirectionEnum.md +docs/MessageFailedCallback.md +docs/MessageFailedCallbackMessage.md +docs/MessageRequest.md +docs/MessageSendingCallback.md +docs/MessageSendingCallbackMessage.md +docs/MessageStatusEnum.md +docs/MessageTypeEnum.md +docs/MessagesApi.md +docs/MessagesList.md +docs/MessagingCodeResponse.md +docs/MessagingRequestError.md +docs/MfaForbiddenRequestError.md +docs/MfaRequestError.md +docs/MfaUnauthorizedRequestError.md +docs/PageInfo.md +docs/PhoneNumberLookupApi.md +docs/PriorityEnum.md +docs/RecordingAvailableCallback.md +docs/RecordingCompleteCallback.md +docs/RecordingStateEnum.md +docs/RecordingsApi.md +docs/RedirectCallback.md +docs/RedirectMethodEnum.md +docs/StatisticsApi.md +docs/StirShaken.md +docs/Tag.md +docs/TnLookupRequestError.md +docs/TranscribeRecording.md +docs/Transcription.md +docs/TranscriptionAvailableCallback.md +docs/TranscriptionList.md +docs/TranscriptionMetadata.md +docs/TransferAnswerCallback.md +docs/TransferCompleteCallback.md +docs/TransferDisconnectCallback.md +docs/UpdateCall.md +docs/UpdateCallRecording.md +docs/UpdateConference.md +docs/UpdateConferenceMember.md +docs/VerifyCodeRequest.md +docs/VerifyCodeResponse.md +docs/VoiceApiError.md +docs/VoiceCodeResponse.md +git_push.sh +lib/bandwidth-sdk.rb +lib/bandwidth-sdk/api/calls_api.rb +lib/bandwidth-sdk/api/conferences_api.rb +lib/bandwidth-sdk/api/media_api.rb +lib/bandwidth-sdk/api/messages_api.rb +lib/bandwidth-sdk/api/mfa_api.rb +lib/bandwidth-sdk/api/phone_number_lookup_api.rb +lib/bandwidth-sdk/api/recordings_api.rb +lib/bandwidth-sdk/api/statistics_api.rb +lib/bandwidth-sdk/api_client.rb +lib/bandwidth-sdk/api_error.rb +lib/bandwidth-sdk/configuration.rb +lib/bandwidth-sdk/models/account_statistics.rb +lib/bandwidth-sdk/models/answer_callback.rb +lib/bandwidth-sdk/models/bridge_complete_callback.rb +lib/bandwidth-sdk/models/bridge_target_complete_callback.rb +lib/bandwidth-sdk/models/call_direction_enum.rb +lib/bandwidth-sdk/models/call_recording_metadata.rb +lib/bandwidth-sdk/models/call_state.rb +lib/bandwidth-sdk/models/call_state_enum.rb +lib/bandwidth-sdk/models/callback_method_enum.rb +lib/bandwidth-sdk/models/code_request.rb +lib/bandwidth-sdk/models/conference.rb +lib/bandwidth-sdk/models/conference_completed_callback.rb +lib/bandwidth-sdk/models/conference_created_callback.rb +lib/bandwidth-sdk/models/conference_member.rb +lib/bandwidth-sdk/models/conference_member_exit_callback.rb +lib/bandwidth-sdk/models/conference_member_join_callback.rb +lib/bandwidth-sdk/models/conference_recording_available_callback.rb +lib/bandwidth-sdk/models/conference_recording_metadata.rb +lib/bandwidth-sdk/models/conference_redirect_callback.rb +lib/bandwidth-sdk/models/conference_state_enum.rb +lib/bandwidth-sdk/models/create_call.rb +lib/bandwidth-sdk/models/create_call_response.rb +lib/bandwidth-sdk/models/create_lookup_response.rb +lib/bandwidth-sdk/models/create_message_request_error.rb +lib/bandwidth-sdk/models/deferred_result.rb +lib/bandwidth-sdk/models/disconnect_callback.rb +lib/bandwidth-sdk/models/diversion.rb +lib/bandwidth-sdk/models/dtmf_callback.rb +lib/bandwidth-sdk/models/field_error.rb +lib/bandwidth-sdk/models/file_format_enum.rb +lib/bandwidth-sdk/models/gather_callback.rb +lib/bandwidth-sdk/models/inbound_message_callback.rb +lib/bandwidth-sdk/models/inbound_message_callback_message.rb +lib/bandwidth-sdk/models/initiate_callback.rb +lib/bandwidth-sdk/models/list_message_direction_enum.rb +lib/bandwidth-sdk/models/list_message_item.rb +lib/bandwidth-sdk/models/lookup_request.rb +lib/bandwidth-sdk/models/lookup_result.rb +lib/bandwidth-sdk/models/lookup_status.rb +lib/bandwidth-sdk/models/lookup_status_enum.rb +lib/bandwidth-sdk/models/machine_detection_complete_callback.rb +lib/bandwidth-sdk/models/machine_detection_configuration.rb +lib/bandwidth-sdk/models/machine_detection_mode_enum.rb +lib/bandwidth-sdk/models/machine_detection_result.rb +lib/bandwidth-sdk/models/media.rb +lib/bandwidth-sdk/models/message.rb +lib/bandwidth-sdk/models/message_delivered_callback.rb +lib/bandwidth-sdk/models/message_delivered_callback_message.rb +lib/bandwidth-sdk/models/message_direction_enum.rb +lib/bandwidth-sdk/models/message_failed_callback.rb +lib/bandwidth-sdk/models/message_failed_callback_message.rb +lib/bandwidth-sdk/models/message_request.rb +lib/bandwidth-sdk/models/message_sending_callback.rb +lib/bandwidth-sdk/models/message_sending_callback_message.rb +lib/bandwidth-sdk/models/message_status_enum.rb +lib/bandwidth-sdk/models/message_type_enum.rb +lib/bandwidth-sdk/models/messages_list.rb +lib/bandwidth-sdk/models/messaging_code_response.rb +lib/bandwidth-sdk/models/messaging_request_error.rb +lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb +lib/bandwidth-sdk/models/mfa_request_error.rb +lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb +lib/bandwidth-sdk/models/page_info.rb +lib/bandwidth-sdk/models/priority_enum.rb +lib/bandwidth-sdk/models/recording_available_callback.rb +lib/bandwidth-sdk/models/recording_complete_callback.rb +lib/bandwidth-sdk/models/recording_state_enum.rb +lib/bandwidth-sdk/models/redirect_callback.rb +lib/bandwidth-sdk/models/redirect_method_enum.rb +lib/bandwidth-sdk/models/stir_shaken.rb +lib/bandwidth-sdk/models/tag.rb +lib/bandwidth-sdk/models/tn_lookup_request_error.rb +lib/bandwidth-sdk/models/transcribe_recording.rb +lib/bandwidth-sdk/models/transcription.rb +lib/bandwidth-sdk/models/transcription_available_callback.rb +lib/bandwidth-sdk/models/transcription_list.rb +lib/bandwidth-sdk/models/transcription_metadata.rb +lib/bandwidth-sdk/models/transfer_answer_callback.rb +lib/bandwidth-sdk/models/transfer_complete_callback.rb +lib/bandwidth-sdk/models/transfer_disconnect_callback.rb +lib/bandwidth-sdk/models/update_call.rb +lib/bandwidth-sdk/models/update_call_recording.rb +lib/bandwidth-sdk/models/update_conference.rb +lib/bandwidth-sdk/models/update_conference_member.rb +lib/bandwidth-sdk/models/verify_code_request.rb +lib/bandwidth-sdk/models/verify_code_response.rb +lib/bandwidth-sdk/models/voice_api_error.rb +lib/bandwidth-sdk/models/voice_code_response.rb +lib/bandwidth-sdk/version.rb diff --git a/.openapi-generator/VERSION b/.openapi-generator/VERSION new file mode 100644 index 00000000..41225218 --- /dev/null +++ b/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.0.0 \ No newline at end of file diff --git a/.rspec b/.rspec new file mode 100644 index 00000000..83e16f80 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml index 0b18990d..06fb0407 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,34 +1,159 @@ -Metrics/ClassLength: - Enabled: false - -Metrics/MethodLength: - Enabled: false - -Metrics/BlockLength: - Enabled: false - -Metrics/ParameterLists: - Enabled: false - -Metrics/AbcSize: - Enabled: false - -Metrics/CyclomaticComplexity: - Enabled: false - -Metrics/PerceivedComplexity: - Enabled: false - -Lint/UnderscorePrefixedVariableName: - Enabled: false - -Naming/AccessorMethodName: - Enabled: false - -Style/AsciiComments: - Enabled: false - -AllCops: - Exclude: - - './test/**/*' - - './*' \ No newline at end of file +# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license) +# Automatically generated by OpenAPI Generator (https://openapi-generator.tech) +AllCops: + TargetRubyVersion: 2.4 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/ElseAlignment: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +Layout/FirstArgumentIndentation: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: false + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: indented_internal_methods + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/LeadingCommentSpace: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeComma: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +Style/DefWithParentheses: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: false + EnforcedStyle: always + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: single_quotes + Exclude: + - lib/bandwidth-sdk/api_client.rb + - lib/bandwidth-sdk/configuration.rb + +#Check quotes inside the string interpolation. +Style/StringLiteralsInInterpolation: + Enabled: true + EnforcedStyle: single_quotes + +# Detect hard tabs, no hard tabs. +Layout/IndentationStyle: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingEmptyLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: false + +# Use quotes for string literals when they are enough. +Style/RedundantPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout/EndAlignment: + Enabled: true + EnforcedStyleAlignWith: variable + AutoCorrect: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +Style/RedundantReturn: + Enabled: true + AllowMultipleReturnValues: true + +Style/Semicolon: + Enabled: true + AllowAsExpressionSeparator: true diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..2e321fcc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: ruby +cache: bundler +rvm: + - 2.7 + - 3.0 + - 3.1 +script: + - bundle install --path vendor/bundle + - bundle exec rspec + - gem build bandwidth-sdk.gemspec + - gem install ./bandwidth-sdk-11.0.0.gem diff --git a/Gemfile b/Gemfile index 02d11b16..ed673756 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,11 @@ -source 'https://rubygems.org' - -group :test do - gem 'rake' -end - -gemspec +source 'https://rubygems.org' + +gemspec + +group :development, :test do + gem 'rake', '~> 13.0.1' + gem 'pry-byebug' + gem 'rubocop', '~> 1.52.0' + gem 'webmock', '~> 3.18.0' + gem 'simplecov', '~> 0.21.2' +end diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 749af7fb..00000000 --- a/LICENSE +++ /dev/null @@ -1,28 +0,0 @@ -License: -======== -The MIT License (MIT) -http://opensource.org/licenses/MIT - -Copyright (c) 2014 - 2020 APIMATIC Limited - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - -Trade Mark: -========== -APIMATIC is a trade mark for APIMATIC Limited \ No newline at end of file diff --git a/README.md b/README.md index 1fdd91e9..36980169 100644 --- a/README.md +++ b/README.md @@ -1,175 +1,240 @@ -# Bandwidth Ruby SDK +# bandwidth-sdk -[![Nightly Tests](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml) +[![Gem Version](https://badge.fury.io/rb/bandwidth-sdk.svg)](https://badge.fury.io/rb/bandwidth-sdk) +[![Tests](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml) +[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) | **OS** | **Ruby** | |:---:|:---:| -| Windows 2016 | 2.6, 2.7, 3.0 | -| Windows 2019 | 2.6, 2.7, 3.0 | -| Ubuntu 20.04 | 2.6, 2.7, 3.0 | -| Ubuntu 22.04 | 2.6, 2.7, 3.0 | +| Windows 2019 | 2.7, 3.0, 3.1, 3.2 | +| Windows 2022 | 2.7, 3.0, 3.1, 3.2 | +| Ubuntu 20.04 | 2.7, 3.0, 3.1, 3.2 | +| Ubuntu 22.04 | 2.7, 3.0, 3.1, 3.2 | -## Getting Started +Bandwidth - the Ruby gem for the Bandwidth -### Installation +# Generated with the command: +`openapi-generator generate -g ruby -i bandwidth.yml -c openapi-config.yml -o ./` -``` -gem install bandwidth-sdk -``` +Bandwidth's Communication APIs -### Initialize +This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: -```ruby -require 'bandwidth' - -include Bandwidth -include Bandwidth::Voice -include Bandwidth::Messaging -include Bandwidth::WebRtc -include Bandwidth::TwoFactorAuth - -bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: 'username', - voice_basic_auth_password: 'password', - messaging_basic_auth_user_name: 'username', - messaging_basic_auth_password: 'username', - two_factor_auth_basic_auth_user_name: 'username', - two_factor_auth_basic_auth_password: 'password', - web_rtc_basic_auth_user_name: 'username', - web_rtc_basic_auth_password: 'password' -) -account_id = "12345" -``` +- API version: 1.0.0 +- Package version: 11.0.0 +- Build package: org.openapitools.codegen.languages.RubyClientCodegen +For more information, please visit [https://dev.bandwidth.com](https://dev.bandwidth.com) -### Create Phone Call +## Installation -```ruby -voice_client = bandwidth_client.voice_client.client +### Build a gem -body = ApiCreateCallRequest.new -body.from = '+16666666666' -body.to = '+17777777777' -body.answer_url = 'https://test.com' -body.application_id = '3-d-4-b-5' +To build the Ruby code into a gem: -begin - response = voice_client.create_call(account_id,:body => body) - puts response.data.call_id #c-d45a41e5-bcb12581-b18e-4bdc-9874-6r3235dfweao - puts response.status_code #201 -rescue Bandwidth::ErrorResponseException => e - puts e.description #Invalid to: must be an E164 telephone number - puts e.response_code #400 -end +```shell +gem build bandwidth-sdk.gemspec ``` -### Generate BXML - -```ruby -response = Bandwidth::Voice::Response.new() -hangup = Bandwidth::Voice::Hangup.new() +Then either install the gem locally: -response.push(hangup) -puts response.to_bxml() +```shell +gem install ./bandwidth-sdk-11.0.0.gem ``` -### Send Text Message +(for development, run `gem install --dev ./bandwidth-sdk-11.0.0.gem` to install the development dependencies) -```ruby -messaging_client = bandwidth_client.messaging_client.client +or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). -body = MessageRequest.new -body.application_id = '1-2-3' -body.to = ['+17777777777'] -body.from = '+18888888888' -body.text = 'Hello from Bandwidth' +Finally add this to the Gemfile: -begin - response = messaging_client.create_message(account_id, body) - puts response.data.id #1570740275373xbn7mbhsfewasdr - puts response.status_code #202 -rescue Bandwidth::GenericClientException => e - puts e.description #Access is denied - puts e.response_code #403 -rescue Bandwidth::PathClientException => e - puts e.message #Your request could not be accepted. - puts e.response_code #400 -end -``` + gem 'bandwidth-sdk', '~> 11.0.0' -### Create A MFA Request +### Install from Git -```ruby -auth_client = bandwidth_client.two_factor_auth_client.mfa - -from_phone = "+18888888888" -to_phone = "+17777777777" -messaging_application_id = "1-d-b" -scope = "scope" -digits = 6 - -body = TwoFactorCodeRequestSchema.new -body.from = from_phone -body.to = to_phone -body.application_id = messaging_application_id -body.scope = scope -body.digits = digits -body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - -auth_client.create_messaging_two_factor(account_id, body) - -code = "123456" #This is the user input to validate - -body = TwoFactorVerifyRequestSchema.new -body.from = from_phone -body.to = to_phone -body.application_id = application_id -body.scope = scope -body.code = code -body.digits = digits -body.expiration_time_in_minutes = 3 - -response = auth_client.create_verify_two_factor(account_id, body) -puts "Auth status: " + response.data.valid.to_s -``` +If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile: -### WebRtc Participant & Session Management - -```ruby -web_rtc_client = bandwidth_client.web_rtc_client.client + gem 'bandwidth-sdk', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' -create_session_body = Session.new -create_session_body.tag = 'new-session' +### Include the Ruby code directly -create_session_response = web_rtc_client.create_session(account_id, :body => create_session_body) -session_id = create_session_response.data.id -puts session_id +Include the Ruby code directly using `-I` as follows: -create_participant_body = Participant.new -create_participant_body.publish_permissions = [ - PublishPermissionEnum::AUDIO, - PublishPermissionEnum::VIDEO -] -create_participant_body.callback_url = "https://sample.com" +```shell +ruby -Ilib script.rb +``` -create_participant_response = web_rtc_client.create_participant(account_id, :body => create_participant_body) -participant_id = create_participant_response.data.participant.id -puts participant_id +## Getting Started -body = Subscriptions.new -body.session_id = "1234-abcd" +Please follow the [installation](#installation) procedure and then run the following code: -web_rtc_client.add_participant_to_session(account_id, session_id, participant_id, body: body) -``` - -## Supported Ruby Versions +```ruby +# Load the gem +require 'bandwidth-sdk' + +# Setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR_USERNAME' + config.password = 'YOUR_PASSWORD' + # Configure faraday connection + config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' } +end -This package can be used with Ruby >= 2.0 +api_instance = Bandwidth::CallsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +create_call = Bandwidth::CreateCall.new({to: '+19195551234', from: '+19195554321', application_id: '1234-qwer-5679-tyui', answer_url: 'https://www.myCallbackServer.example/webhooks/answer'}) # CreateCall | JSON object containing information to create an outbound call -## Documentation +begin + #Create Call + result = api_instance.create_call(account_id, create_call) + p result +rescue Bandwidth::ApiError => e + puts "Exception when calling CallsApi->create_call: #{e}" +end -Documentation for this package can be found at https://dev.bandwidth.com/sdks/ruby.html +``` -## Credentials +## Documentation for API Endpoints + +All URIs are relative to *http://localhost* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*Bandwidth::CallsApi* | [**create_call**](docs/CallsApi.md#create_call) | **POST** /accounts/{accountId}/calls | Create Call +*Bandwidth::CallsApi* | [**get_call_state**](docs/CallsApi.md#get_call_state) | **GET** /accounts/{accountId}/calls/{callId} | Get Call State Information +*Bandwidth::CallsApi* | [**update_call**](docs/CallsApi.md#update_call) | **POST** /accounts/{accountId}/calls/{callId} | Update Call +*Bandwidth::CallsApi* | [**update_call_bxml**](docs/CallsApi.md#update_call_bxml) | **PUT** /accounts/{accountId}/calls/{callId}/bxml | Update Call BXML +*Bandwidth::ConferencesApi* | [**download_conference_recording**](docs/ConferencesApi.md#download_conference_recording) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media | Download Conference Recording +*Bandwidth::ConferencesApi* | [**get_conference**](docs/ConferencesApi.md#get_conference) | **GET** /accounts/{accountId}/conferences/{conferenceId} | Get Conference Information +*Bandwidth::ConferencesApi* | [**get_conference_member**](docs/ConferencesApi.md#get_conference_member) | **GET** /accounts/{accountId}/conferences/{conferenceId}/members/{memberId} | Get Conference Member +*Bandwidth::ConferencesApi* | [**get_conference_recording**](docs/ConferencesApi.md#get_conference_recording) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId} | Get Conference Recording Information +*Bandwidth::ConferencesApi* | [**list_conference_recordings**](docs/ConferencesApi.md#list_conference_recordings) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings | Get Conference Recordings +*Bandwidth::ConferencesApi* | [**list_conferences**](docs/ConferencesApi.md#list_conferences) | **GET** /accounts/{accountId}/conferences | Get Conferences +*Bandwidth::ConferencesApi* | [**update_conference**](docs/ConferencesApi.md#update_conference) | **POST** /accounts/{accountId}/conferences/{conferenceId} | Update Conference +*Bandwidth::ConferencesApi* | [**update_conference_bxml**](docs/ConferencesApi.md#update_conference_bxml) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/bxml | Update Conference BXML +*Bandwidth::ConferencesApi* | [**update_conference_member**](docs/ConferencesApi.md#update_conference_member) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/members/{memberId} | Update Conference Member +*Bandwidth::MFAApi* | [**generate_messaging_code**](docs/MFAApi.md#generate_messaging_code) | **POST** /accounts/{accountId}/code/messaging | Messaging Authentication Code +*Bandwidth::MFAApi* | [**generate_voice_code**](docs/MFAApi.md#generate_voice_code) | **POST** /accounts/{accountId}/code/voice | Voice Authentication Code +*Bandwidth::MFAApi* | [**verify_code**](docs/MFAApi.md#verify_code) | **POST** /accounts/{accountId}/code/verify | Verify Authentication Code +*Bandwidth::MediaApi* | [**delete_media**](docs/MediaApi.md#delete_media) | **DELETE** /users/{accountId}/media/{mediaId} | Delete Media +*Bandwidth::MediaApi* | [**get_media**](docs/MediaApi.md#get_media) | **GET** /users/{accountId}/media/{mediaId} | Get Media +*Bandwidth::MediaApi* | [**list_media**](docs/MediaApi.md#list_media) | **GET** /users/{accountId}/media | List Media +*Bandwidth::MediaApi* | [**upload_media**](docs/MediaApi.md#upload_media) | **PUT** /users/{accountId}/media/{mediaId} | Upload Media +*Bandwidth::MessagesApi* | [**create_message**](docs/MessagesApi.md#create_message) | **POST** /users/{accountId}/messages | Create Message +*Bandwidth::MessagesApi* | [**list_messages**](docs/MessagesApi.md#list_messages) | **GET** /users/{accountId}/messages | List Messages +*Bandwidth::PhoneNumberLookupApi* | [**create_lookup**](docs/PhoneNumberLookupApi.md#create_lookup) | **POST** /accounts/{accountId}/tnlookup | Create Lookup +*Bandwidth::PhoneNumberLookupApi* | [**get_lookup_status**](docs/PhoneNumberLookupApi.md#get_lookup_status) | **GET** /accounts/{accountId}/tnlookup/{requestId} | Get Lookup Request Status +*Bandwidth::RecordingsApi* | [**delete_call_transcription**](docs/RecordingsApi.md#delete_call_transcription) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Delete Transcription +*Bandwidth::RecordingsApi* | [**delete_recording**](docs/RecordingsApi.md#delete_recording) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId} | Delete Recording +*Bandwidth::RecordingsApi* | [**delete_recording_media**](docs/RecordingsApi.md#delete_recording_media) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media | Delete Recording Media +*Bandwidth::RecordingsApi* | [**download_call_recording**](docs/RecordingsApi.md#download_call_recording) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media | Download Recording +*Bandwidth::RecordingsApi* | [**get_call_recording**](docs/RecordingsApi.md#get_call_recording) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId} | Get Call Recording +*Bandwidth::RecordingsApi* | [**get_call_transcription**](docs/RecordingsApi.md#get_call_transcription) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Get Transcription +*Bandwidth::RecordingsApi* | [**list_account_call_recordings**](docs/RecordingsApi.md#list_account_call_recordings) | **GET** /accounts/{accountId}/recordings | Get Call Recordings +*Bandwidth::RecordingsApi* | [**list_call_recordings**](docs/RecordingsApi.md#list_call_recordings) | **GET** /accounts/{accountId}/calls/{callId}/recordings | List Call Recordings +*Bandwidth::RecordingsApi* | [**transcribe_call_recording**](docs/RecordingsApi.md#transcribe_call_recording) | **POST** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Create Transcription Request +*Bandwidth::RecordingsApi* | [**update_call_recording_state**](docs/RecordingsApi.md#update_call_recording_state) | **PUT** /accounts/{accountId}/calls/{callId}/recording | Update Recording +*Bandwidth::StatisticsApi* | [**get_statistics**](docs/StatisticsApi.md#get_statistics) | **GET** /accounts/{accountId}/statistics | Get Account Statistics + + +## Documentation for Models + + - [Bandwidth::AccountStatistics](docs/AccountStatistics.md) + - [Bandwidth::AnswerCallback](docs/AnswerCallback.md) + - [Bandwidth::BridgeCompleteCallback](docs/BridgeCompleteCallback.md) + - [Bandwidth::BridgeTargetCompleteCallback](docs/BridgeTargetCompleteCallback.md) + - [Bandwidth::CallDirectionEnum](docs/CallDirectionEnum.md) + - [Bandwidth::CallRecordingMetadata](docs/CallRecordingMetadata.md) + - [Bandwidth::CallState](docs/CallState.md) + - [Bandwidth::CallStateEnum](docs/CallStateEnum.md) + - [Bandwidth::CallbackMethodEnum](docs/CallbackMethodEnum.md) + - [Bandwidth::CodeRequest](docs/CodeRequest.md) + - [Bandwidth::Conference](docs/Conference.md) + - [Bandwidth::ConferenceCompletedCallback](docs/ConferenceCompletedCallback.md) + - [Bandwidth::ConferenceCreatedCallback](docs/ConferenceCreatedCallback.md) + - [Bandwidth::ConferenceMember](docs/ConferenceMember.md) + - [Bandwidth::ConferenceMemberExitCallback](docs/ConferenceMemberExitCallback.md) + - [Bandwidth::ConferenceMemberJoinCallback](docs/ConferenceMemberJoinCallback.md) + - [Bandwidth::ConferenceRecordingAvailableCallback](docs/ConferenceRecordingAvailableCallback.md) + - [Bandwidth::ConferenceRecordingMetadata](docs/ConferenceRecordingMetadata.md) + - [Bandwidth::ConferenceRedirectCallback](docs/ConferenceRedirectCallback.md) + - [Bandwidth::ConferenceStateEnum](docs/ConferenceStateEnum.md) + - [Bandwidth::CreateCall](docs/CreateCall.md) + - [Bandwidth::CreateCallResponse](docs/CreateCallResponse.md) + - [Bandwidth::CreateLookupResponse](docs/CreateLookupResponse.md) + - [Bandwidth::CreateMessageRequestError](docs/CreateMessageRequestError.md) + - [Bandwidth::DeferredResult](docs/DeferredResult.md) + - [Bandwidth::DisconnectCallback](docs/DisconnectCallback.md) + - [Bandwidth::Diversion](docs/Diversion.md) + - [Bandwidth::DtmfCallback](docs/DtmfCallback.md) + - [Bandwidth::FieldError](docs/FieldError.md) + - [Bandwidth::FileFormatEnum](docs/FileFormatEnum.md) + - [Bandwidth::GatherCallback](docs/GatherCallback.md) + - [Bandwidth::InboundMessageCallback](docs/InboundMessageCallback.md) + - [Bandwidth::InboundMessageCallbackMessage](docs/InboundMessageCallbackMessage.md) + - [Bandwidth::InitiateCallback](docs/InitiateCallback.md) + - [Bandwidth::ListMessageDirectionEnum](docs/ListMessageDirectionEnum.md) + - [Bandwidth::ListMessageItem](docs/ListMessageItem.md) + - [Bandwidth::LookupRequest](docs/LookupRequest.md) + - [Bandwidth::LookupResult](docs/LookupResult.md) + - [Bandwidth::LookupStatus](docs/LookupStatus.md) + - [Bandwidth::LookupStatusEnum](docs/LookupStatusEnum.md) + - [Bandwidth::MachineDetectionCompleteCallback](docs/MachineDetectionCompleteCallback.md) + - [Bandwidth::MachineDetectionConfiguration](docs/MachineDetectionConfiguration.md) + - [Bandwidth::MachineDetectionModeEnum](docs/MachineDetectionModeEnum.md) + - [Bandwidth::MachineDetectionResult](docs/MachineDetectionResult.md) + - [Bandwidth::Media](docs/Media.md) + - [Bandwidth::Message](docs/Message.md) + - [Bandwidth::MessageDeliveredCallback](docs/MessageDeliveredCallback.md) + - [Bandwidth::MessageDeliveredCallbackMessage](docs/MessageDeliveredCallbackMessage.md) + - [Bandwidth::MessageDirectionEnum](docs/MessageDirectionEnum.md) + - [Bandwidth::MessageFailedCallback](docs/MessageFailedCallback.md) + - [Bandwidth::MessageFailedCallbackMessage](docs/MessageFailedCallbackMessage.md) + - [Bandwidth::MessageRequest](docs/MessageRequest.md) + - [Bandwidth::MessageSendingCallback](docs/MessageSendingCallback.md) + - [Bandwidth::MessageSendingCallbackMessage](docs/MessageSendingCallbackMessage.md) + - [Bandwidth::MessageStatusEnum](docs/MessageStatusEnum.md) + - [Bandwidth::MessageTypeEnum](docs/MessageTypeEnum.md) + - [Bandwidth::MessagesList](docs/MessagesList.md) + - [Bandwidth::MessagingCodeResponse](docs/MessagingCodeResponse.md) + - [Bandwidth::MessagingRequestError](docs/MessagingRequestError.md) + - [Bandwidth::MfaForbiddenRequestError](docs/MfaForbiddenRequestError.md) + - [Bandwidth::MfaRequestError](docs/MfaRequestError.md) + - [Bandwidth::MfaUnauthorizedRequestError](docs/MfaUnauthorizedRequestError.md) + - [Bandwidth::PageInfo](docs/PageInfo.md) + - [Bandwidth::PriorityEnum](docs/PriorityEnum.md) + - [Bandwidth::RecordingAvailableCallback](docs/RecordingAvailableCallback.md) + - [Bandwidth::RecordingCompleteCallback](docs/RecordingCompleteCallback.md) + - [Bandwidth::RecordingStateEnum](docs/RecordingStateEnum.md) + - [Bandwidth::RedirectCallback](docs/RedirectCallback.md) + - [Bandwidth::RedirectMethodEnum](docs/RedirectMethodEnum.md) + - [Bandwidth::StirShaken](docs/StirShaken.md) + - [Bandwidth::Tag](docs/Tag.md) + - [Bandwidth::TnLookupRequestError](docs/TnLookupRequestError.md) + - [Bandwidth::TranscribeRecording](docs/TranscribeRecording.md) + - [Bandwidth::Transcription](docs/Transcription.md) + - [Bandwidth::TranscriptionAvailableCallback](docs/TranscriptionAvailableCallback.md) + - [Bandwidth::TranscriptionList](docs/TranscriptionList.md) + - [Bandwidth::TranscriptionMetadata](docs/TranscriptionMetadata.md) + - [Bandwidth::TransferAnswerCallback](docs/TransferAnswerCallback.md) + - [Bandwidth::TransferCompleteCallback](docs/TransferCompleteCallback.md) + - [Bandwidth::TransferDisconnectCallback](docs/TransferDisconnectCallback.md) + - [Bandwidth::UpdateCall](docs/UpdateCall.md) + - [Bandwidth::UpdateCallRecording](docs/UpdateCallRecording.md) + - [Bandwidth::UpdateConference](docs/UpdateConference.md) + - [Bandwidth::UpdateConferenceMember](docs/UpdateConferenceMember.md) + - [Bandwidth::VerifyCodeRequest](docs/VerifyCodeRequest.md) + - [Bandwidth::VerifyCodeResponse](docs/VerifyCodeResponse.md) + - [Bandwidth::VoiceApiError](docs/VoiceApiError.md) + - [Bandwidth::VoiceCodeResponse](docs/VoiceCodeResponse.md) + + +## Documentation for Authorization + + +Authentication schemes defined for the API: +### Basic + +- **Type**: HTTP basic authentication -Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html diff --git a/Rakefile b/Rakefile index 6bf529f4..55a4d0a1 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1,30 @@ -lib = File.expand_path('../lib', __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) - -require "bundler/gem_tasks" -require 'rake/testtask' - -Rake::TestTask.new(:test) do |t| - t.libs << "test" - t.test_files = FileList['test/**/test_*.rb', 'spec/**/*_spec.rb'] - t.warning = false -end - -task :default => :test +require 'bundler/gem_tasks' + +begin + require 'rspec/core/rake_task' + + desc 'Run All Tests' + RSpec::Core::RakeTask.new(:spec) + + desc 'Run Only Unit Tests' + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = './spec/api/**/*_spec.rb' + end + RSpec::Core::RakeTask.new(:unit) do |t| + t.pattern = './spec/models/**/*_spec.rb' + end + + desc 'Run Only Integration Tests' + RSpec::Core::RakeTask.new(:integration) do |t| + t.pattern = './spec/integration/*_spec.rb' + end + + desc 'Run Only Client Unit Tests' + RSpec::Core::RakeTask.new(:client) do |t| + t.pattern = './spec/*_spec.rb' + end + + task default: :spec +rescue LoadError + # no rspec available +end diff --git a/bandwidth-sdk.gemspec b/bandwidth-sdk.gemspec new file mode 100644 index 00000000..3ed52c1c --- /dev/null +++ b/bandwidth-sdk.gemspec @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- + +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +$:.push File.expand_path('../lib', __FILE__) +require 'bandwidth-sdk/version' + +Gem::Specification.new do |s| + s.name = 'bandwidth-sdk' + s.version = Bandwidth::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ['Bandwidth'] + s.email = ['dx@bandwidth.com'] + s.homepage = 'https://github.com/Bandwidth/ruby-sdk' + s.summary = 'Bandwidth Ruby SDK' + s.description = 'The official client SDK for Bandwidth's Voice, Messaging, MFA, and WebRTC APIs' + s.license = 'MIT' + s.required_ruby_version = '>=2.7' + + s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0' + s.add_runtime_dependency 'faraday-multipart' + s.add_runtime_dependency 'ox', '~> 2.4' + + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + + s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } + s.test_files = `find spec/*`.split("\n") + s.executables = [] + s.require_paths = ['lib'] +end diff --git a/bandwidth.gemspec b/bandwidth.gemspec deleted file mode 100644 index 78bbecea..00000000 --- a/bandwidth.gemspec +++ /dev/null @@ -1,23 +0,0 @@ -Gem::Specification.new do |s| - s.name = 'bandwidth-sdk' - s.version = '10.5.0' - s.summary = 'Bandwidth' - s.description = 'The official client SDK for Bandwidht\'s Voice, Messaging, MFA, and WebRTC APIs' - s.authors = ['Bandwidth'] - s.email = 'dx@bandwidth.com' - s.homepage = 'https://github.com/Bandwidth/ruby-sdk' - s.license = 'MIT' - s.add_dependency('logging', '~> 2.3') - s.add_dependency('faraday', '>= 1.0', '< 3.0') - s.add_dependency('faraday-follow_redirects', '~> 0.3') - s.add_dependency('faraday-multipart', '~> 1.0') - s.add_dependency('faraday-retry', '~> 1.0') - s.add_dependency('faraday-http-cache', '~> 2.2') - s.add_dependency('builder', '~> 3.2.4') - s.add_development_dependency('minitest', '~> 5.14', '>= 5.14.1') - s.add_development_dependency('minitest-proveit', '~> 1.0') - s.add_development_dependency('test-unit') - s.required_ruby_version = ['>= 2.0'] - s.files = Dir['{bin,lib,man,test,spec}/**/*', 'README*', 'LICENSE*'] - s.require_paths = ['lib'] -end diff --git a/bandwidth.yml b/bandwidth.yml new file mode 100644 index 00000000..1cbcd06f --- /dev/null +++ b/bandwidth.yml @@ -0,0 +1,5626 @@ +openapi: 3.0.3 +info: + title: Bandwidth + description: Bandwidth's Communication APIs + contact: + name: Bandwidth + url: https://dev.bandwidth.com + email: letstalk@bandwidth.com + version: 1.0.0 +security: + - Basic: [] +tags: + - name: Messages + - name: Media + - name: Calls + - name: Conferences + - name: Recordings + - name: Statistics + - name: MFA + - name: Phone Number Lookup +paths: + /users/{accountId}/media: + get: + summary: List Media + description: Gets a list of your media files. No query parameters are supported. + operationId: listMedia + tags: + - Media + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/continuationToken' + responses: + '200': + $ref: '#/components/responses/listMediaResponse' + '400': + $ref: '#/components/responses/messagingBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + servers: &ref_0 + - url: https://messaging.bandwidth.com/api/v2 + description: Production + /users/{accountId}/media/{mediaId}: + get: + summary: Get Media + description: Downloads a media file you previously uploaded. + operationId: getMedia + tags: + - Media + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/mediaId' + responses: + '200': + $ref: '#/components/responses/getMediaResponse' + '400': + $ref: '#/components/responses/messagingBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + put: + summary: Upload Media + description: >- + Upload a file. You may add headers to the request in order to provide + some control to your media file. + + + If a file is uploaded with the same name as a file that already exists + under this account, the previous file will be overwritten. + + + A list of supported media types can be found + [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-). + operationId: uploadMedia + tags: + - Media + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/mediaId' + - $ref: '#/components/parameters/contentType' + - $ref: '#/components/parameters/cacheControl' + requestBody: + $ref: '#/components/requestBodies/uploadMediaRequest' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/messagingBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + delete: + summary: Delete Media + description: |- + Deletes a media file from Bandwidth API server. Make sure you don't have + any application scripts still using the media before you delete. + + If you accidentally delete a media file you can immediately upload a new + file with the same name. + operationId: deleteMedia + tags: + - Media + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/mediaId' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/messagingBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + servers: *ref_0 + /users/{accountId}/messages: + get: + summary: List Messages + description: Returns a list of messages based on query parameters. + operationId: listMessages + tags: + - Messages + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/messageId' + - $ref: '#/components/parameters/sourceTn' + - $ref: '#/components/parameters/destinationTn' + - $ref: '#/components/parameters/messageStatus' + - $ref: '#/components/parameters/messageDirection' + - $ref: '#/components/parameters/carrierName' + - $ref: '#/components/parameters/messageType' + - $ref: '#/components/parameters/errorCode' + - $ref: '#/components/parameters/fromDateTime' + - $ref: '#/components/parameters/toDateTime' + - $ref: '#/components/parameters/campaignId' + - $ref: '#/components/parameters/sort' + - $ref: '#/components/parameters/pageToken' + - $ref: '#/components/parameters/limit' + - $ref: '#/components/parameters/limitTotalCount' + responses: + '200': + $ref: '#/components/responses/listMessagesResponse' + '400': + $ref: '#/components/responses/messagingBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + post: + summary: Create Message + description: >- + Endpoint for sending text messages and picture messages using V2 + messaging. + operationId: createMessage + tags: + - Messages + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/createMessageRequest' + responses: + '202': + $ref: '#/components/responses/createMessageResponse' + '400': + $ref: '#/components/responses/createMessageBadRequestError' + '401': + $ref: '#/components/responses/messagingUnauthorizedError' + '403': + $ref: '#/components/responses/messagingForbiddenError' + '404': + $ref: '#/components/responses/messagingNotFoundError' + '406': + $ref: '#/components/responses/messagingNotAcceptableError' + '415': + $ref: '#/components/responses/messagingInvalidMediaTypeError' + '429': + $ref: '#/components/responses/messagingTooManyRequestsError' + '500': + $ref: '#/components/responses/messagingInternalServerError' + callbacks: + inboundCallback: + $ref: '#/components/callbacks/inboundCallback' + statusCallback: + $ref: '#/components/callbacks/statusCallback' + servers: *ref_0 + /accounts/{accountId}/calls: + post: + tags: + - Calls + summary: Create Call + description: >- + Creates an outbound phone call. + + + All calls are initially queued. Your outbound calls will initiated at a + specific dequeueing rate, enabling your application to "fire and forget" + when creating calls. Queued calls may not be modified until they are + dequeued and placed, but may be removed from your queue on demand. + + + Please note: Calls submitted to your queue will be placed + approximately in order, but exact ordering is not guaranteed. + operationId: createCall + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/createCallRequest' + responses: + '201': + $ref: '#/components/responses/createCallResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: &ref_1 + - url: https://voice.bandwidth.com/api/v2 + description: Production + /accounts/{accountId}/calls/{callId}: + get: + tags: + - Calls + summary: Get Call State Information + description: >- + Retrieve the current state of a specific call. This information is + near-realtime, so it may take a few minutes for your call to be + accessible using this endpoint. + + + **Note**: Call information is kept for 7 days after the calls are hung + up. If you attempt to retrieve information for a call that is older than + 7 days, you will get an HTTP 404 response. + operationId: getCallState + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + responses: + '200': + $ref: '#/components/responses/getCallStateResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + post: + tags: + - Calls + summary: Update Call + description: >- + Interrupts and redirects a call to a different URL that should return a + BXML document. + operationId: updateCall + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + requestBody: + $ref: '#/components/requestBodies/updateCallRequest' + responses: + '200': + description: Call was successfully modified. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '409': + $ref: '#/components/responses/voiceConflictError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/bxml: + put: + tags: + - Calls + summary: Update Call BXML + description: Interrupts and replaces an active call's BXML document. + operationId: updateCallBxml + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + requestBody: + $ref: '#/components/requestBodies/updateCallBxmlRequest' + responses: + '204': + description: Call BXML was successfully replaced. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '409': + $ref: '#/components/responses/voiceConflictError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences: + get: + tags: + - Conferences + summary: Get Conferences + description: >- + Returns a max of 1000 conferences, sorted by `createdTime` from oldest + to newest. + + + **NOTE:** If the number of conferences in the account is bigger than + `pageSize`, a `Link` header (with format `<{url}>; rel="next"`) will be + returned in the response. The url can be used to retrieve the next page + of conference records. + operationId: listConferences + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/name' + - $ref: '#/components/parameters/minCreatedTime' + - $ref: '#/components/parameters/maxCreatedTime' + - $ref: '#/components/parameters/pageSize' + - $ref: '#/components/parameters/pageToken1' + responses: + '200': + $ref: '#/components/responses/listConferencesResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}: + get: + tags: + - Conferences + summary: Get Conference Information + description: Returns information about the specified conference. + operationId: getConference + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + responses: + '200': + $ref: '#/components/responses/getConferenceResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + post: + tags: + - Conferences + summary: Update Conference + description: Update the conference state. + operationId: updateConference + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + requestBody: + $ref: '#/components/requestBodies/updateConferenceRequest' + responses: + '204': + description: Conference was successfully modified. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}/bxml: + put: + tags: + - Conferences + summary: Update Conference BXML + description: Update the conference BXML document. + operationId: updateConferenceBxml + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + requestBody: + $ref: '#/components/requestBodies/updateConferenceBxmlRequest' + responses: + '204': + description: Conference successfully modified. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}/members/{memberId}: + get: + tags: + - Conferences + summary: Get Conference Member + description: Returns information about the specified conference member. + operationId: getConferenceMember + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + - $ref: '#/components/parameters/memberId' + responses: + '200': + $ref: '#/components/responses/getConferenceMemberResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + put: + tags: + - Conferences + summary: Update Conference Member + description: Updates settings for a particular conference member. + operationId: updateConferenceMember + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + - $ref: '#/components/parameters/memberId' + requestBody: + $ref: '#/components/requestBodies/updateConferenceMemberRequest' + responses: + '204': + description: Conference member was successfully modified. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}/recordings: + get: + tags: + - Conferences + summary: Get Conference Recordings + description: >- + Returns a (potentially empty) list of metadata for the recordings that + took place during the specified conference. + operationId: listConferenceRecordings + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + responses: + '200': + $ref: '#/components/responses/listConferenceRecordingsResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}: + get: + tags: + - Conferences + summary: Get Conference Recording Information + description: Returns metadata for the specified recording. + operationId: getConferenceRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + - $ref: '#/components/parameters/recordingId' + responses: + '200': + $ref: '#/components/responses/getConferenceRecordingResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media: + get: + tags: + - Conferences + summary: Download Conference Recording + description: Downloads the specified recording file. + operationId: downloadConferenceRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/conferenceId' + - $ref: '#/components/parameters/recordingId' + responses: + '200': + $ref: '#/components/responses/downloadRecordingMediaResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/recordings: + get: + tags: + - Recordings + summary: Get Call Recordings + description: >- + Returns a list of metadata for the recordings associated with the + + specified account. The list can be filtered by the optional from, to, + minStartTime, + + and maxStartTime arguments. The list is capped at 1000 entries and may + be + + empty if no recordings match the specified criteria. + operationId: listAccountCallRecordings + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/to' + - $ref: '#/components/parameters/from' + - $ref: '#/components/parameters/minStartTime' + - $ref: '#/components/parameters/maxStartTime' + responses: + '200': + $ref: '#/components/responses/listCallRecordingsResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/recording: + put: + tags: + - Recordings + summary: Update Recording + description: Pause or resume a recording on an active phone call. + operationId: updateCallRecordingState + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + requestBody: + $ref: '#/components/requestBodies/updateCallRecordingRequest' + responses: + '200': + description: Recording state was successfully modified. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/recordings: + get: + tags: + - Recordings + summary: List Call Recordings + description: |- + Returns a (potentially empty) list of metadata for the recordings + that took place during the specified call. + operationId: listCallRecordings + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + responses: + '200': + $ref: '#/components/responses/listCallRecordingsResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/recordings/{recordingId}: + get: + tags: + - Recordings + summary: Get Call Recording + description: Returns metadata for the specified recording. + operationId: getCallRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '200': + $ref: '#/components/responses/getCallRecordingResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + delete: + tags: + - Recordings + summary: Delete Recording + description: >- + Delete the recording information, media and transcription. + + + Note: After the deletion is requested and a `204` is returned, neither + the recording metadata nor the actual media nor its transcription will + be accessible anymore. However, the media of the specified recording is + not deleted immediately. This deletion process, while transparent and + irreversible, can take an additional 24 to 48 hours. + operationId: deleteRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '204': + description: Recording was deleted. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media: + get: + tags: + - Recordings + summary: Download Recording + description: Downloads the specified recording. + operationId: downloadCallRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '200': + $ref: '#/components/responses/downloadRecordingMediaResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + delete: + tags: + - Recordings + summary: Delete Recording Media + description: Deletes the specified recording's media. + operationId: deleteRecordingMedia + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '204': + description: The recording media was successfully deleted. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription: + get: + tags: + - Recordings + summary: Get Transcription + description: >- + Downloads the specified transcription. + + + If the transcribed recording was multi-channel, then there will be 2 + transcripts. + + The caller/called party transcript will be the first item while + [``](/docs/voice/bxml/playAudio) and + [``](/docs/voice/bxml/speakSentence) transcript will be + the second item. + + During a [``](/docs/voice/bxml/transfer) the A-leg transcript + will be the first item while the B-leg transcript will be the second + item. + operationId: getCallTranscription + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '200': + $ref: '#/components/responses/getCallTranscriptionResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + post: + tags: + - Recordings + summary: Create Transcription Request + description: >- + Generate the transcription for a specific recording. Transcription + + can succeed only for recordings of length greater than 500 milliseconds + and + + less than 4 hours. + operationId: transcribeCallRecording + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + requestBody: + $ref: '#/components/requestBodies/transcribeRecordingRequest' + responses: + '204': + description: Transcription was successfully requested. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + delete: + tags: + - Recordings + summary: Delete Transcription + description: >- + Deletes the specified recording's transcription. + + + Note: After the deletion is requested and a `204` is returned, the + transcription will not be accessible anymore. However, it is not deleted + immediately. This deletion process, while transparent and irreversible, + can take an additional 24 to 48 hours. + operationId: deleteCallTranscription + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/callId' + - $ref: '#/components/parameters/recordingId' + responses: + '204': + description: The transcription was successfully deleted. + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/statistics: + get: + tags: + - Statistics + summary: Get Account Statistics + description: Returns details about the current state of the account. + operationId: getStatistics + parameters: + - $ref: '#/components/parameters/accountId' + responses: + '200': + $ref: '#/components/responses/getStatisticsResponse' + '400': + $ref: '#/components/responses/voiceBadRequestError' + '401': + $ref: '#/components/responses/voiceUnauthorizedError' + '403': + $ref: '#/components/responses/voiceForbiddenError' + '404': + $ref: '#/components/responses/voiceNotFoundError' + '405': + $ref: '#/components/responses/voiceNotAllowedError' + '415': + $ref: '#/components/responses/voiceUnsupportedMediaTypeError' + '429': + $ref: '#/components/responses/voiceTooManyRequestsError' + '500': + $ref: '#/components/responses/voiceInternalServerError' + servers: *ref_1 + /accounts/{accountId}/code/voice: + post: + tags: + - MFA + summary: Voice Authentication Code + description: Send an MFA Code via a phone call. + operationId: generateVoiceCode + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/codeRequest' + responses: + '200': + $ref: '#/components/responses/voiceCodeResponse' + '400': + $ref: '#/components/responses/mfaBadRequestError' + '401': + $ref: '#/components/responses/mfaUnauthorizedError' + '403': + $ref: '#/components/responses/mfaForbiddenError' + '500': + $ref: '#/components/responses/mfaInternalServerError' + servers: &ref_2 + - url: https://mfa.bandwidth.com/api/v1 + description: Production + /accounts/{accountId}/code/messaging: + post: + tags: + - MFA + summary: Messaging Authentication Code + description: Send an MFA code via text message (SMS). + operationId: generateMessagingCode + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/codeRequest' + responses: + '200': + $ref: '#/components/responses/messagingCodeResponse' + '400': + $ref: '#/components/responses/mfaBadRequestError' + '401': + $ref: '#/components/responses/mfaUnauthorizedError' + '403': + $ref: '#/components/responses/mfaForbiddenError' + '500': + $ref: '#/components/responses/mfaInternalServerError' + servers: *ref_2 + /accounts/{accountId}/code/verify: + post: + tags: + - MFA + summary: Verify Authentication Code + description: Verify a previously sent MFA code. + operationId: verifyCode + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/codeVerify' + responses: + '200': + $ref: '#/components/responses/verifyCodeResponse' + '400': + $ref: '#/components/responses/mfaBadRequestError' + '401': + $ref: '#/components/responses/mfaUnauthorizedError' + '403': + $ref: '#/components/responses/mfaForbiddenError' + '429': + $ref: '#/components/responses/mfaTooManyRequestsError' + '500': + $ref: '#/components/responses/mfaInternalServerError' + servers: *ref_2 + /accounts/{accountId}/tnlookup: + post: + summary: Create Lookup + description: Create a Phone Number Lookup Request. + operationId: createLookup + tags: + - Phone Number Lookup + parameters: + - $ref: '#/components/parameters/accountId' + requestBody: + $ref: '#/components/requestBodies/createLookupRequest' + responses: + '202': + $ref: '#/components/responses/createLookupResponse' + '400': + $ref: '#/components/responses/tnLookupBadRequestError' + '401': + $ref: '#/components/responses/tnLookupUnauthorizedError' + '403': + $ref: '#/components/responses/tnLookupForbiddenError' + '415': + $ref: '#/components/responses/tnLookupMediaTypeError' + '429': + $ref: '#/components/responses/tnLookupTooManyRequestsError' + '500': + $ref: '#/components/responses/tnLookupInternalServerError' + servers: &ref_3 + - url: https://numbers.bandwidth.com/api/v1 + description: Production + /accounts/{accountId}/tnlookup/{requestId}: + get: + summary: Get Lookup Request Status + description: Get an existing Phone Number Lookup Request. + operationId: getLookupStatus + tags: + - Phone Number Lookup + parameters: + - $ref: '#/components/parameters/accountId' + - $ref: '#/components/parameters/requestId' + responses: + '200': + $ref: '#/components/responses/getLookupResponse' + '400': + $ref: '#/components/responses/tnLookupBadRequestError' + '401': + $ref: '#/components/responses/tnLookupUnauthorizedError' + '403': + $ref: '#/components/responses/tnLookupForbiddenError' + '404': + description: Not Found + '429': + $ref: '#/components/responses/tnLookupTooManyRequestsError' + '500': + $ref: '#/components/responses/tnLookupInternalServerError' + servers: *ref_3 +components: + schemas: + priorityEnum: + type: string + description: |- + The priority specified by the user. + + Not supported on MMS. + enum: + - default + - high + example: default + messageStatusEnum: + type: string + description: >- + The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED + DELIVERED ACCEPTED UNDELIVERED. + enum: + - RECEIVED + - QUEUED + - SENDING + - SENT + - FAILED + - DELIVERED + - ACCEPTED + - UNDELIVERED + example: RECEIVED + listMessageDirectionEnum: + type: string + description: The direction of the message. One of INBOUND OUTBOUND. + enum: + - INBOUND + - OUTBOUND + messageDirectionEnum: + type: string + description: The direction of the message. One of in out. + enum: + - in + - out + messageTypeEnum: + type: string + description: The type of message. Either SMS or MMS. + enum: + - sms + - mms + example: sms + fieldError: + type: object + properties: + fieldName: + type: string + description: The name of the field that contains the error + example: from + description: + type: string + description: The error associated with the field + example: >- + '+invalid' must be replaced with a valid E164 formatted telephone + number + messagesList: + title: MessagesList + type: object + properties: + totalCount: + type: integer + description: >- + The total number of messages matched by the search. When the request + has limitTotalCount set to true this value is limited to 10,000. + example: 100 + pageInfo: + $ref: '#/components/schemas/pageInfo' + messages: + type: array + items: + $ref: '#/components/schemas/listMessageItem' + listMessageItem: + title: listMessageItem + type: object + properties: + messageId: + type: string + description: The message id + example: 1589228074636lm4k2je7j7jklbn2 + accountId: + type: string + description: The account id associated with this message. + example: '9900000' + sourceTn: + type: string + description: The source phone number of the message. + example: '+15554443333' + destinationTn: + type: string + description: The recipient phone number of the message. + example: '+15554442222' + messageStatus: + $ref: '#/components/schemas/messageStatusEnum' + messageDirection: + $ref: '#/components/schemas/listMessageDirectionEnum' + messageType: + $ref: '#/components/schemas/messageTypeEnum' + segmentCount: + type: integer + description: The number of segments the message was sent as. + example: 1 + errorCode: + type: integer + description: The numeric error code of the message. + example: 9902 + receiveTime: + type: string + format: date-time + description: The ISO 8601 datetime of the message. + example: 2020-04-07T14:03:07.000Z + carrierName: + type: string + nullable: true + description: >- + The name of the carrier. Not currently supported for MMS coming + soon. + example: other + messageSize: + type: integer + description: The size of the message including message content and headers. + nullable: true + example: 27 + messageLength: + type: integer + description: The length of the message content. + example: 18 + attachmentCount: + type: integer + description: The number of attachments the message has. + nullable: true + example: 1 + recipientCount: + type: integer + description: The number of recipients the message has. + nullable: true + example: 1 + campaignClass: + type: string + description: The campaign class of the message if it has one. + nullable: true + example: T + campaignId: + type: string + description: The campaign ID of the message if it has one. + nullable: true + example: CJEUMDK + pageInfo: + title: PageInfo + type: object + properties: + prevPage: + type: string + description: The link to the previous page for pagination. + example: >- + https://messaging.bandwidth.com/api/v2/users/accountId/messages?messageStatus=DLR_EXPIRED&nextPage=DLAPE902 + nextPage: + type: string + description: The link to the next page for pagination. + example: >- + https://messaging.bandwidth.com/api/v2/users/accountId/messages?messageStatus=DLR_EXPIRED&prevPage=GL83PD3C + prevPageToken: + type: string + description: The isolated pagination token for the previous page. + example: DLAPE902 + nextPageToken: + type: string + description: The isolated pagination token for the next page. + example: GL83PD3C + messagingRequestError: + title: MessagingRequestError + type: object + properties: + type: + type: string + description: + type: string + required: + - type + - description + createMessageRequestError: + title: CreateMessageRequestError + type: object + properties: + type: + type: string + description: + type: string + fieldErrors: + type: array + items: + $ref: '#/components/schemas/fieldError' + required: + - type + - description + media: + title: Media + type: object + properties: + content: + type: string + contentLength: + type: integer + mediaName: + type: string + tag: + title: Tag + type: object + properties: + key: + type: string + value: + type: string + deferredResult: + title: DeferredResult + type: object + properties: + result: + type: object + setOrExpired: + type: boolean + message: + title: Message + type: object + properties: + id: + type: string + description: The id of the message. + example: 1589228074636lm4k2je7j7jklbn2 + owner: + type: string + description: The Bandwidth phone number associated with the message. + example: '+15554443333' + applicationId: + type: string + description: The application ID associated with the message. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + time: + type: string + format: date-time + description: The datetime stamp of the message in ISO 8601 + example: 2022-09-14T18:20:16.000Z + segmentCount: + type: integer + description: >- + The number of segments the original message from the user is broken + into before sending over to carrier networks. + example: 2 + direction: + $ref: '#/components/schemas/messageDirectionEnum' + to: + uniqueItems: true + type: array + items: + type: string + description: The phone number recipients of the message. + example: + - '+15552223333' + from: + type: string + description: The phone number the message was sent from. + example: '+15553332222' + media: + uniqueItems: true + type: array + items: + type: string + description: >- + The list of media URLs sent in the message. Including a `filename` + field in the `Content-Disposition` header of the media linked with a + URL will set the displayed file name. This is a best practice to + ensure that your media has a readable file name. + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + text: + type: string + description: The contents of the message. + example: Hello world + tag: + type: string + description: The custom string set by the user. + example: custom tag + priority: + $ref: '#/components/schemas/priorityEnum' + expiration: + type: string + format: date-time + description: The expiration date-time set by the user. + example: '2021-02-01T11:29:18-05:00' + messageRequest: + title: MessageRequest + type: object + required: + - applicationId + - to + - from + properties: + applicationId: + type: string + description: >- + The ID of the Application your from number is associated with in the + Bandwidth Phone Number Dashboard. + example: 93de2206-9669-4e07-948d-329f4b722ee2 + to: + uniqueItems: true + type: array + description: The phone number(s) the message should be sent to in E164 format. + example: + - '+15554443333' + - '+15552223333' + items: + type: string + from: + type: string + description: >- + One of your telephone numbers the message should come from in E164 + format. + example: '+15551113333' + text: + type: string + description: The contents of the text message. Must be 2048 characters or less. + maxLength: 2048 + example: Hello world + media: + type: array + items: + type: string + format: uri + maxLength: 4096 + description: >- + A list of URLs to include as media attachments as part of the + message. + + Each URL can be at most 4096 characters. + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + tag: + type: string + description: >- + A custom string that will be included in callback events of the + message. Max 1024 characters. + example: custom string + priority: + $ref: '#/components/schemas/priorityEnum' + expiration: + type: string + format: date-time + description: >- + A string with the date/time value that the message will + automatically expire by. This must be a valid RFC-3339 value, e.g., + 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a + date-time in the future. + + Not supported on MMS. + example: '2021-02-01T11:29:18-05:00' + inboundMessageCallback: + description: Inbound Message Callback + type: object + properties: + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + type: + type: string + example: message-received + to: + type: string + example: '+15552223333' + description: + type: string + example: Incoming message received + message: + $ref: '#/components/schemas/inboundMessageCallbackMessage' + required: + - time + - type + - to + - description + - message + inboundMessageCallbackMessage: + description: Inbound Message Callback Message Schema + type: object + properties: + id: + type: string + example: 1661365814859loidf7mcwd4qacn7 + owner: + type: string + example: '+15553332222' + applicationId: + type: string + example: 93de2206-9669-4e07-948d-329f4b722ee2 + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + segmentCount: + type: integer + example: 1 + direction: + $ref: '#/components/schemas/messageDirectionEnum' + to: + uniqueItems: true + type: array + items: + type: string + example: + - '+15552223333' + from: + type: string + example: '+15553332222' + text: + type: string + example: Hello world + tag: + type: string + example: custom string + media: + type: array + items: + type: string + format: uri + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + priority: + $ref: '#/components/schemas/priorityEnum' + required: + - id + - owner + - applicationId + - time + - segmentCount + - direction + - to + - from + - text + messageSendingCallback: + type: object + description: Message Sending Callback + properties: + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + type: + type: string + example: message-sending + to: + type: string + example: '+15552223333' + description: + type: string + example: Message is sending to carrier + message: + $ref: '#/components/schemas/messageSendingCallbackMessage' + required: + - time + - type + - to + - description + - message + messageSendingCallbackMessage: + description: Message Sending Callback Message Schema + type: object + properties: + id: + type: string + example: 1661365814859loidf7mcwd4qacn7 + owner: + type: string + example: '+15553332222' + applicationId: + type: string + example: 93de2206-9669-4e07-948d-329f4b722ee2 + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + segmentCount: + type: integer + example: 1 + direction: + $ref: '#/components/schemas/messageDirectionEnum' + to: + uniqueItems: true + type: array + items: + type: string + example: + - '+15552223333' + from: + type: string + example: '+15553332222' + text: + type: string + example: Hello world + tag: + type: string + example: custom string + media: + type: array + items: + type: string + format: uri + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + priority: + $ref: '#/components/schemas/priorityEnum' + required: + - id + - owner + - applicationId + - time + - segmentCount + - direction + - to + - from + - text + - media + - priority + messageDeliveredCallback: + description: Message Delivered Callback + type: object + properties: + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + type: + type: string + example: message-delivered + to: + type: string + example: '+15552223333' + description: + type: string + example: Message delivered to carrier. + message: + $ref: '#/components/schemas/messageDeliveredCallbackMessage' + required: + - time + - type + - to + - description + - message + messageDeliveredCallbackMessage: + description: Message Delivered Callback Message Schema + type: object + properties: + id: + type: string + example: 1661365814859loidf7mcwd4qacn7 + owner: + type: string + example: '+15553332222' + applicationId: + type: string + example: 93de2206-9669-4e07-948d-329f4b722ee2 + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + segmentCount: + type: integer + example: 1 + direction: + $ref: '#/components/schemas/messageDirectionEnum' + to: + uniqueItems: true + type: array + items: + type: string + example: + - '+15552223333' + from: + type: string + example: '+15553332222' + text: + type: string + example: Hello world + tag: + type: string + example: custom string + media: + type: array + items: + type: string + format: uri + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + priority: + $ref: '#/components/schemas/priorityEnum' + required: + - id + - owner + - applicationId + - time + - segmentCount + - direction + - to + - from + - text + - tag + messageFailedCallback: + description: Message Failed Callback + type: object + properties: + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + type: + type: string + example: message-failed + to: + type: string + example: '+15552223333' + description: + type: string + example: rejected-unallocated-from-number + message: + $ref: '#/components/schemas/messageFailedCallbackMessage' + errorCode: + type: integer + example: 9902 + required: + - time + - type + - to + - description + - message + - errorCode + messageFailedCallbackMessage: + description: Message Failed Callback Message Schema + type: object + properties: + id: + type: string + example: 1661365814859loidf7mcwd4qacn7 + owner: + type: string + example: '+15553332222' + applicationId: + type: string + example: 93de2206-9669-4e07-948d-329f4b722ee2 + time: + type: string + format: date-time + example: 2016-09-14T18:20:16.000Z + segmentCount: + type: integer + example: 1 + direction: + $ref: '#/components/schemas/messageDirectionEnum' + to: + uniqueItems: true + type: array + items: + type: string + example: + - '+15552223333' + from: + type: string + example: '+15553332222' + text: + type: string + example: Hello world + tag: + type: string + example: custom string + media: + type: array + items: + type: string + format: uri + example: + - https://dev.bandwidth.com/images/bandwidth-logo.png + - https://dev.bandwidth.com/images/github_logo.png + priority: + $ref: '#/components/schemas/priorityEnum' + required: + - id + - owner + - applicationId + - time + - segmentCount + - direction + - to + - from + - text + - tag + - priority + callbackMethodEnum: + type: string + nullable: true + default: POST + enum: + - GET + - POST + description: >- + The HTTP method to use to deliver the callback. GET or POST. Default + value is POST. + example: POST + redirectMethodEnum: + type: string + nullable: true + default: POST + enum: + - GET + - POST + description: >- + The HTTP method to use for the request to `redirectUrl`. GET + + or POST. Default value is POST.

Not allowed if `state` is + `completed`. + example: POST + recordingStateEnum: + type: string + enum: + - paused + - recording + description: |- + The recording state. Possible values: + + `paused` to pause an active recording + + `recording` to resume a paused recording + example: paused + callDirectionEnum: + type: string + enum: + - inbound + - outbound + description: The direction of the call. + example: inbound + fileFormatEnum: + type: string + enum: + - mp3 + - wav + description: The format that the recording is stored in. + example: wav + callStateEnum: + nullable: true + type: string + default: active + enum: + - active + - completed + description: >- + The call state. Possible values:
`active` to redirect the + + call (default)
`completed` to hang up the call if it is answered, + cancel + + it if it is an unanswered outbound call, or reject it if it an + unanswered + + inbound call + example: completed + conferenceStateEnum: + nullable: true + type: string + default: active + enum: + - active + - completed + description: >- + Setting the conference state to `completed` ends the conference and + ejects all members. + example: completed + machineDetectionModeEnum: + type: string + default: async + enum: + - sync + - async + description: >- + The machine detection mode. If set to 'async', the detection + + result will be sent in a 'machineDetectionComplete' callback. If set to + + 'sync', the 'answer' callback will wait for the machine detection to + complete + + and will include its result. + example: async + createCall: + type: object + required: + - answerUrl + - applicationId + - from + - to + properties: + to: + type: string + description: >- + The destination to call (must be an E.164 formatted number + + (e.g. `+15555551212`) or a SIP URI (e.g. + `sip:user@server.example`)). + example: '+19195551234' + from: + type: string + description: >- + A Bandwidth phone number on your account the call should come + + from (must be in E.164 format, like `+15555551212`, or be one of the + following + + strings: `Restricted`, `Anonymous`, `Private`, or `Unavailable`). + example: '+19195554321' + displayName: + nullable: true + type: string + description: >- + The caller display name to use when the call is created. + + May not exceed 256 characters nor contain control characters such as + new lines. + maxLength: 256 + example: John Doe + uui: + nullable: true + type: string + example: >- + eyJhbGciOiJIUzI1NiJ9.WyJoaSJd.-znkjYyCkgz4djmHUPSXl9YrJ6Nix_XvmlwKGFh5ERM;encoding=jwt,aGVsbG8gd29ybGQ;encoding=base64 + description: >- + A comma-separated list of 'User-To-User' headers to be sent + + in the INVITE when calling a SIP URI. Each value must end with an + 'encoding' + + parameter as described in RFC + + 7433. Only 'jwt' and 'base64' encodings are allowed. The entire + value + + cannot exceed 350 characters, including parameters and separators. + applicationId: + type: string + description: The id of the application associated with the `from` number. + example: 1234-qwer-5679-tyui + answerUrl: + type: string + format: uri + description: >- + The full URL to send the Answer + + event to when the called party answers. This endpoint should return + the + + first BXML document to be executed in + the + + call. + + + Must use `https` if specifying `username` and `password`. + maxLength: 2048 + example: https://www.myCallbackServer.example/webhooks/answer + answerMethod: + $ref: '#/components/schemas/callbackMethodEnum' + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + answerFallbackUrl: + nullable: true + type: string + format: uri + description: >- + A fallback url which, if provided, will be used to retry the + + `answer` webhook delivery in case `answerUrl` fails to respond + + + Must use `https` if specifying `fallbackUsername` and + `fallbackPassword`. + maxLength: 2048 + example: https://www.myFallbackServer.example/webhooks/answer + answerFallbackMethod: + $ref: '#/components/schemas/callbackMethodEnum' + fallbackUsername: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + fallbackPassword: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + disconnectUrl: + nullable: true + type: string + format: uri + description: >- + The URL to send the Disconnect event to when + the call ends. This event does not expect a BXML response. + maxLength: 2048 + example: https://www.myCallbackServer.example/webhooks/disconnect + disconnectMethod: + $ref: '#/components/schemas/callbackMethodEnum' + callTimeout: + nullable: true + type: number + format: double + description: >- + The timeout (in seconds) for the callee to answer the call + + after it starts ringing. If the call does not start ringing within + 30s, + + the call will be cancelled regardless of this value. Can be any + numeric + + value (including decimals) between 1 and 300. + minimum: 1 + maximum: 300 + default: 30 + example: 30 + callbackTimeout: + nullable: true + type: number + format: double + description: >- + This is the timeout (in seconds) to use when delivering webhooks + + for the call. Can be any numeric value (including decimals) between + 1 + + and 25. + minimum: 1 + maximum: 25 + default: 15 + example: 15 + machineDetection: + $ref: '#/components/schemas/machineDetectionConfiguration' + priority: + nullable: true + type: integer + minimum: 1 + maximum: 5 + default: 5 + description: >- + The priority of this call over other calls from your account. For + example, if during a call + + your application needs to place a new call and bridge it with the + current + + call, you might want to create the call with priority 1 so that it + will + + be the next call picked off your queue, ahead of other less time + sensitive + + calls. A lower value means higher priority, so a priority 1 call + takes + + precedence over a priority 2 call. + example: 5 + tag: + nullable: true + type: string + description: >- + A custom string that will be sent with all webhooks for this + + call unless overwritten by a future `` + + verb or `tag` attribute on another verb, or cleared. + + + May be cleared by setting `tag=""` + + + Max length 256 characters. + maxLength: 256 + example: arbitrary text here + createCallResponse: + type: object + required: + - accountId + - answerMethod + - answerUrl + - applicationId + - callId + - callUrl + - disconnectMethod + - from + - to + properties: + applicationId: + type: string + example: 04e88489-df02-4e34-a0ee-27a91849555f + description: The id of the application associated with the `from` number. + accountId: + type: string + example: '9900000' + description: The bandwidth account ID associated with the call. + callId: + type: string + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + description: Programmable Voice API Call ID. + to: + type: string + example: '+19195551234' + description: Recipient of the outgoing call. + from: + type: string + example: '+19195554321' + description: Phone number that created the outbound call. + enqueuedTime: + nullable: true + type: string + format: date-time + description: The time at which the call was accepted into the queue. + example: '2022-06-16T13:15:07.160Z' + callUrl: + type: string + format: uri + example: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + description: The URL to update this call's state. + callTimeout: + type: number + format: double + example: 30 + description: >- + The timeout (in seconds) for the callee to answer the call after it + starts ringing. + callbackTimeout: + type: number + format: double + example: 15 + description: >- + This is the timeout (in seconds) to use when delivering webhooks for + the call. + tag: + nullable: true + type: string + example: My custom tag value + description: Custom tag value. + answerMethod: + $ref: '#/components/schemas/callbackMethodEnum' + answerUrl: + type: string + format: uri + example: https://myServer.example/bandwidth/webhooks/answer + description: URL to deliver the `answer` event webhook. + answerFallbackMethod: + $ref: '#/components/schemas/callbackMethodEnum' + answerFallbackUrl: + nullable: true + type: string + format: uri + example: https://myFallbackServer.example/bandwidth/webhooks/answer + description: Fallback URL to deliver the `answer` event webhook. + disconnectMethod: + $ref: '#/components/schemas/callbackMethodEnum' + disconnectUrl: + nullable: true + type: string + format: uri + example: https://myServer.example/bandwidth/webhooks/disconnect + description: URL to deliver the `disconnect` event webhook. + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + fallbackUsername: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + fallbackPassword: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + priority: + nullable: true + type: integer + example: 5 + description: The priority of this call over other calls from your account. + callState: + type: object + properties: + applicationId: + type: string + description: The application id associated with the call. + example: 04e88489-df02-4e34-a0ee-27a91849555f + accountId: + type: string + description: The account id associated with the call. + example: '9900000' + callId: + type: string + description: The programmable voice API call ID. + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + parentCallId: + nullable: true + type: string + description: >- + The A-leg call id, set only if this call is the B-leg of a + [``](/docs/voice/bxml/transfer). + example: c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + to: + type: string + description: >- + The phone number that received the call, in E.164 format (e.g. + +15555555555), or if the call was to a SIP URI, the SIP URI. + example: '+19195551234' + from: + type: string + description: >- + The phone number that made the call, in E.164 format (e.g. + +15555555555). + example: '19195554321' + direction: + $ref: '#/components/schemas/callDirectionEnum' + state: + description: >- + The current state of the call. Current possible values are + + `queued`, `initiated`, `answered` and `disconnected`. Additional + states + + may be added in the future, so your application must be tolerant of + unknown + + values. + type: string + example: disconnected + stirShaken: + nullable: true + type: object + description: >- + For inbound calls, the Bandwidth STIR/SHAKEN implementation will + verify the information provided in the inbound invite request + `Identity` header. + + The verification status is stored in the call state `stirShaken` + property as follows. + + + | Property | Description | + + |:------------------|:------------| + + | verstat | (optional) The verification status indicating whether + the verification was successful or not. Possible values are + `TN-Verification-Passed` or `TN-Verification-Failed`. | + + | attestationIndicator | (optional) The attestation level verified + by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` + (gateway). | + + | originatingId | (optional) A unique origination identifier. | + + + Note that these are common properties but that the `stirShaken` + object is free form and can contain other key-value pairs. + + + More information: [Understanding + STIR/SHAKEN](https://www.bandwidth.com/regulations/stir-shaken). + additionalProperties: + type: string + example: + verstat: TN-Verification-Passed + attestationIndicator: A + originatingId: abc123 + identity: + nullable: true + type: string + description: >- + The value of the `Identity` header from the inbound invite + + request. Only present for inbound calls and if the account is + configured + + to forward this header. + example: >- + eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9idy1zaGFrZW4tY2VydC1wdWIuczMuYW1hem9uYXdzLmNvbS9iYW5kd2lkdGgtc2hha2VuLWNlcnRfMjAyMzA3MTYucGVtIn0.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTg0MjgyMDI4MCJdfSwiaWF0IjoxNjU2NTM0MzM2LCJvcmlnIjp7InRuIjoiMTkxOTQ0NDI2ODMifSwib3JpZ2lkIjoiNDk0NTlhOGEtNDJmNi0zNTFjLTkzNjEtYWRmNTdhOWUwOGNhIn0.56un9sRw_uH-sbJvnUsqdevlVxbOVjn8MVlGTlBMicjaZuRRwxfiNp-C9zYCMKTTCbc-QdYPN05F61XNVN4D3w;info=;alg=ES256;ppt=shaken + enqueuedTime: + nullable: true + type: string + format: date-time + description: The time this call was placed in queue. + example: '2022-06-16T13:15:07.160Z' + startTime: + nullable: true + type: string + format: date-time + description: >- + The time the call was initiated, in ISO 8601 format. `null` if the + call is still in your queue. + example: '2022-06-16T13:15:07.160Z' + answerTime: + nullable: true + type: string + format: date-time + description: >- + Populated once the call has been answered, with the time in ISO 8601 + format. + example: '2022-06-16T13:15:18.126Z' + endTime: + nullable: true + type: string + format: date-time + description: Populated once the call has ended, with the time in ISO 8601 format. + example: '2022-06-16T13:15:18.314Z' + disconnectCause: + nullable: true + type: string + description: >- + | Cause | Description | + + |:------|:------------| + + | `hangup`| One party hung up the call, a + [``](../../bxml/verbs/hangup.md) verb was executed, or there + was no more BXML to execute; it indicates that the call ended + normally. | + + | `busy` | Callee was busy. | + + | `timeout` | Call wasn't answered before the `callTimeout` was + reached. | + + | `cancel` | Call was cancelled by its originator while it was + ringing. | + + | `rejected` | Call was rejected by the callee. | + + | `callback-error` | BXML callback couldn't be delivered to your + callback server. | + + | `invalid-bxml` | Invalid BXML was returned in response to a + callback. | + + | `application-error` | An unsupported action was tried on the call, + e.g. trying to play a .ogg audio. | + + | `account-limit` | Account rate limits were reached. | + + | `node-capacity-exceeded` | System maximum capacity was reached. | + + | `error` | Some error not described in any of the other causes + happened on the call. | + + | `unknown` | Unknown error happened on the call. | + + + Note: This list is not exhaustive and other values can appear in the + future. + errorMessage: + nullable: true + type: string + description: >- + Populated only if the call ended with an error, with text explaining + the reason. + example: null + errorId: + nullable: true + type: string + description: >- + Populated only if the call ended with an error, with a Bandwidth + internal id that references the error event. + example: null + lastUpdate: + type: string + format: date-time + description: The last time the call had a state update, in ISO 8601 format. + example: '2022-06-16T13:15:18.314Z' + updateCall: + type: object + properties: + state: + $ref: '#/components/schemas/callStateEnum' + redirectUrl: + description: |- + The URL to send the [Redirect](/docs/voice/bxml/redirect) event + to which will provide new BXML. + + Required if `state` is `active`. + + Not allowed if `state` is `completed`. + nullable: true + type: string + format: uri + example: https://myServer.example/bandwidth/webhooks/redirect + redirectMethod: + $ref: '#/components/schemas/redirectMethodEnum' + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + redirectFallbackUrl: + nullable: true + type: string + format: uri + description: |- + A fallback url which, if provided, will be used to retry the + redirect callback delivery in case `redirectUrl` fails to respond. + example: https://myFallbackServer.example/bandwidth/webhooks/redirect + redirectFallbackMethod: + $ref: '#/components/schemas/redirectMethodEnum' + fallbackUsername: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + fallbackPassword: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + tag: + nullable: true + type: string + description: >- + A custom string that will be sent with this and all future + + callbacks unless overwritten by a future `tag` attribute or + [``](/docs/voice/bxml/tag) + + verb, or cleared. + + + May be cleared by setting `tag=""`. + + + Max length 256 characters. + + + Not allowed if `state` is `completed`. + maxLength: 256 + example: My Custom Tag + updateCallRecording: + type: object + required: + - state + properties: + state: + $ref: '#/components/schemas/recordingStateEnum' + accountStatistics: + type: object + properties: + currentCallQueueSize: + type: integer + description: The number of calls currently enqueued. + example: 0 + maxCallQueueSize: + type: integer + description: >- + The maximum size of the queue before outgoing calls start being + rejected. + example: 900 + callRecordingMetadata: + type: object + properties: + applicationId: + $ref: '#/components/schemas/applicationId' + accountId: + $ref: '#/components/schemas/accountId' + callId: + $ref: '#/components/schemas/callId' + parentCallId: + $ref: '#/components/schemas/parentCallId' + recordingId: + $ref: '#/components/schemas/recordingId' + to: + $ref: '#/components/schemas/to' + from: + $ref: '#/components/schemas/from' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + duration: + $ref: '#/components/schemas/duration' + direction: + $ref: '#/components/schemas/callDirectionEnum' + channels: + $ref: '#/components/schemas/channels' + startTime: + $ref: '#/components/schemas/startTime' + endTime: + $ref: '#/components/schemas/endTime' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + status: + $ref: '#/components/schemas/status' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + transcription: + $ref: '#/components/schemas/transcriptionMetadata' + conference: + type: object + properties: + id: + type: string + description: The Bandwidth-generated conference ID. + example: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9 + name: + type: string + description: The name of the conference, as specified by your application. + example: my-conference-name + createdTime: + type: string + format: date-time + description: The time the conference was initiated, in ISO 8601 format. + example: '2022-06-17T22:19:40.375Z' + completedTime: + nullable: true + type: string + format: date-time + description: The time the conference was terminated, in ISO 8601 format. + example: '2022-06-17T22:20:00.000Z' + conferenceEventUrl: + nullable: true + type: string + format: uri + description: The URL to send the conference-related events. + example: https://myServer.example/bandwidth/webhooks/conferenceEvent + conferenceEventMethod: + $ref: '#/components/schemas/callbackMethodEnum' + tag: + nullable: true + type: string + description: >- + The custom string attached to the conference that will be sent with + callbacks. + example: my custom tag + activeMembers: + type: array + nullable: true + items: + $ref: '#/components/schemas/conferenceMember' + description: >- + A list of active members of the conference. Omitted if this + + is a response to the [Get Conferences + endpoint](/apis/voice#tag/Conferences/operation/listConferences). + updateConference: + type: object + properties: + status: + $ref: '#/components/schemas/conferenceStateEnum' + redirectUrl: + nullable: true + type: string + format: uri + description: >- + The URL to send the + [conferenceRedirect](/docs/voice/webhooks/conferenceRedirect) + + event which will provide new BXML. Not allowed if `state` is + `completed`, + + but required if `state` is `active`. + example: https://myServer.example/bandwidth/webhooks/conferenceRedirect + redirectMethod: + $ref: '#/components/schemas/redirectMethodEnum' + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + redirectFallbackUrl: + nullable: true + type: string + format: uri + description: >- + A fallback url which, if provided, will be used to retry the + + `conferenceRedirect` webhook delivery in case `redirectUrl` fails to + respond. Not + + allowed if `state` is `completed`. + example: >- + https://myFallbackServer.example/bandwidth/webhooks/conferenceRedirect + redirectFallbackMethod: + $ref: '#/components/schemas/redirectMethodEnum' + fallbackUsername: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + fallbackPassword: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + conferenceMember: + type: object + properties: + callId: + $ref: '#/components/schemas/callId' + conferenceId: + $ref: '#/components/schemas/conferenceId' + memberUrl: + type: string + description: >- + A URL that may be used to retrieve information about or update + + the state of this conference member. This is the URL of this + member's + + [Get Conference Member](/apis/voice/#operation/getConferenceMember) + endpoint + + and [Modify Conference + Member](/apis/voice/#operation/updateConferenceMember) + + endpoint. + example: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/members/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + mute: + type: boolean + description: >- + Whether or not this member is currently muted. Members who are muted + are still able to hear other participants. + + + If used in a PUT request, updates this member's mute status. Has no + effect if omitted. + example: false + hold: + type: boolean + description: >- + Whether or not this member is currently on hold. Members who are on + hold are not able to hear or speak in the conference. + + + If used in a PUT request, updates this member's hold status. Has no + effect if omitted. + example: false + callIdsToCoach: + nullable: true + type: array + items: + type: string + description: >- + If this member had a value set for `callIdsToCoach` in its + [Conference](/docs/voice/bxml/conference) verb or this list was + added with a previous PUT request to modify the member, this is that + list of calls. + + + If present in a PUT request, modifies the calls that this member is + coaching. Has no effect if omitted. See the documentation for the + [Conference](/docs/voice/bxml/conference) verb for more details + about coaching. + + Note that this will not add the matching calls to the conference; + each call must individually execute a Conference verb to join. + example: + - c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + updateConferenceMember: + type: object + properties: + mute: + type: boolean + description: >- + Whether or not this member is currently muted. Members who are muted + are still able to hear other participants. + + + Updates this member's mute status. Has no effect if omitted. + example: false + hold: + type: boolean + description: >- + Whether or not this member is currently on hold. Members who are on + hold are not able to hear or speak in the conference. + + + Updates this member's hold status. Has no effect if omitted. + example: false + callIdsToCoach: + nullable: true + type: array + items: + type: string + description: >- + If this member had a value set for `callIdsToCoach` in its + [Conference](/docs/voice/bxml/conference) verb or this list was + added with a previous PUT request to modify the member, this is that + list of calls. + + + Modifies the calls that this member is coaching. Has no effect if + omitted. See the documentation for the + [Conference](/docs/voice/bxml/conference) verb for more details + about coaching. + + + Note that this will not add the matching calls to the conference; + each call must individually execute a Conference verb to join. + example: + - c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + conferenceRecordingMetadata: + type: object + properties: + accountId: + $ref: '#/components/schemas/accountId' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + recordingId: + $ref: '#/components/schemas/recordingId' + duration: + $ref: '#/components/schemas/duration' + channels: + $ref: '#/components/schemas/channels' + startTime: + $ref: '#/components/schemas/startTime' + endTime: + $ref: '#/components/schemas/endTime' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + status: + $ref: '#/components/schemas/status' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + machineDetectionConfiguration: + type: object + description: >- + The machine detection request used to perform machine detection on the + call. + properties: + mode: + $ref: '#/components/schemas/machineDetectionModeEnum' + detectionTimeout: + nullable: true + type: number + format: double + description: >- + The timeout used for the whole operation, in seconds. If no + + result is determined in this period, a callback with a `timeout` + result + + is sent. + default: 15 + example: 15 + silenceTimeout: + nullable: true + type: number + format: double + description: >- + If no speech is detected in this period, a callback with a 'silence' + result is sent. + default: 10 + example: 10 + speechThreshold: + nullable: true + type: number + format: double + description: >- + When speech has ended and a result couldn't be determined based + + on the audio content itself, this value is used to determine if the + speaker + + is a machine based on the speech duration. If the length of the + speech + + detected is greater than or equal to this threshold, the result will + be + + 'answering-machine'. If the length of speech detected is below this + threshold, + + the result will be 'human'. + default: 10 + example: 10 + speechEndThreshold: + nullable: true + type: number + format: double + description: >- + Amount of silence (in seconds) before assuming the callee has + finished speaking. + default: 5 + example: 5 + machineSpeechEndThreshold: + nullable: true + type: number + format: double + description: >- + When an answering machine is detected, the amount of silence (in + seconds) before assuming the message has finished playing. + + If not provided it will default to the speechEndThreshold value. + example: 5 + delayResult: + nullable: true + type: boolean + description: >- + If set to 'true' and if an answering machine is detected, the + + 'answering-machine' callback will be delayed until the machine is + done + + speaking, or an end of message tone is detected, or until the + 'detectionTimeout' is exceeded. If false, the 'answering-machine' + + result is sent immediately. + default: false + example: false + callbackUrl: + nullable: true + description: >- + The URL to send the 'machineDetectionComplete' webhook when the + detection is completed. Only for 'async' mode. + type: string + format: uri + maxLength: 2048 + example: https://myServer.example/bandwidth/webhooks/machineDetectionComplete + callbackMethod: + $ref: '#/components/schemas/callbackMethodEnum' + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + fallbackUrl: + nullable: true + type: string + format: uri + description: >- + A fallback URL which, if provided, will be used to retry the + + machine detection complete webhook delivery in case `callbackUrl` + fails + + to respond + maxLength: 2048 + example: >- + https://myFallbackServer.example/bandwidth/webhooks/machineDetectionComplete + fallbackMethod: + $ref: '#/components/schemas/callbackMethodEnum' + fallbackUsername: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + fallbackPassword: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + transcribeRecording: + type: object + properties: + callbackUrl: + type: string + format: uri + description: >- + The URL to send the + [TranscriptionAvailable](/docs/voice/webhooks/transcriptionAvailable) + + event to. You should not include sensitive or + personally-identifiable + + information in the callbackUrl field! Always use the proper username + and + + password fields for authorization. + example: https://myServer.example/bandwidth/webhooks/transcriptionAvailable + callbackMethod: + $ref: '#/components/schemas/callbackMethodEnum' + username: + type: string + nullable: true + description: Basic auth username. + maxLength: 1024 + example: mySecretUsername + password: + type: string + nullable: true + description: Basic auth password. + maxLength: 1024 + example: mySecretPassword1! + tag: + $ref: '#/components/schemas/tag1' + callbackTimeout: + nullable: true + type: number + format: double + minimum: 1 + maximum: 25 + default: 15 + description: >- + This is the timeout (in seconds) to use when delivering the + + webhook to `callbackUrl`. Can be any numeric value (including + decimals) + + between 1 and 25. + example: 5.5 + detectLanguage: + type: boolean + nullable: true + description: >- + A boolean value to indicate that the recording may not be in + English, and the transcription service will need to detect the + dominant language the recording is in and transcribe accordingly. + Current supported languages are English, French, and Spanish. + default: false + example: true + transcriptionList: + type: object + properties: + transcripts: + type: array + items: + $ref: '#/components/schemas/transcription' + transcriptionMetadata: + nullable: true + type: object + description: If the recording was transcribed, metadata about the transcription + properties: + id: + type: string + description: The unique transcription ID + example: t-387bd648-18f3-4823-9d16-746bca0003c9 + status: + $ref: '#/components/schemas/status' + completedTime: + type: string + description: The time that the transcription was completed + example: '2022-06-13T18:46:29.715Z' + url: + type: string + format: uri + description: The URL of the [transcription](#operation/getCallTranscription) + example: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcription + voiceApiError: + type: object + properties: + type: + type: string + description: + type: string + id: + nullable: true + type: string + answerCallback: + type: object + description: >- + The Answer event is sent to the answerUrl specified in the createCall + request when an outbound call is answered. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + machineDetectionResult: + $ref: '#/components/schemas/machineDetectionResult' + bridgeCompleteCallback: + type: object + description: >- + If the target call leaves the , then this callback is sent to + the bridgeCompleteUrl, and the BXML returned in it is executed on the + call. If this webhook is sent, the Bridge Target Complete webhook is NOT + sent. This callback is also sent if any problem occurs that prevents the + calls to be bridged. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + cause: + $ref: '#/components/schemas/cause' + errorMessage: + $ref: '#/components/schemas/errorMessage' + errorId: + $ref: '#/components/schemas/errorId' + bridgeTargetCompleteCallback: + type: object + description: >- + If the originating call leaves the , then this callback is sent + to the bridgeTargetCompleteUrl, and the BXML returned in it is executed + on the target call. If this webhook is sent, the Bridge Complete webhook + is NOT sent. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + conferenceCreatedCallback: + type: object + description: >- + The Conference Created event is fired whenever a new conference that + specified a callbackUrl is created. The response may be either empty or + a BXML document. Only the following verbs are valid for conferences: + PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, + ResumeRecording. Audio verbs will be heard by all members of the + conference. Recordings capture audio from all members who are not muted + or on hold, as well as any audio verbs that are played into the + conference. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + tag: + $ref: '#/components/schemas/tag1' + conferenceRedirectCallback: + type: object + description: >- + The Conference Redirect event is fired whenever an existing conference + is modified via a POST request made to the /conferences/{conferenceId} + endpoint. The response may be either empty or a BXML document. Only the + following verbs are valid for conferences: PlayAudio, SpeakSentence, + StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio + verbs will be heard by all members of the conference. Recordings capture + audio from all members who are not muted or on hold, as well as any + audio verbs that are played into the conference. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + tag: + $ref: '#/components/schemas/tag1' + conferenceMemberJoinCallback: + type: object + description: >- + The Conference Member Join event is fired whenever a caller joins a + conference that specified a callbackUrl. The response may be either + empty or a BXML document. Only the following verbs are valid for + conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, + PauseRecording, ResumeRecording. Audio verbs will be heard by all + members of the conference. Recordings capture audio from all members who + are not muted or on hold, as well as any audio verbs that are played + into the conference. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + callId: + $ref: '#/components/schemas/callId' + tag: + $ref: '#/components/schemas/tag1' + conferenceMemberExitCallback: + type: object + description: >- + The Conference Member Exit event is fired whenever a caller exits a + conference that specified a callbackUrl. The response may be either + empty or a BXML document. Only the following verbs are valid for + conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, + PauseRecording, ResumeRecording. Audio verbs will be heard by all + members of the conference. Recordings capture audio from all members who + are not muted or on hold, as well as any audio verbs that are played + into the conference. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + callId: + $ref: '#/components/schemas/callId' + tag: + $ref: '#/components/schemas/tag1' + conferenceCompletedCallback: + type: object + description: >- + The Conference Completed event is fired when the last member leaves the + conference. The response to this event may not contain BXML. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + tag: + $ref: '#/components/schemas/tag1' + conferenceRecordingAvailableCallback: + type: object + description: >- + The Conference Recording Available event is sent after a conference + recording has been processed. It indicates that the recording is + available for download. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + conferenceId: + $ref: '#/components/schemas/conferenceId' + name: + $ref: '#/components/schemas/name' + accountId: + $ref: '#/components/schemas/accountId' + recordingId: + $ref: '#/components/schemas/recordingId' + channels: + $ref: '#/components/schemas/channels' + startTime: + $ref: '#/components/schemas/startTime' + endTime: + $ref: '#/components/schemas/endTime' + duration: + $ref: '#/components/schemas/duration' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + tag: + $ref: '#/components/schemas/tag1' + status: + $ref: '#/components/schemas/status' + disconnectCallback: + type: object + description: The Disconnect event is fired when a call ends, for any reason. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + callId: + $ref: '#/components/schemas/callId' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + endTime: + $ref: '#/components/schemas/endTime' + cause: + $ref: '#/components/schemas/cause' + errorMessage: + $ref: '#/components/schemas/errorMessage' + errorId: + $ref: '#/components/schemas/errorId' + tag: + $ref: '#/components/schemas/tag1' + dtmfCallback: + type: object + description: >- + The DTMF event is sent for every digit detected after a + verb is executed. You may not respond to this event with BXML. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + callId: + $ref: '#/components/schemas/callId' + direction: + $ref: '#/components/schemas/callDirectionEnum' + digit: + $ref: '#/components/schemas/digit' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + parentCallId: + $ref: '#/components/schemas/parentCallId' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + tag: + $ref: '#/components/schemas/tag1' + gatherCallback: + type: object + description: >- + The gather event is sent after a verb is executed. Its purpose + is to report the gathered digits to the calling application. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + digits: + $ref: '#/components/schemas/digits' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + parentCallId: + $ref: '#/components/schemas/parentCallId' + terminatingDigit: + $ref: '#/components/schemas/terminatingDigit' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + tag: + $ref: '#/components/schemas/tag1' + initiateCallback: + type: object + description: >- + The Initiate event is fired when an inbound call is received for a + Telephone Number on your Account. It is sent to the URL specified in the + application associated with the location (sip-peer) that the called + telephone number belongs to. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + startTime: + $ref: '#/components/schemas/startTime' + diversion: + $ref: '#/components/schemas/diversion' + stirShaken: + $ref: '#/components/schemas/stirShaken' + machineDetectionCompleteCallback: + type: object + description: >- + This event is sent to the url informed when requesting a machine + detection operation. It contains the machine detection operation result, + which can be: human, answering-machine, silence, timeout, error. This + event is not sent when sync answering machine detection mode is chosen. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + machineDetectionResult: + $ref: '#/components/schemas/machineDetectionResult' + recordingCompleteCallback: + type: object + description: >- + The Record Complete event is sent after a verb has executed if + the call is still active. The BXML returned by this callback is executed + next. When the recording is available for download, a Recording + Available event will be sent. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + parentCallId: + $ref: '#/components/schemas/parentCallId' + recordingId: + $ref: '#/components/schemas/recordingId' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + endTime: + $ref: '#/components/schemas/endTime' + duration: + $ref: '#/components/schemas/duration' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + channels: + $ref: '#/components/schemas/channels' + tag: + $ref: '#/components/schemas/tag1' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + recordingAvailableCallback: + type: object + description: >- + The Recording Available event is sent after a recording has been + processed. It indicates that the recording is available for download. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + parentCallId: + $ref: '#/components/schemas/parentCallId' + recordingId: + $ref: '#/components/schemas/recordingId' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + endTime: + $ref: '#/components/schemas/endTime' + duration: + $ref: '#/components/schemas/duration' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + channels: + $ref: '#/components/schemas/status' + tag: + $ref: '#/components/schemas/tag1' + status: + $ref: '#/components/schemas/status' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + redirectCallback: + type: object + description: >- + The Redirect event is fired when a verb is executed. Its + purpose is to get the next set of verbs from the calling application. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + parentCallId: + $ref: '#/components/schemas/parentCallId' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + transcriptionAvailableCallback: + type: object + description: >- + The Transcription Available event is sent when the recording + transcription is available to be downloaded. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + mediaUrl: + $ref: '#/components/schemas/mediaUrl' + parentCallId: + $ref: '#/components/schemas/parentCallId' + recordingId: + $ref: '#/components/schemas/recordingId' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + endTime: + $ref: '#/components/schemas/endTime' + duration: + $ref: '#/components/schemas/duration' + fileFormat: + $ref: '#/components/schemas/fileFormatEnum' + tag: + $ref: '#/components/schemas/tag1' + transcription: + $ref: '#/components/schemas/transcription' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + transferAnswerCallback: + type: object + description: >- + When processing a verb, this event is sent when a called + party (B-leg) answers. The event is sent to the endpoint specified in + the transferAnswerUrl attribute of the tag that answered. + BXML returned by this callback will be executed for the called party + only. After all BXML has been executed, the called party will be bridged + to the original call. Most BXML verbs are allowed in response to a + transferAnswer event, but some are not allowed. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + transferCompleteCallback: + type: object + description: >- + This event is sent to the transferCompleteUrl of the A-leg's + verb when the transferred call (B-leg) completes. In a simultaneous + ringing scenario, only one B-leg succeeds and this event corresponds to + that successful leg. If none of the calls were answered, the + transferComplete event corresponds to one of the legs. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + tag: + $ref: '#/components/schemas/tag1' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + cause: + $ref: '#/components/schemas/cause' + errorMessage: + $ref: '#/components/schemas/errorMessage' + errorId: + $ref: '#/components/schemas/errorId' + transferDisconnectCallback: + type: object + description: >- + This event is sent to the transferDisconnectUrl of each + tag when its respective call leg ends for any reason. The event is sent + in the normal case, when the transferred leg is answered and later hung + up, but is also sent if the new leg was never answered in the first + place, if it was rejected, and if the original call leg hung up before + the transferred leg. + properties: + eventType: + $ref: '#/components/schemas/eventType' + eventTime: + $ref: '#/components/schemas/eventTime' + accountId: + $ref: '#/components/schemas/accountId' + applicationId: + $ref: '#/components/schemas/applicationId' + from: + $ref: '#/components/schemas/from' + to: + $ref: '#/components/schemas/to' + direction: + $ref: '#/components/schemas/callDirectionEnum' + callId: + $ref: '#/components/schemas/callId' + callUrl: + $ref: '#/components/schemas/callUrl' + parentCallId: + $ref: '#/components/schemas/parentCallId' + enqueuedTime: + $ref: '#/components/schemas/enqueuedTime' + startTime: + $ref: '#/components/schemas/startTime' + answerTime: + $ref: '#/components/schemas/answerTime' + endTime: + $ref: '#/components/schemas/endTime' + tag: + $ref: '#/components/schemas/tag1' + transferCallerId: + $ref: '#/components/schemas/transferCallerId' + transferTo: + $ref: '#/components/schemas/transferTo' + cause: + $ref: '#/components/schemas/cause' + errorMessage: + $ref: '#/components/schemas/errorMessage' + errorId: + $ref: '#/components/schemas/errorId' + eventType: + type: string + description: >- + The event type, value can be one of the following: answer, + bridgeComplete, bridgeTargetComplete, conferenceCreated, + conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, + conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, + gather, initiate, machineDetectionComplete, recordingComplete, + recordingAvailable, redirect, transcriptionAvailable, transferAnswer, + transferComplete, transferDisconnect. + example: bridgeComplete + eventTime: + type: string + format: date-time + description: >- + The approximate UTC date and time when the event was generated by the + Bandwidth server, in ISO 8601 format. This may not be exactly the time + of event execution. + example: '2022-06-17T22:19:40.375Z' + accountId: + type: string + description: The user account associated with the call. + example: '920012' + applicationId: + type: string + description: The id of the application associated with the call. + example: 04e88489-df02-4e34-a0ee-27a91849555f + to: + type: string + description: >- + The phone number that received the call, in E.164 format (e.g. + +15555555555). + example: '+15555555555' + from: + type: string + description: >- + The provided identifier of the caller: can be a phone number in E.164 + format (e.g. +15555555555) or one of Private, Restricted, Unavailable, + or Anonymous. + example: '+15555555555' + conferenceId: + type: string + description: The unique, Bandwidth-generated ID of the conference that was recorded + example: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9 + name: + type: string + description: The user-specified name of the conference that was recorded + example: my-conference-name + recordingId: + type: string + description: The unique ID of this recording + example: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833 + duration: + type: string + description: The duration of the recording in ISO-8601 format + example: PT13.67S + channels: + type: integer + format: int32 + description: >- + Always `1` for conference recordings; multi-channel recordings are not + supported on conferences. + example: 1 + digit: + type: string + description: The digit collected in the call. + example: '2' + digits: + type: string + description: >- + (optional) The digits, letters, and/or symbols entered by the user. The + string is empty if a timeout occurred before any buttons were pressed. + example: '123' + terminatingDigit: + type: string + description: >- + (optional) The digit the user pressed to end the gather. Empty string + value if no terminating digit was pressed. + example: '#' + startTime: + type: string + format: date-time + description: Time the call was started, in ISO 8601 format. + example: '2022-06-17T22:19:40.375Z' + enqueuedTime: + type: string + format: date-time + description: >- + (optional) If call queueing is enabled and this is an outbound call, + time the call was queued, in ISO 8601 format. + example: '2022-06-17T22:20:00.000Z' + nullable: true + answerTime: + type: string + format: date-time + description: Time the call was answered, in ISO 8601 format. + example: '2022-06-17T22:20:00.000Z' + nullable: true + endTime: + type: string + format: date-time + description: The time that the recording ended in ISO-8601 format + example: '2022-06-17T22:20:00.000Z' + status: + type: string + description: >- + The current status of the process. For recording, current possible + values are 'processing', 'partial', 'complete', 'deleted', and 'error'. + For transcriptions, current possible values are 'none', 'processing', + 'available', 'error', 'timeout', 'file-size-too-big', and + 'file-size-too-small'. Additional states may be added in the future, so + your application must be tolerant of unknown values. + example: completed + transferCallerId: + type: string + description: >- + The phone number used as the from field of the B-leg call, in E.164 + format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or + Unavailable. + example: '+15555555555' + transferTo: + type: string + description: >- + The phone number used as the to field of the B-leg call, in E.164 format + (e.g. +15555555555). + example: +15555555555) + mediaUrl: + nullable: true + type: string + format: uri + description: >- + The URL that can be used to download the recording. Only present if the + recording is finished and may be downloaded. + example: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media + callId: + type: string + description: The call id associated with the event. + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + callUrl: + type: string + description: The URL of the call associated with the event. + example: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + parentCallId: + type: string + description: >- + (optional) If the event is related to the B leg of a , the + call id of the original call leg that executed the . + Otherwise, this field will not be present. + example: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d + tag1: + type: string + description: >- + (optional) The tag specified on call creation. If no tag was specified + or it was previously cleared, this field will not be present. + example: exampleTag + nullable: true + cause: + type: string + description: >- + Reason the call failed - hangup, busy, timeout, cancel, rejected, + callback-error, invalid-bxml, application-error, account-limit, + node-capacity-exceeded, error, or unknown. + example: busy + errorMessage: + type: string + description: >- + Text explaining the reason that caused the call to fail in case of + errors. + example: >- + Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged + with another call + nullable: true + errorId: + type: string + description: Bandwidth's internal id that references the error event. + example: 4642074b-7b58-478b-96e4-3a60955c6765 + nullable: true + machineDetectionResult: + type: object + description: >- + (optional) if machine detection was requested in sync mode, the result + will be specified here. Possible values are the same as the async + counterpart: Machine Detection Complete + properties: + value: + type: string + description: >- + Possible values are answering-machine, human, silence, timeout, or + error. + example: answering-machine + duration: + type: string + description: The amount of time it took to determine the result. + example: PT4.9891287S + nullable: true + diversion: + type: object + properties: + reason: + type: string + description: >- + The reason for the diversion. Common values: unknown, user-busy, + no-answer, unavailable, unconditional, time-of-day, do-not-disturb, + deflection, follow-me, out-of-service, away. + example: unavailable + privacy: + type: string + description: off or full + example: 'off' + screen: + type: string + description: >- + No if the number was provided by the user, yes if the number was + provided by the network + example: 'no' + counter: + type: string + description: The number of diversions that have occurred + example: '2' + limit: + type: string + description: The maximum number of diversions allowed for this session + example: '3' + unknown: + type: string + description: >- + The normal list of values is not exhaustive. Your application must + be tolerant of unlisted keys and unlisted values of those keys. + example: unknownValue + origTo: + type: string + description: >- + Always present. Indicates the last telephone number that the call + was diverted from. + example: '+15558884444' + transcription: + type: object + properties: + text: + type: string + description: The transcribed text + example: Nice talking to you, friend! + confidence: + type: number + format: double + description: >- + The confidence on the recognized content, ranging from `0.0` to + `1.0` with `1.0` being the highest confidence. + example: 0.9 + stirShaken: + type: object + properties: + verstat: + type: string + description: >- + (optional) The verification status indicating whether the + verification was successful or not. Possible values are + TN-Verification-Passed and TN-Verification-Failed. + example: Tn-Verification-Passed + attestationIndicator: + type: string + description: >- + (optional) The attestation level verified by Bandwidth. Possible + values are A (full), B (partial) or C (gateway). + example: A + originatingId: + type: string + description: (optional) A unique origination identifier. + example: 99759086-1335-11ed-9bcf-5f7d464e91af + codeRequest: + type: object + properties: + to: + type: string + description: The phone number to send the mfa code to. + pattern: ^\+[1-9]\d{1,14}$ + example: '+19195551234' + from: + type: string + description: The application phone number, the sender of the mfa code. + pattern: ^\+[1-9]\d{1,14}$ + maxLength: 32 + example: '+19195554321' + applicationId: + type: string + description: The application unique ID, obtained from Bandwidth. + maxLength: 50 + example: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1 + scope: + type: string + description: >- + An optional field to denote what scope or action the mfa code is + addressing. If not supplied, defaults to "2FA". + maxLength: 25 + example: 2FA + message: + type: string + description: >- + The message format of the mfa code. There are three values that the + system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" + and "{NAME} value template are optional, while "{CODE}" must be + supplied. As the name would suggest, code will be replace with the + actual mfa code. Name is replaced with the application name, + configured during provisioning of mfa. The scope value is the same + value sent during the call and partitioned by the server. + maxLength: 2048 + example: Your temporary {NAME} {SCOPE} code is {CODE} + digits: + type: integer + description: >- + The number of digits for your mfa code. The valid number ranges + from 2 to 8, inclusively. + minimum: 4 + maximum: 8 + example: 6 + required: + - to + - from + - applicationId + - message + - digits + voiceCodeResponse: + type: object + properties: + callId: + type: string + description: Programmable Voice API Call ID. + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + messagingCodeResponse: + type: object + properties: + messageId: + type: string + description: Messaging API Message ID. + example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 + verifyCodeRequest: + type: object + properties: + to: + type: string + description: The phone number to send the mfa code to. + pattern: ^\+[1-9]\d{1,14}$ + example: '+19195551234' + scope: + type: string + description: >- + An optional field to denote what scope or action the mfa code is + addressing. If not supplied, defaults to "2FA". + example: 2FA + expirationTimeInMinutes: + type: number + description: >- + The time period, in minutes, to validate the mfa code. By setting + this to 3 minutes, it will mean any code generated within the last 3 + minutes are still valid. The valid range for expiration time is + between 0 and 15 minutes, exclusively and inclusively, respectively. + minimum: 1 + maximum: 15 + example: 3 + code: + type: string + description: The generated mfa code to check if valid. + minLength: 4 + maxLength: 8 + example: '123456' + required: + - to + - expirationTimeInMinutes + - code + verifyCodeResponse: + type: object + properties: + valid: + type: boolean + description: Whether or not the supplied code is valid. + example: true + mfaRequestError: + type: object + properties: + error: + type: string + description: A message describing the error with your request. + example: 400 Request is malformed or invalid + requestId: + type: string + description: The associated requestId from AWS. + example: 354cc8a3-6701-461e-8fa7-8671703dd898 + mfaUnauthorizedRequestError: + type: object + properties: + message: + type: string + description: Unauthorized + example: Unauthorized + mfaForbiddenRequestError: + type: object + properties: + message: + type: string + description: >- + The message containing the reason behind the request being + forbidden. + example: Missing Authentication Token + lookupStatusEnum: + type: string + description: >- + The status of the request (IN_PROGRESS, COMPLETE, PARTIAL_COMPLETE, or + FAILED). + enum: + - IN_PROGRESS + - COMPLETE + - PARTIAL_COMPLETE + - FAILED + example: COMPLETE + lookupRequest: + type: object + description: Create phone number lookup request. + properties: + tns: + type: array + items: + type: string + required: + - tns + createLookupResponse: + type: object + description: >- + The request has been accepted for processing but not yet finished and in + a terminal state (COMPLETE, PARTIAL_COMPLETE, or FAILED). + properties: + requestId: + type: string + description: The phone number lookup request ID from Bandwidth. + status: + $ref: '#/components/schemas/lookupStatusEnum' + lookupStatus: + type: object + description: >- + If requestId exists, the result for that request is returned. See the + Examples for details on the various responses that you can receive. + Generally, if you see a Response Code of 0 in a result for a TN, + information will be available for it. Any other Response Code will + indicate no information was available for the TN. + properties: + requestId: + type: string + description: The requestId. + example: 004223a0-8b17-41b1-bf81-20732adf5590 + status: + $ref: '#/components/schemas/lookupStatusEnum' + result: + type: array + description: The carrier information results for the specified telephone number. + items: + $ref: '#/components/schemas/lookupResult' + failedTelephoneNumbers: + type: array + description: The telephone numbers whose lookup failed. + items: + type: string + example: + - '+191955512345' + lookupResult: + type: object + description: Carrier information results for the specified telephone number. + properties: + Response Code: + type: integer + description: Our vendor's response code. + example: 0 + Message: + type: string + description: Message associated with the response code. + example: NOERROR + E.164 Format: + type: string + description: The telephone number in E.164 format. + example: '+19195551234' + Formatted: + type: string + description: The formatted version of the telephone number. + example: (919) 555-1234 + Country: + type: string + description: The country of the telephone number. + example: US + Line Type: + type: string + description: The line type of the telephone number. + example: Mobile + Line Provider: + type: string + description: The messaging service provider of the telephone number. + example: Verizon Wireless + Mobile Country Code: + type: string + description: The first half of the Home Network Identity (HNI). + example: '310' + Mobile Network Code: + type: string + description: The second half of the HNI. + example: '010' + tnLookupRequestError: + type: object + properties: + message: + type: string + description: A description of what validation error occurred. + example: example error message + responses: + createMessageResponse: + description: Accepted + content: + application/json: + schema: + $ref: '#/components/schemas/message' + listMessagesResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/messagesList' + getMediaResponse: + description: OK + content: + application/octet-stream: + schema: + type: string + description: Successful Operation + format: binary + listMediaResponse: + description: OK + headers: + Continuation-Token: + description: Continuation token used to retrieve subsequent media. + schema: + type: string + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/media' + messagingBadRequestError: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingNotAcceptableError: + description: Not Acceptable + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + createMessageBadRequestError: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/createMessageRequestError' + messagingUnauthorizedError: + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingForbiddenError: + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingNotFoundError: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingInvalidMediaTypeError: + description: Unsupported Media Type + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingTooManyRequestsError: + description: Too Many Requests + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + messagingInternalServerError: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/messagingRequestError' + createCallResponse: + description: Call Successfully Created + headers: + Location: + description: The URL for further interactions with this call + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/createCallResponse' + examples: + createCall Response: + $ref: '#/components/examples/createCallResponseExample' + getCallStateResponse: + description: Call found + content: + application/json: + schema: + $ref: '#/components/schemas/callState' + getStatisticsResponse: + description: Statistics Found + content: + application/json: + schema: + $ref: '#/components/schemas/accountStatistics' + listCallRecordingsResponse: + description: Recordings retrieved successfully + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/callRecordingMetadata' + getCallRecordingResponse: + description: Recording found + content: + application/json: + schema: + $ref: '#/components/schemas/callRecordingMetadata' + downloadRecordingMediaResponse: + description: Media found + content: + audio/vnd.wave: + schema: + type: string + format: binary + audio/mpeg: + schema: + type: string + format: binary + getCallTranscriptionResponse: + description: Transcription found + content: + application/json: + schema: + $ref: '#/components/schemas/transcriptionList' + listConferencesResponse: + description: Conferences retrieved successfully + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/conference' + examples: + listConferences Response: + $ref: '#/components/examples/listConferencesResponseExample' + getConferenceResponse: + description: Conferences retrieved successfully + content: + application/json: + schema: + $ref: '#/components/schemas/conference' + getConferenceMemberResponse: + description: Conference member found + content: + application/json: + schema: + $ref: '#/components/schemas/conferenceMember' + listConferenceRecordingsResponse: + description: Conference recordings retrieved successfully + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/conferenceRecordingMetadata' + getConferenceRecordingResponse: + description: Conference recording found + content: + application/json: + schema: + $ref: '#/components/schemas/conferenceRecordingMetadata' + voiceBadRequestError: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + badRequestErrorExample: + $ref: '#/components/examples/voiceBadRequestErrorExample' + voiceUnauthorizedError: + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + unauthorizedErrorExample: + $ref: '#/components/examples/voiceUnauthorizedErrorExample' + voiceForbiddenError: + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + forbiddenErrorExample: + $ref: '#/components/examples/voiceForbiddenErrorExample' + voiceNotFoundError: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + notFoundErrorExample: + $ref: '#/components/examples/voiceNotFoundErrorExample' + voiceNotAllowedError: + description: Method Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + notAllowedErrorExample: + $ref: '#/components/examples/voiceNotAllowedErrorExample' + voiceConflictError: + description: Conflict + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + conflictErrorExample: + $ref: '#/components/examples/voiceConflictErrorExample' + voiceUnsupportedMediaTypeError: + description: Unsupported Media Type + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + tooManyRequestsErrorExample: + $ref: '#/components/examples/voiceUnsupportedMediaTypeErrorExample' + voiceTooManyRequestsError: + description: Too Many Requests + headers: + Retry-After: + description: When you should try your request again. + schema: + type: string + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + tooManyRequestsErrorExample: + $ref: '#/components/examples/voiceTooManyRequestsErrorExample' + voiceInternalServerError: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/voiceApiError' + examples: + internalServerErrorExample: + $ref: '#/components/examples/voiceInternalServerErrorExample' + voiceCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/voiceCodeResponse' + messagingCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/messagingCodeResponse' + verifyCodeResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/verifyCodeResponse' + mfaBadRequestError: + description: Bad Request + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/mfaRequestError' + mfaUnauthorizedError: + description: Unauthorized + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/mfaUnauthorizedRequestError' + mfaForbiddenError: + description: Forbidden + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/mfaForbiddenRequestError' + mfaTooManyRequestsError: + description: Too Many Requests + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/mfaRequestError' + mfaInternalServerError: + description: Internal Server Error + headers: {} + content: + application/json: + schema: + $ref: '#/components/schemas/mfaRequestError' + createLookupResponse: + description: Accepted + content: + application/json: + schema: + $ref: '#/components/schemas/createLookupResponse' + examples: + lookupResponseExample: + $ref: '#/components/examples/lookupInProgressExample' + getLookupResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/lookupStatus' + examples: + lookupInProgressExample: + $ref: '#/components/examples/lookupInProgressExample' + lookupFailedExample: + $ref: '#/components/examples/lookupFailedExample' + lookupSingleNumberCompleteExample: + $ref: '#/components/examples/lookupSingleNumberCompleteExample' + lookupMultipleNumbersCompleteExample: + $ref: '#/components/examples/lookupMultipleNumbersCompleteExample' + lookupMultipleNumbersPartialCompleteExample: + $ref: >- + #/components/examples/lookupMultipleNumbersPartialCompleteExample + lookupSingleNumberCompleteNoInfoExample: + $ref: '#/components/examples/lookupSingleNumberCompleteNoInfoExample' + tnLookupBadRequestError: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + badRequest: + summary: Example Bad Request Error + value: + message: 'Some tns do not match e164 format: 1234' + tnLookupUnauthorizedError: + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + unauthorized: + summary: Example Unauthorized Error + value: + message: Unauthorized + tnLookupForbiddenError: + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + forbidden: + summary: Example Forbidden Error + value: + message: >- + Authorization header requires 'Credential' parameter. + Authorization header requires 'Signature' parameter. + Authorization header requires 'SignedHeaders' parameter. + Authorization header requires existence of either a + 'X-Amz-Date' or a 'Date' header. Authorization=Basic + Y2tvZloPTGhHgywYIzGlcGVlcGvvcGovYTIGIt==' + tnLookupMediaTypeError: + description: Unsupported Media Type + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + mediaType: + summary: Example Unsupported Media Type Error + value: + message: Content-Type must be application/json. + tnLookupTooManyRequestsError: + description: Too Many Requests + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + mediaType: + summary: Example Too Many Requests Error + value: + message: Too many requests. + tnLookupInternalServerError: + description: Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/tnLookupRequestError' + examples: + mediaType: + summary: Example Internal Server Error Error + value: + message: Request has not been passed further. + parameters: + accountId: + in: path + name: accountId + required: true + schema: + type: string + description: Your Bandwidth Account ID. + example: '9900000' + mediaId: + in: path + name: mediaId + required: true + description: Media ID to retrieve. + example: 14762070468292kw2fuqty55yp2b2/0/bw.png + schema: + type: string + contentType: + in: header + name: Content-Type + style: simple + explode: false + description: The media type of the entity-body. + example: audio/wav + schema: + type: string + cacheControl: + in: header + name: Cache-Control + style: simple + explode: false + description: >- + General-header field is used to specify directives that MUST be obeyed + by all caching mechanisms along the request/response chain. + example: no-cache + schema: + type: string + continuationToken: + in: header + name: Continuation-Token + description: Continuation token used to retrieve subsequent media. + example: >- + 1XEi2tsFtLo1JbtLwETnM1ZJ+PqAa8w6ENvC5QKvwyrCDYII663Gy5M4s40owR1tjkuWUif6qbWvFtQJR5/ipqbUnfAqL254LKNlPy6tATCzioKSuHuOqgzloDkSwRtX0LtcL2otHS69hK343m+SjdL+vlj71tT39 + schema: + type: string + messageId: + in: query + name: messageId + required: false + description: >- + The ID of the message to search for. Special characters need to be + encoded using URL encoding. Message IDs could come in different formats, + e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and + 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that + you must include at least one query parameter. + example: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 + schema: + type: string + sourceTn: + in: query + name: sourceTn + required: false + description: >- + The phone number that sent the message. Accepted values are: a single + full phone number a comma separated list of full phone numbers (maximum + of 10) or a single partial phone number (minimum of 5 characters e.g. + '%2B1919'). + example: '%2B15554443333' + schema: + type: string + destinationTn: + in: query + name: destinationTn + required: false + description: >- + The phone number that received the message. Accepted values are: a + single full phone number a comma separated list of full phone numbers + (maximum of 10) or a single partial phone number (minimum of 5 + characters e.g. '%2B1919'). + example: '%2B15554443333' + schema: + type: string + messageStatus: + in: query + name: messageStatus + required: false + description: >- + The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED + DELIVERED ACCEPTED UNDELIVERED. + schema: + $ref: '#/components/schemas/messageStatusEnum' + messageDirection: + in: query + name: messageDirection + required: false + description: The direction of the message. One of INBOUND OUTBOUND. + schema: + $ref: '#/components/schemas/listMessageDirectionEnum' + carrierName: + in: query + name: carrierName + required: false + description: >- + The name of the carrier used for this message. Possible values include + but are not limited to Verizon and TMobile. Special characters need to + be encoded using URL encoding (i.e. AT&T should be passed as AT%26T). + example: Verizon + schema: + type: string + messageType: + in: query + name: messageType + required: false + description: The type of message. Either sms or mms. + schema: + $ref: '#/components/schemas/messageTypeEnum' + errorCode: + in: query + name: errorCode + required: false + description: The error code of the message. + example: 9902 + schema: + type: integer + fromDateTime: + in: query + name: fromDateTime + required: false + description: >- + The start of the date range to search in ISO 8601 format. Uses the + message receive time. The date range to search in is currently 14 days. + example: 2022-09-14T18:20:16.000Z + schema: + type: string + toDateTime: + in: query + name: toDateTime + required: false + description: >- + The end of the date range to search in ISO 8601 format. Uses the message + receive time. The date range to search in is currently 14 days. + example: 2022-09-14T18:20:16.000Z + schema: + type: string + campaignId: + in: query + name: campaignId + required: false + description: The campaign ID of the message. + example: CJEUMDK + schema: + type: string + sort: + in: query + name: sort + required: false + description: >- + The field and direction to sort by combined with a colon. Direction is + either asc or desc. + example: sourceTn:desc + schema: + type: string + pageToken: + in: query + name: pageToken + required: false + description: A base64 encoded value used for pagination of results. + example: gdEewhcJLQRB5 + schema: + type: string + limit: + in: query + name: limit + required: false + description: >- + The maximum records requested in search result. Default 100. The sum of + limit and after cannot be more than 10000. + schema: + type: integer + example: 50 + limitTotalCount: + in: query + name: limitTotalCount + required: false + description: >- + When set to true, the response's totalCount field will have a maximum + value of 10,000. When set to false, or excluded, this will give an + accurate totalCount of all messages that match the provided filters. If + you are experiencing latency, try using this parameter to limit your + results. + example: true + schema: + type: boolean + callId: + name: callId + in: path + required: true + schema: + type: string + description: Programmable Voice API Call ID. + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + recordingId: + name: recordingId + in: path + required: true + schema: + type: string + description: Programmable Voice API Recording ID. + example: r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + conferenceId: + name: conferenceId + in: path + required: true + schema: + type: string + description: Programmable Voice API Conference ID. + example: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9 + memberId: + name: memberId + in: path + required: true + schema: + type: string + description: Programmable Voice API Conference Member ID. + example: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + to: + name: to + in: query + required: false + schema: + type: string + description: Filter results by the `to` field. + example: '%2b19195551234' + from: + name: from + in: query + required: false + schema: + type: string + description: Filter results by the `from` field. + example: '%2b19195554321' + name: + name: name + in: query + required: false + schema: + type: string + description: Filter results by the `name` field. + example: my-custom-name + minCreatedTime: + name: minCreatedTime + in: query + required: false + schema: + type: string + description: >- + Filter results to conferences which have a `createdTime` after or at + `minCreatedTime` (in ISO8601 format). + example: '2022-06-21T19:13:21Z' + maxCreatedTime: + name: maxCreatedTime + in: query + required: false + schema: + type: string + description: >- + Filter results to conferences which have a `createdTime` before or at + `maxCreatedTime` (in ISO8601 format). + example: '2022-06-21T19:13:21Z' + minStartTime: + name: minStartTime + in: query + required: false + schema: + type: string + description: >- + Filter results to recordings which have a `startTime` after or including + `minStartTime` (in ISO8601 format). + example: '2022-06-21T19:13:21Z' + maxStartTime: + name: maxStartTime + in: query + required: false + schema: + type: string + description: >- + Filter results to recordings which have a `startTime` before + `maxStartTime` (in ISO8601 format). + example: '2022-06-21T19:13:21Z' + pageSize: + name: pageSize + in: query + required: false + schema: + type: integer + format: int32 + minimum: 1 + maximum: 1000 + default: 1000 + description: Specifies the max number of conferences that will be returned. + example: 500 + pageToken1: + name: pageToken + in: query + required: false + schema: + type: string + description: >- + Not intended for explicit use. To use pagination, follow the links in + the `Link` header of the response, as indicated in the endpoint + description. + requestId: + name: requestId + in: path + required: true + schema: + type: string + description: The phone number lookup request ID from Bandwidth. + example: 004223a0-8b17-41b1-bf81-20732adf5590 + requestBodies: + createMessageRequest: + content: + application/json: + schema: + $ref: '#/components/schemas/messageRequest' + required: true + uploadMediaRequest: + content: + application/json: + schema: + type: string + format: binary + application/ogg: + schema: + type: string + format: binary + application/pdf: + schema: + type: string + format: binary + application/rtf: + schema: + type: string + format: binary + application/zip: + schema: + type: string + format: binary + application/x-tar: + schema: + type: string + format: binary + application/xml: + schema: + type: string + format: binary + application/gzip: + schema: + type: string + format: binary + application/x-bzip2: + schema: + type: string + format: binary + application/x-gzip: + schema: + type: string + format: binary + application/smil: + schema: + type: string + format: binary + application/javascript: + schema: + type: string + format: binary + audio/mp4: + schema: + type: string + format: binary + audio/mpeg: + schema: + type: string + format: binary + audio/ogg: + schema: + type: string + format: binary + audio/flac: + schema: + type: string + format: binary + audio/webm: + schema: + type: string + format: binary + audio/wav: + schema: + type: string + format: binary + audio/amr: + schema: + type: string + format: binary + audio/3gpp: + schema: + type: string + format: binary + image/bmp: + schema: + type: string + format: binary + image/gif: + schema: + type: string + format: binary + image/jpeg: + schema: + type: string + format: binary + image/pjpeg: + schema: + type: string + format: binary + image/png: + schema: + type: string + format: binary + image/svg+xml: + schema: + type: string + format: binary + image/tiff: + schema: + type: string + format: binary + image/webp: + schema: + type: string + format: binary + image/x-icon: + schema: + type: string + format: binary + text/css: + schema: + type: string + format: binary + text/csv: + schema: + type: string + format: binary + text/calendar: + schema: + type: string + format: binary + text/plain: + schema: + type: string + format: binary + text/javascript: + schema: + type: string + format: binary + text/vcard: + schema: + type: string + format: binary + text/vnd.wap.wml: + schema: + type: string + format: binary + text/xml: + schema: + type: string + format: binary + video/avi: + schema: + type: string + format: binary + video/mp4: + schema: + type: string + format: binary + video/mpeg: + schema: + type: string + format: binary + video/ogg: + schema: + type: string + format: binary + video/quicktime: + schema: + type: string + format: binary + video/webm: + schema: + type: string + format: binary + video/x-ms-wmv: + schema: + type: string + format: binary + required: true + createCallRequest: + description: JSON object containing information to create an outbound call + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/createCall' + updateCallRequest: + description: >- + JSON object containing information to redirect an existing call to a new + BXML document + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/updateCall' + updateCallBxmlRequest: + required: true + content: + application/xml: + schema: + type: string + description: A valid BXML document to replace the call's current BXML. + examples: + speakSentence: + summary: Speak Sentence + value: |- + + + This is a test sentence. + + redirectUrl: + summary: Redirect + value: |- + + + + + updateCallRecordingRequest: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/updateCallRecording' + transcribeRecordingRequest: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/transcribeRecording' + updateConferenceRequest: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/updateConference' + updateConferenceBxmlRequest: + required: true + content: + application/xml: + schema: + type: string + description: A valid BXML document to replace the call's current BXML. + examples: + stopRecording: + summary: Stop Recording + value: |- + + + + + updateConferenceMemberRequest: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/updateConferenceMember' + codeRequest: + description: MFA code request body. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/codeRequest' + codeVerify: + description: MFA code verify request body. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/verifyCodeRequest' + createLookupRequest: + description: Phone number lookup request. + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/lookupRequest' + examples: + singleNumberRequestExample: + $ref: '#/components/examples/singleNumberRequestExample' + multipleNumberRequestExample: + $ref: '#/components/examples/multipleNumberRequestExample' + securitySchemes: + Basic: + type: http + scheme: basic + description: |- + Basic authentication is a simple authentication scheme built into the + HTTP protocol. To use it, send your HTTP requests with an Authorization + header that contains the word Basic followed by a space and a + base64-encoded string `username:password`Example: `Authorization: Basic + ZGVtbZpwQDU1dzByZA==` + callbacks: + inboundCallback: + '{inboundCallbackUrl}': + post: + requestBody: + required: true + description: Inbound Message Callback Payload + content: + application/json: + schema: + $ref: '#/components/schemas/inboundMessageCallback' + responses: + '200': + description: OK + statusCallback: + '{statusCallbackUrl}': + post: + requestBody: + required: true + description: Status Callback Payload + content: + application/json: + schema: + type: object + oneOf: + - $ref: '#/components/schemas/messageSendingCallback' + - $ref: '#/components/schemas/messageDeliveredCallback' + - $ref: '#/components/schemas/messageFailedCallback' + responses: + '200': + description: OK + examples: + createCallResponseExample: + summary: Example of a createCall Response + value: + applicationId: 04e88489-df02-4e34-a0ee-27a91849555f + accountId: '9900000' + callId: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + to: '+19195551234' + from: '+19195554312' + enqueuedTime: '2022-06-16T13:15:07.160Z' + callUrl: >- + https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + callTimeout: 30 + callbackTimeout: 15 + tag: My custom tag value + answerMethod: POST + answerUrl: https://myServer.example/bandwidth/webhooks/answer + answerFallbackMethod: POST + disconnectMethod: POST + disconnectUrl: https://myServer.example/bandwidth/webhooks/disconnect + username: mySecretUsername + password: '*****' + fallbackUsername: mySecretUsername + fallbackPassword: '*****' + priority: 5 + listConferencesResponseExample: + summary: Example of a listConferences Response + value: + - id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9 + name: my-conference-name + createdTime: '2022-06-17T22:19:40.375Z' + completedTime: '2022-06-17T22:20:00.000Z' + conferenceEventUrl: https://myServer.example/bandwidth/webhooks/conferenceEvent + conferenceEventMethod: POST + tag: my custom tag + voiceBadRequestErrorExample: + summary: Example of a Bad Request (400) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceUnauthorizedErrorExample: + summary: Example of an Unauthorized (401) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceForbiddenErrorExample: + summary: Example of a Forbidden (403) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceNotFoundErrorExample: + summary: Example of a Not Found (404) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceNotAllowedErrorExample: + summary: Example of a Not Allowed (405) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceConflictErrorExample: + summary: Example of a Conflict (409) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceUnsupportedMediaTypeErrorExample: + summary: Example of an Unsupported Media Type (415) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceTooManyRequestsErrorExample: + summary: Example of a Too Many Requests (429) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + voiceInternalServerErrorExample: + summary: Example of an Internal Server (500) Error + value: + type: validation + description: 'Invalid answerUrl: only http and https are allowed.' + singleNumberRequestExample: + summary: Example Number Lookup Request for One Number + value: + tns: + - '+19195551234' + multipleNumberRequestExample: + summary: Example Number Lookup Request for Multiple Numbers + value: + tns: + - '+19195551234' + - '+19195554321' + lookupInProgressExample: + summary: Example Lookup In Progress Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: IN_PROGRESS + lookupFailedExample: + summary: Example Lookup Failed Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: FAILED + failedTelephoneNumbers: + - '+191955512345' + lookupSingleNumberCompleteExample: + summary: Example Single Number Lookup Complete Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: COMPLETE + result: + - Response Code: 0 + Message: NOERROR + E.164 Format: '+19195551234' + Formatted: (919) 555-1234 + Country: US + Line Type: Mobile + Line Provider: Verizon Wireless + Mobile Country Code: '310' + Mobile Network Code: '010' + lookupMultipleNumbersCompleteExample: + summary: Example Multiple Numbers Lookup Complete Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: COMPLETE + result: + - Response Code: 0 + Message: NOERROR + E.164 Format: '+19195551234' + Formatted: (919) 555-1234 + Country: US + Line Type: Mobile + Line Provider: Verizon Wireless + Mobile Country Code: '310' + Mobile Network Code: '010' + - Response Code: 0 + Message: NOERROR + E.164 Format: '+19195554321' + Formatted: (919) 555-4321 + Country: US + Line Type: Mobile + Line Provider: T-Mobile USA + Mobile Country Code: '310' + Mobile Network Code: '160' + lookupMultipleNumbersPartialCompleteExample: + summary: Example Multiple Numbers Lookup Partial Complete Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: PARTIAL_COMPLETE + result: + - Response Code: 0 + Message: NOERROR + E.164 Format: '+19195551234' + Formatted: (919) 555-1234 + Country: US + Line Type: Mobile + Line Provider: Verizon Wireless + Mobile Country Code: '310' + Mobile Network Code: '010' + failedTelephoneNumbers: + - '+191955512345' + lookupSingleNumberCompleteNoInfoExample: + summary: Example Single Number Lookup Complete with No Information Response + value: + requestId: 004223a0-8b17-41b1-bf81-20732adf5590 + status: COMPLETE + result: + - Response Code: 3 + Message: NXDOMAIN + E.164 Format: '+19195550000' + Formatted: (919) 555-0000 + Country: US diff --git a/custom_templates/Gemfile.mustache b/custom_templates/Gemfile.mustache new file mode 100644 index 00000000..ed673756 --- /dev/null +++ b/custom_templates/Gemfile.mustache @@ -0,0 +1,11 @@ +source 'https://rubygems.org' + +gemspec + +group :development, :test do + gem 'rake', '~> 13.0.1' + gem 'pry-byebug' + gem 'rubocop', '~> 1.52.0' + gem 'webmock', '~> 3.18.0' + gem 'simplecov', '~> 0.21.2' +end diff --git a/custom_templates/README.mustache b/custom_templates/README.mustache new file mode 100644 index 00000000..9ca7a51d --- /dev/null +++ b/custom_templates/README.mustache @@ -0,0 +1,173 @@ +# {{gemName}} + +[![Gem Version](https://badge.fury.io/rb/bandwidth-sdk.svg)](https://badge.fury.io/rb/bandwidth-sdk) +[![Tests](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml) +[![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop) + + +| **OS** | **Ruby** | +|:---:|:---:| +| Windows 2019 | 2.7, 3.0, 3.1, 3.2 | +| Windows 2022 | 2.7, 3.0, 3.1, 3.2 | +| Ubuntu 20.04 | 2.7, 3.0, 3.1, 3.2 | +| Ubuntu 22.04 | 2.7, 3.0, 3.1, 3.2 | + +{{moduleName}} - the Ruby gem for the {{appName}} + +# Generated with the command: +`openapi-generator generate -g ruby -i bandwidth.yml -c openapi-config.yml -o ./` + +{{#appDescriptionWithNewLines}} +{{{.}}} +{{/appDescriptionWithNewLines}} + +This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: + +- API version: {{appVersion}} +- Package version: {{gemVersion}} +{{^hideGenerationTimestamp}} +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} +- Build package: {{generatorClass}} +{{#infoUrl}} +For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +## Installation + +### Build a gem + +To build the Ruby code into a gem: + +```shell +gem build {{{gemName}}}.gemspec +``` + +Then either install the gem locally: + +```shell +gem install ./{{{gemName}}}-{{{gemVersion}}}.gem +``` + +(for development, run `gem install --dev ./{{{gemName}}}-{{{gemVersion}}}.gem` to install the development dependencies) + +or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). + +Finally add this to the Gemfile: + + gem '{{{gemName}}}', '~> {{{gemVersion}}}' + +### Install from Git + +If the Ruby gem is hosted at a git repository: https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}, then add the following in the Gemfile: + + gem '{{{gemName}}}', :git => 'https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}.git' + +### Include the Ruby code directly + +Include the Ruby code directly using `-I` as follows: + +```shell +ruby -Ilib script.rb +``` + +## Getting Started + +Please follow the [installation](#installation) procedure and then run the following code: + +```ruby +# Load the gem +require '{{{gemName}}}' +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}} +# Setup authorization +{{{moduleName}}}.configure do |config|{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} + # Configure HTTP basic authorization: {{{name}}} + config.username = 'YOUR_USERNAME' + config.password = 'YOUR_PASSWORD'{{/isBasicBasic}}{{#isBasicBearer}} + # Configure Bearer authorization{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}: {{{name}}} + config.access_token = 'YOUR_BEARER_TOKEN' + # Configure a proc to get access tokens in lieu of the static access_token configuration + config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } {{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} + # Configure API key authorization: {{{name}}} + config.api_key['{{{name}}}'] = 'YOUR API KEY' + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + # config.api_key_prefix['{{{name}}}'] = 'Bearer'{{/isApiKey}}{{#isOAuth}} + # Configure OAuth2 access token for authorization: {{{name}}} + config.access_token = 'YOUR ACCESS TOKEN' + # Configure a proc to get access tokens in lieu of the static access_token configuration + config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } {{/isOAuth}} + {{#isFaraday}} + # Configure faraday connection + config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' } + {{/isFaraday}} +{{/authMethods}}end +{{/hasAuthMethods}} + +api_instance = {{{moduleName}}}::{{{classname}}}.new +{{#requiredParams}} +{{{paramName}}} = {{{vendorExtensions.x-ruby-example}}} # {{{dataType}}} | {{{description}}} +{{/requiredParams}} +{{#optionalParams}} +{{#-first}} +opts = { +{{/-first}} + {{{paramName}}}: {{{vendorExtensions.x-ruby-example}}}{{^-last}},{{/-last}} # {{{dataType}}} | {{{description}}} +{{#-last}} +} +{{/-last}} +{{/optionalParams}} + +begin +{{#summary}} #{{{.}}} +{{/summary}} {{#returnType}}result = {{/returnType}}api_instance.{{{operationId}}}{{#hasParams}}({{#requiredParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-last}}{{#hasRequiredParams}}, {{/hasRequiredParams}}opts{{/-last}}{{/optionalParams}}){{/hasParams}}{{#returnType}} + p result{{/returnType}} +rescue {{{moduleName}}}::ApiError => e + puts "Exception when calling {{classname}}->{{{operationId}}}: #{e}" +end +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{moduleName}}::{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{{summary}}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation for Models + +{{#models}}{{#model}} - [{{moduleName}}::{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +## Documentation for Authorization + +{{^authMethods}}Endpoints do not require authorization.{{/authMethods}} +{{#hasAuthMethods}}Authentication schemes defined for the API:{{/hasAuthMethods}} +{{#authMethods}} +### {{name}} + +{{#isApiKey}} + +- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}} +{{#isBasicBasic}}- **Type**: HTTP basic authentication +{{/isBasicBasic}}{{#isBasicBearer}}- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} +{{/isBasicBearer}}{{#isHttpSignature}}- **Type**: HTTP signature authentication +{{/isHttpSignature}} +{{/isBasic}} +{{#isOAuth}} + +- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorization URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} diff --git a/custom_templates/gem.mustache b/custom_templates/gem.mustache new file mode 100644 index 00000000..ed66ea55 --- /dev/null +++ b/custom_templates/gem.mustache @@ -0,0 +1,99 @@ +=begin +{{> api_info}} +=end + +# Common files +require '{{gemName}}/api_client' +require '{{gemName}}/api_error' +require '{{gemName}}/version' +require '{{gemName}}/configuration' + +# Models +{{^useAutoload}} +{{#models}} +{{#model}} +{{^parent}} +require '{{gemName}}/{{modelPackage}}/{{classFilename}}' +{{/parent}} +{{/model}} +{{/models}} +{{#models}} +{{#model}} +{{#parent}} +require '{{gemName}}/{{modelPackage}}/{{classFilename}}' +{{/parent}} +{{/model}} +{{/models}} +{{/useAutoload}} +{{#useAutoload}} +{{#models}} +{{#model}} +{{moduleName}}.autoload :{{classname}}, '{{gemName}}/{{modelPackage}}/{{classFilename}}' +{{/model}} +{{/models}} +{{/useAutoload}} + +# BXML +require 'bandwidth-sdk/models/bxml/root' +require 'bandwidth-sdk/models/bxml/bxml' +require 'bandwidth-sdk/models/bxml/response' +require 'bandwidth-sdk/models/bxml/verb' +require 'bandwidth-sdk/models/bxml/nestable_verb' +require 'bandwidth-sdk/models/bxml/verbs/bridge' +require 'bandwidth-sdk/models/bxml/verbs/conference' +require 'bandwidth-sdk/models/bxml/verbs/custom_param' +require 'bandwidth-sdk/models/bxml/verbs/forward' +require 'bandwidth-sdk/models/bxml/verbs/gather' +require 'bandwidth-sdk/models/bxml/verbs/hangup' +require 'bandwidth-sdk/models/bxml/verbs/pause_recording' +require 'bandwidth-sdk/models/bxml/verbs/pause' +require 'bandwidth-sdk/models/bxml/verbs/phone_number' +require 'bandwidth-sdk/models/bxml/verbs/play_audio' +require 'bandwidth-sdk/models/bxml/verbs/record' +require 'bandwidth-sdk/models/bxml/verbs/redirect' +require 'bandwidth-sdk/models/bxml/verbs/resume_recording' +require 'bandwidth-sdk/models/bxml/verbs/ring' +require 'bandwidth-sdk/models/bxml/verbs/send_dtmf' +require 'bandwidth-sdk/models/bxml/verbs/sip_uri' +require 'bandwidth-sdk/models/bxml/verbs/speak_sentence' +require 'bandwidth-sdk/models/bxml/verbs/start_gather' +require 'bandwidth-sdk/models/bxml/verbs/start_recording' +require 'bandwidth-sdk/models/bxml/verbs/start_stream' +require 'bandwidth-sdk/models/bxml/verbs/start_transcription' +require 'bandwidth-sdk/models/bxml/verbs/stop_gather' +require 'bandwidth-sdk/models/bxml/verbs/stop_recording' +require 'bandwidth-sdk/models/bxml/verbs/stop_stream' +require 'bandwidth-sdk/models/bxml/verbs/stop_transcription' +require 'bandwidth-sdk/models/bxml/verbs/stream_param' +require 'bandwidth-sdk/models/bxml/verbs/tag' +require 'bandwidth-sdk/models/bxml/verbs/transfer' + +# APIs +{{#apiInfo}} +{{#apis}} +{{^useAutoload}} +require '{{importPath}}' +{{/useAutoload}} +{{#useAutoload}} +{{moduleName}}.autoload :{{classname}}, '{{importPath}}' +{{/useAutoload}} +{{/apis}} +{{/apiInfo}} + +module {{moduleName}} + class << self + # Customize default settings for the SDK using block. + # {{moduleName}}.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default + end + end + end +end diff --git a/custom_templates/gemspec.mustache b/custom_templates/gemspec.mustache new file mode 100644 index 00000000..5442f71b --- /dev/null +++ b/custom_templates/gemspec.mustache @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- + +=begin +{{> api_info}} +=end + +$:.push File.expand_path("../lib", __FILE__) +require "{{gemName}}/version" + +Gem::Specification.new do |s| + s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}" + s.version = {{moduleName}}::VERSION + s.platform = Gem::Platform::RUBY + s.authors = ["{{gemAuthor}}{{^gemAuthor}}OpenAPI-Generator{{/gemAuthor}}"] + s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"] + s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}" + s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}" + s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}" + s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}" + s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.7{{/gemRequiredRubyVersion}}" + + {{#isFaraday}} + s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0' + s.add_runtime_dependency 'faraday-multipart' + {{/isFaraday}} + {{^isFaraday}} + s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1' + {{/isFaraday}} + s.add_runtime_dependency 'ox', '~> 2.4' + + s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0' + + s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? } + s.test_files = `find spec/*`.split("\n") + s.executables = [] + s.require_paths = ["lib"] +end diff --git a/docs/AccountStatistics.md b/docs/AccountStatistics.md new file mode 100644 index 00000000..7786deb4 --- /dev/null +++ b/docs/AccountStatistics.md @@ -0,0 +1,20 @@ +# Bandwidth::AccountStatistics + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **current_call_queue_size** | **Integer** | The number of calls currently enqueued. | [optional] | +| **max_call_queue_size** | **Integer** | The maximum size of the queue before outgoing calls start being rejected. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::AccountStatistics.new( + current_call_queue_size: 0, + max_call_queue_size: 900 +) +``` + diff --git a/docs/AnswerCallback.md b/docs/AnswerCallback.md new file mode 100644 index 00000000..c3989f6b --- /dev/null +++ b/docs/AnswerCallback.md @@ -0,0 +1,44 @@ +# Bandwidth::AnswerCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **machine_detection_result** | [**MachineDetectionResult**](MachineDetectionResult.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::AnswerCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + machine_detection_result: null +) +``` + diff --git a/docs/BridgeCompleteCallback.md b/docs/BridgeCompleteCallback.md new file mode 100644 index 00000000..916ef99f --- /dev/null +++ b/docs/BridgeCompleteCallback.md @@ -0,0 +1,48 @@ +# Bandwidth::BridgeCompleteCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **cause** | **String** | Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. | [optional] | +| **error_message** | **String** | Text explaining the reason that caused the call to fail in case of errors. | [optional] | +| **error_id** | **String** | Bandwidth's internal id that references the error event. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::BridgeCompleteCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + cause: busy, + error_message: Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged with another call, + error_id: 4642074b-7b58-478b-96e4-3a60955c6765 +) +``` + diff --git a/docs/BridgeTargetCompleteCallback.md b/docs/BridgeTargetCompleteCallback.md new file mode 100644 index 00000000..273fd538 --- /dev/null +++ b/docs/BridgeTargetCompleteCallback.md @@ -0,0 +1,42 @@ +# Bandwidth::BridgeTargetCompleteCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::BridgeTargetCompleteCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag +) +``` + diff --git a/docs/CallDirectionEnum.md b/docs/CallDirectionEnum.md new file mode 100644 index 00000000..be53c1e2 --- /dev/null +++ b/docs/CallDirectionEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::CallDirectionEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CallDirectionEnum.new() +``` + diff --git a/docs/CallRecordingMetadata.md b/docs/CallRecordingMetadata.md new file mode 100644 index 00000000..a099923c --- /dev/null +++ b/docs/CallRecordingMetadata.md @@ -0,0 +1,52 @@ +# Bandwidth::CallRecordingMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **channels** | **Integer** | Always `1` for conference recordings; multi-channel recordings are not supported on conferences. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **status** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | +| **transcription** | [**TranscriptionMetadata**](TranscriptionMetadata.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CallRecordingMetadata.new( + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + account_id: 920012, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + to: +15555555555, + from: +15555555555, + transfer_caller_id: +15555555555, + transfer_to: +15555555555), + duration: PT13.67S, + direction: null, + channels: 1, + start_time: 2022-06-17T22:19:40.375Z, + end_time: 2022-06-17T22:20Z, + file_format: null, + status: completed, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media, + transcription: null +) +``` + diff --git a/docs/CallState.md b/docs/CallState.md new file mode 100644 index 00000000..4c4240e3 --- /dev/null +++ b/docs/CallState.md @@ -0,0 +1,52 @@ +# Bandwidth::CallState + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **application_id** | **String** | The application id associated with the call. | [optional] | +| **account_id** | **String** | The account id associated with the call. | [optional] | +| **call_id** | **String** | The programmable voice API call ID. | [optional] | +| **parent_call_id** | **String** | The A-leg call id, set only if this call is the B-leg of a [`<Transfer>`](/docs/voice/bxml/transfer). | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555), or if the call was to a SIP URI, the SIP URI. | [optional] | +| **from** | **String** | The phone number that made the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **state** | **String** | The current state of the call. Current possible values are `queued`, `initiated`, `answered` and `disconnected`. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **stir_shaken** | **Hash<String, String>** | For inbound calls, the Bandwidth STIR/SHAKEN implementation will verify the information provided in the inbound invite request `Identity` header. The verification status is stored in the call state `stirShaken` property as follows. | Property | Description | |:------------------|:------------| | verstat | (optional) The verification status indicating whether the verification was successful or not. Possible values are `TN-Verification-Passed` or `TN-Verification-Failed`. | | attestationIndicator | (optional) The attestation level verified by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` (gateway). | | originatingId | (optional) A unique origination identifier. | Note that these are common properties but that the `stirShaken` object is free form and can contain other key-value pairs. More information: [Understanding STIR/SHAKEN](https://www.bandwidth.com/regulations/stir-shaken). | [optional] | +| **identity** | **String** | The value of the `Identity` header from the inbound invite request. Only present for inbound calls and if the account is configured to forward this header. | [optional] | +| **enqueued_time** | **Time** | The time this call was placed in queue. | [optional] | +| **start_time** | **Time** | The time the call was initiated, in ISO 8601 format. `null` if the call is still in your queue. | [optional] | +| **answer_time** | **Time** | Populated once the call has been answered, with the time in ISO 8601 format. | [optional] | +| **end_time** | **Time** | Populated once the call has ended, with the time in ISO 8601 format. | [optional] | +| **disconnect_cause** | **String** | | Cause | Description | |:------|:------------| | `hangup`| One party hung up the call, a [`<Hangup>`](../../bxml/verbs/hangup.md) verb was executed, or there was no more BXML to execute; it indicates that the call ended normally. | | `busy` | Callee was busy. | | `timeout` | Call wasn't answered before the `callTimeout` was reached. | | `cancel` | Call was cancelled by its originator while it was ringing. | | `rejected` | Call was rejected by the callee. | | `callback-error` | BXML callback couldn't be delivered to your callback server. | | `invalid-bxml` | Invalid BXML was returned in response to a callback. | | `application-error` | An unsupported action was tried on the call, e.g. trying to play a .ogg audio. | | `account-limit` | Account rate limits were reached. | | `node-capacity-exceeded` | System maximum capacity was reached. | | `error` | Some error not described in any of the other causes happened on the call. | | `unknown` | Unknown error happened on the call. | Note: This list is not exhaustive and other values can appear in the future. | [optional] | +| **error_message** | **String** | Populated only if the call ended with an error, with text explaining the reason. | [optional] | +| **error_id** | **String** | Populated only if the call ended with an error, with a Bandwidth internal id that references the error event. | [optional] | +| **last_update** | **Time** | The last time the call had a state update, in ISO 8601 format. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CallState.new( + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + account_id: 9900000, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + to: +19195551234, + from: 19195554321, + direction: null, + state: disconnected, + stir_shaken: {"verstat":"TN-Verification-Passed","attestationIndicator":"A","originatingId":"abc123"}, + identity: eyJhbGciOiJFUzI1NiIsInBwdCI6InNoYWtlbiIsInR5cCI6InBhc3Nwb3J0IiwieDV1IjoiaHR0cHM6Ly9idy1zaGFrZW4tY2VydC1wdWIuczMuYW1hem9uYXdzLmNvbS9iYW5kd2lkdGgtc2hha2VuLWNlcnRfMjAyMzA3MTYucGVtIn0.eyJhdHRlc3QiOiJBIiwiZGVzdCI6eyJ0biI6WyIxOTg0MjgyMDI4MCJdfSwiaWF0IjoxNjU2NTM0MzM2LCJvcmlnIjp7InRuIjoiMTkxOTQ0NDI2ODMifSwib3JpZ2lkIjoiNDk0NTlhOGEtNDJmNi0zNTFjLTkzNjEtYWRmNTdhOWUwOGNhIn0.56un9sRw_uH-sbJvnUsqdevlVxbOVjn8MVlGTlBMicjaZuRRwxfiNp-C9zYCMKTTCbc-QdYPN05F61XNVN4D3w;info=<https://bw-shaken-cert-pub.s3.amazonaws.com/bandwidth-shaken-cert_20230716.pem>;alg=ES256;ppt=shaken, + enqueued_time: 2022-06-16T13:15:07.160Z, + start_time: 2022-06-16T13:15:07.160Z, + answer_time: 2022-06-16T13:15:18.126Z, + end_time: 2022-06-16T13:15:18.314Z, + disconnect_cause: null, + error_message: null, + error_id: null, + last_update: 2022-06-16T13:15:18.314Z +) +``` + diff --git a/docs/CallStateEnum.md b/docs/CallStateEnum.md new file mode 100644 index 00000000..483b4a8c --- /dev/null +++ b/docs/CallStateEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::CallStateEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CallStateEnum.new() +``` + diff --git a/docs/CallbackMethodEnum.md b/docs/CallbackMethodEnum.md new file mode 100644 index 00000000..5f8a72bb --- /dev/null +++ b/docs/CallbackMethodEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::CallbackMethodEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CallbackMethodEnum.new() +``` + diff --git a/docs/CallsApi.md b/docs/CallsApi.md new file mode 100644 index 00000000..36c7f190 --- /dev/null +++ b/docs/CallsApi.md @@ -0,0 +1,304 @@ +# Bandwidth::CallsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_call**](CallsApi.md#create_call) | **POST** /accounts/{accountId}/calls | Create Call | +| [**get_call_state**](CallsApi.md#get_call_state) | **GET** /accounts/{accountId}/calls/{callId} | Get Call State Information | +| [**update_call**](CallsApi.md#update_call) | **POST** /accounts/{accountId}/calls/{callId} | Update Call | +| [**update_call_bxml**](CallsApi.md#update_call_bxml) | **PUT** /accounts/{accountId}/calls/{callId}/bxml | Update Call BXML | + + +## create_call + +> create_call(account_id, create_call) + +Create Call + +Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. Please note: Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::CallsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +create_call = Bandwidth::CreateCall.new({to: '+19195551234', from: '+19195554321', application_id: '1234-qwer-5679-tyui', answer_url: 'https://www.myCallbackServer.example/webhooks/answer'}) # CreateCall | JSON object containing information to create an outbound call + +begin + # Create Call + result = api_instance.create_call(account_id, create_call) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->create_call: #{e}" +end +``` + +#### Using the create_call_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_call_with_http_info(account_id, create_call) + +```ruby +begin + # Create Call + data, status_code, headers = api_instance.create_call_with_http_info(account_id, create_call) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->create_call_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **create_call** | [**CreateCall**](CreateCall.md) | JSON object containing information to create an outbound call | | + +### Return type + +[**CreateCallResponse**](CreateCallResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## get_call_state + +> get_call_state(account_id, call_id) + +Get Call State Information + +Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::CallsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. + +begin + # Get Call State Information + result = api_instance.get_call_state(account_id, call_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->get_call_state: #{e}" +end +``` + +#### Using the get_call_state_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_call_state_with_http_info(account_id, call_id) + +```ruby +begin + # Get Call State Information + data, status_code, headers = api_instance.get_call_state_with_http_info(account_id, call_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->get_call_state_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | + +### Return type + +[**CallState**](CallState.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_call + +> update_call(account_id, call_id, update_call) + +Update Call + +Interrupts and redirects a call to a different URL that should return a BXML document. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::CallsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +update_call = Bandwidth::UpdateCall.new # UpdateCall | JSON object containing information to redirect an existing call to a new BXML document + +begin + # Update Call + api_instance.update_call(account_id, call_id, update_call) +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->update_call: #{e}" +end +``` + +#### Using the update_call_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_call_with_http_info(account_id, call_id, update_call) + +```ruby +begin + # Update Call + data, status_code, headers = api_instance.update_call_with_http_info(account_id, call_id, update_call) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->update_call_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **update_call** | [**UpdateCall**](UpdateCall.md) | JSON object containing information to redirect an existing call to a new BXML document | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## update_call_bxml + +> update_call_bxml(account_id, call_id, body) + +Update Call BXML + +Interrupts and replaces an active call's BXML document. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::CallsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +body = ' + + This is a test sentence. +' # String | + +begin + # Update Call BXML + api_instance.update_call_bxml(account_id, call_id, body) +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->update_call_bxml: #{e}" +end +``` + +#### Using the update_call_bxml_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_call_bxml_with_http_info(account_id, call_id, body) + +```ruby +begin + # Update Call BXML + data, status_code, headers = api_instance.update_call_bxml_with_http_info(account_id, call_id, body) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling CallsApi->update_call_bxml_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **body** | **String** | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/xml +- **Accept**: application/json + diff --git a/docs/CodeRequest.md b/docs/CodeRequest.md new file mode 100644 index 00000000..c9070ceb --- /dev/null +++ b/docs/CodeRequest.md @@ -0,0 +1,28 @@ +# Bandwidth::CodeRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **to** | **String** | The phone number to send the mfa code to. | | +| **from** | **String** | The application phone number, the sender of the mfa code. | | +| **application_id** | **String** | The application unique ID, obtained from Bandwidth. | | +| **scope** | **String** | An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\". | [optional] | +| **message** | **String** | The message format of the mfa code. There are three values that the system will replace \"{CODE}\", \"{NAME}\", \"{SCOPE}\". The \"{SCOPE}\" and \"{NAME} value template are optional, while \"{CODE}\" must be supplied. As the name would suggest, code will be replace with the actual mfa code. Name is replaced with the application name, configured during provisioning of mfa. The scope value is the same value sent during the call and partitioned by the server. | | +| **digits** | **Integer** | The number of digits for your mfa code. The valid number ranges from 2 to 8, inclusively. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CodeRequest.new( + to: +19195551234, + from: +19195554321, + application_id: 66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1, + scope: 2FA, + message: Your temporary {NAME} {SCOPE} code is {CODE}, + digits: 6 +) +``` + diff --git a/docs/Conference.md b/docs/Conference.md new file mode 100644 index 00000000..5ca36db6 --- /dev/null +++ b/docs/Conference.md @@ -0,0 +1,32 @@ +# Bandwidth::Conference + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The Bandwidth-generated conference ID. | [optional] | +| **name** | **String** | The name of the conference, as specified by your application. | [optional] | +| **created_time** | **Time** | The time the conference was initiated, in ISO 8601 format. | [optional] | +| **completed_time** | **Time** | The time the conference was terminated, in ISO 8601 format. | [optional] | +| **conference_event_url** | **String** | The URL to send the conference-related events. | [optional] | +| **conference_event_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **tag** | **String** | The custom string attached to the conference that will be sent with callbacks. | [optional] | +| **active_members** | [**Array<ConferenceMember>**](ConferenceMember.md) | A list of active members of the conference. Omitted if this is a response to the [Get Conferences endpoint](/apis/voice#tag/Conferences/operation/listConferences). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Conference.new( + id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + created_time: 2022-06-17T22:19:40.375Z, + completed_time: 2022-06-17T22:20Z, + conference_event_url: https://myServer.example/bandwidth/webhooks/conferenceEvent, + conference_event_method: null, + tag: my custom tag, + active_members: null +) +``` + diff --git a/docs/ConferenceCompletedCallback.md b/docs/ConferenceCompletedCallback.md new file mode 100644 index 00000000..5815eb66 --- /dev/null +++ b/docs/ConferenceCompletedCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::ConferenceCompletedCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceCompletedCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + tag: exampleTag +) +``` + diff --git a/docs/ConferenceCreatedCallback.md b/docs/ConferenceCreatedCallback.md new file mode 100644 index 00000000..2ddc9335 --- /dev/null +++ b/docs/ConferenceCreatedCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::ConferenceCreatedCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceCreatedCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + tag: exampleTag +) +``` + diff --git a/docs/ConferenceMember.md b/docs/ConferenceMember.md new file mode 100644 index 00000000..6948cfc4 --- /dev/null +++ b/docs/ConferenceMember.md @@ -0,0 +1,28 @@ +# Bandwidth::ConferenceMember + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **member_url** | **String** | A URL that may be used to retrieve information about or update the state of this conference member. This is the URL of this member's [Get Conference Member](/apis/voice/#operation/getConferenceMember) endpoint and [Modify Conference Member](/apis/voice/#operation/updateConferenceMember) endpoint. | [optional] | +| **mute** | **Boolean** | Whether or not this member is currently muted. Members who are muted are still able to hear other participants. If used in a PUT request, updates this member's mute status. Has no effect if omitted. | [optional] | +| **hold** | **Boolean** | Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. If used in a PUT request, updates this member's hold status. Has no effect if omitted. | [optional] | +| **call_ids_to_coach** | **Array<String>** | If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. If present in a PUT request, modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceMember.new( + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + member_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/members/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + mute: false, + hold: false, + call_ids_to_coach: ["c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"] +) +``` + diff --git a/docs/ConferenceMemberExitCallback.md b/docs/ConferenceMemberExitCallback.md new file mode 100644 index 00000000..89479dae --- /dev/null +++ b/docs/ConferenceMemberExitCallback.md @@ -0,0 +1,32 @@ +# Bandwidth::ConferenceMemberExitCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceMemberExitCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + from: +15555555555, + to: +15555555555, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + tag: exampleTag +) +``` + diff --git a/docs/ConferenceMemberJoinCallback.md b/docs/ConferenceMemberJoinCallback.md new file mode 100644 index 00000000..f8e2708f --- /dev/null +++ b/docs/ConferenceMemberJoinCallback.md @@ -0,0 +1,32 @@ +# Bandwidth::ConferenceMemberJoinCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceMemberJoinCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + from: +15555555555, + to: +15555555555, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + tag: exampleTag +) +``` + diff --git a/docs/ConferenceRecordingAvailableCallback.md b/docs/ConferenceRecordingAvailableCallback.md new file mode 100644 index 00000000..4b193a68 --- /dev/null +++ b/docs/ConferenceRecordingAvailableCallback.md @@ -0,0 +1,44 @@ +# Bandwidth::ConferenceRecordingAvailableCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **channels** | **Integer** | Always `1` for conference recordings; multi-channel recordings are not supported on conferences. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **status** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceRecordingAvailableCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + account_id: 920012, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + channels: 1, + start_time: 2022-06-17T22:19:40.375Z, + end_time: 2022-06-17T22:20Z, + duration: PT13.67S, + file_format: null, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media, + tag: exampleTag, + status: completed +) +``` + diff --git a/docs/ConferenceRecordingMetadata.md b/docs/ConferenceRecordingMetadata.md new file mode 100644 index 00000000..effcaea7 --- /dev/null +++ b/docs/ConferenceRecordingMetadata.md @@ -0,0 +1,38 @@ +# Bandwidth::ConferenceRecordingMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **channels** | **Integer** | Always `1` for conference recordings; multi-channel recordings are not supported on conferences. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **status** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceRecordingMetadata.new( + account_id: 920012, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + duration: PT13.67S, + channels: 1, + start_time: 2022-06-17T22:19:40.375Z, + end_time: 2022-06-17T22:20Z, + file_format: null, + status: completed, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media +) +``` + diff --git a/docs/ConferenceRedirectCallback.md b/docs/ConferenceRedirectCallback.md new file mode 100644 index 00000000..2b218d01 --- /dev/null +++ b/docs/ConferenceRedirectCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::ConferenceRedirectCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **conference_id** | **String** | The unique, Bandwidth-generated ID of the conference that was recorded | [optional] | +| **name** | **String** | The user-specified name of the conference that was recorded | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceRedirectCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + conference_id: conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9, + name: my-conference-name, + tag: exampleTag +) +``` + diff --git a/docs/ConferenceStateEnum.md b/docs/ConferenceStateEnum.md new file mode 100644 index 00000000..fac69498 --- /dev/null +++ b/docs/ConferenceStateEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::ConferenceStateEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ConferenceStateEnum.new() +``` + diff --git a/docs/ConferencesApi.md b/docs/ConferencesApi.md new file mode 100644 index 00000000..e8b0945b --- /dev/null +++ b/docs/ConferencesApi.md @@ -0,0 +1,688 @@ +# Bandwidth::ConferencesApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**download_conference_recording**](ConferencesApi.md#download_conference_recording) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media | Download Conference Recording | +| [**get_conference**](ConferencesApi.md#get_conference) | **GET** /accounts/{accountId}/conferences/{conferenceId} | Get Conference Information | +| [**get_conference_member**](ConferencesApi.md#get_conference_member) | **GET** /accounts/{accountId}/conferences/{conferenceId}/members/{memberId} | Get Conference Member | +| [**get_conference_recording**](ConferencesApi.md#get_conference_recording) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId} | Get Conference Recording Information | +| [**list_conference_recordings**](ConferencesApi.md#list_conference_recordings) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings | Get Conference Recordings | +| [**list_conferences**](ConferencesApi.md#list_conferences) | **GET** /accounts/{accountId}/conferences | Get Conferences | +| [**update_conference**](ConferencesApi.md#update_conference) | **POST** /accounts/{accountId}/conferences/{conferenceId} | Update Conference | +| [**update_conference_bxml**](ConferencesApi.md#update_conference_bxml) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/bxml | Update Conference BXML | +| [**update_conference_member**](ConferencesApi.md#update_conference_member) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/members/{memberId} | Update Conference Member | + + +## download_conference_recording + +> File download_conference_recording(account_id, conference_id, recording_id) + +Download Conference Recording + +Downloads the specified recording file. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Download Conference Recording + result = api_instance.download_conference_recording(account_id, conference_id, recording_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->download_conference_recording: #{e}" +end +``` + +#### Using the download_conference_recording_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> download_conference_recording_with_http_info(account_id, conference_id, recording_id) + +```ruby +begin + # Download Conference Recording + data, status_code, headers = api_instance.download_conference_recording_with_http_info(account_id, conference_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => File +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->download_conference_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +**File** + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: audio/vnd.wave, audio/mpeg, application/json + + +## get_conference + +> get_conference(account_id, conference_id) + +Get Conference Information + +Returns information about the specified conference. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. + +begin + # Get Conference Information + result = api_instance.get_conference(account_id, conference_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference: #{e}" +end +``` + +#### Using the get_conference_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_conference_with_http_info(account_id, conference_id) + +```ruby +begin + # Get Conference Information + data, status_code, headers = api_instance.get_conference_with_http_info(account_id, conference_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | + +### Return type + +[**Conference**](Conference.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_conference_member + +> get_conference_member(account_id, conference_id, member_id) + +Get Conference Member + +Returns information about the specified conference member. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +member_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Conference Member ID. + +begin + # Get Conference Member + result = api_instance.get_conference_member(account_id, conference_id, member_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference_member: #{e}" +end +``` + +#### Using the get_conference_member_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_conference_member_with_http_info(account_id, conference_id, member_id) + +```ruby +begin + # Get Conference Member + data, status_code, headers = api_instance.get_conference_member_with_http_info(account_id, conference_id, member_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference_member_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **member_id** | **String** | Programmable Voice API Conference Member ID. | | + +### Return type + +[**ConferenceMember**](ConferenceMember.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_conference_recording + +> get_conference_recording(account_id, conference_id, recording_id) + +Get Conference Recording Information + +Returns metadata for the specified recording. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Get Conference Recording Information + result = api_instance.get_conference_recording(account_id, conference_id, recording_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference_recording: #{e}" +end +``` + +#### Using the get_conference_recording_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_conference_recording_with_http_info(account_id, conference_id, recording_id) + +```ruby +begin + # Get Conference Recording Information + data, status_code, headers = api_instance.get_conference_recording_with_http_info(account_id, conference_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->get_conference_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +[**ConferenceRecordingMetadata**](ConferenceRecordingMetadata.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_conference_recordings + +> > list_conference_recordings(account_id, conference_id) + +Get Conference Recordings + +Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. + +begin + # Get Conference Recordings + result = api_instance.list_conference_recordings(account_id, conference_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->list_conference_recordings: #{e}" +end +``` + +#### Using the list_conference_recordings_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_conference_recordings_with_http_info(account_id, conference_id) + +```ruby +begin + # Get Conference Recordings + data, status_code, headers = api_instance.list_conference_recordings_with_http_info(account_id, conference_id) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->list_conference_recordings_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | + +### Return type + +[**Array<ConferenceRecordingMetadata>**](ConferenceRecordingMetadata.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_conferences + +> > list_conferences(account_id, opts) + +Get Conferences + +Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +opts = { + name: 'my-custom-name', # String | Filter results by the `name` field. + min_created_time: '2022-06-21T19:13:21Z', # String | Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format). + max_created_time: '2022-06-21T19:13:21Z', # String | Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format). + page_size: 500, # Integer | Specifies the max number of conferences that will be returned. + page_token: 'page_token_example' # String | Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description. +} + +begin + # Get Conferences + result = api_instance.list_conferences(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->list_conferences: #{e}" +end +``` + +#### Using the list_conferences_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_conferences_with_http_info(account_id, opts) + +```ruby +begin + # Get Conferences + data, status_code, headers = api_instance.list_conferences_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->list_conferences_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **name** | **String** | Filter results by the `name` field. | [optional] | +| **min_created_time** | **String** | Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format). | [optional] | +| **max_created_time** | **String** | Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format). | [optional] | +| **page_size** | **Integer** | Specifies the max number of conferences that will be returned. | [optional][default to 1000] | +| **page_token** | **String** | Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description. | [optional] | + +### Return type + +[**Array<Conference>**](Conference.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_conference + +> update_conference(account_id, conference_id, update_conference) + +Update Conference + +Update the conference state. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +update_conference = Bandwidth::UpdateConference.new # UpdateConference | + +begin + # Update Conference + api_instance.update_conference(account_id, conference_id, update_conference) +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference: #{e}" +end +``` + +#### Using the update_conference_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_conference_with_http_info(account_id, conference_id, update_conference) + +```ruby +begin + # Update Conference + data, status_code, headers = api_instance.update_conference_with_http_info(account_id, conference_id, update_conference) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **update_conference** | [**UpdateConference**](UpdateConference.md) | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## update_conference_bxml + +> update_conference_bxml(account_id, conference_id, body) + +Update Conference BXML + +Update the conference BXML document. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +body = ' + + +' # String | + +begin + # Update Conference BXML + api_instance.update_conference_bxml(account_id, conference_id, body) +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference_bxml: #{e}" +end +``` + +#### Using the update_conference_bxml_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_conference_bxml_with_http_info(account_id, conference_id, body) + +```ruby +begin + # Update Conference BXML + data, status_code, headers = api_instance.update_conference_bxml_with_http_info(account_id, conference_id, body) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference_bxml_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **body** | **String** | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/xml +- **Accept**: application/json + + +## update_conference_member + +> update_conference_member(account_id, conference_id, member_id, update_conference_member) + +Update Conference Member + +Updates settings for a particular conference member. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ConferencesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' # String | Programmable Voice API Conference ID. +member_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Conference Member ID. +update_conference_member = Bandwidth::UpdateConferenceMember.new # UpdateConferenceMember | + +begin + # Update Conference Member + api_instance.update_conference_member(account_id, conference_id, member_id, update_conference_member) +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference_member: #{e}" +end +``` + +#### Using the update_conference_member_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member) + +```ruby +begin + # Update Conference Member + data, status_code, headers = api_instance.update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling ConferencesApi->update_conference_member_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **conference_id** | **String** | Programmable Voice API Conference ID. | | +| **member_id** | **String** | Programmable Voice API Conference Member ID. | | +| **update_conference_member** | [**UpdateConferenceMember**](UpdateConferenceMember.md) | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/CreateCall.md b/docs/CreateCall.md new file mode 100644 index 00000000..a38537ca --- /dev/null +++ b/docs/CreateCall.md @@ -0,0 +1,56 @@ +# Bandwidth::CreateCall + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **to** | **String** | The destination to call (must be an E.164 formatted number (e.g. `+15555551212`) or a SIP URI (e.g. `sip:user@server.example`)). | | +| **from** | **String** | A Bandwidth phone number on your account the call should come from (must be in E.164 format, like `+15555551212`, or be one of the following strings: `Restricted`, `Anonymous`, `Private`, or `Unavailable`). | | +| **display_name** | **String** | The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines. | [optional] | +| **uui** | **String** | A comma-separated list of 'User-To-User' headers to be sent in the INVITE when calling a SIP URI. Each value must end with an 'encoding' parameter as described in <a href='https://tools.ietf.org/html/rfc7433'>RFC 7433</a>. Only 'jwt' and 'base64' encodings are allowed. The entire value cannot exceed 350 characters, including parameters and separators. | [optional] | +| **application_id** | **String** | The id of the application associated with the `from` number. | | +| **answer_url** | **String** | The full URL to send the <a href='/docs/voice/webhooks/answer'>Answer</a> event to when the called party answers. This endpoint should return the first <a href='/docs/voice/bxml'>BXML document</a> to be executed in the call. Must use `https` if specifying `username` and `password`. | | +| **answer_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **answer_fallback_url** | **String** | A fallback url which, if provided, will be used to retry the `answer` webhook delivery in case `answerUrl` fails to respond Must use `https` if specifying `fallbackUsername` and `fallbackPassword`. | [optional] | +| **answer_fallback_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **fallback_username** | **String** | Basic auth username. | [optional] | +| **fallback_password** | **String** | Basic auth password. | [optional] | +| **disconnect_url** | **String** | The URL to send the <a href='/docs/voice/webhooks/disconnect'>Disconnect</a> event to when the call ends. This event does not expect a BXML response. | [optional] | +| **disconnect_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **call_timeout** | **Float** | The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Can be any numeric value (including decimals) between 1 and 300. | [optional][default to 30] | +| **callback_timeout** | **Float** | This is the timeout (in seconds) to use when delivering webhooks for the call. Can be any numeric value (including decimals) between 1 and 25. | [optional][default to 15] | +| **machine_detection** | [**MachineDetectionConfiguration**](MachineDetectionConfiguration.md) | | [optional] | +| **priority** | **Integer** | The priority of this call over other calls from your account. For example, if during a call your application needs to place a new call and bridge it with the current call, you might want to create the call with priority 1 so that it will be the next call picked off your queue, ahead of other less time sensitive calls. A lower value means higher priority, so a priority 1 call takes precedence over a priority 2 call. | [optional][default to 5] | +| **tag** | **String** | A custom string that will be sent with all webhooks for this call unless overwritten by a future <a href='/docs/voice/bxml/tag'>`<Tag>`</a> verb or `tag` attribute on another verb, or cleared. May be cleared by setting `tag=\"\"` Max length 256 characters. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateCall.new( + to: +19195551234, + from: +19195554321, + display_name: John Doe, + uui: eyJhbGciOiJIUzI1NiJ9.WyJoaSJd.-znkjYyCkgz4djmHUPSXl9YrJ6Nix_XvmlwKGFh5ERM;encoding=jwt,aGVsbG8gd29ybGQ;encoding=base64, + application_id: 1234-qwer-5679-tyui, + answer_url: https://www.myCallbackServer.example/webhooks/answer, + answer_method: null, + username: mySecretUsername, + password: mySecretPassword1!, + answer_fallback_url: https://www.myFallbackServer.example/webhooks/answer, + answer_fallback_method: null, + fallback_username: mySecretUsername, + fallback_password: mySecretPassword1!, + disconnect_url: https://www.myCallbackServer.example/webhooks/disconnect, + disconnect_method: null, + call_timeout: 30, + callback_timeout: 15, + machine_detection: null, + priority: 5, + tag: arbitrary text here +) +``` + diff --git a/docs/CreateCallResponse.md b/docs/CreateCallResponse.md new file mode 100644 index 00000000..e6412103 --- /dev/null +++ b/docs/CreateCallResponse.md @@ -0,0 +1,58 @@ +# Bandwidth::CreateCallResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **application_id** | **String** | The id of the application associated with the `from` number. | | +| **account_id** | **String** | The bandwidth account ID associated with the call. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **to** | **String** | Recipient of the outgoing call. | | +| **from** | **String** | Phone number that created the outbound call. | | +| **enqueued_time** | **Time** | The time at which the call was accepted into the queue. | [optional] | +| **call_url** | **String** | The URL to update this call's state. | | +| **call_timeout** | **Float** | The timeout (in seconds) for the callee to answer the call after it starts ringing. | [optional] | +| **callback_timeout** | **Float** | This is the timeout (in seconds) to use when delivering webhooks for the call. | [optional] | +| **tag** | **String** | Custom tag value. | [optional] | +| **answer_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [default to 'POST'] | +| **answer_url** | **String** | URL to deliver the `answer` event webhook. | | +| **answer_fallback_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **answer_fallback_url** | **String** | Fallback URL to deliver the `answer` event webhook. | [optional] | +| **disconnect_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [default to 'POST'] | +| **disconnect_url** | **String** | URL to deliver the `disconnect` event webhook. | [optional] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **fallback_username** | **String** | Basic auth username. | [optional] | +| **fallback_password** | **String** | Basic auth password. | [optional] | +| **priority** | **Integer** | The priority of this call over other calls from your account. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateCallResponse.new( + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + account_id: 9900000, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + to: +19195551234, + from: +19195554321, + enqueued_time: 2022-06-16T13:15:07.160Z, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_timeout: 30, + callback_timeout: 15, + tag: My custom tag value, + answer_method: null, + answer_url: https://myServer.example/bandwidth/webhooks/answer, + answer_fallback_method: null, + answer_fallback_url: https://myFallbackServer.example/bandwidth/webhooks/answer, + disconnect_method: null, + disconnect_url: https://myServer.example/bandwidth/webhooks/disconnect, + username: mySecretUsername, + password: mySecretPassword1!, + fallback_username: mySecretUsername, + fallback_password: mySecretPassword1!, + priority: 5 +) +``` + diff --git a/docs/CreateLookupResponse.md b/docs/CreateLookupResponse.md new file mode 100644 index 00000000..dae614e2 --- /dev/null +++ b/docs/CreateLookupResponse.md @@ -0,0 +1,20 @@ +# Bandwidth::CreateLookupResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **request_id** | **String** | The phone number lookup request ID from Bandwidth. | [optional] | +| **status** | [**LookupStatusEnum**](LookupStatusEnum.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateLookupResponse.new( + request_id: null, + status: null +) +``` + diff --git a/docs/CreateMessageRequestError.md b/docs/CreateMessageRequestError.md new file mode 100644 index 00000000..fd6aee11 --- /dev/null +++ b/docs/CreateMessageRequestError.md @@ -0,0 +1,22 @@ +# Bandwidth::CreateMessageRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | | +| **description** | **String** | | | +| **field_errors** | [**Array<FieldError>**](FieldError.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateMessageRequestError.new( + type: null, + description: null, + field_errors: null +) +``` + diff --git a/docs/CreateParticipantRequest.md b/docs/CreateParticipantRequest.md new file mode 100644 index 00000000..9e3d2159 --- /dev/null +++ b/docs/CreateParticipantRequest.md @@ -0,0 +1,24 @@ +# Bandwidth::CreateParticipantRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **callback_url** | **String** | Full callback url to use for notifications about this participant. | [optional] | +| **publish_permissions** | [**Array<PublishPermissionsEnum>**](PublishPermissionsEnum.md) | Defines if this participant can publish audio or video. | [optional] | +| **tag** | **String** | User defined tag to associate with the participant. | [optional] | +| **device_api_version** | [**DeviceApiVersionEnum**](DeviceApiVersionEnum.md) | | [optional][default to 'V3'] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateParticipantRequest.new( + callback_url: https://example.com/callback, + publish_permissions: ["VIDEO","AUDIO"], + tag: participant1, + device_api_version: null +) +``` + diff --git a/docs/CreateParticipantResponse.md b/docs/CreateParticipantResponse.md new file mode 100644 index 00000000..03f94266 --- /dev/null +++ b/docs/CreateParticipantResponse.md @@ -0,0 +1,20 @@ +# Bandwidth::CreateParticipantResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **participant** | [**Participant**](Participant.md) | | [optional] | +| **token** | **String** | Auth token for the returned participant. This should be passed to the participant so that they can connect to the platform. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::CreateParticipantResponse.new( + participant: null, + token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyfQ.L8i6g3PfcHlioHCCPURC9pmXT7gdJpx3kOoyAfNUwCc +) +``` + diff --git a/docs/DeferredResult.md b/docs/DeferredResult.md new file mode 100644 index 00000000..602bcacc --- /dev/null +++ b/docs/DeferredResult.md @@ -0,0 +1,20 @@ +# Bandwidth::DeferredResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **result** | **Object** | | [optional] | +| **set_or_expired** | **Boolean** | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::DeferredResult.new( + result: null, + set_or_expired: null +) +``` + diff --git a/docs/DeviceApiVersionEnum.md b/docs/DeviceApiVersionEnum.md new file mode 100644 index 00000000..30970c47 --- /dev/null +++ b/docs/DeviceApiVersionEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::DeviceApiVersionEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::DeviceApiVersionEnum.new() +``` + diff --git a/docs/DisconenctCallback.md b/docs/DisconenctCallback.md new file mode 100644 index 00000000..a0f462d6 --- /dev/null +++ b/docs/DisconenctCallback.md @@ -0,0 +1,50 @@ +# Bandwidth::DisconenctCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **String** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **cause** | **String** | Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. | [optional] | +| **error_message** | **String** | Text explaining the reason that caused the call to fail in case of errors. | [optional] | +| **error_id** | **String** | Bandwidth's internal id that references the error event. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::DisconenctCallback.new( + event_type: bridgeComplete, + event_time: null, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + direction: null, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + end_time: 2022-06-17T22:20Z, + cause: busy, + error_message: Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged with another call, + error_id: 4642074b-7b58-478b-96e4-3a60955c6765, + tag: exampleTag +) +``` + diff --git a/docs/DisconnectCallback.md b/docs/DisconnectCallback.md new file mode 100644 index 00000000..9f04b862 --- /dev/null +++ b/docs/DisconnectCallback.md @@ -0,0 +1,50 @@ +# Bandwidth::DisconnectCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **cause** | **String** | Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. | [optional] | +| **error_message** | **String** | Text explaining the reason that caused the call to fail in case of errors. | [optional] | +| **error_id** | **String** | Bandwidth's internal id that references the error event. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::DisconnectCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + direction: null, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + end_time: 2022-06-17T22:20Z, + cause: busy, + error_message: Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged with another call, + error_id: 4642074b-7b58-478b-96e4-3a60955c6765, + tag: exampleTag +) +``` + diff --git a/docs/Diversion.md b/docs/Diversion.md new file mode 100644 index 00000000..e7c81b08 --- /dev/null +++ b/docs/Diversion.md @@ -0,0 +1,30 @@ +# Bandwidth::Diversion + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **reason** | **String** | The reason for the diversion. Common values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. | [optional] | +| **privacy** | **String** | off or full | [optional] | +| **screen** | **String** | No if the number was provided by the user, yes if the number was provided by the network | [optional] | +| **counter** | **String** | The number of diversions that have occurred | [optional] | +| **limit** | **String** | The maximum number of diversions allowed for this session | [optional] | +| **unknown** | **String** | The normal list of values is not exhaustive. Your application must be tolerant of unlisted keys and unlisted values of those keys. | [optional] | +| **orig_to** | **String** | Always present. Indicates the last telephone number that the call was diverted from. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Diversion.new( + reason: unavailable, + privacy: off, + screen: no, + counter: 2, + limit: 3, + unknown: unknownValue, + orig_to: +15558884444 +) +``` + diff --git a/docs/DtmfCallback.md b/docs/DtmfCallback.md new file mode 100644 index 00000000..f2732b6b --- /dev/null +++ b/docs/DtmfCallback.md @@ -0,0 +1,50 @@ +# Bandwidth::DtmfCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **digit** | **String** | The digit collected in the call. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::DtmfCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + direction: null, + digit: 2, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + transfer_caller_id: +15555555555, + transfer_to: +15555555555), + tag: exampleTag +) +``` + diff --git a/docs/FieldError.md b/docs/FieldError.md new file mode 100644 index 00000000..fbd0167e --- /dev/null +++ b/docs/FieldError.md @@ -0,0 +1,20 @@ +# Bandwidth::FieldError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **field_name** | **String** | The name of the field that contains the error | [optional] | +| **description** | **String** | The error associated with the field | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::FieldError.new( + field_name: from, + description: '+invalid' must be replaced with a valid E164 formatted telephone number +) +``` + diff --git a/docs/FileFormatEnum.md b/docs/FileFormatEnum.md new file mode 100644 index 00000000..d3b2dd44 --- /dev/null +++ b/docs/FileFormatEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::FileFormatEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::FileFormatEnum.new() +``` + diff --git a/docs/ForbiddenRequest.md b/docs/ForbiddenRequest.md new file mode 100644 index 00000000..ab75cf43 --- /dev/null +++ b/docs/ForbiddenRequest.md @@ -0,0 +1,18 @@ +# Bandwidth::ForbiddenRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | The message containing the reason behind the request being forbidden. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ForbiddenRequest.new( + message: Missing Authentication Token +) +``` + diff --git a/docs/GatherCallback.md b/docs/GatherCallback.md new file mode 100644 index 00000000..6489e6a2 --- /dev/null +++ b/docs/GatherCallback.md @@ -0,0 +1,52 @@ +# Bandwidth::GatherCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **digits** | **String** | (optional) The digits, letters, and/or symbols entered by the user. The string is empty if a timeout occurred before any buttons were pressed. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **terminating_digit** | **String** | (optional) The digit the user pressed to end the gather. Empty string value if no terminating digit was pressed. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::GatherCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + digits: 123, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + terminating_digit: #, + transfer_caller_id: +15555555555, + transfer_to: +15555555555), + tag: exampleTag +) +``` + diff --git a/docs/InboundMessageCallback.md b/docs/InboundMessageCallback.md new file mode 100644 index 00000000..73d327f0 --- /dev/null +++ b/docs/InboundMessageCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::InboundMessageCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **time** | **Time** | | | +| **type** | **String** | | | +| **to** | **String** | | | +| **description** | **String** | | | +| **message** | [**InboundMessageCallbackMessage**](InboundMessageCallbackMessage.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::InboundMessageCallback.new( + time: 2016-09-14T18:20:16Z, + type: message-received, + to: +15552223333, + description: Incoming message received, + message: null +) +``` + diff --git a/docs/InboundMessageCallbackMessage.md b/docs/InboundMessageCallbackMessage.md new file mode 100644 index 00000000..4ef3b41f --- /dev/null +++ b/docs/InboundMessageCallbackMessage.md @@ -0,0 +1,40 @@ +# Bandwidth::InboundMessageCallbackMessage + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **owner** | **String** | | | +| **application_id** | **String** | | | +| **time** | **Time** | | | +| **segment_count** | **Integer** | | | +| **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | | +| **to** | **Array<String>** | | | +| **from** | **String** | | | +| **text** | **String** | | | +| **tag** | **String** | | [optional] | +| **media** | **Array<String>** | | [optional] | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::InboundMessageCallbackMessage.new( + id: 1661365814859loidf7mcwd4qacn7, + owner: +15553332222, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + time: 2016-09-14T18:20:16Z, + segment_count: 1, + direction: null, + to: ["+15552223333"], + from: +15553332222, + text: Hello world, + tag: custom string, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"], + priority: null +) +``` + diff --git a/docs/InitiateCallback.md b/docs/InitiateCallback.md new file mode 100644 index 00000000..e30039f8 --- /dev/null +++ b/docs/InitiateCallback.md @@ -0,0 +1,40 @@ +# Bandwidth::InitiateCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **diversion** | [**Diversion**](Diversion.md) | | [optional] | +| **stir_shaken** | [**StirShaken**](StirShaken.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::InitiateCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + start_time: 2022-06-17T22:19:40.375Z, + diversion: null, + stir_shaken: null +) +``` + diff --git a/docs/ListMessageDirectionEnum.md b/docs/ListMessageDirectionEnum.md new file mode 100644 index 00000000..c1f6d09b --- /dev/null +++ b/docs/ListMessageDirectionEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::ListMessageDirectionEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ListMessageDirectionEnum.new() +``` + diff --git a/docs/ListMessageItem.md b/docs/ListMessageItem.md new file mode 100644 index 00000000..1c2b8ea1 --- /dev/null +++ b/docs/ListMessageItem.md @@ -0,0 +1,50 @@ +# Bandwidth::ListMessageItem + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message_id** | **String** | The message id | [optional] | +| **account_id** | **String** | The account id associated with this message. | [optional] | +| **source_tn** | **String** | The source phone number of the message. | [optional] | +| **destination_tn** | **String** | The recipient phone number of the message. | [optional] | +| **message_status** | [**MessageStatusEnum**](MessageStatusEnum.md) | | [optional] | +| **message_direction** | [**ListMessageDirectionEnum**](ListMessageDirectionEnum.md) | | [optional] | +| **message_type** | [**MessageTypeEnum**](MessageTypeEnum.md) | | [optional] | +| **segment_count** | **Integer** | The number of segments the message was sent as. | [optional] | +| **error_code** | **Integer** | The numeric error code of the message. | [optional] | +| **receive_time** | **Time** | The ISO 8601 datetime of the message. | [optional] | +| **carrier_name** | **String** | The name of the carrier. Not currently supported for MMS coming soon. | [optional] | +| **message_size** | **Integer** | The size of the message including message content and headers. | [optional] | +| **message_length** | **Integer** | The length of the message content. | [optional] | +| **attachment_count** | **Integer** | The number of attachments the message has. | [optional] | +| **recipient_count** | **Integer** | The number of recipients the message has. | [optional] | +| **campaign_class** | **String** | The campaign class of the message if it has one. | [optional] | +| **campaign_id** | **String** | The campaign ID of the message if it has one. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ListMessageItem.new( + message_id: 1589228074636lm4k2je7j7jklbn2, + account_id: 9900000, + source_tn: +15554443333, + destination_tn: +15554442222, + message_status: null, + message_direction: null, + message_type: null, + segment_count: 1, + error_code: 9902, + receive_time: 2020-04-07T14:03:07Z, + carrier_name: other, + message_size: 27, + message_length: 18, + attachment_count: 1, + recipient_count: 1, + campaign_class: T, + campaign_id: CJEUMDK +) +``` + diff --git a/docs/LookupRequest.md b/docs/LookupRequest.md new file mode 100644 index 00000000..566786c8 --- /dev/null +++ b/docs/LookupRequest.md @@ -0,0 +1,18 @@ +# Bandwidth::LookupRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **tns** | **Array<String>** | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::LookupRequest.new( + tns: null +) +``` + diff --git a/docs/LookupResult.md b/docs/LookupResult.md new file mode 100644 index 00000000..647963b8 --- /dev/null +++ b/docs/LookupResult.md @@ -0,0 +1,34 @@ +# Bandwidth::LookupResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **response_code** | **Integer** | Our vendor's response code. | [optional] | +| **message** | **String** | Message associated with the response code. | [optional] | +| **e_164_format** | **String** | The telephone number in E.164 format. | [optional] | +| **formatted** | **String** | The formatted version of the telephone number. | [optional] | +| **country** | **String** | The country of the telephone number. | [optional] | +| **line_type** | **String** | The line type of the telephone number. | [optional] | +| **line_provider** | **String** | The messaging service provider of the telephone number. | [optional] | +| **mobile_country_code** | **String** | The first half of the Home Network Identity (HNI). | [optional] | +| **mobile_network_code** | **String** | The second half of the HNI. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::LookupResult.new( + response_code: 0, + message: NOERROR, + e_164_format: +19195551234, + formatted: (919) 555-1234, + country: US, + line_type: Mobile, + line_provider: Verizon Wireless, + mobile_country_code: 310, + mobile_network_code: 010 +) +``` + diff --git a/docs/LookupStatus.md b/docs/LookupStatus.md new file mode 100644 index 00000000..4864c861 --- /dev/null +++ b/docs/LookupStatus.md @@ -0,0 +1,24 @@ +# Bandwidth::LookupStatus + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **request_id** | **String** | The requestId. | [optional] | +| **status** | [**LookupStatusEnum**](LookupStatusEnum.md) | | [optional] | +| **result** | [**Array<LookupResult>**](LookupResult.md) | The carrier information results for the specified telephone number. | [optional] | +| **failed_telephone_numbers** | **Array<String>** | The telephone numbers whose lookup failed. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::LookupStatus.new( + request_id: 004223a0-8b17-41b1-bf81-20732adf5590, + status: null, + result: null, + failed_telephone_numbers: ["+191955512345"] +) +``` + diff --git a/docs/LookupStatusEnum.md b/docs/LookupStatusEnum.md new file mode 100644 index 00000000..f3dbe4d0 --- /dev/null +++ b/docs/LookupStatusEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::LookupStatusEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::LookupStatusEnum.new() +``` + diff --git a/docs/MFAApi.md b/docs/MFAApi.md new file mode 100644 index 00000000..bef6c1fb --- /dev/null +++ b/docs/MFAApi.md @@ -0,0 +1,226 @@ +# Bandwidth::MFAApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**generate_messaging_code**](MFAApi.md#generate_messaging_code) | **POST** /accounts/{accountId}/code/messaging | Messaging Authentication Code | +| [**generate_voice_code**](MFAApi.md#generate_voice_code) | **POST** /accounts/{accountId}/code/voice | Voice Authentication Code | +| [**verify_code**](MFAApi.md#verify_code) | **POST** /accounts/{accountId}/code/verify | Verify Authentication Code | + + +## generate_messaging_code + +> generate_messaging_code(account_id, code_request) + +Messaging Authentication Code + +Send an MFA code via text message (SMS). + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MFAApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +code_request = Bandwidth::CodeRequest.new({to: '+19195551234', from: '+19195554321', application_id: '66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1', message: 'Your temporary {NAME} {SCOPE} code is {CODE}', digits: 6}) # CodeRequest | MFA code request body. + +begin + # Messaging Authentication Code + result = api_instance.generate_messaging_code(account_id, code_request) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->generate_messaging_code: #{e}" +end +``` + +#### Using the generate_messaging_code_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> generate_messaging_code_with_http_info(account_id, code_request) + +```ruby +begin + # Messaging Authentication Code + data, status_code, headers = api_instance.generate_messaging_code_with_http_info(account_id, code_request) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->generate_messaging_code_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **code_request** | [**CodeRequest**](CodeRequest.md) | MFA code request body. | | + +### Return type + +[**MessagingCodeResponse**](MessagingCodeResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## generate_voice_code + +> generate_voice_code(account_id, code_request) + +Voice Authentication Code + +Send an MFA Code via a phone call. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MFAApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +code_request = Bandwidth::CodeRequest.new({to: '+19195551234', from: '+19195554321', application_id: '66fd98ae-ac8d-a00f-7fcd-ba3280aeb9b1', message: 'Your temporary {NAME} {SCOPE} code is {CODE}', digits: 6}) # CodeRequest | MFA code request body. + +begin + # Voice Authentication Code + result = api_instance.generate_voice_code(account_id, code_request) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->generate_voice_code: #{e}" +end +``` + +#### Using the generate_voice_code_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> generate_voice_code_with_http_info(account_id, code_request) + +```ruby +begin + # Voice Authentication Code + data, status_code, headers = api_instance.generate_voice_code_with_http_info(account_id, code_request) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->generate_voice_code_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **code_request** | [**CodeRequest**](CodeRequest.md) | MFA code request body. | | + +### Return type + +[**VoiceCodeResponse**](VoiceCodeResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## verify_code + +> verify_code(account_id, verify_code_request) + +Verify Authentication Code + +Verify a previously sent MFA code. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MFAApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +verify_code_request = Bandwidth::VerifyCodeRequest.new({to: '+19195551234', expiration_time_in_minutes: 3, code: '123456'}) # VerifyCodeRequest | MFA code verify request body. + +begin + # Verify Authentication Code + result = api_instance.verify_code(account_id, verify_code_request) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->verify_code: #{e}" +end +``` + +#### Using the verify_code_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> verify_code_with_http_info(account_id, verify_code_request) + +```ruby +begin + # Verify Authentication Code + data, status_code, headers = api_instance.verify_code_with_http_info(account_id, verify_code_request) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling MFAApi->verify_code_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **verify_code_request** | [**VerifyCodeRequest**](VerifyCodeRequest.md) | MFA code verify request body. | | + +### Return type + +[**VerifyCodeResponse**](VerifyCodeResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/MachineDetectionCompleteCallback.md b/docs/MachineDetectionCompleteCallback.md new file mode 100644 index 00000000..2b7b0ccb --- /dev/null +++ b/docs/MachineDetectionCompleteCallback.md @@ -0,0 +1,44 @@ +# Bandwidth::MachineDetectionCompleteCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **machine_detection_result** | [**MachineDetectionResult**](MachineDetectionResult.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MachineDetectionCompleteCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + machine_detection_result: null +) +``` + diff --git a/docs/MachineDetectionConfiguration.md b/docs/MachineDetectionConfiguration.md new file mode 100644 index 00000000..737b3da4 --- /dev/null +++ b/docs/MachineDetectionConfiguration.md @@ -0,0 +1,46 @@ +# Bandwidth::MachineDetectionConfiguration + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **mode** | [**MachineDetectionModeEnum**](MachineDetectionModeEnum.md) | | [optional][default to 'async'] | +| **detection_timeout** | **Float** | The timeout used for the whole operation, in seconds. If no result is determined in this period, a callback with a `timeout` result is sent. | [optional][default to 15] | +| **silence_timeout** | **Float** | If no speech is detected in this period, a callback with a 'silence' result is sent. | [optional][default to 10] | +| **speech_threshold** | **Float** | When speech has ended and a result couldn't be determined based on the audio content itself, this value is used to determine if the speaker is a machine based on the speech duration. If the length of the speech detected is greater than or equal to this threshold, the result will be 'answering-machine'. If the length of speech detected is below this threshold, the result will be 'human'. | [optional][default to 10] | +| **speech_end_threshold** | **Float** | Amount of silence (in seconds) before assuming the callee has finished speaking. | [optional][default to 5] | +| **machine_speech_end_threshold** | **Float** | When an answering machine is detected, the amount of silence (in seconds) before assuming the message has finished playing. If not provided it will default to the speechEndThreshold value. | [optional] | +| **delay_result** | **Boolean** | If set to 'true' and if an answering machine is detected, the 'answering-machine' callback will be delayed until the machine is done speaking, or an end of message tone is detected, or until the 'detectionTimeout' is exceeded. If false, the 'answering-machine' result is sent immediately. | [optional][default to false] | +| **callback_url** | **String** | The URL to send the 'machineDetectionComplete' webhook when the detection is completed. Only for 'async' mode. | [optional] | +| **callback_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **fallback_url** | **String** | A fallback URL which, if provided, will be used to retry the machine detection complete webhook delivery in case `callbackUrl` fails to respond | [optional] | +| **fallback_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **fallback_username** | **String** | Basic auth username. | [optional] | +| **fallback_password** | **String** | Basic auth password. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MachineDetectionConfiguration.new( + mode: null, + detection_timeout: 15, + silence_timeout: 10, + speech_threshold: 10, + speech_end_threshold: 5, + machine_speech_end_threshold: 5, + delay_result: false, + callback_url: https://myServer.example/bandwidth/webhooks/machineDetectionComplete, + callback_method: null, + username: mySecretUsername, + password: mySecretPassword1!, + fallback_url: https://myFallbackServer.example/bandwidth/webhooks/machineDetectionComplete, + fallback_method: null, + fallback_username: mySecretUsername, + fallback_password: mySecretPassword1! +) +``` + diff --git a/docs/MachineDetectionModeEnum.md b/docs/MachineDetectionModeEnum.md new file mode 100644 index 00000000..3e9f9b4f --- /dev/null +++ b/docs/MachineDetectionModeEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::MachineDetectionModeEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MachineDetectionModeEnum.new() +``` + diff --git a/docs/MachineDetectionResult.md b/docs/MachineDetectionResult.md new file mode 100644 index 00000000..f349841d --- /dev/null +++ b/docs/MachineDetectionResult.md @@ -0,0 +1,20 @@ +# Bandwidth::MachineDetectionResult + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **value** | **String** | Possible values are answering-machine, human, silence, timeout, or error. | [optional] | +| **duration** | **String** | The amount of time it took to determine the result. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MachineDetectionResult.new( + value: answering-machine, + duration: PT4.9891287S +) +``` + diff --git a/docs/Media.md b/docs/Media.md new file mode 100644 index 00000000..73427243 --- /dev/null +++ b/docs/Media.md @@ -0,0 +1,22 @@ +# Bandwidth::Media + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **content** | **String** | | [optional] | +| **content_length** | **Integer** | | [optional] | +| **media_name** | **String** | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Media.new( + content: null, + content_length: null, + media_name: null +) +``` + diff --git a/docs/MediaApi.md b/docs/MediaApi.md new file mode 100644 index 00000000..ac0c433e --- /dev/null +++ b/docs/MediaApi.md @@ -0,0 +1,307 @@ +# Bandwidth::MediaApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**delete_media**](MediaApi.md#delete_media) | **DELETE** /users/{accountId}/media/{mediaId} | Delete Media | +| [**get_media**](MediaApi.md#get_media) | **GET** /users/{accountId}/media/{mediaId} | Get Media | +| [**list_media**](MediaApi.md#list_media) | **GET** /users/{accountId}/media | List Media | +| [**upload_media**](MediaApi.md#upload_media) | **PUT** /users/{accountId}/media/{mediaId} | Upload Media | + + +## delete_media + +> delete_media(account_id, media_id) + +Delete Media + +Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MediaApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' # String | Media ID to retrieve. + +begin + # Delete Media + api_instance.delete_media(account_id, media_id) +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->delete_media: #{e}" +end +``` + +#### Using the delete_media_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_media_with_http_info(account_id, media_id) + +```ruby +begin + # Delete Media + data, status_code, headers = api_instance.delete_media_with_http_info(account_id, media_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->delete_media_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **media_id** | **String** | Media ID to retrieve. | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_media + +> File get_media(account_id, media_id) + +Get Media + +Downloads a media file you previously uploaded. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MediaApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' # String | Media ID to retrieve. + +begin + # Get Media + result = api_instance.get_media(account_id, media_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->get_media: #{e}" +end +``` + +#### Using the get_media_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> get_media_with_http_info(account_id, media_id) + +```ruby +begin + # Get Media + data, status_code, headers = api_instance.get_media_with_http_info(account_id, media_id) + p status_code # => 2xx + p headers # => { ... } + p data # => File +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->get_media_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **media_id** | **String** | Media ID to retrieve. | | + +### Return type + +**File** + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/octet-stream, application/json + + +## list_media + +> > list_media(account_id, opts) + +List Media + +Gets a list of your media files. No query parameters are supported. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MediaApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +opts = { + continuation_token: '1XEi2tsFtLo1JbtLwETnM1ZJ+PqAa8w6ENvC5QKvwyrCDYII663Gy5M4s40owR1tjkuWUif6qbWvFtQJR5/ipqbUnfAqL254LKNlPy6tATCzioKSuHuOqgzloDkSwRtX0LtcL2otHS69hK343m+SjdL+vlj71tT39' # String | Continuation token used to retrieve subsequent media. +} + +begin + # List Media + result = api_instance.list_media(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->list_media: #{e}" +end +``` + +#### Using the list_media_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_media_with_http_info(account_id, opts) + +```ruby +begin + # List Media + data, status_code, headers = api_instance.list_media_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->list_media_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **continuation_token** | **String** | Continuation token used to retrieve subsequent media. | [optional] | + +### Return type + +[**Array<Media>**](Media.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## upload_media + +> upload_media(account_id, media_id, body, opts) + +Upload Media + +Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-). + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MediaApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' # String | Media ID to retrieve. +body = File.new('/path/to/some/file') # File | +opts = { + content_type: 'audio/wav', # String | The media type of the entity-body. + cache_control: 'no-cache' # String | General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. +} + +begin + # Upload Media + api_instance.upload_media(account_id, media_id, body, opts) +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->upload_media: #{e}" +end +``` + +#### Using the upload_media_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> upload_media_with_http_info(account_id, media_id, body, opts) + +```ruby +begin + # Upload Media + data, status_code, headers = api_instance.upload_media_with_http_info(account_id, media_id, body, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling MediaApi->upload_media_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **media_id** | **String** | Media ID to retrieve. | | +| **body** | **File** | | | +| **content_type** | **String** | The media type of the entity-body. | [optional] | +| **cache_control** | **String** | General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json, application/ogg, application/pdf, application/rtf, application/zip, application/x-tar, application/xml, application/gzip, application/x-bzip2, application/x-gzip, application/smil, application/javascript, audio/mp4, audio/mpeg, audio/ogg, audio/flac, audio/webm, audio/wav, audio/amr, audio/3gpp, image/bmp, image/gif, image/jpeg, image/pjpeg, image/png, image/svg+xml, image/tiff, image/webp, image/x-icon, text/css, text/csv, text/calendar, text/plain, text/javascript, text/vcard, text/vnd.wap.wml, text/xml, video/avi, video/mp4, video/mpeg, video/ogg, video/quicktime, video/webm, video/x-ms-wmv +- **Accept**: application/json + diff --git a/docs/Message.md b/docs/Message.md new file mode 100644 index 00000000..266db3a5 --- /dev/null +++ b/docs/Message.md @@ -0,0 +1,42 @@ +# Bandwidth::Message + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The id of the message. | [optional] | +| **owner** | **String** | The Bandwidth phone number associated with the message. | [optional] | +| **application_id** | **String** | The application ID associated with the message. | [optional] | +| **time** | **Time** | The datetime stamp of the message in ISO 8601 | [optional] | +| **segment_count** | **Integer** | The number of segments the original message from the user is broken into before sending over to carrier networks. | [optional] | +| **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | [optional] | +| **to** | **Array<String>** | The phone number recipients of the message. | [optional] | +| **from** | **String** | The phone number the message was sent from. | [optional] | +| **media** | **Array<String>** | The list of media URLs sent in the message. Including a `filename` field in the `Content-Disposition` header of the media linked with a URL will set the displayed file name. This is a best practice to ensure that your media has a readable file name. | [optional] | +| **text** | **String** | The contents of the message. | [optional] | +| **tag** | **String** | The custom string set by the user. | [optional] | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | +| **expiration** | **Time** | The expiration date-time set by the user. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Message.new( + id: 1589228074636lm4k2je7j7jklbn2, + owner: +15554443333, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + time: 2022-09-14T18:20:16Z, + segment_count: 2, + direction: null, + to: ["+15552223333"], + from: +15553332222, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png"], + text: Hello world, + tag: custom tag, + priority: null, + expiration: 2021-02-01T11:29:18-05:00 +) +``` + diff --git a/docs/MessageDeliveredCallback.md b/docs/MessageDeliveredCallback.md new file mode 100644 index 00000000..a28ffd85 --- /dev/null +++ b/docs/MessageDeliveredCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::MessageDeliveredCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **time** | **Time** | | | +| **type** | **String** | | | +| **to** | **String** | | | +| **description** | **String** | | | +| **message** | [**MessageDeliveredCallbackMessage**](MessageDeliveredCallbackMessage.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageDeliveredCallback.new( + time: 2016-09-14T18:20:16Z, + type: message-delivered, + to: +15552223333, + description: Message delivered to carrier., + message: null +) +``` + diff --git a/docs/MessageDeliveredCallbackMessage.md b/docs/MessageDeliveredCallbackMessage.md new file mode 100644 index 00000000..197d583d --- /dev/null +++ b/docs/MessageDeliveredCallbackMessage.md @@ -0,0 +1,40 @@ +# Bandwidth::MessageDeliveredCallbackMessage + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **owner** | **String** | | | +| **application_id** | **String** | | | +| **time** | **Time** | | | +| **segment_count** | **Integer** | | | +| **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | | +| **to** | **Array<String>** | | | +| **from** | **String** | | | +| **text** | **String** | | | +| **tag** | **String** | | | +| **media** | **Array<String>** | | [optional] | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageDeliveredCallbackMessage.new( + id: 1661365814859loidf7mcwd4qacn7, + owner: +15553332222, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + time: 2016-09-14T18:20:16Z, + segment_count: 1, + direction: null, + to: ["+15552223333"], + from: +15553332222, + text: Hello world, + tag: custom string, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"], + priority: null +) +``` + diff --git a/docs/MessageDirectionEnum.md b/docs/MessageDirectionEnum.md new file mode 100644 index 00000000..c79aeb2b --- /dev/null +++ b/docs/MessageDirectionEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::MessageDirectionEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageDirectionEnum.new() +``` + diff --git a/docs/MessageFailedCallback.md b/docs/MessageFailedCallback.md new file mode 100644 index 00000000..d9d65772 --- /dev/null +++ b/docs/MessageFailedCallback.md @@ -0,0 +1,28 @@ +# Bandwidth::MessageFailedCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **time** | **Time** | | | +| **type** | **String** | | | +| **to** | **String** | | | +| **description** | **String** | | | +| **message** | [**MessageFailedCallbackMessage**](MessageFailedCallbackMessage.md) | | | +| **error_code** | **Integer** | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageFailedCallback.new( + time: 2016-09-14T18:20:16Z, + type: message-failed, + to: +15552223333, + description: rejected-unallocated-from-number, + message: null, + error_code: 9902 +) +``` + diff --git a/docs/MessageFailedCallbackMessage.md b/docs/MessageFailedCallbackMessage.md new file mode 100644 index 00000000..7716c6a9 --- /dev/null +++ b/docs/MessageFailedCallbackMessage.md @@ -0,0 +1,40 @@ +# Bandwidth::MessageFailedCallbackMessage + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **owner** | **String** | | | +| **application_id** | **String** | | | +| **time** | **Time** | | | +| **segment_count** | **Integer** | | | +| **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | | +| **to** | **Array<String>** | | | +| **from** | **String** | | | +| **text** | **String** | | | +| **tag** | **String** | | | +| **media** | **Array<String>** | | [optional] | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageFailedCallbackMessage.new( + id: 1661365814859loidf7mcwd4qacn7, + owner: +15553332222, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + time: 2016-09-14T18:20:16Z, + segment_count: 1, + direction: null, + to: ["+15552223333"], + from: +15553332222, + text: Hello world, + tag: custom string, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"], + priority: null +) +``` + diff --git a/docs/MessageRequest.md b/docs/MessageRequest.md new file mode 100644 index 00000000..d5f64c2e --- /dev/null +++ b/docs/MessageRequest.md @@ -0,0 +1,32 @@ +# Bandwidth::MessageRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **application_id** | **String** | The ID of the Application your from number is associated with in the Bandwidth Phone Number Dashboard. | | +| **to** | **Array<String>** | The phone number(s) the message should be sent to in E164 format. | | +| **from** | **String** | One of your telephone numbers the message should come from in E164 format. | | +| **text** | **String** | The contents of the text message. Must be 2048 characters or less. | [optional] | +| **media** | **Array<String>** | A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. | [optional] | +| **tag** | **String** | A custom string that will be included in callback events of the message. Max 1024 characters. | [optional] | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | [optional] | +| **expiration** | **Time** | A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future. Not supported on MMS. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageRequest.new( + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + to: ["+15554443333","+15552223333"], + from: +15551113333, + text: Hello world, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"], + tag: custom string, + priority: null, + expiration: 2021-02-01T11:29:18-05:00 +) +``` + diff --git a/docs/MessageSendingCallback.md b/docs/MessageSendingCallback.md new file mode 100644 index 00000000..cd233d8e --- /dev/null +++ b/docs/MessageSendingCallback.md @@ -0,0 +1,26 @@ +# Bandwidth::MessageSendingCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **time** | **Time** | | | +| **type** | **String** | | | +| **to** | **String** | | | +| **description** | **String** | | | +| **message** | [**MessageSendingCallbackMessage**](MessageSendingCallbackMessage.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageSendingCallback.new( + time: 2016-09-14T18:20:16Z, + type: message-sending, + to: +15552223333, + description: Message is sending to carrier, + message: null +) +``` + diff --git a/docs/MessageSendingCallbackMessage.md b/docs/MessageSendingCallbackMessage.md new file mode 100644 index 00000000..79b530aa --- /dev/null +++ b/docs/MessageSendingCallbackMessage.md @@ -0,0 +1,40 @@ +# Bandwidth::MessageSendingCallbackMessage + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | | | +| **owner** | **String** | | | +| **application_id** | **String** | | | +| **time** | **Time** | | | +| **segment_count** | **Integer** | | | +| **direction** | [**MessageDirectionEnum**](MessageDirectionEnum.md) | | | +| **to** | **Array<String>** | | | +| **from** | **String** | | | +| **text** | **String** | | | +| **tag** | **String** | | [optional] | +| **media** | **Array<String>** | | | +| **priority** | [**PriorityEnum**](PriorityEnum.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageSendingCallbackMessage.new( + id: 1661365814859loidf7mcwd4qacn7, + owner: +15553332222, + application_id: 93de2206-9669-4e07-948d-329f4b722ee2, + time: 2016-09-14T18:20:16Z, + segment_count: 1, + direction: null, + to: ["+15552223333"], + from: +15553332222, + text: Hello world, + tag: custom string, + media: ["https://dev.bandwidth.com/images/bandwidth-logo.png","https://dev.bandwidth.com/images/github_logo.png"], + priority: null +) +``` + diff --git a/docs/MessageStatusEnum.md b/docs/MessageStatusEnum.md new file mode 100644 index 00000000..4e9f67e4 --- /dev/null +++ b/docs/MessageStatusEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::MessageStatusEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageStatusEnum.new() +``` + diff --git a/docs/MessageTypeEnum.md b/docs/MessageTypeEnum.md new file mode 100644 index 00000000..325d06ca --- /dev/null +++ b/docs/MessageTypeEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::MessageTypeEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessageTypeEnum.new() +``` + diff --git a/docs/MessagesApi.md b/docs/MessagesApi.md new file mode 100644 index 00000000..b32f532d --- /dev/null +++ b/docs/MessagesApi.md @@ -0,0 +1,183 @@ +# Bandwidth::MessagesApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_message**](MessagesApi.md#create_message) | **POST** /users/{accountId}/messages | Create Message | +| [**list_messages**](MessagesApi.md#list_messages) | **GET** /users/{accountId}/messages | List Messages | + + +## create_message + +> create_message(account_id, message_request) + +Create Message + +Endpoint for sending text messages and picture messages using V2 messaging. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MessagesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +message_request = Bandwidth::MessageRequest.new({application_id: '93de2206-9669-4e07-948d-329f4b722ee2', to: ["+15554443333", "+15552223333"], from: '+15551113333'}) # MessageRequest | + +begin + # Create Message + result = api_instance.create_message(account_id, message_request) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MessagesApi->create_message: #{e}" +end +``` + +#### Using the create_message_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_message_with_http_info(account_id, message_request) + +```ruby +begin + # Create Message + data, status_code, headers = api_instance.create_message_with_http_info(account_id, message_request) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling MessagesApi->create_message_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **message_request** | [**MessageRequest**](MessageRequest.md) | | | + +### Return type + +[**Message**](Message.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## list_messages + +> list_messages(account_id, opts) + +List Messages + +Returns a list of messages based on query parameters. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::MessagesApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +opts = { + message_id: '9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6', # String | The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter. + source_tn: '%2B15554443333', # String | The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + destination_tn: '%2B15554443333', # String | The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + message_status: Bandwidth::MessageStatusEnum::RECEIVED, # MessageStatusEnum | The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED. + message_direction: Bandwidth::ListMessageDirectionEnum::INBOUND, # ListMessageDirectionEnum | The direction of the message. One of INBOUND OUTBOUND. + carrier_name: 'Verizon', # String | The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T). + message_type: Bandwidth::MessageTypeEnum::SMS, # MessageTypeEnum | The type of message. Either sms or mms. + error_code: 9902, # Integer | The error code of the message. + from_date_time: '2022-09-14T18:20:16.000Z', # String | The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + to_date_time: '2022-09-14T18:20:16.000Z', # String | The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + campaign_id: 'CJEUMDK', # String | The campaign ID of the message. + sort: 'sourceTn:desc', # String | The field and direction to sort by combined with a colon. Direction is either asc or desc. + page_token: 'gdEewhcJLQRB5', # String | A base64 encoded value used for pagination of results. + limit: 50, # Integer | The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000. + limit_total_count: true # Boolean | When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results. +} + +begin + # List Messages + result = api_instance.list_messages(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling MessagesApi->list_messages: #{e}" +end +``` + +#### Using the list_messages_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> list_messages_with_http_info(account_id, opts) + +```ruby +begin + # List Messages + data, status_code, headers = api_instance.list_messages_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling MessagesApi->list_messages_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **message_id** | **String** | The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter. | [optional] | +| **source_tn** | **String** | The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). | [optional] | +| **destination_tn** | **String** | The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). | [optional] | +| **message_status** | [**MessageStatusEnum**](.md) | The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED. | [optional] | +| **message_direction** | [**ListMessageDirectionEnum**](.md) | The direction of the message. One of INBOUND OUTBOUND. | [optional] | +| **carrier_name** | **String** | The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T). | [optional] | +| **message_type** | [**MessageTypeEnum**](.md) | The type of message. Either sms or mms. | [optional] | +| **error_code** | **Integer** | The error code of the message. | [optional] | +| **from_date_time** | **String** | The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. | [optional] | +| **to_date_time** | **String** | The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. | [optional] | +| **campaign_id** | **String** | The campaign ID of the message. | [optional] | +| **sort** | **String** | The field and direction to sort by combined with a colon. Direction is either asc or desc. | [optional] | +| **page_token** | **String** | A base64 encoded value used for pagination of results. | [optional] | +| **limit** | **Integer** | The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000. | [optional] | +| **limit_total_count** | **Boolean** | When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results. | [optional] | + +### Return type + +[**MessagesList**](MessagesList.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/MessagesList.md b/docs/MessagesList.md new file mode 100644 index 00000000..8eae4842 --- /dev/null +++ b/docs/MessagesList.md @@ -0,0 +1,22 @@ +# Bandwidth::MessagesList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **total_count** | **Integer** | The total number of messages matched by the search. When the request has limitTotalCount set to true this value is limited to 10,000. | [optional] | +| **page_info** | [**PageInfo**](PageInfo.md) | | [optional] | +| **messages** | [**Array<ListMessageItem>**](ListMessageItem.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessagesList.new( + total_count: 100, + page_info: null, + messages: null +) +``` + diff --git a/docs/MessagingCodeResponse.md b/docs/MessagingCodeResponse.md new file mode 100644 index 00000000..0f1d7930 --- /dev/null +++ b/docs/MessagingCodeResponse.md @@ -0,0 +1,18 @@ +# Bandwidth::MessagingCodeResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message_id** | **String** | Messaging API Message ID. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessagingCodeResponse.new( + message_id: 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 +) +``` + diff --git a/docs/MessagingRequestError.md b/docs/MessagingRequestError.md new file mode 100644 index 00000000..26ec1624 --- /dev/null +++ b/docs/MessagingRequestError.md @@ -0,0 +1,20 @@ +# Bandwidth::MessagingRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | | +| **description** | **String** | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MessagingRequestError.new( + type: null, + description: null +) +``` + diff --git a/docs/MfaForbiddenRequestError.md b/docs/MfaForbiddenRequestError.md new file mode 100644 index 00000000..4e311511 --- /dev/null +++ b/docs/MfaForbiddenRequestError.md @@ -0,0 +1,18 @@ +# Bandwidth::MfaForbiddenRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | The message containing the reason behind the request being forbidden. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MfaForbiddenRequestError.new( + message: Missing Authentication Token +) +``` + diff --git a/docs/MfaRequestError.md b/docs/MfaRequestError.md new file mode 100644 index 00000000..6fd9adbe --- /dev/null +++ b/docs/MfaRequestError.md @@ -0,0 +1,20 @@ +# Bandwidth::MfaRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **error** | **String** | A message describing the error with your request. | [optional] | +| **request_id** | **String** | The associated requestId from AWS. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MfaRequestError.new( + error: 400 Request is malformed or invalid, + request_id: 354cc8a3-6701-461e-8fa7-8671703dd898 +) +``` + diff --git a/docs/MfaUnauthorizedRequestError.md b/docs/MfaUnauthorizedRequestError.md new file mode 100644 index 00000000..c1dec158 --- /dev/null +++ b/docs/MfaUnauthorizedRequestError.md @@ -0,0 +1,18 @@ +# Bandwidth::MfaUnauthorizedRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | Unauthorized | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::MfaUnauthorizedRequestError.new( + message: Unauthorized +) +``` + diff --git a/docs/PageInfo.md b/docs/PageInfo.md new file mode 100644 index 00000000..8a0a864d --- /dev/null +++ b/docs/PageInfo.md @@ -0,0 +1,24 @@ +# Bandwidth::PageInfo + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **prev_page** | **String** | The link to the previous page for pagination. | [optional] | +| **next_page** | **String** | The link to the next page for pagination. | [optional] | +| **prev_page_token** | **String** | The isolated pagination token for the previous page. | [optional] | +| **next_page_token** | **String** | The isolated pagination token for the next page. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::PageInfo.new( + prev_page: https://messaging.bandwidth.com/api/v2/users/accountId/messages?messageStatus=DLR_EXPIRED&nextPage=DLAPE902, + next_page: https://messaging.bandwidth.com/api/v2/users/accountId/messages?messageStatus=DLR_EXPIRED&prevPage=GL83PD3C, + prev_page_token: DLAPE902, + next_page_token: GL83PD3C +) +``` + diff --git a/docs/Participant.md b/docs/Participant.md new file mode 100644 index 00000000..4d57b803 --- /dev/null +++ b/docs/Participant.md @@ -0,0 +1,30 @@ +# Bandwidth::Participant + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique id of the participant. | [optional][readonly] | +| **callback_url** | **String** | Full callback url to use for notifications about this participant. | [optional] | +| **publish_permissions** | [**Array<PublishPermissionsEnum>**](PublishPermissionsEnum.md) | Defines if this participant can publish audio or video. | [optional] | +| **sessions** | **Array<String>** | List of session ids this participant is associated with Capped to one Upon creation of a Participant, returns as an empty array. | [optional][readonly] | +| **subscriptions** | [**Subscriptions**](Subscriptions.md) | | [optional] | +| **tag** | **String** | User defined tag to associate with the participant. | [optional] | +| **device_api_version** | [**DeviceApiVersionEnum**](DeviceApiVersionEnum.md) | | [optional][default to 'V3'] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Participant.new( + id: 320e2af6-13ec-498d-8b51-daba52c37853, + callback_url: https://example.com/callback, + publish_permissions: ["VIDEO","AUDIO"], + sessions: ["75c21163-e110-41bc-bd76-1bb428ec85d5"], + subscriptions: null, + tag: participant1, + device_api_version: null +) +``` + diff --git a/docs/ParticipantSubscription.md b/docs/ParticipantSubscription.md new file mode 100644 index 00000000..913d50dc --- /dev/null +++ b/docs/ParticipantSubscription.md @@ -0,0 +1,20 @@ +# Bandwidth::ParticipantSubscription + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **participant_id** | **String** | The Participant the subscriber will be subscribed to | | +| **stream_aliases** | **Array<String>** | (optional) An array of specific streamAliases owned by the Participant that the subscriber will be subscribed to. Background: A streamAlias is created by a WebRTC client when it connects and declares a name for the related stream. The client is responsible for informing the application of any created streamAliases to enable the application to subscribe to specific streamAliases. Subscribing to a `streamAlias` that does not exist is undefined. If the array is empty all aliases are assumed. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::ParticipantSubscription.new( + participant_id: 568749d5-04d5-483d-adf5-deac7dd3d521, + stream_aliases: ["alias_1","alias_2"] +) +``` + diff --git a/docs/ParticipantsApi.md b/docs/ParticipantsApi.md new file mode 100644 index 00000000..3b18501d --- /dev/null +++ b/docs/ParticipantsApi.md @@ -0,0 +1,227 @@ +# Bandwidth::ParticipantsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_participant**](ParticipantsApi.md#create_participant) | **POST** /accounts/{accountId}/participants | Create Participant | +| [**delete_participant**](ParticipantsApi.md#delete_participant) | **DELETE** /accounts/{accountId}/participants/{participantId} | Delete Participant | +| [**get_participant**](ParticipantsApi.md#get_participant) | **GET** /accounts/{accountId}/participants/{participantId} | Get Participant | + + +## create_participant + +> create_participant(account_id, opts) + +Create Participant + +Create a new participant under this account. Participants are idempotent, so relevant parameters must be set in this function if desired. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ParticipantsApi.new +account_id = '9900000' # String | Account ID +opts = { + create_participant_request: Bandwidth::CreateParticipantRequest.new # CreateParticipantRequest | Create participant request body. +} + +begin + # Create Participant + result = api_instance.create_participant(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->create_participant: #{e}" +end +``` + +#### Using the create_participant_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_participant_with_http_info(account_id, opts) + +```ruby +begin + # Create Participant + data, status_code, headers = api_instance.create_participant_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->create_participant_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **create_participant_request** | [**CreateParticipantRequest**](CreateParticipantRequest.md) | Create participant request body. | [optional] | + +### Return type + +[**CreateParticipantResponse**](CreateParticipantResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## delete_participant + +> delete_participant(account_id, participant_id) + +Delete Participant + +Delete participant by ID. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ParticipantsApi.new +account_id = '9900000' # String | Account ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID + +begin + # Delete Participant + api_instance.delete_participant(account_id, participant_id) +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->delete_participant: #{e}" +end +``` + +#### Using the delete_participant_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_participant_with_http_info(account_id, participant_id) + +```ruby +begin + # Delete Participant + data, status_code, headers = api_instance.delete_participant_with_http_info(account_id, participant_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->delete_participant_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **participant_id** | **String** | Participant ID | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_participant + +> get_participant(account_id, participant_id) + +Get Participant + +Get participant by ID. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::ParticipantsApi.new +account_id = '9900000' # String | Account ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID + +begin + # Get Participant + result = api_instance.get_participant(account_id, participant_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->get_participant: #{e}" +end +``` + +#### Using the get_participant_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_participant_with_http_info(account_id, participant_id) + +```ruby +begin + # Get Participant + data, status_code, headers = api_instance.get_participant_with_http_info(account_id, participant_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling ParticipantsApi->get_participant_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **participant_id** | **String** | Participant ID | | + +### Return type + +[**Participant**](Participant.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/PhoneNumberLookupApi.md b/docs/PhoneNumberLookupApi.md new file mode 100644 index 00000000..52a9d1cb --- /dev/null +++ b/docs/PhoneNumberLookupApi.md @@ -0,0 +1,153 @@ +# Bandwidth::PhoneNumberLookupApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**create_lookup**](PhoneNumberLookupApi.md#create_lookup) | **POST** /accounts/{accountId}/tnlookup | Create Lookup | +| [**get_lookup_status**](PhoneNumberLookupApi.md#get_lookup_status) | **GET** /accounts/{accountId}/tnlookup/{requestId} | Get Lookup Request Status | + + +## create_lookup + +> create_lookup(account_id, lookup_request) + +Create Lookup + +Create a Phone Number Lookup Request. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::PhoneNumberLookupApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +lookup_request = Bandwidth::LookupRequest.new({tns: ['tns_example']}) # LookupRequest | Phone number lookup request. + +begin + # Create Lookup + result = api_instance.create_lookup(account_id, lookup_request) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling PhoneNumberLookupApi->create_lookup: #{e}" +end +``` + +#### Using the create_lookup_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_lookup_with_http_info(account_id, lookup_request) + +```ruby +begin + # Create Lookup + data, status_code, headers = api_instance.create_lookup_with_http_info(account_id, lookup_request) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling PhoneNumberLookupApi->create_lookup_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **lookup_request** | [**LookupRequest**](LookupRequest.md) | Phone number lookup request. | | + +### Return type + +[**CreateLookupResponse**](CreateLookupResponse.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## get_lookup_status + +> get_lookup_status(account_id, request_id) + +Get Lookup Request Status + +Get an existing Phone Number Lookup Request. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::PhoneNumberLookupApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +request_id = '004223a0-8b17-41b1-bf81-20732adf5590' # String | The phone number lookup request ID from Bandwidth. + +begin + # Get Lookup Request Status + result = api_instance.get_lookup_status(account_id, request_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling PhoneNumberLookupApi->get_lookup_status: #{e}" +end +``` + +#### Using the get_lookup_status_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_lookup_status_with_http_info(account_id, request_id) + +```ruby +begin + # Get Lookup Request Status + data, status_code, headers = api_instance.get_lookup_status_with_http_info(account_id, request_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling PhoneNumberLookupApi->get_lookup_status_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **request_id** | **String** | The phone number lookup request ID from Bandwidth. | | + +### Return type + +[**LookupStatus**](LookupStatus.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/PriorityEnum.md b/docs/PriorityEnum.md new file mode 100644 index 00000000..34dab6d7 --- /dev/null +++ b/docs/PriorityEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::PriorityEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::PriorityEnum.new() +``` + diff --git a/docs/PublishPermissionsEnum.md b/docs/PublishPermissionsEnum.md new file mode 100644 index 00000000..6b103580 --- /dev/null +++ b/docs/PublishPermissionsEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::PublishPermissionsEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::PublishPermissionsEnum.new() +``` + diff --git a/docs/RecordingAvailableCallback.md b/docs/RecordingAvailableCallback.md new file mode 100644 index 00000000..1d8527ee --- /dev/null +++ b/docs/RecordingAvailableCallback.md @@ -0,0 +1,60 @@ +# Bandwidth::RecordingAvailableCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **channels** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **status** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RecordingAvailableCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + end_time: 2022-06-17T22:20Z, + duration: PT13.67S, + file_format: null, + channels: completed, + tag: exampleTag, + status: completed, + transfer_caller_id: +15555555555, + transfer_to: +15555555555) +) +``` + diff --git a/docs/RecordingCompleteCallback.md b/docs/RecordingCompleteCallback.md new file mode 100644 index 00000000..29ccb1b7 --- /dev/null +++ b/docs/RecordingCompleteCallback.md @@ -0,0 +1,60 @@ +# Bandwidth::RecordingCompleteCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **channels** | **Integer** | Always `1` for conference recordings; multi-channel recordings are not supported on conferences. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RecordingCompleteCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + end_time: 2022-06-17T22:20Z, + duration: PT13.67S, + file_format: null, + channels: 1, + tag: exampleTag, + transfer_caller_id: +15555555555, + transfer_to: +15555555555) +) +``` + diff --git a/docs/RecordingStateEnum.md b/docs/RecordingStateEnum.md new file mode 100644 index 00000000..1a847b60 --- /dev/null +++ b/docs/RecordingStateEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::RecordingStateEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RecordingStateEnum.new() +``` + diff --git a/docs/RecordingsApi.md b/docs/RecordingsApi.md new file mode 100644 index 00000000..7faa3d73 --- /dev/null +++ b/docs/RecordingsApi.md @@ -0,0 +1,758 @@ +# Bandwidth::RecordingsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**delete_call_transcription**](RecordingsApi.md#delete_call_transcription) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Delete Transcription | +| [**delete_recording**](RecordingsApi.md#delete_recording) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId} | Delete Recording | +| [**delete_recording_media**](RecordingsApi.md#delete_recording_media) | **DELETE** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media | Delete Recording Media | +| [**download_call_recording**](RecordingsApi.md#download_call_recording) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media | Download Recording | +| [**get_call_recording**](RecordingsApi.md#get_call_recording) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId} | Get Call Recording | +| [**get_call_transcription**](RecordingsApi.md#get_call_transcription) | **GET** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Get Transcription | +| [**list_account_call_recordings**](RecordingsApi.md#list_account_call_recordings) | **GET** /accounts/{accountId}/recordings | Get Call Recordings | +| [**list_call_recordings**](RecordingsApi.md#list_call_recordings) | **GET** /accounts/{accountId}/calls/{callId}/recordings | List Call Recordings | +| [**transcribe_call_recording**](RecordingsApi.md#transcribe_call_recording) | **POST** /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription | Create Transcription Request | +| [**update_call_recording_state**](RecordingsApi.md#update_call_recording_state) | **PUT** /accounts/{accountId}/calls/{callId}/recording | Update Recording | + + +## delete_call_transcription + +> delete_call_transcription(account_id, call_id, recording_id) + +Delete Transcription + +Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Delete Transcription + api_instance.delete_call_transcription(account_id, call_id, recording_id) +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_call_transcription: #{e}" +end +``` + +#### Using the delete_call_transcription_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_call_transcription_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Delete Transcription + data, status_code, headers = api_instance.delete_call_transcription_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_call_transcription_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## delete_recording + +> delete_recording(account_id, call_id, recording_id) + +Delete Recording + +Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Delete Recording + api_instance.delete_recording(account_id, call_id, recording_id) +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_recording: #{e}" +end +``` + +#### Using the delete_recording_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_recording_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Delete Recording + data, status_code, headers = api_instance.delete_recording_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## delete_recording_media + +> delete_recording_media(account_id, call_id, recording_id) + +Delete Recording Media + +Deletes the specified recording's media. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Delete Recording Media + api_instance.delete_recording_media(account_id, call_id, recording_id) +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_recording_media: #{e}" +end +``` + +#### Using the delete_recording_media_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_recording_media_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Delete Recording Media + data, status_code, headers = api_instance.delete_recording_media_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->delete_recording_media_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## download_call_recording + +> File download_call_recording(account_id, call_id, recording_id) + +Download Recording + +Downloads the specified recording. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Download Recording + result = api_instance.download_call_recording(account_id, call_id, recording_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->download_call_recording: #{e}" +end +``` + +#### Using the download_call_recording_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> download_call_recording_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Download Recording + data, status_code, headers = api_instance.download_call_recording_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => File +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->download_call_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +**File** + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: audio/vnd.wave, audio/mpeg, application/json + + +## get_call_recording + +> get_call_recording(account_id, call_id, recording_id) + +Get Call Recording + +Returns metadata for the specified recording. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Get Call Recording + result = api_instance.get_call_recording(account_id, call_id, recording_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->get_call_recording: #{e}" +end +``` + +#### Using the get_call_recording_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_call_recording_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Get Call Recording + data, status_code, headers = api_instance.get_call_recording_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->get_call_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +[**CallRecordingMetadata**](CallRecordingMetadata.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_call_transcription + +> get_call_transcription(account_id, call_id, recording_id) + +Get Transcription + +Downloads the specified transcription. If the transcribed recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [``](/docs/voice/bxml/playAudio) and [``](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [``](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. + +begin + # Get Transcription + result = api_instance.get_call_transcription(account_id, call_id, recording_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->get_call_transcription: #{e}" +end +``` + +#### Using the get_call_transcription_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_call_transcription_with_http_info(account_id, call_id, recording_id) + +```ruby +begin + # Get Transcription + data, status_code, headers = api_instance.get_call_transcription_with_http_info(account_id, call_id, recording_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->get_call_transcription_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | + +### Return type + +[**TranscriptionList**](TranscriptionList.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_account_call_recordings + +> > list_account_call_recordings(account_id, opts) + +Get Call Recordings + +Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +opts = { + to: '%2b19195551234', # String | Filter results by the `to` field. + from: '%2b19195554321', # String | Filter results by the `from` field. + min_start_time: '2022-06-21T19:13:21Z', # String | Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format). + max_start_time: '2022-06-21T19:13:21Z' # String | Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format). +} + +begin + # Get Call Recordings + result = api_instance.list_account_call_recordings(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->list_account_call_recordings: #{e}" +end +``` + +#### Using the list_account_call_recordings_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_account_call_recordings_with_http_info(account_id, opts) + +```ruby +begin + # Get Call Recordings + data, status_code, headers = api_instance.list_account_call_recordings_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->list_account_call_recordings_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **to** | **String** | Filter results by the `to` field. | [optional] | +| **from** | **String** | Filter results by the `from` field. | [optional] | +| **min_start_time** | **String** | Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format). | [optional] | +| **max_start_time** | **String** | Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format). | [optional] | + +### Return type + +[**Array<CallRecordingMetadata>**](CallRecordingMetadata.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_call_recordings + +> > list_call_recordings(account_id, call_id) + +List Call Recordings + +Returns a (potentially empty) list of metadata for the recordings that took place during the specified call. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. + +begin + # List Call Recordings + result = api_instance.list_call_recordings(account_id, call_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->list_call_recordings: #{e}" +end +``` + +#### Using the list_call_recordings_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_call_recordings_with_http_info(account_id, call_id) + +```ruby +begin + # List Call Recordings + data, status_code, headers = api_instance.list_call_recordings_with_http_info(account_id, call_id) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->list_call_recordings_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | + +### Return type + +[**Array<CallRecordingMetadata>**](CallRecordingMetadata.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## transcribe_call_recording + +> transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording) + +Create Transcription Request + +Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Recording ID. +transcribe_recording = Bandwidth::TranscribeRecording.new # TranscribeRecording | + +begin + # Create Transcription Request + api_instance.transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording) +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->transcribe_call_recording: #{e}" +end +``` + +#### Using the transcribe_call_recording_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording) + +```ruby +begin + # Create Transcription Request + data, status_code, headers = api_instance.transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->transcribe_call_recording_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **recording_id** | **String** | Programmable Voice API Recording ID. | | +| **transcribe_recording** | [**TranscribeRecording**](TranscribeRecording.md) | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## update_call_recording_state + +> update_call_recording_state(account_id, call_id, update_call_recording) + +Update Recording + +Pause or resume a recording on an active phone call. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::RecordingsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. +call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' # String | Programmable Voice API Call ID. +update_call_recording = Bandwidth::UpdateCallRecording.new({state: Bandwidth::RecordingStateEnum::PAUSED}) # UpdateCallRecording | + +begin + # Update Recording + api_instance.update_call_recording_state(account_id, call_id, update_call_recording) +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->update_call_recording_state: #{e}" +end +``` + +#### Using the update_call_recording_state_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_call_recording_state_with_http_info(account_id, call_id, update_call_recording) + +```ruby +begin + # Update Recording + data, status_code, headers = api_instance.update_call_recording_state_with_http_info(account_id, call_id, update_call_recording) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling RecordingsApi->update_call_recording_state_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | +| **call_id** | **String** | Programmable Voice API Call ID. | | +| **update_call_recording** | [**UpdateCallRecording**](UpdateCallRecording.md) | | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/RedirectCallback.md b/docs/RedirectCallback.md new file mode 100644 index 00000000..4d433b30 --- /dev/null +++ b/docs/RedirectCallback.md @@ -0,0 +1,48 @@ +# Bandwidth::RedirectCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RedirectCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + transfer_caller_id: +15555555555, + transfer_to: +15555555555) +) +``` + diff --git a/docs/RedirectMethodEnum.md b/docs/RedirectMethodEnum.md new file mode 100644 index 00000000..6a3b89cf --- /dev/null +++ b/docs/RedirectMethodEnum.md @@ -0,0 +1,15 @@ +# Bandwidth::RedirectMethodEnum + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RedirectMethodEnum.new() +``` + diff --git a/docs/RequestError.md b/docs/RequestError.md new file mode 100644 index 00000000..435a830b --- /dev/null +++ b/docs/RequestError.md @@ -0,0 +1,20 @@ +# Bandwidth::RequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **error** | **String** | A message describing the error with your request. | [optional] | +| **request_id** | **String** | The associated requestId from AWS. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::RequestError.new( + error: Internal error, + request_id: 12af78d1-5f88-4917-925d-17c1ac8fda7a +) +``` + diff --git a/docs/Session.md b/docs/Session.md new file mode 100644 index 00000000..3ecaf79a --- /dev/null +++ b/docs/Session.md @@ -0,0 +1,20 @@ +# Bandwidth::Session + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | Unique id of the session. | [optional] | +| **tag** | **String** | User defined tag to associate with the session. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Session.new( + id: 75c21163-e110-41bc-bd76-1bb428ec85d5, + tag: session1 +) +``` + diff --git a/docs/SessionsApi.md b/docs/SessionsApi.md new file mode 100644 index 00000000..83a64520 --- /dev/null +++ b/docs/SessionsApi.md @@ -0,0 +1,605 @@ +# Bandwidth::SessionsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**add_participant_to_session**](SessionsApi.md#add_participant_to_session) | **PUT** /accounts/{accountId}/sessions/{sessionId}/participants/{participantId} | Add Participant to Session | +| [**create_session**](SessionsApi.md#create_session) | **POST** /accounts/{accountId}/sessions | Create Session | +| [**delete_session**](SessionsApi.md#delete_session) | **DELETE** /accounts/{accountId}/sessions/{sessionId} | Delete Session | +| [**get_participant_subscriptions**](SessionsApi.md#get_participant_subscriptions) | **GET** /accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions | Get Participant Subscriptions | +| [**get_session**](SessionsApi.md#get_session) | **GET** /accounts/{accountId}/sessions/{sessionId} | Get Session | +| [**list_session_participants**](SessionsApi.md#list_session_participants) | **GET** /accounts/{accountId}/sessions/{sessionId}/participants | List Participants in Session | +| [**remove_participant_from_session**](SessionsApi.md#remove_participant_from_session) | **DELETE** /accounts/{accountId}/sessions/{sessionId}/participants/{participantId} | Remove Participant from Session | +| [**update_participant_subscriptions**](SessionsApi.md#update_participant_subscriptions) | **PUT** /accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions | Update Participant Subscriptions | + + +## add_participant_to_session + +> add_participant_to_session(account_id, session_id, participant_id, opts) + +Add Participant to Session + +Add a participant to a session. Subscriptions can optionally be provided as part of this call. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID +opts = { + subscriptions: Bandwidth::Subscriptions.new # Subscriptions | The Body describes an optional set of subscriptions to apply to the participant. Calling this endpoint with no/empty body will only add the participant to the session, and will not subscribe the Participant to any media. The request body for this endpoint is OPTIONAL and provided as a convenience to avoid additional calls to the Update Participant Subscriptions endpoint. --- If a body is provided it will result in direct control over what Participants are subscribed to. - if the participants Array is provided and not empty, that list of Participants will be subscribed To - if the participants Array is missing or empty, and the sessionId is provided, the participant will be subscribed to the session, including all subsequent changes to the membership of the session - if the sessionId and the participant Array are both missing or empty, no subscriptions will be created +} + +begin + # Add Participant to Session + api_instance.add_participant_to_session(account_id, session_id, participant_id, opts) +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->add_participant_to_session: #{e}" +end +``` + +#### Using the add_participant_to_session_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> add_participant_to_session_with_http_info(account_id, session_id, participant_id, opts) + +```ruby +begin + # Add Participant to Session + data, status_code, headers = api_instance.add_participant_to_session_with_http_info(account_id, session_id, participant_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->add_participant_to_session_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | +| **participant_id** | **String** | Participant ID | | +| **subscriptions** | [**Subscriptions**](Subscriptions.md) | The Body describes an optional set of subscriptions to apply to the participant. Calling this endpoint with no/empty body will only add the participant to the session, and will not subscribe the Participant to any media. The request body for this endpoint is OPTIONAL and provided as a convenience to avoid additional calls to the Update Participant Subscriptions endpoint. --- If a body is provided it will result in direct control over what Participants are subscribed to. - if the participants Array is provided and not empty, that list of Participants will be subscribed To - if the participants Array is missing or empty, and the sessionId is provided, the participant will be subscribed to the session, including all subsequent changes to the membership of the session - if the sessionId and the participant Array are both missing or empty, no subscriptions will be created | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## create_session + +> create_session(account_id, opts) + +Create Session + +Create a new session. Sessions are idempotent, so relevant parameters must be set in this function if desired. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +opts = { + session: Bandwidth::Session.new # Session | Create session request body. +} + +begin + # Create Session + result = api_instance.create_session(account_id, opts) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->create_session: #{e}" +end +``` + +#### Using the create_session_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> create_session_with_http_info(account_id, opts) + +```ruby +begin + # Create Session + data, status_code, headers = api_instance.create_session_with_http_info(account_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->create_session_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session** | [**Session**](Session.md) | Create session request body. | [optional] | + +### Return type + +[**Session**](Session.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## delete_session + +> delete_session(account_id, session_id) + +Delete Session + +Delete session by ID. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID + +begin + # Delete Session + api_instance.delete_session(account_id, session_id) +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->delete_session: #{e}" +end +``` + +#### Using the delete_session_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> delete_session_with_http_info(account_id, session_id) + +```ruby +begin + # Delete Session + data, status_code, headers = api_instance.delete_session_with_http_info(account_id, session_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->delete_session_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_participant_subscriptions + +> get_participant_subscriptions(account_id, session_id, participant_id) + +Get Participant Subscriptions + +Get a participant's subscriptions. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID + +begin + # Get Participant Subscriptions + result = api_instance.get_participant_subscriptions(account_id, session_id, participant_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->get_participant_subscriptions: #{e}" +end +``` + +#### Using the get_participant_subscriptions_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_participant_subscriptions_with_http_info(account_id, session_id, participant_id) + +```ruby +begin + # Get Participant Subscriptions + data, status_code, headers = api_instance.get_participant_subscriptions_with_http_info(account_id, session_id, participant_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->get_participant_subscriptions_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | +| **participant_id** | **String** | Participant ID | | + +### Return type + +[**Subscriptions**](Subscriptions.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## get_session + +> get_session(account_id, session_id) + +Get Session + +Get session by ID. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID + +begin + # Get Session + result = api_instance.get_session(account_id, session_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->get_session: #{e}" +end +``` + +#### Using the get_session_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_session_with_http_info(account_id, session_id) + +```ruby +begin + # Get Session + data, status_code, headers = api_instance.get_session_with_http_info(account_id, session_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->get_session_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | + +### Return type + +[**Session**](Session.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## list_session_participants + +> > list_session_participants(account_id, session_id) + +List Participants in Session + +List participants in a session. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID + +begin + # List Participants in Session + result = api_instance.list_session_participants(account_id, session_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->list_session_participants: #{e}" +end +``` + +#### Using the list_session_participants_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> >, Integer, Hash)> list_session_participants_with_http_info(account_id, session_id) + +```ruby +begin + # List Participants in Session + data, status_code, headers = api_instance.list_session_participants_with_http_info(account_id, session_id) + p status_code # => 2xx + p headers # => { ... } + p data # => > +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->list_session_participants_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | + +### Return type + +[**Array<Participant>**](Participant.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## remove_participant_from_session + +> remove_participant_from_session(account_id, session_id, participant_id) + +Remove Participant from Session + +Remove a participant from a session. This will automatically remove any subscriptions the participant has associated with this session. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID + +begin + # Remove Participant from Session + api_instance.remove_participant_from_session(account_id, session_id, participant_id) +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->remove_participant_from_session: #{e}" +end +``` + +#### Using the remove_participant_from_session_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> remove_participant_from_session_with_http_info(account_id, session_id, participant_id) + +```ruby +begin + # Remove Participant from Session + data, status_code, headers = api_instance.remove_participant_from_session_with_http_info(account_id, session_id, participant_id) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->remove_participant_from_session_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | +| **participant_id** | **String** | Participant ID | | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## update_participant_subscriptions + +> update_participant_subscriptions(account_id, session_id, participant_id, opts) + +Update Participant Subscriptions + +Update a participant's subscriptions. This is a full update that will replace the participant's subscriptions. It allows subscription to the entire Session, a subset list of Participants in that Session, or specific media streams on any of the listed Participants. First call `getParticipantSubscriptions` if you need the current subscriptions. Calling this API with no `Subscriptions` object to remove all subscriptions. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::SessionsApi.new +account_id = '9900000' # String | Account ID +session_id = 'cb5054ee-a69b-41ac-9ab2-04d6370826b4' # String | Session ID +participant_id = '62e0ecb9-0b1b-5115-aae4-4f36123d6bb1' # String | Participant ID +opts = { + subscriptions: Bandwidth::Subscriptions.new # Subscriptions | The body describes the desired subscriptions for the Participant. --- If a body is provided it will result in direct control over what Participants are subscribed to. - if the participants Array is provided and not empty, that list of Participants will be subscribed To - if the participants Array is missing or empty, and the sessionId is provided, the participant will be subscribed to the session, including all subsequent changes to the membership of the session - if the sessionId and the participant Array are both missing or empty, no subscriptions will be created +} + +begin + # Update Participant Subscriptions + api_instance.update_participant_subscriptions(account_id, session_id, participant_id, opts) +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->update_participant_subscriptions: #{e}" +end +``` + +#### Using the update_participant_subscriptions_with_http_info variant + +This returns an Array which contains the response data (`nil` in this case), status code and headers. + +> update_participant_subscriptions_with_http_info(account_id, session_id, participant_id, opts) + +```ruby +begin + # Update Participant Subscriptions + data, status_code, headers = api_instance.update_participant_subscriptions_with_http_info(account_id, session_id, participant_id, opts) + p status_code # => 2xx + p headers # => { ... } + p data # => nil +rescue Bandwidth::ApiError => e + puts "Error when calling SessionsApi->update_participant_subscriptions_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Account ID | | +| **session_id** | **String** | Session ID | | +| **participant_id** | **String** | Participant ID | | +| **subscriptions** | [**Subscriptions**](Subscriptions.md) | The body describes the desired subscriptions for the Participant. --- If a body is provided it will result in direct control over what Participants are subscribed to. - if the participants Array is provided and not empty, that list of Participants will be subscribed To - if the participants Array is missing or empty, and the sessionId is provided, the participant will be subscribed to the session, including all subsequent changes to the membership of the session - if the sessionId and the participant Array are both missing or empty, no subscriptions will be created | [optional] | + +### Return type + +nil (empty response body) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + diff --git a/docs/StatisticsApi.md b/docs/StatisticsApi.md new file mode 100644 index 00000000..8809fd44 --- /dev/null +++ b/docs/StatisticsApi.md @@ -0,0 +1,78 @@ +# Bandwidth::StatisticsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +| ------ | ------------ | ----------- | +| [**get_statistics**](StatisticsApi.md#get_statistics) | **GET** /accounts/{accountId}/statistics | Get Account Statistics | + + +## get_statistics + +> get_statistics(account_id) + +Get Account Statistics + +Returns details about the current state of the account. + +### Examples + +```ruby +require 'time' +require 'bandwidth-sdk' +# setup authorization +Bandwidth.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' +end + +api_instance = Bandwidth::StatisticsApi.new +account_id = '9900000' # String | Your Bandwidth Account ID. + +begin + # Get Account Statistics + result = api_instance.get_statistics(account_id) + p result +rescue Bandwidth::ApiError => e + puts "Error when calling StatisticsApi->get_statistics: #{e}" +end +``` + +#### Using the get_statistics_with_http_info variant + +This returns an Array which contains the response data, status code and headers. + +> , Integer, Hash)> get_statistics_with_http_info(account_id) + +```ruby +begin + # Get Account Statistics + data, status_code, headers = api_instance.get_statistics_with_http_info(account_id) + p status_code # => 2xx + p headers # => { ... } + p data # => +rescue Bandwidth::ApiError => e + puts "Error when calling StatisticsApi->get_statistics_with_http_info: #{e}" +end +``` + +### Parameters + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **account_id** | **String** | Your Bandwidth Account ID. | | + +### Return type + +[**AccountStatistics**](AccountStatistics.md) + +### Authorization + +[Basic](../README.md#Basic) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/StirShaken.md b/docs/StirShaken.md new file mode 100644 index 00000000..42f1e965 --- /dev/null +++ b/docs/StirShaken.md @@ -0,0 +1,22 @@ +# Bandwidth::StirShaken + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **verstat** | **String** | (optional) The verification status indicating whether the verification was successful or not. Possible values are TN-Verification-Passed and TN-Verification-Failed. | [optional] | +| **attestation_indicator** | **String** | (optional) The attestation level verified by Bandwidth. Possible values are A (full), B (partial) or C (gateway). | [optional] | +| **originating_id** | **String** | (optional) A unique origination identifier. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::StirShaken.new( + verstat: Tn-Verification-Passed, + attestation_indicator: A, + originating_id: 99759086-1335-11ed-9bcf-5f7d464e91af +) +``` + diff --git a/docs/Subscriptions.md b/docs/Subscriptions.md new file mode 100644 index 00000000..ada96411 --- /dev/null +++ b/docs/Subscriptions.md @@ -0,0 +1,20 @@ +# Bandwidth::Subscriptions + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **session_id** | **String** | If present, and not overridden by the array of participants, it represents the session the subscriptions are associated with. If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session). Upon creation of a Participant, returns as an empty object. | [optional] | +| **participants** | [**Array<ParticipantSubscription>**](ParticipantSubscription.md) | (optional) A list of participants in the session that will be subscribed to. If present and not empty or null, this will override any sessionId specified in the body. Returns empty if used during the creation of a Participant. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Subscriptions.new( + session_id: d8886aad-b956-4e1b-b2f4-d7c9f8162772, + participants: [{"participantId":"568749d5-04d5-483d-adf5-deac7dd3d521"},{"participantId":"0275e47f-dd21-4cf0-a1e1-dfdc719e73a7","streamAliases":["alias_1","alias_2"]}] +) +``` + diff --git a/docs/Tag.md b/docs/Tag.md new file mode 100644 index 00000000..0c2a8756 --- /dev/null +++ b/docs/Tag.md @@ -0,0 +1,20 @@ +# Bandwidth::Tag + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **key** | **String** | | [optional] | +| **value** | **String** | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Tag.new( + key: null, + value: null +) +``` + diff --git a/docs/TnLookupRequestError.md b/docs/TnLookupRequestError.md new file mode 100644 index 00000000..ed31bd7f --- /dev/null +++ b/docs/TnLookupRequestError.md @@ -0,0 +1,18 @@ +# Bandwidth::TnLookupRequestError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | A description of what validation error occurred. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TnLookupRequestError.new( + message: example error message +) +``` + diff --git a/docs/TranscribeRecording.md b/docs/TranscribeRecording.md new file mode 100644 index 00000000..de2ab0f9 --- /dev/null +++ b/docs/TranscribeRecording.md @@ -0,0 +1,30 @@ +# Bandwidth::TranscribeRecording + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **callback_url** | **String** | The URL to send the [TranscriptionAvailable](/docs/voice/webhooks/transcriptionAvailable) event to. You should not include sensitive or personally-identifiable information in the callbackUrl field! Always use the proper username and password fields for authorization. | [optional] | +| **callback_method** | [**CallbackMethodEnum**](CallbackMethodEnum.md) | | [optional][default to 'POST'] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **callback_timeout** | **Float** | This is the timeout (in seconds) to use when delivering the webhook to `callbackUrl`. Can be any numeric value (including decimals) between 1 and 25. | [optional][default to 15] | +| **detect_language** | **Boolean** | A boolean value to indicate that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. | [optional][default to false] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TranscribeRecording.new( + callback_url: https://myServer.example/bandwidth/webhooks/transcriptionAvailable, + callback_method: null, + username: mySecretUsername, + password: mySecretPassword1!, + tag: exampleTag, + callback_timeout: 5.5, + detect_language: true +) +``` + diff --git a/docs/Transcription.md b/docs/Transcription.md new file mode 100644 index 00000000..7caa4d2a --- /dev/null +++ b/docs/Transcription.md @@ -0,0 +1,20 @@ +# Bandwidth::Transcription + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **text** | **String** | The transcribed text | [optional] | +| **confidence** | **Float** | The confidence on the recognized content, ranging from `0.0` to `1.0` with `1.0` being the highest confidence. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::Transcription.new( + text: Nice talking to you, friend!, + confidence: 0.9 +) +``` + diff --git a/docs/TranscriptionAvailableCallback.md b/docs/TranscriptionAvailableCallback.md new file mode 100644 index 00000000..e5b28e5c --- /dev/null +++ b/docs/TranscriptionAvailableCallback.md @@ -0,0 +1,58 @@ +# Bandwidth::TranscriptionAvailableCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **media_url** | **String** | The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **recording_id** | **String** | The unique ID of this recording | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **duration** | **String** | The duration of the recording in ISO-8601 format | [optional] | +| **file_format** | [**FileFormatEnum**](FileFormatEnum.md) | | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transcription** | [**Transcription**](Transcription.md) | | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TranscriptionAvailableCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + media_url: https://voice.bandwidth.com/api/v2/accounts/9900000/conferences/conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9/recordings/r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833/media, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + recording_id: r-fbe05094-9fd2afe9-bf5b-4c68-820a-41a01c1c5833, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + end_time: 2022-06-17T22:20Z, + duration: PT13.67S, + file_format: null, + tag: exampleTag, + transcription: null, + transfer_caller_id: +15555555555, + transfer_to: +15555555555) +) +``` + diff --git a/docs/TranscriptionList.md b/docs/TranscriptionList.md new file mode 100644 index 00000000..949c92cf --- /dev/null +++ b/docs/TranscriptionList.md @@ -0,0 +1,18 @@ +# Bandwidth::TranscriptionList + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **transcripts** | [**Array<Transcription>**](Transcription.md) | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TranscriptionList.new( + transcripts: null +) +``` + diff --git a/docs/TranscriptionMetadata.md b/docs/TranscriptionMetadata.md new file mode 100644 index 00000000..b9a4d61f --- /dev/null +++ b/docs/TranscriptionMetadata.md @@ -0,0 +1,24 @@ +# Bandwidth::TranscriptionMetadata + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **id** | **String** | The unique transcription ID | [optional] | +| **status** | **String** | The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. | [optional] | +| **completed_time** | **String** | The time that the transcription was completed | [optional] | +| **url** | **String** | The URL of the [transcription](#operation/getCallTranscription) | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TranscriptionMetadata.new( + id: t-387bd648-18f3-4823-9d16-746bca0003c9, + status: completed, + completed_time: 2022-06-13T18:46:29.715Z, + url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/recordings/r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85/transcription +) +``` + diff --git a/docs/TransferAnswerCallback.md b/docs/TransferAnswerCallback.md new file mode 100644 index 00000000..b1b09035 --- /dev/null +++ b/docs/TransferAnswerCallback.md @@ -0,0 +1,46 @@ +# Bandwidth::TransferAnswerCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TransferAnswerCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + transfer_caller_id: +15555555555, + transfer_to: +15555555555) +) +``` + diff --git a/docs/TransferCompleteCallback.md b/docs/TransferCompleteCallback.md new file mode 100644 index 00000000..b4c530cc --- /dev/null +++ b/docs/TransferCompleteCallback.md @@ -0,0 +1,52 @@ +# Bandwidth::TransferCompleteCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | +| **cause** | **String** | Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. | [optional] | +| **error_message** | **String** | Text explaining the reason that caused the call to fail in case of errors. | [optional] | +| **error_id** | **String** | Bandwidth's internal id that references the error event. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TransferCompleteCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + tag: exampleTag, + transfer_caller_id: +15555555555, + transfer_to: +15555555555), + cause: busy, + error_message: Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged with another call, + error_id: 4642074b-7b58-478b-96e4-3a60955c6765 +) +``` + diff --git a/docs/TransferDisconnectCallback.md b/docs/TransferDisconnectCallback.md new file mode 100644 index 00000000..8933cc88 --- /dev/null +++ b/docs/TransferDisconnectCallback.md @@ -0,0 +1,56 @@ +# Bandwidth::TransferDisconnectCallback + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **event_type** | **String** | The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. | [optional] | +| **event_time** | **Time** | The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. | [optional] | +| **account_id** | **String** | The user account associated with the call. | [optional] | +| **application_id** | **String** | The id of the application associated with the call. | [optional] | +| **from** | **String** | The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. | [optional] | +| **to** | **String** | The phone number that received the call, in E.164 format (e.g. +15555555555). | [optional] | +| **direction** | [**CallDirectionEnum**](CallDirectionEnum.md) | | [optional] | +| **call_id** | **String** | The call id associated with the event. | [optional] | +| **call_url** | **String** | The URL of the call associated with the event. | [optional] | +| **parent_call_id** | **String** | (optional) If the event is related to the B leg of a <Transfer>, the call id of the original call leg that executed the <Transfer>. Otherwise, this field will not be present. | [optional] | +| **enqueued_time** | **Time** | (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. | [optional] | +| **start_time** | **Time** | Time the call was started, in ISO 8601 format. | [optional] | +| **answer_time** | **Time** | Time the call was answered, in ISO 8601 format. | [optional] | +| **end_time** | **Time** | The time that the recording ended in ISO-8601 format | [optional] | +| **tag** | **String** | (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. | [optional] | +| **transfer_caller_id** | **String** | The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. | [optional] | +| **transfer_to** | **String** | The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). | [optional] | +| **cause** | **String** | Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. | [optional] | +| **error_message** | **String** | Text explaining the reason that caused the call to fail in case of errors. | [optional] | +| **error_id** | **String** | Bandwidth's internal id that references the error event. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::TransferDisconnectCallback.new( + event_type: bridgeComplete, + event_time: 2022-06-17T22:19:40.375Z, + account_id: 920012, + application_id: 04e88489-df02-4e34-a0ee-27a91849555f, + from: +15555555555, + to: +15555555555, + direction: null, + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + call_url: https://voice.bandwidth.com/api/v2/accounts/9900000/calls/c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85, + parent_call_id: c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d, + enqueued_time: 2022-06-17T22:20Z, + start_time: 2022-06-17T22:19:40.375Z, + answer_time: 2022-06-17T22:20Z, + end_time: 2022-06-17T22:20Z, + tag: exampleTag, + transfer_caller_id: +15555555555, + transfer_to: +15555555555), + cause: busy, + error_message: Call c-2a913f94-6a486f3a-3cae-4034-bcc3-f0c9fa77ca2f is already bridged with another call, + error_id: 4642074b-7b58-478b-96e4-3a60955c6765 +) +``` + diff --git a/docs/UnauthorizedRequest.md b/docs/UnauthorizedRequest.md new file mode 100644 index 00000000..e307c8bf --- /dev/null +++ b/docs/UnauthorizedRequest.md @@ -0,0 +1,18 @@ +# Bandwidth::UnauthorizedRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **message** | **String** | Unauthorized | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::UnauthorizedRequest.new( + message: Unauthorized +) +``` + diff --git a/docs/UpdateCall.md b/docs/UpdateCall.md new file mode 100644 index 00000000..f8f4a16f --- /dev/null +++ b/docs/UpdateCall.md @@ -0,0 +1,36 @@ +# Bandwidth::UpdateCall + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **state** | [**CallStateEnum**](CallStateEnum.md) | | [optional][default to 'active'] | +| **redirect_url** | **String** | The URL to send the [Redirect](/docs/voice/bxml/redirect) event to which will provide new BXML. Required if `state` is `active`. Not allowed if `state` is `completed`. | [optional] | +| **redirect_method** | [**RedirectMethodEnum**](RedirectMethodEnum.md) | | [optional][default to 'POST'] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **redirect_fallback_url** | **String** | A fallback url which, if provided, will be used to retry the redirect callback delivery in case `redirectUrl` fails to respond. | [optional] | +| **redirect_fallback_method** | [**RedirectMethodEnum**](RedirectMethodEnum.md) | | [optional][default to 'POST'] | +| **fallback_username** | **String** | Basic auth username. | [optional] | +| **fallback_password** | **String** | Basic auth password. | [optional] | +| **tag** | **String** | A custom string that will be sent with this and all future callbacks unless overwritten by a future `tag` attribute or [`<Tag>`](/docs/voice/bxml/tag) verb, or cleared. May be cleared by setting `tag=\"\"`. Max length 256 characters. Not allowed if `state` is `completed`. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::UpdateCall.new( + state: null, + redirect_url: https://myServer.example/bandwidth/webhooks/redirect, + redirect_method: null, + username: mySecretUsername, + password: mySecretPassword1!, + redirect_fallback_url: https://myFallbackServer.example/bandwidth/webhooks/redirect, + redirect_fallback_method: null, + fallback_username: mySecretUsername, + fallback_password: mySecretPassword1!, + tag: My Custom Tag +) +``` + diff --git a/docs/UpdateCallRecording.md b/docs/UpdateCallRecording.md new file mode 100644 index 00000000..f57cf27d --- /dev/null +++ b/docs/UpdateCallRecording.md @@ -0,0 +1,18 @@ +# Bandwidth::UpdateCallRecording + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **state** | [**RecordingStateEnum**](RecordingStateEnum.md) | | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::UpdateCallRecording.new( + state: null +) +``` + diff --git a/docs/UpdateConference.md b/docs/UpdateConference.md new file mode 100644 index 00000000..9843a89d --- /dev/null +++ b/docs/UpdateConference.md @@ -0,0 +1,34 @@ +# Bandwidth::UpdateConference + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **status** | [**ConferenceStateEnum**](ConferenceStateEnum.md) | | [optional][default to 'active'] | +| **redirect_url** | **String** | The URL to send the [conferenceRedirect](/docs/voice/webhooks/conferenceRedirect) event which will provide new BXML. Not allowed if `state` is `completed`, but required if `state` is `active`. | [optional] | +| **redirect_method** | [**RedirectMethodEnum**](RedirectMethodEnum.md) | | [optional][default to 'POST'] | +| **username** | **String** | Basic auth username. | [optional] | +| **password** | **String** | Basic auth password. | [optional] | +| **redirect_fallback_url** | **String** | A fallback url which, if provided, will be used to retry the `conferenceRedirect` webhook delivery in case `redirectUrl` fails to respond. Not allowed if `state` is `completed`. | [optional] | +| **redirect_fallback_method** | [**RedirectMethodEnum**](RedirectMethodEnum.md) | | [optional][default to 'POST'] | +| **fallback_username** | **String** | Basic auth username. | [optional] | +| **fallback_password** | **String** | Basic auth password. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::UpdateConference.new( + status: null, + redirect_url: https://myServer.example/bandwidth/webhooks/conferenceRedirect, + redirect_method: null, + username: mySecretUsername, + password: mySecretPassword1!, + redirect_fallback_url: https://myFallbackServer.example/bandwidth/webhooks/conferenceRedirect, + redirect_fallback_method: null, + fallback_username: mySecretUsername, + fallback_password: mySecretPassword1! +) +``` + diff --git a/docs/UpdateConferenceMember.md b/docs/UpdateConferenceMember.md new file mode 100644 index 00000000..2e3ad699 --- /dev/null +++ b/docs/UpdateConferenceMember.md @@ -0,0 +1,22 @@ +# Bandwidth::UpdateConferenceMember + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **mute** | **Boolean** | Whether or not this member is currently muted. Members who are muted are still able to hear other participants. Updates this member's mute status. Has no effect if omitted. | [optional] | +| **hold** | **Boolean** | Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. Updates this member's hold status. Has no effect if omitted. | [optional] | +| **call_ids_to_coach** | **Array<String>** | If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. Modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::UpdateConferenceMember.new( + mute: false, + hold: false, + call_ids_to_coach: ["c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"] +) +``` + diff --git a/docs/VerifyCodeRequest.md b/docs/VerifyCodeRequest.md new file mode 100644 index 00000000..b85de500 --- /dev/null +++ b/docs/VerifyCodeRequest.md @@ -0,0 +1,24 @@ +# Bandwidth::VerifyCodeRequest + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **to** | **String** | The phone number to send the mfa code to. | | +| **scope** | **String** | An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\". | [optional] | +| **expiration_time_in_minutes** | **Float** | The time period, in minutes, to validate the mfa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively. | | +| **code** | **String** | The generated mfa code to check if valid. | | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::VerifyCodeRequest.new( + to: +19195551234, + scope: 2FA, + expiration_time_in_minutes: 3, + code: 123456 +) +``` + diff --git a/docs/VerifyCodeResponse.md b/docs/VerifyCodeResponse.md new file mode 100644 index 00000000..7a34c68c --- /dev/null +++ b/docs/VerifyCodeResponse.md @@ -0,0 +1,18 @@ +# Bandwidth::VerifyCodeResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **valid** | **Boolean** | Whether or not the supplied code is valid. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::VerifyCodeResponse.new( + valid: true +) +``` + diff --git a/docs/VoiceApiError.md b/docs/VoiceApiError.md new file mode 100644 index 00000000..b7e2d143 --- /dev/null +++ b/docs/VoiceApiError.md @@ -0,0 +1,22 @@ +# Bandwidth::VoiceApiError + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **type** | **String** | | [optional] | +| **description** | **String** | | [optional] | +| **id** | **String** | | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::VoiceApiError.new( + type: null, + description: null, + id: null +) +``` + diff --git a/docs/VoiceCodeResponse.md b/docs/VoiceCodeResponse.md new file mode 100644 index 00000000..3d16cefc --- /dev/null +++ b/docs/VoiceCodeResponse.md @@ -0,0 +1,18 @@ +# Bandwidth::VoiceCodeResponse + +## Properties + +| Name | Type | Description | Notes | +| ---- | ---- | ----------- | ----- | +| **call_id** | **String** | Programmable Voice API Call ID. | [optional] | + +## Example + +```ruby +require 'bandwidth-sdk' + +instance = Bandwidth::VoiceCodeResponse.new( + call_id: c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 +) +``` + diff --git a/git_push.sh b/git_push.sh new file mode 100644 index 00000000..f53a75d4 --- /dev/null +++ b/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/lib/bandwidth-sdk.rb b/lib/bandwidth-sdk.rb new file mode 100644 index 00000000..87f7417f --- /dev/null +++ b/lib/bandwidth-sdk.rb @@ -0,0 +1,170 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +# Common files +require 'bandwidth-sdk/api_client' +require 'bandwidth-sdk/api_error' +require 'bandwidth-sdk/version' +require 'bandwidth-sdk/configuration' + +# Models +require 'bandwidth-sdk/models/account_statistics' +require 'bandwidth-sdk/models/answer_callback' +require 'bandwidth-sdk/models/bridge_complete_callback' +require 'bandwidth-sdk/models/bridge_target_complete_callback' +require 'bandwidth-sdk/models/call_direction_enum' +require 'bandwidth-sdk/models/call_recording_metadata' +require 'bandwidth-sdk/models/call_state' +require 'bandwidth-sdk/models/call_state_enum' +require 'bandwidth-sdk/models/callback_method_enum' +require 'bandwidth-sdk/models/code_request' +require 'bandwidth-sdk/models/conference' +require 'bandwidth-sdk/models/conference_completed_callback' +require 'bandwidth-sdk/models/conference_created_callback' +require 'bandwidth-sdk/models/conference_member' +require 'bandwidth-sdk/models/conference_member_exit_callback' +require 'bandwidth-sdk/models/conference_member_join_callback' +require 'bandwidth-sdk/models/conference_recording_available_callback' +require 'bandwidth-sdk/models/conference_recording_metadata' +require 'bandwidth-sdk/models/conference_redirect_callback' +require 'bandwidth-sdk/models/conference_state_enum' +require 'bandwidth-sdk/models/create_call' +require 'bandwidth-sdk/models/create_call_response' +require 'bandwidth-sdk/models/create_lookup_response' +require 'bandwidth-sdk/models/create_message_request_error' +require 'bandwidth-sdk/models/deferred_result' +require 'bandwidth-sdk/models/disconnect_callback' +require 'bandwidth-sdk/models/diversion' +require 'bandwidth-sdk/models/dtmf_callback' +require 'bandwidth-sdk/models/field_error' +require 'bandwidth-sdk/models/file_format_enum' +require 'bandwidth-sdk/models/gather_callback' +require 'bandwidth-sdk/models/inbound_message_callback' +require 'bandwidth-sdk/models/inbound_message_callback_message' +require 'bandwidth-sdk/models/initiate_callback' +require 'bandwidth-sdk/models/list_message_direction_enum' +require 'bandwidth-sdk/models/list_message_item' +require 'bandwidth-sdk/models/lookup_request' +require 'bandwidth-sdk/models/lookup_result' +require 'bandwidth-sdk/models/lookup_status' +require 'bandwidth-sdk/models/lookup_status_enum' +require 'bandwidth-sdk/models/machine_detection_complete_callback' +require 'bandwidth-sdk/models/machine_detection_configuration' +require 'bandwidth-sdk/models/machine_detection_mode_enum' +require 'bandwidth-sdk/models/machine_detection_result' +require 'bandwidth-sdk/models/media' +require 'bandwidth-sdk/models/message' +require 'bandwidth-sdk/models/message_delivered_callback' +require 'bandwidth-sdk/models/message_delivered_callback_message' +require 'bandwidth-sdk/models/message_direction_enum' +require 'bandwidth-sdk/models/message_failed_callback' +require 'bandwidth-sdk/models/message_failed_callback_message' +require 'bandwidth-sdk/models/message_request' +require 'bandwidth-sdk/models/message_sending_callback' +require 'bandwidth-sdk/models/message_sending_callback_message' +require 'bandwidth-sdk/models/message_status_enum' +require 'bandwidth-sdk/models/message_type_enum' +require 'bandwidth-sdk/models/messages_list' +require 'bandwidth-sdk/models/messaging_code_response' +require 'bandwidth-sdk/models/messaging_request_error' +require 'bandwidth-sdk/models/mfa_forbidden_request_error' +require 'bandwidth-sdk/models/mfa_request_error' +require 'bandwidth-sdk/models/mfa_unauthorized_request_error' +require 'bandwidth-sdk/models/page_info' +require 'bandwidth-sdk/models/priority_enum' +require 'bandwidth-sdk/models/recording_available_callback' +require 'bandwidth-sdk/models/recording_complete_callback' +require 'bandwidth-sdk/models/recording_state_enum' +require 'bandwidth-sdk/models/redirect_callback' +require 'bandwidth-sdk/models/redirect_method_enum' +require 'bandwidth-sdk/models/stir_shaken' +require 'bandwidth-sdk/models/tag' +require 'bandwidth-sdk/models/tn_lookup_request_error' +require 'bandwidth-sdk/models/transcribe_recording' +require 'bandwidth-sdk/models/transcription' +require 'bandwidth-sdk/models/transcription_available_callback' +require 'bandwidth-sdk/models/transcription_list' +require 'bandwidth-sdk/models/transcription_metadata' +require 'bandwidth-sdk/models/transfer_answer_callback' +require 'bandwidth-sdk/models/transfer_complete_callback' +require 'bandwidth-sdk/models/transfer_disconnect_callback' +require 'bandwidth-sdk/models/update_call' +require 'bandwidth-sdk/models/update_call_recording' +require 'bandwidth-sdk/models/update_conference' +require 'bandwidth-sdk/models/update_conference_member' +require 'bandwidth-sdk/models/verify_code_request' +require 'bandwidth-sdk/models/verify_code_response' +require 'bandwidth-sdk/models/voice_api_error' +require 'bandwidth-sdk/models/voice_code_response' + +# BXML +require 'bandwidth-sdk/models/bxml/root' +require 'bandwidth-sdk/models/bxml/bxml' +require 'bandwidth-sdk/models/bxml/response' +require 'bandwidth-sdk/models/bxml/verb' +require 'bandwidth-sdk/models/bxml/nestable_verb' +require 'bandwidth-sdk/models/bxml/verbs/bridge' +require 'bandwidth-sdk/models/bxml/verbs/conference' +require 'bandwidth-sdk/models/bxml/verbs/custom_param' +require 'bandwidth-sdk/models/bxml/verbs/forward' +require 'bandwidth-sdk/models/bxml/verbs/gather' +require 'bandwidth-sdk/models/bxml/verbs/hangup' +require 'bandwidth-sdk/models/bxml/verbs/pause_recording' +require 'bandwidth-sdk/models/bxml/verbs/pause' +require 'bandwidth-sdk/models/bxml/verbs/phone_number' +require 'bandwidth-sdk/models/bxml/verbs/play_audio' +require 'bandwidth-sdk/models/bxml/verbs/record' +require 'bandwidth-sdk/models/bxml/verbs/redirect' +require 'bandwidth-sdk/models/bxml/verbs/resume_recording' +require 'bandwidth-sdk/models/bxml/verbs/ring' +require 'bandwidth-sdk/models/bxml/verbs/send_dtmf' +require 'bandwidth-sdk/models/bxml/verbs/sip_uri' +require 'bandwidth-sdk/models/bxml/verbs/speak_sentence' +require 'bandwidth-sdk/models/bxml/verbs/start_gather' +require 'bandwidth-sdk/models/bxml/verbs/start_recording' +require 'bandwidth-sdk/models/bxml/verbs/start_stream' +require 'bandwidth-sdk/models/bxml/verbs/start_transcription' +require 'bandwidth-sdk/models/bxml/verbs/stop_gather' +require 'bandwidth-sdk/models/bxml/verbs/stop_recording' +require 'bandwidth-sdk/models/bxml/verbs/stop_stream' +require 'bandwidth-sdk/models/bxml/verbs/stop_transcription' +require 'bandwidth-sdk/models/bxml/verbs/stream_param' +require 'bandwidth-sdk/models/bxml/verbs/tag' +require 'bandwidth-sdk/models/bxml/verbs/transfer' + +# APIs +require 'bandwidth-sdk/api/calls_api' +require 'bandwidth-sdk/api/conferences_api' +require 'bandwidth-sdk/api/mfa_api' +require 'bandwidth-sdk/api/media_api' +require 'bandwidth-sdk/api/messages_api' +require 'bandwidth-sdk/api/phone_number_lookup_api' +require 'bandwidth-sdk/api/recordings_api' +require 'bandwidth-sdk/api/statistics_api' + +module Bandwidth + class << self + # Customize default settings for the SDK using block. + # Bandwidth.configure do |config| + # config.username = "xxx" + # config.password = "xxx" + # end + # If no block given, return the default Configuration object. + def configure + if block_given? + yield(Configuration.default) + else + Configuration.default + end + end + end +end diff --git a/lib/bandwidth-sdk/api/calls_api.rb b/lib/bandwidth-sdk/api/calls_api.rb new file mode 100644 index 00000000..4ab1d659 --- /dev/null +++ b/lib/bandwidth-sdk/api/calls_api.rb @@ -0,0 +1,325 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class CallsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Call + # Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. Please note: Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed. + # @param account_id [String] Your Bandwidth Account ID. + # @param create_call [CreateCall] JSON object containing information to create an outbound call + # @param [Hash] opts the optional parameters + # @return [CreateCallResponse] + def create_call(account_id, create_call, opts = {}) + data, _status_code, _headers = create_call_with_http_info(account_id, create_call, opts) + data + end + + # Create Call + # Creates an outbound phone call. All calls are initially queued. Your outbound calls will initiated at a specific dequeueing rate, enabling your application to \"fire and forget\" when creating calls. Queued calls may not be modified until they are dequeued and placed, but may be removed from your queue on demand. <b>Please note:</b> Calls submitted to your queue will be placed approximately in order, but exact ordering is not guaranteed. + # @param account_id [String] Your Bandwidth Account ID. + # @param create_call [CreateCall] JSON object containing information to create an outbound call + # @param [Hash] opts the optional parameters + # @return [Array<(CreateCallResponse, Integer, Hash)>] CreateCallResponse data, response status code and response headers + def create_call_with_http_info(account_id, create_call, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CallsApi.create_call ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.create_call" + end + # verify the required parameter 'create_call' is set + if @api_client.config.client_side_validation && create_call.nil? + fail ArgumentError, "Missing the required parameter 'create_call' when calling CallsApi.create_call" + end + # resource path + local_var_path = '/accounts/{accountId}/calls'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(create_call) + + # return_type + return_type = opts[:debug_return_type] || 'CreateCallResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"CallsApi.create_call", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CallsApi#create_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Call State Information + # Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param [Hash] opts the optional parameters + # @return [CallState] + def get_call_state(account_id, call_id, opts = {}) + data, _status_code, _headers = get_call_state_with_http_info(account_id, call_id, opts) + data + end + + # Get Call State Information + # Retrieve the current state of a specific call. This information is near-realtime, so it may take a few minutes for your call to be accessible using this endpoint. **Note**: Call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an HTTP 404 response. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param [Hash] opts the optional parameters + # @return [Array<(CallState, Integer, Hash)>] CallState data, response status code and response headers + def get_call_state_with_http_info(account_id, call_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CallsApi.get_call_state ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.get_call_state" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.get_call_state" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CallState' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"CallsApi.get_call_state", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CallsApi#get_call_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Call + # Interrupts and redirects a call to a different URL that should return a BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document + # @param [Hash] opts the optional parameters + # @return [nil] + def update_call(account_id, call_id, update_call, opts = {}) + update_call_with_http_info(account_id, call_id, update_call, opts) + nil + end + + # Update Call + # Interrupts and redirects a call to a different URL that should return a BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param update_call [UpdateCall] JSON object containing information to redirect an existing call to a new BXML document + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_call_with_http_info(account_id, call_id, update_call, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CallsApi.update_call ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call" + end + # verify the required parameter 'update_call' is set + if @api_client.config.client_side_validation && update_call.nil? + fail ArgumentError, "Missing the required parameter 'update_call' when calling CallsApi.update_call" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"CallsApi.update_call", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CallsApi#update_call\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Call BXML + # Interrupts and replaces an active call's BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param body [String] + # @param [Hash] opts the optional parameters + # @return [nil] + def update_call_bxml(account_id, call_id, body, opts = {}) + update_call_bxml_with_http_info(account_id, call_id, body, opts) + nil + end + + # Update Call BXML + # Interrupts and replaces an active call's BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param body [String] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_call_bxml_with_http_info(account_id, call_id, body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: CallsApi.update_call_bxml ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.update_call_bxml" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling CallsApi.update_call_bxml" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling CallsApi.update_call_bxml" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"CallsApi.update_call_bxml", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: CallsApi#update_call_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/conferences_api.rb b/lib/bandwidth-sdk/api/conferences_api.rb new file mode 100644 index 00000000..28adc783 --- /dev/null +++ b/lib/bandwidth-sdk/api/conferences_api.rb @@ -0,0 +1,717 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class ConferencesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Download Conference Recording + # Downloads the specified recording file. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [File] + def download_conference_recording(account_id, conference_id, recording_id, opts = {}) + data, _status_code, _headers = download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts) + data + end + + # Download Conference Recording + # Downloads the specified recording file. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers + def download_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.download_conference_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.download_conference_recording" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.download_conference_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.download_conference_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'File' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.download_conference_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#download_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Conference Information + # Returns information about the specified conference. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param [Hash] opts the optional parameters + # @return [Conference] + def get_conference(account_id, conference_id, opts = {}) + data, _status_code, _headers = get_conference_with_http_info(account_id, conference_id, opts) + data + end + + # Get Conference Information + # Returns information about the specified conference. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param [Hash] opts the optional parameters + # @return [Array<(Conference, Integer, Hash)>] Conference data, response status code and response headers + def get_conference_with_http_info(account_id, conference_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Conference' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.get_conference", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#get_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Conference Member + # Returns information about the specified conference member. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param member_id [String] Programmable Voice API Conference Member ID. + # @param [Hash] opts the optional parameters + # @return [ConferenceMember] + def get_conference_member(account_id, conference_id, member_id, opts = {}) + data, _status_code, _headers = get_conference_member_with_http_info(account_id, conference_id, member_id, opts) + data + end + + # Get Conference Member + # Returns information about the specified conference member. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param member_id [String] Programmable Voice API Conference Member ID. + # @param [Hash] opts the optional parameters + # @return [Array<(ConferenceMember, Integer, Hash)>] ConferenceMember data, response status code and response headers + def get_conference_member_with_http_info(account_id, conference_id, member_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_member ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_member" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_member" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.get_conference_member" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ConferenceMember' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.get_conference_member", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#get_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Conference Recording Information + # Returns metadata for the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [ConferenceRecordingMetadata] + def get_conference_recording(account_id, conference_id, recording_id, opts = {}) + data, _status_code, _headers = get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts) + data + end + + # Get Conference Recording Information + # Returns metadata for the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(ConferenceRecordingMetadata, Integer, Hash)>] ConferenceRecordingMetadata data, response status code and response headers + def get_conference_recording_with_http_info(account_id, conference_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.get_conference_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.get_conference_recording" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.get_conference_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling ConferencesApi.get_conference_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ConferenceRecordingMetadata' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.get_conference_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#get_conference_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Conference Recordings + # Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param [Hash] opts the optional parameters + # @return [Array] + def list_conference_recordings(account_id, conference_id, opts = {}) + data, _status_code, _headers = list_conference_recordings_with_http_info(account_id, conference_id, opts) + data + end + + # Get Conference Recordings + # Returns a (potentially empty) list of metadata for the recordings that took place during the specified conference. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param [Hash] opts the optional parameters + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + def list_conference_recordings_with_http_info(account_id, conference_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.list_conference_recordings ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conference_recordings" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.list_conference_recordings" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.list_conference_recordings", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#list_conference_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Conferences + # Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :name Filter results by the `name` field. + # @option opts [String] :min_created_time Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format). + # @option opts [String] :max_created_time Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format). + # @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000) + # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description. + # @return [Array] + def list_conferences(account_id, opts = {}) + data, _status_code, _headers = list_conferences_with_http_info(account_id, opts) + data + end + + # Get Conferences + # Returns a max of 1000 conferences, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of conferences in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of conference records. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :name Filter results by the `name` field. + # @option opts [String] :min_created_time Filter results to conferences which have a `createdTime` after or at `minCreatedTime` (in ISO8601 format). + # @option opts [String] :max_created_time Filter results to conferences which have a `createdTime` before or at `maxCreatedTime` (in ISO8601 format). + # @option opts [Integer] :page_size Specifies the max number of conferences that will be returned. (default to 1000) + # @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description. + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + def list_conferences_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.list_conferences ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.list_conferences" + end + if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000 + fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be smaller than or equal to 1000.' + end + + if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1 + fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ConferencesApi.list_conferences, must be greater than or equal to 1.' + end + + # resource path + local_var_path = '/accounts/{accountId}/conferences'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil? + query_params[:'minCreatedTime'] = opts[:'min_created_time'] if !opts[:'min_created_time'].nil? + query_params[:'maxCreatedTime'] = opts[:'max_created_time'] if !opts[:'max_created_time'].nil? + query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil? + query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.list_conferences", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#list_conferences\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Conference + # Update the conference state. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param update_conference [UpdateConference] + # @param [Hash] opts the optional parameters + # @return [nil] + def update_conference(account_id, conference_id, update_conference, opts = {}) + update_conference_with_http_info(account_id, conference_id, update_conference, opts) + nil + end + + # Update Conference + # Update the conference state. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param update_conference [UpdateConference] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_conference_with_http_info(account_id, conference_id, update_conference, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference" + end + # verify the required parameter 'update_conference' is set + if @api_client.config.client_side_validation && update_conference.nil? + fail ArgumentError, "Missing the required parameter 'update_conference' when calling ConferencesApi.update_conference" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.update_conference", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#update_conference\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Conference BXML + # Update the conference BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param body [String] + # @param [Hash] opts the optional parameters + # @return [nil] + def update_conference_bxml(account_id, conference_id, body, opts = {}) + update_conference_bxml_with_http_info(account_id, conference_id, body, opts) + nil + end + + # Update Conference BXML + # Update the conference BXML document. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param body [String] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_conference_bxml_with_http_info(account_id, conference_id, body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_bxml ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_bxml" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_bxml" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling ConferencesApi.update_conference_bxml" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/bxml'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/xml']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.update_conference_bxml", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#update_conference_bxml\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Conference Member + # Updates settings for a particular conference member. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param member_id [String] Programmable Voice API Conference Member ID. + # @param update_conference_member [UpdateConferenceMember] + # @param [Hash] opts the optional parameters + # @return [nil] + def update_conference_member(account_id, conference_id, member_id, update_conference_member, opts = {}) + update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts) + nil + end + + # Update Conference Member + # Updates settings for a particular conference member. + # @param account_id [String] Your Bandwidth Account ID. + # @param conference_id [String] Programmable Voice API Conference ID. + # @param member_id [String] Programmable Voice API Conference Member ID. + # @param update_conference_member [UpdateConferenceMember] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_conference_member_with_http_info(account_id, conference_id, member_id, update_conference_member, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ConferencesApi.update_conference_member ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling ConferencesApi.update_conference_member" + end + # verify the required parameter 'conference_id' is set + if @api_client.config.client_side_validation && conference_id.nil? + fail ArgumentError, "Missing the required parameter 'conference_id' when calling ConferencesApi.update_conference_member" + end + # verify the required parameter 'member_id' is set + if @api_client.config.client_side_validation && member_id.nil? + fail ArgumentError, "Missing the required parameter 'member_id' when calling ConferencesApi.update_conference_member" + end + # verify the required parameter 'update_conference_member' is set + if @api_client.config.client_side_validation && update_conference_member.nil? + fail ArgumentError, "Missing the required parameter 'update_conference_member' when calling ConferencesApi.update_conference_member" + end + # resource path + local_var_path = '/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'conferenceId' + '}', CGI.escape(conference_id.to_s)).sub('{' + 'memberId' + '}', CGI.escape(member_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_conference_member) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"ConferencesApi.update_conference_member", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ConferencesApi#update_conference_member\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/media_api.rb b/lib/bandwidth-sdk/api/media_api.rb new file mode 100644 index 00000000..bad2d8e5 --- /dev/null +++ b/lib/bandwidth-sdk/api/media_api.rb @@ -0,0 +1,312 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class MediaApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Delete Media + # Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name. + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_media(account_id, media_id, opts = {}) + delete_media_with_http_info(account_id, media_id, opts) + nil + end + + # Delete Media + # Deletes a media file from Bandwidth API server. Make sure you don't have any application scripts still using the media before you delete. If you accidentally delete a media file you can immediately upload a new file with the same name. + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_media_with_http_info(account_id, media_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MediaApi.delete_media ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.delete_media" + end + # verify the required parameter 'media_id' is set + if @api_client.config.client_side_validation && media_id.nil? + fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.delete_media" + end + # resource path + local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MediaApi.delete_media", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MediaApi#delete_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Media + # Downloads a media file you previously uploaded. + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param [Hash] opts the optional parameters + # @return [File] + def get_media(account_id, media_id, opts = {}) + data, _status_code, _headers = get_media_with_http_info(account_id, media_id, opts) + data + end + + # Get Media + # Downloads a media file you previously uploaded. + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param [Hash] opts the optional parameters + # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers + def get_media_with_http_info(account_id, media_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MediaApi.get_media ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.get_media" + end + # verify the required parameter 'media_id' is set + if @api_client.config.client_side_validation && media_id.nil? + fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.get_media" + end + # resource path + local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream', 'application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'File' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MediaApi.get_media", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MediaApi#get_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Media + # Gets a list of your media files. No query parameters are supported. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :continuation_token Continuation token used to retrieve subsequent media. + # @return [Array] + def list_media(account_id, opts = {}) + data, _status_code, _headers = list_media_with_http_info(account_id, opts) + data + end + + # List Media + # Gets a list of your media files. No query parameters are supported. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :continuation_token Continuation token used to retrieve subsequent media. + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + def list_media_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MediaApi.list_media ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.list_media" + end + # resource path + local_var_path = '/users/{accountId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params[:'Continuation-Token'] = opts[:'continuation_token'] if !opts[:'continuation_token'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MediaApi.list_media", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MediaApi#list_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Upload Media + # Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-). + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param body [File] + # @param [Hash] opts the optional parameters + # @option opts [String] :content_type The media type of the entity-body. + # @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. + # @return [nil] + def upload_media(account_id, media_id, body, opts = {}) + upload_media_with_http_info(account_id, media_id, body, opts) + nil + end + + # Upload Media + # Upload a file. You may add headers to the request in order to provide some control to your media file. If a file is uploaded with the same name as a file that already exists under this account, the previous file will be overwritten. A list of supported media types can be found [here](https://support.bandwidth.com/hc/en-us/articles/360014128994-What-MMS-file-types-are-supported-). + # @param account_id [String] Your Bandwidth Account ID. + # @param media_id [String] Media ID to retrieve. + # @param body [File] + # @param [Hash] opts the optional parameters + # @option opts [String] :content_type The media type of the entity-body. + # @option opts [String] :cache_control General-header field is used to specify directives that MUST be obeyed by all caching mechanisms along the request/response chain. + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def upload_media_with_http_info(account_id, media_id, body, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MediaApi.upload_media ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MediaApi.upload_media" + end + # verify the required parameter 'media_id' is set + if @api_client.config.client_side_validation && media_id.nil? + fail ArgumentError, "Missing the required parameter 'media_id' when calling MediaApi.upload_media" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling MediaApi.upload_media" + end + # resource path + local_var_path = '/users/{accountId}/media/{mediaId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'mediaId' + '}', CGI.escape(media_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json', 'application/ogg', 'application/pdf', 'application/rtf', 'application/zip', 'application/x-tar', 'application/xml', 'application/gzip', 'application/x-bzip2', 'application/x-gzip', 'application/smil', 'application/javascript', 'audio/mp4', 'audio/mpeg', 'audio/ogg', 'audio/flac', 'audio/webm', 'audio/wav', 'audio/amr', 'audio/3gpp', 'image/bmp', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/svg+xml', 'image/tiff', 'image/webp', 'image/x-icon', 'text/css', 'text/csv', 'text/calendar', 'text/plain', 'text/javascript', 'text/vcard', 'text/vnd.wap.wml', 'text/xml', 'video/avi', 'video/mp4', 'video/mpeg', 'video/ogg', 'video/quicktime', 'video/webm', 'video/x-ms-wmv']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + header_params[:'Content-Type'] = opts[:'content_type'] if !opts[:'content_type'].nil? + header_params[:'Cache-Control'] = opts[:'cache_control'] if !opts[:'cache_control'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MediaApi.upload_media", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MediaApi#upload_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/messages_api.rb b/lib/bandwidth-sdk/api/messages_api.rb new file mode 100644 index 00000000..4f1cdc1f --- /dev/null +++ b/lib/bandwidth-sdk/api/messages_api.rb @@ -0,0 +1,204 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class MessagesApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Message + # Endpoint for sending text messages and picture messages using V2 messaging. + # @param account_id [String] Your Bandwidth Account ID. + # @param message_request [MessageRequest] + # @param [Hash] opts the optional parameters + # @return [Message] + def create_message(account_id, message_request, opts = {}) + data, _status_code, _headers = create_message_with_http_info(account_id, message_request, opts) + data + end + + # Create Message + # Endpoint for sending text messages and picture messages using V2 messaging. + # @param account_id [String] Your Bandwidth Account ID. + # @param message_request [MessageRequest] + # @param [Hash] opts the optional parameters + # @return [Array<(Message, Integer, Hash)>] Message data, response status code and response headers + def create_message_with_http_info(account_id, message_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MessagesApi.create_message ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.create_message" + end + # verify the required parameter 'message_request' is set + if @api_client.config.client_side_validation && message_request.nil? + fail ArgumentError, "Missing the required parameter 'message_request' when calling MessagesApi.create_message" + end + # resource path + local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(message_request) + + # return_type + return_type = opts[:debug_return_type] || 'Message' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MessagesApi.create_message", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MessagesApi#create_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Messages + # Returns a list of messages based on query parameters. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter. + # @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + # @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + # @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED. + # @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND. + # @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T). + # @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms. + # @option opts [Integer] :error_code The error code of the message. + # @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + # @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + # @option opts [String] :campaign_id The campaign ID of the message. + # @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc. + # @option opts [String] :page_token A base64 encoded value used for pagination of results. + # @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000. + # @option opts [Boolean] :limit_total_count When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results. + # @return [MessagesList] + def list_messages(account_id, opts = {}) + data, _status_code, _headers = list_messages_with_http_info(account_id, opts) + data + end + + # List Messages + # Returns a list of messages based on query parameters. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :message_id The ID of the message to search for. Special characters need to be encoded using URL encoding. Message IDs could come in different formats, e.g., 9e0df4ca-b18d-40d7-a59f-82fcdf5ae8e6 and 1589228074636lm4k2je7j7jklbn2 are valid message ID formats. Note that you must include at least one query parameter. + # @option opts [String] :source_tn The phone number that sent the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + # @option opts [String] :destination_tn The phone number that received the message. Accepted values are: a single full phone number a comma separated list of full phone numbers (maximum of 10) or a single partial phone number (minimum of 5 characters e.g. '%2B1919'). + # @option opts [MessageStatusEnum] :message_status The status of the message. One of RECEIVED QUEUED SENDING SENT FAILED DELIVERED ACCEPTED UNDELIVERED. + # @option opts [ListMessageDirectionEnum] :message_direction The direction of the message. One of INBOUND OUTBOUND. + # @option opts [String] :carrier_name The name of the carrier used for this message. Possible values include but are not limited to Verizon and TMobile. Special characters need to be encoded using URL encoding (i.e. AT&T should be passed as AT%26T). + # @option opts [MessageTypeEnum] :message_type The type of message. Either sms or mms. + # @option opts [Integer] :error_code The error code of the message. + # @option opts [String] :from_date_time The start of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + # @option opts [String] :to_date_time The end of the date range to search in ISO 8601 format. Uses the message receive time. The date range to search in is currently 14 days. + # @option opts [String] :campaign_id The campaign ID of the message. + # @option opts [String] :sort The field and direction to sort by combined with a colon. Direction is either asc or desc. + # @option opts [String] :page_token A base64 encoded value used for pagination of results. + # @option opts [Integer] :limit The maximum records requested in search result. Default 100. The sum of limit and after cannot be more than 10000. + # @option opts [Boolean] :limit_total_count When set to true, the response's totalCount field will have a maximum value of 10,000. When set to false, or excluded, this will give an accurate totalCount of all messages that match the provided filters. If you are experiencing latency, try using this parameter to limit your results. + # @return [Array<(MessagesList, Integer, Hash)>] MessagesList data, response status code and response headers + def list_messages_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MessagesApi.list_messages ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MessagesApi.list_messages" + end + # resource path + local_var_path = '/users/{accountId}/messages'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'messageId'] = opts[:'message_id'] if !opts[:'message_id'].nil? + query_params[:'sourceTn'] = opts[:'source_tn'] if !opts[:'source_tn'].nil? + query_params[:'destinationTn'] = opts[:'destination_tn'] if !opts[:'destination_tn'].nil? + query_params[:'messageStatus'] = opts[:'message_status'] if !opts[:'message_status'].nil? + query_params[:'messageDirection'] = opts[:'message_direction'] if !opts[:'message_direction'].nil? + query_params[:'carrierName'] = opts[:'carrier_name'] if !opts[:'carrier_name'].nil? + query_params[:'messageType'] = opts[:'message_type'] if !opts[:'message_type'].nil? + query_params[:'errorCode'] = opts[:'error_code'] if !opts[:'error_code'].nil? + query_params[:'fromDateTime'] = opts[:'from_date_time'] if !opts[:'from_date_time'].nil? + query_params[:'toDateTime'] = opts[:'to_date_time'] if !opts[:'to_date_time'].nil? + query_params[:'campaignId'] = opts[:'campaign_id'] if !opts[:'campaign_id'].nil? + query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? + query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil? + query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? + query_params[:'limitTotalCount'] = opts[:'limit_total_count'] if !opts[:'limit_total_count'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'MessagesList' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MessagesApi.list_messages", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MessagesApi#list_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/mfa_api.rb b/lib/bandwidth-sdk/api/mfa_api.rb new file mode 100644 index 00000000..becdf34f --- /dev/null +++ b/lib/bandwidth-sdk/api/mfa_api.rb @@ -0,0 +1,244 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class MFAApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Messaging Authentication Code + # Send an MFA code via text message (SMS). + # @param account_id [String] Your Bandwidth Account ID. + # @param code_request [CodeRequest] MFA code request body. + # @param [Hash] opts the optional parameters + # @return [MessagingCodeResponse] + def generate_messaging_code(account_id, code_request, opts = {}) + data, _status_code, _headers = generate_messaging_code_with_http_info(account_id, code_request, opts) + data + end + + # Messaging Authentication Code + # Send an MFA code via text message (SMS). + # @param account_id [String] Your Bandwidth Account ID. + # @param code_request [CodeRequest] MFA code request body. + # @param [Hash] opts the optional parameters + # @return [Array<(MessagingCodeResponse, Integer, Hash)>] MessagingCodeResponse data, response status code and response headers + def generate_messaging_code_with_http_info(account_id, code_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MFAApi.generate_messaging_code ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_messaging_code" + end + # verify the required parameter 'code_request' is set + if @api_client.config.client_side_validation && code_request.nil? + fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_messaging_code" + end + # resource path + local_var_path = '/accounts/{accountId}/code/messaging'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request) + + # return_type + return_type = opts[:debug_return_type] || 'MessagingCodeResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MFAApi.generate_messaging_code", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MFAApi#generate_messaging_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Voice Authentication Code + # Send an MFA Code via a phone call. + # @param account_id [String] Your Bandwidth Account ID. + # @param code_request [CodeRequest] MFA code request body. + # @param [Hash] opts the optional parameters + # @return [VoiceCodeResponse] + def generate_voice_code(account_id, code_request, opts = {}) + data, _status_code, _headers = generate_voice_code_with_http_info(account_id, code_request, opts) + data + end + + # Voice Authentication Code + # Send an MFA Code via a phone call. + # @param account_id [String] Your Bandwidth Account ID. + # @param code_request [CodeRequest] MFA code request body. + # @param [Hash] opts the optional parameters + # @return [Array<(VoiceCodeResponse, Integer, Hash)>] VoiceCodeResponse data, response status code and response headers + def generate_voice_code_with_http_info(account_id, code_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MFAApi.generate_voice_code ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.generate_voice_code" + end + # verify the required parameter 'code_request' is set + if @api_client.config.client_side_validation && code_request.nil? + fail ArgumentError, "Missing the required parameter 'code_request' when calling MFAApi.generate_voice_code" + end + # resource path + local_var_path = '/accounts/{accountId}/code/voice'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(code_request) + + # return_type + return_type = opts[:debug_return_type] || 'VoiceCodeResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MFAApi.generate_voice_code", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MFAApi#generate_voice_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Verify Authentication Code + # Verify a previously sent MFA code. + # @param account_id [String] Your Bandwidth Account ID. + # @param verify_code_request [VerifyCodeRequest] MFA code verify request body. + # @param [Hash] opts the optional parameters + # @return [VerifyCodeResponse] + def verify_code(account_id, verify_code_request, opts = {}) + data, _status_code, _headers = verify_code_with_http_info(account_id, verify_code_request, opts) + data + end + + # Verify Authentication Code + # Verify a previously sent MFA code. + # @param account_id [String] Your Bandwidth Account ID. + # @param verify_code_request [VerifyCodeRequest] MFA code verify request body. + # @param [Hash] opts the optional parameters + # @return [Array<(VerifyCodeResponse, Integer, Hash)>] VerifyCodeResponse data, response status code and response headers + def verify_code_with_http_info(account_id, verify_code_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: MFAApi.verify_code ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling MFAApi.verify_code" + end + # verify the required parameter 'verify_code_request' is set + if @api_client.config.client_side_validation && verify_code_request.nil? + fail ArgumentError, "Missing the required parameter 'verify_code_request' when calling MFAApi.verify_code" + end + # resource path + local_var_path = '/accounts/{accountId}/code/verify'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(verify_code_request) + + # return_type + return_type = opts[:debug_return_type] || 'VerifyCodeResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"MFAApi.verify_code", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: MFAApi#verify_code\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/phone_number_lookup_api.rb b/lib/bandwidth-sdk/api/phone_number_lookup_api.rb new file mode 100644 index 00000000..a5c8e0a8 --- /dev/null +++ b/lib/bandwidth-sdk/api/phone_number_lookup_api.rb @@ -0,0 +1,165 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class PhoneNumberLookupApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Create Lookup + # Create a Phone Number Lookup Request. + # @param account_id [String] Your Bandwidth Account ID. + # @param lookup_request [LookupRequest] Phone number lookup request. + # @param [Hash] opts the optional parameters + # @return [CreateLookupResponse] + def create_lookup(account_id, lookup_request, opts = {}) + data, _status_code, _headers = create_lookup_with_http_info(account_id, lookup_request, opts) + data + end + + # Create Lookup + # Create a Phone Number Lookup Request. + # @param account_id [String] Your Bandwidth Account ID. + # @param lookup_request [LookupRequest] Phone number lookup request. + # @param [Hash] opts the optional parameters + # @return [Array<(CreateLookupResponse, Integer, Hash)>] CreateLookupResponse data, response status code and response headers + def create_lookup_with_http_info(account_id, lookup_request, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.create_lookup ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.create_lookup" + end + # verify the required parameter 'lookup_request' is set + if @api_client.config.client_side_validation && lookup_request.nil? + fail ArgumentError, "Missing the required parameter 'lookup_request' when calling PhoneNumberLookupApi.create_lookup" + end + # resource path + local_var_path = '/accounts/{accountId}/tnlookup'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(lookup_request) + + # return_type + return_type = opts[:debug_return_type] || 'CreateLookupResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"PhoneNumberLookupApi.create_lookup", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PhoneNumberLookupApi#create_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Lookup Request Status + # Get an existing Phone Number Lookup Request. + # @param account_id [String] Your Bandwidth Account ID. + # @param request_id [String] The phone number lookup request ID from Bandwidth. + # @param [Hash] opts the optional parameters + # @return [LookupStatus] + def get_lookup_status(account_id, request_id, opts = {}) + data, _status_code, _headers = get_lookup_status_with_http_info(account_id, request_id, opts) + data + end + + # Get Lookup Request Status + # Get an existing Phone Number Lookup Request. + # @param account_id [String] Your Bandwidth Account ID. + # @param request_id [String] The phone number lookup request ID from Bandwidth. + # @param [Hash] opts the optional parameters + # @return [Array<(LookupStatus, Integer, Hash)>] LookupStatus data, response status code and response headers + def get_lookup_status_with_http_info(account_id, request_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: PhoneNumberLookupApi.get_lookup_status ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling PhoneNumberLookupApi.get_lookup_status" + end + # verify the required parameter 'request_id' is set + if @api_client.config.client_side_validation && request_id.nil? + fail ArgumentError, "Missing the required parameter 'request_id' when calling PhoneNumberLookupApi.get_lookup_status" + end + # resource path + local_var_path = '/accounts/{accountId}/tnlookup/{requestId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'requestId' + '}', CGI.escape(request_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'LookupStatus' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"PhoneNumberLookupApi.get_lookup_status", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: PhoneNumberLookupApi#get_lookup_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/recordings_api.rb b/lib/bandwidth-sdk/api/recordings_api.rb new file mode 100644 index 00000000..3adbdbdf --- /dev/null +++ b/lib/bandwidth-sdk/api/recordings_api.rb @@ -0,0 +1,782 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class RecordingsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Delete Transcription + # Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_call_transcription(account_id, call_id, recording_id, opts = {}) + delete_call_transcription_with_http_info(account_id, call_id, recording_id, opts) + nil + end + + # Delete Transcription + # Deletes the specified recording's transcription. Note: After the deletion is requested and a `204` is returned, the transcription will not be accessible anymore. However, it is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_call_transcription_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_call_transcription ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_call_transcription" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_call_transcription" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_call_transcription" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.delete_call_transcription", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#delete_call_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Recording + # Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_recording(account_id, call_id, recording_id, opts = {}) + delete_recording_with_http_info(account_id, call_id, recording_id, opts) + nil + end + + # Delete Recording + # Delete the recording information, media and transcription. Note: After the deletion is requested and a `204` is returned, neither the recording metadata nor the actual media nor its transcription will be accessible anymore. However, the media of the specified recording is not deleted immediately. This deletion process, while transparent and irreversible, can take an additional 24 to 48 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_recording_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.delete_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#delete_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Delete Recording Media + # Deletes the specified recording's media. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [nil] + def delete_recording_media(account_id, call_id, recording_id, opts = {}) + delete_recording_media_with_http_info(account_id, call_id, recording_id, opts) + nil + end + + # Delete Recording Media + # Deletes the specified recording's media. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_recording_media_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.delete_recording_media ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.delete_recording_media" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.delete_recording_media" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.delete_recording_media" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.delete_recording_media", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#delete_recording_media\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Download Recording + # Downloads the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [File] + def download_call_recording(account_id, call_id, recording_id, opts = {}) + data, _status_code, _headers = download_call_recording_with_http_info(account_id, call_id, recording_id, opts) + data + end + + # Download Recording + # Downloads the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(File, Integer, Hash)>] File data, response status code and response headers + def download_call_recording_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.download_call_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.download_call_recording" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.download_call_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.download_call_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['audio/vnd.wave', 'audio/mpeg', 'application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'File' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.download_call_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#download_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Call Recording + # Returns metadata for the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [CallRecordingMetadata] + def get_call_recording(account_id, call_id, recording_id, opts = {}) + data, _status_code, _headers = get_call_recording_with_http_info(account_id, call_id, recording_id, opts) + data + end + + # Get Call Recording + # Returns metadata for the specified recording. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(CallRecordingMetadata, Integer, Hash)>] CallRecordingMetadata data, response status code and response headers + def get_call_recording_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.get_call_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_call_recording" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_call_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_call_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'CallRecordingMetadata' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.get_call_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#get_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Transcription + # Downloads the specified transcription. If the transcribed recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [``](/docs/voice/bxml/playAudio) and [``](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [``](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [TranscriptionList] + def get_call_transcription(account_id, call_id, recording_id, opts = {}) + data, _status_code, _headers = get_call_transcription_with_http_info(account_id, call_id, recording_id, opts) + data + end + + # Get Transcription + # Downloads the specified transcription. If the transcribed recording was multi-channel, then there will be 2 transcripts. The caller/called party transcript will be the first item while [`<PlayAudio>`](/docs/voice/bxml/playAudio) and [`<SpeakSentence>`](/docs/voice/bxml/speakSentence) transcript will be the second item. During a [`<Transfer>`](/docs/voice/bxml/transfer) the A-leg transcript will be the first item while the B-leg transcript will be the second item. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param [Hash] opts the optional parameters + # @return [Array<(TranscriptionList, Integer, Hash)>] TranscriptionList data, response status code and response headers + def get_call_transcription_with_http_info(account_id, call_id, recording_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.get_call_transcription ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.get_call_transcription" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.get_call_transcription" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.get_call_transcription" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'TranscriptionList' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.get_call_transcription", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#get_call_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Get Call Recordings + # Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :to Filter results by the `to` field. + # @option opts [String] :from Filter results by the `from` field. + # @option opts [String] :min_start_time Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format). + # @option opts [String] :max_start_time Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format). + # @return [Array] + def list_account_call_recordings(account_id, opts = {}) + data, _status_code, _headers = list_account_call_recordings_with_http_info(account_id, opts) + data + end + + # Get Call Recordings + # Returns a list of metadata for the recordings associated with the specified account. The list can be filtered by the optional from, to, minStartTime, and maxStartTime arguments. The list is capped at 1000 entries and may be empty if no recordings match the specified criteria. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @option opts [String] :to Filter results by the `to` field. + # @option opts [String] :from Filter results by the `from` field. + # @option opts [String] :min_start_time Filter results to recordings which have a `startTime` after or including `minStartTime` (in ISO8601 format). + # @option opts [String] :max_start_time Filter results to recordings which have a `startTime` before `maxStartTime` (in ISO8601 format). + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + def list_account_call_recordings_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.list_account_call_recordings ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_account_call_recordings" + end + # resource path + local_var_path = '/accounts/{accountId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil? + query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil? + query_params[:'minStartTime'] = opts[:'min_start_time'] if !opts[:'min_start_time'].nil? + query_params[:'maxStartTime'] = opts[:'max_start_time'] if !opts[:'max_start_time'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.list_account_call_recordings", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#list_account_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # List Call Recordings + # Returns a (potentially empty) list of metadata for the recordings that took place during the specified call. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param [Hash] opts the optional parameters + # @return [Array] + def list_call_recordings(account_id, call_id, opts = {}) + data, _status_code, _headers = list_call_recordings_with_http_info(account_id, call_id, opts) + data + end + + # List Call Recordings + # Returns a (potentially empty) list of metadata for the recordings that took place during the specified call. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param [Hash] opts the optional parameters + # @return [Array<(Array, Integer, Hash)>] Array data, response status code and response headers + def list_call_recordings_with_http_info(account_id, call_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.list_call_recordings ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.list_call_recordings" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.list_call_recordings" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'Array' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.list_call_recordings", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#list_call_recordings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Create Transcription Request + # Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param transcribe_recording [TranscribeRecording] + # @param [Hash] opts the optional parameters + # @return [nil] + def transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording, opts = {}) + transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts) + nil + end + + # Create Transcription Request + # Generate the transcription for a specific recording. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param recording_id [String] Programmable Voice API Recording ID. + # @param transcribe_recording [TranscribeRecording] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def transcribe_call_recording_with_http_info(account_id, call_id, recording_id, transcribe_recording, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.transcribe_call_recording ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.transcribe_call_recording" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.transcribe_call_recording" + end + # verify the required parameter 'recording_id' is set + if @api_client.config.client_side_validation && recording_id.nil? + fail ArgumentError, "Missing the required parameter 'recording_id' when calling RecordingsApi.transcribe_call_recording" + end + # verify the required parameter 'transcribe_recording' is set + if @api_client.config.client_side_validation && transcribe_recording.nil? + fail ArgumentError, "Missing the required parameter 'transcribe_recording' when calling RecordingsApi.transcribe_call_recording" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)).sub('{' + 'recordingId' + '}', CGI.escape(recording_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(transcribe_recording) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.transcribe_call_recording", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#transcribe_call_recording\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Update Recording + # Pause or resume a recording on an active phone call. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param update_call_recording [UpdateCallRecording] + # @param [Hash] opts the optional parameters + # @return [nil] + def update_call_recording_state(account_id, call_id, update_call_recording, opts = {}) + update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts) + nil + end + + # Update Recording + # Pause or resume a recording on an active phone call. + # @param account_id [String] Your Bandwidth Account ID. + # @param call_id [String] Programmable Voice API Call ID. + # @param update_call_recording [UpdateCallRecording] + # @param [Hash] opts the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def update_call_recording_state_with_http_info(account_id, call_id, update_call_recording, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: RecordingsApi.update_call_recording_state ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling RecordingsApi.update_call_recording_state" + end + # verify the required parameter 'call_id' is set + if @api_client.config.client_side_validation && call_id.nil? + fail ArgumentError, "Missing the required parameter 'call_id' when calling RecordingsApi.update_call_recording_state" + end + # verify the required parameter 'update_call_recording' is set + if @api_client.config.client_side_validation && update_call_recording.nil? + fail ArgumentError, "Missing the required parameter 'update_call_recording' when calling RecordingsApi.update_call_recording_state" + end + # resource path + local_var_path = '/accounts/{accountId}/calls/{callId}/recording'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)).sub('{' + 'callId' + '}', CGI.escape(call_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + content_type = @api_client.select_header_content_type(['application/json']) + if !content_type.nil? + header_params['Content-Type'] = content_type + end + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(update_call_recording) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"RecordingsApi.update_call_recording_state", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: RecordingsApi#update_call_recording_state\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api/statistics_api.rb b/lib/bandwidth-sdk/api/statistics_api.rb new file mode 100644 index 00000000..bbb1ebb5 --- /dev/null +++ b/lib/bandwidth-sdk/api/statistics_api.rb @@ -0,0 +1,85 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'cgi' + +module Bandwidth + class StatisticsApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Get Account Statistics + # Returns details about the current state of the account. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @return [AccountStatistics] + def get_statistics(account_id, opts = {}) + data, _status_code, _headers = get_statistics_with_http_info(account_id, opts) + data + end + + # Get Account Statistics + # Returns details about the current state of the account. + # @param account_id [String] Your Bandwidth Account ID. + # @param [Hash] opts the optional parameters + # @return [Array<(AccountStatistics, Integer, Hash)>] AccountStatistics data, response status code and response headers + def get_statistics_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: StatisticsApi.get_statistics ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling StatisticsApi.get_statistics" + end + # resource path + local_var_path = '/accounts/{accountId}/statistics'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AccountStatistics' + + # auth_names + auth_names = opts[:debug_auth_names] || ['Basic'] + + new_options = opts.merge( + :operation => :"StatisticsApi.get_statistics", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: StatisticsApi#get_statistics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/bandwidth-sdk/api_client.rb b/lib/bandwidth-sdk/api_client.rb new file mode 100644 index 00000000..2412b9d5 --- /dev/null +++ b/lib/bandwidth-sdk/api_client.rb @@ -0,0 +1,428 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'json' +require 'logger' +require 'tempfile' +require 'time' +require 'faraday' +require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0') + +module Bandwidth + class ApiClient + # The Configuration object holding settings to be used in the API client. + attr_accessor :config + + # Defines the headers to be used in HTTP requests of all API calls by default. + # + # @return [Hash] + attr_accessor :default_headers + + # Initializes the ApiClient + # @option config [Configuration] Configuration for initializing the object, default to Configuration.default + def initialize(config = Configuration.default) + @config = config + @user_agent = "OpenAPI-Generator/#{VERSION}/ruby" + @default_headers = { + 'Content-Type' => 'application/json', + 'User-Agent' => @user_agent + } + end + + def self.default + @@default ||= ApiClient.new + end + + # Call an API with given options. + # + # @return [Array<(Object, Integer, Hash)>] an array of 3 elements: + # the data deserialized from response body (could be nil), response status code and response headers. + def call_api(http_method, path, opts = {}) + begin + response = connection(opts).public_send(http_method.to_sym.downcase) do |req| + build_request(http_method, path, req, opts) + end + + if config.debugging + config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" + end + + unless response.success? + if response.status == 0 && response.respond_to?(:return_message) + # Errors from libcurl will be made visible here + fail ApiError.new(code: 0, + message: response.return_message) + else + fail ApiError.new(code: response.status, + response_headers: response.headers, + response_body: response.body), + response.reason_phrase + end + end + rescue Faraday::TimeoutError + fail ApiError.new('Connection timed out') + rescue Faraday::ConnectionFailed + fail ApiError.new('Connection failed') + end + + if opts[:return_type] + data = deserialize(response, opts[:return_type]) + else + data = nil + end + return data, response.status, response.headers + end + + # Builds the HTTP request + # + # @param [String] http_method HTTP method/verb (e.g. POST) + # @param [String] path URL path (e.g. /account/new) + # @option opts [Hash] :header_params Header parameters + # @option opts [Hash] :query_params Query parameters + # @option opts [Hash] :form_params Query parameters + # @option opts [Object] :body HTTP body (JSON/XML) + # @return [Faraday::Request] A Faraday Request + def build_request(http_method, path, request, opts = {}) + url = build_request_url(path, opts) + http_method = http_method.to_sym.downcase + + header_params = @default_headers.merge(opts[:header_params] || {}) + query_params = opts[:query_params] || {} + form_params = opts[:form_params] || {} + + update_params_for_auth! header_params, query_params, opts[:auth_names] + + if [:post, :patch, :put, :delete].include?(http_method) + req_body = build_request_body(header_params, form_params, opts[:body]) + if config.debugging + config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n" + end + end + request.headers = header_params + request.body = req_body + + # Overload default options only if provided + request.options.params_encoder = config.params_encoder if config.params_encoder + request.options.timeout = config.timeout if config.timeout + + request.url url + request.params = query_params + download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary' + request + end + + # Builds the HTTP request body + # + # @param [Hash] header_params Header parameters + # @param [Hash] form_params Query parameters + # @param [Object] body HTTP body (JSON/XML) + # @return [String] HTTP body data in the form of string + def build_request_body(header_params, form_params, body) + # http form + if header_params['Content-Type'] == 'application/x-www-form-urlencoded' + data = URI.encode_www_form(form_params) + elsif header_params['Content-Type'] == 'multipart/form-data' + data = {} + form_params.each do |key, value| + case value + when ::File, ::Tempfile + # TODO hardcode to application/octet-stream, need better way to detect content type + data[key] = Faraday::FilePart.new(value.path, 'application/octet-stream', value.path) + when ::Array, nil + # let Faraday handle Array and nil parameters + data[key] = value + else + data[key] = value.to_s + end + end + elsif body + data = body.is_a?(String) ? body : body.to_json + else + data = nil + end + data + end + + def download_file(request) + @stream = [] + + # handle streaming Responses + request.options.on_data = Proc.new do |chunk, overall_received_bytes| + @stream << chunk + end + end + + def connection(opts) + opts[:header_params]['Content-Type'] == 'multipart/form-data' ? connection_multipart : connection_regular + end + + def connection_multipart + @connection_multipart ||= build_connection do |conn| + conn.request :multipart + conn.request :url_encoded + end + end + + def connection_regular + @connection_regular ||= build_connection + end + + def build_connection + Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn| + basic_auth(conn) + config.configure_middleware(conn) + yield(conn) if block_given? + conn.adapter(Faraday.default_adapter) + config.configure_connection(conn) + end + end + + def ssl_options + { + ca_file: config.ssl_ca_file, + verify: config.ssl_verify, + verify_mode: config.ssl_verify_mode, + client_cert: config.ssl_client_cert, + client_key: config.ssl_client_key + } + end + + def basic_auth(conn) + if config.username && config.password + if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0') + conn.request(:authorization, :basic, config.username, config.password) + else + conn.request(:basic_auth, config.username, config.password) + end + end + end + + # Check if the given MIME is a JSON MIME. + # JSON MIME examples: + # application/json + # application/json; charset=UTF8 + # APPLICATION/JSON + # */* + # @param [String] mime MIME + # @return [Boolean] True if the MIME is application/json + def json_mime?(mime) + (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? + end + + # Deserialize the response to the given return type. + # + # @param [Response] response HTTP response + # @param [String] return_type some examples: "User", "Array", "Hash" + def deserialize(response, return_type) + body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + if return_type == 'File' + if @config.return_binary_data == true + # return byte stream + encoding = body.encoding + return @stream.join.force_encoding(encoding) + else + # return file instead of binary data + content_disposition = response.headers['Content-Disposition'] + if content_disposition && content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = body.encoding + @tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile.write(@stream.join.force_encoding(encoding)) + @tempfile.close + @config.logger.info "Temp file written to #{@tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" + return @tempfile + end + end + + return nil if body.nil? || body.empty? + + # return response body directly for String return type + return body if return_type == 'String' + + # ensuring a default content type + content_type = response.headers['Content-Type'] || 'application/json' + + fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type) + + begin + data = JSON.parse("[#{body}]", :symbolize_names => true)[0] + rescue JSON::ParserError => e + if %w(String Date Time).include?(return_type) + data = body + else + raise e + end + end + + convert_to_type data, return_type + end + + # Convert data to the given return type. + # @param [Object] data Data to be converted + # @param [String] return_type Return type + # @return [Mixed] Data in a particular type + def convert_to_type(data, return_type) + return nil if data.nil? + case return_type + when 'String' + data.to_s + when 'Integer' + data.to_i + when 'Float' + data.to_f + when 'Boolean' + data == true + when 'Time' + # parse date time (expecting ISO 8601 format) + Time.parse data + when 'Date' + # parse date time (expecting ISO 8601 format) + Date.parse data + when 'Object' + # generic object (usually a Hash), return directly + data + when /\AArray<(.+)>\z/ + # e.g. Array + sub_type = $1 + data.map { |item| convert_to_type(item, sub_type) } + when /\AHash\\z/ + # e.g. Hash + sub_type = $1 + {}.tap do |hash| + data.each { |k, v| hash[k] = convert_to_type(v, sub_type) } + end + else + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(return_type) + klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data) + end + end + + # Sanitize filename by removing path. + # e.g. ../../sun.gif becomes sun.gif + # + # @param [String] filename the filename to be sanitized + # @return [String] the sanitized filename + def sanitize_filename(filename) + filename.gsub(/.*[\/\\]/, '') + end + + def build_request_url(path, opts = {}) + # Add leading and trailing slashes to path + path = "/#{path}".gsub(/\/+/, '/') + @config.base_url(opts[:operation]) + path + end + + # Update header and query params based on authentication settings. + # + # @param [Hash] header_params Header parameters + # @param [Hash] query_params Query parameters + # @param [String] auth_names Authentication scheme name + def update_params_for_auth!(header_params, query_params, auth_names) + Array(auth_names).each do |auth_name| + auth_setting = @config.auth_settings[auth_name] + next unless auth_setting + case auth_setting[:in] + when 'header' then header_params[auth_setting[:key]] = auth_setting[:value] + when 'query' then query_params[auth_setting[:key]] = auth_setting[:value] + else fail ArgumentError, 'Authentication token must be in `query` or `header`' + end + end + end + + # Sets user agent in HTTP header + # + # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0) + def user_agent=(user_agent) + @user_agent = user_agent + @default_headers['User-Agent'] = @user_agent + end + + # Return Accept header based on an array of accepts provided. + # @param [Array] accepts array for Accept + # @return [String] the Accept header (e.g. application/json) + def select_header_accept(accepts) + return nil if accepts.nil? || accepts.empty? + # use JSON when present, otherwise use all of the provided + json_accept = accepts.find { |s| json_mime?(s) } + json_accept || accepts.join(',') + end + + # Return Content-Type header based on an array of content types provided. + # @param [Array] content_types array for Content-Type + # @return [String] the Content-Type header (e.g. application/json) + def select_header_content_type(content_types) + # return nil by default + return if content_types.nil? || content_types.empty? + # use JSON when present, otherwise use the first one + json_content_type = content_types.find { |s| json_mime?(s) } + json_content_type || content_types.first + end + + # Convert object (array, hash, object, etc) to JSON string. + # @param [Object] model object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_http_body(model) + return model if model.nil? || model.is_a?(String) + local_body = nil + if model.is_a?(Array) + local_body = model.map { |m| object_to_hash(m) } + else + local_body = object_to_hash(model) + end + local_body.to_json + end + + # Convert object(non-array) to hash. + # @param [Object] obj object to be converted into JSON string + # @return [String] JSON string representation of the object + def object_to_hash(obj) + if obj.respond_to?(:to_hash) + obj.to_hash + else + obj + end + end + + # Build parameter value according to the given collection format. + # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi + def build_collection_param(param, collection_format) + case collection_format + when :csv + param.join(',') + when :ssv + param.join(' ') + when :tsv + param.join("\t") + when :pipes + param.join('|') + when :multi + # return the array directly as typhoeus will handle it as expected + param + else + fail "unknown collection format: #{collection_format.inspect}" + end + end + end +end diff --git a/lib/bandwidth-sdk/api_error.rb b/lib/bandwidth-sdk/api_error.rb new file mode 100644 index 00000000..901fb837 --- /dev/null +++ b/lib/bandwidth-sdk/api_error.rb @@ -0,0 +1,58 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +module Bandwidth + class ApiError < StandardError + attr_reader :code, :response_headers, :response_body + + # Usage examples: + # ApiError.new + # ApiError.new("message") + # ApiError.new(:code => 500, :response_headers => {}, :response_body => "") + # ApiError.new(:code => 404, :message => "Not Found") + def initialize(arg = nil) + if arg.is_a? Hash + if arg.key?(:message) || arg.key?('message') + super(arg[:message] || arg['message']) + else + super arg + end + + arg.each do |k, v| + instance_variable_set "@#{k}", v + end + else + super arg + @message = arg + end + end + + # Override to_s to display a friendly error message + def to_s + message + end + + def message + if @message.nil? + msg = 'Error message: the server returns an error' + else + msg = @message + end + + msg += "\nHTTP status code: #{code}" if code + msg += "\nResponse headers: #{response_headers}" if response_headers + msg += "\nResponse body: #{response_body}" if response_body + + msg + end + end +end diff --git a/lib/bandwidth-sdk/configuration.rb b/lib/bandwidth-sdk/configuration.rb new file mode 100644 index 00000000..d9a0ad5b --- /dev/null +++ b/lib/bandwidth-sdk/configuration.rb @@ -0,0 +1,591 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +module Bandwidth + class Configuration + # Defines url scheme + attr_accessor :scheme + + # Defines url host + attr_accessor :host + + # Defines url base path + attr_accessor :base_path + + # Define server configuration index + attr_accessor :server_index + + # Define server operation configuration index + attr_accessor :server_operation_index + + # Default server variables + attr_accessor :server_variables + + # Default server operation variables + attr_accessor :server_operation_variables + + # Defines API keys used with API Key authentications. + # + # @return [Hash] key: parameter name, value: parameter value (API key) + # + # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string) + # config.api_key['api_key'] = 'xxx' + attr_accessor :api_key + + # Defines API key prefixes used with API Key authentications. + # + # @return [Hash] key: parameter name, value: API key prefix + # + # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers) + # config.api_key_prefix['api_key'] = 'Token' + attr_accessor :api_key_prefix + + # Defines the username used with HTTP basic authentication. + # + # @return [String] + attr_accessor :username + + # Defines the password used with HTTP basic authentication. + # + # @return [String] + attr_accessor :password + + # Defines the access token (Bearer) used with OAuth2. + attr_accessor :access_token + + # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2. + # Overrides the access_token if set + # @return [Proc] + attr_accessor :access_token_getter + + # Set this to return data as binary instead of downloading a temp file. When enabled (set to true) + # HTTP responses with return type `File` will be returned as a stream of binary data. + # Default to false. + attr_accessor :return_binary_data + + # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response + # details will be logged with `logger.debug` (see the `logger` attribute). + # Default to false. + # + # @return [true, false] + attr_accessor :debugging + + # Defines the logger used for debugging. + # Default to `Rails.logger` (when in Rails) or logging to STDOUT. + # + # @return [#debug] + attr_accessor :logger + + # Defines the temporary folder to store downloaded files + # (for API endpoints that have file response). + # Default to use `Tempfile`. + # + # @return [String] + attr_accessor :temp_folder_path + + # The time limit for HTTP request in seconds. + # Default to 0 (never times out). + attr_accessor :timeout + + # Set this to false to skip client side validation in the operation. + # Default to true. + # @return [true, false] + attr_accessor :client_side_validation + + ### TLS/SSL setting + # Set this to false to skip verifying SSL certificate when calling API from https server. + # Default to true. + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + # @return [true, false] + attr_accessor :ssl_verify + + ### TLS/SSL setting + # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html) + # + # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks. + # + attr_accessor :ssl_verify_mode + + ### TLS/SSL setting + # Set this to customize the certificate file to verify the peer. + # + # @return [String] the path to the certificate file + attr_accessor :ssl_ca_file + + ### TLS/SSL setting + # Client certificate file (for client certificate) + attr_accessor :ssl_client_cert + + ### TLS/SSL setting + # Client private key file (for client certificate) + attr_accessor :ssl_client_key + + ### Proxy setting + # HTTP Proxy settings + attr_accessor :proxy + + # Set this to customize parameters encoder of array parameter. + # Default to nil. Faraday uses NestedParamsEncoder when nil. + # + # @see The params_encoder option of Faraday. Related source code: + # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders + attr_accessor :params_encoder + + + attr_accessor :inject_format + + attr_accessor :force_ending_format + + def initialize + @scheme = 'http' + @host = 'localhost' + @base_path = '' + @server_index = nil + @server_operation_index = {} + @server_variables = {} + @server_operation_variables = {} + @api_key = {} + @api_key_prefix = {} + @client_side_validation = true + @ssl_verify = true + @ssl_verify_mode = nil + @ssl_ca_file = nil + @ssl_client_cert = nil + @ssl_client_key = nil + @middlewares = Hash.new { |h, k| h[k] = [] } + @configure_connection_blocks = [] + @timeout = 60 + # return data as binary instead of file + @return_binary_data = false + @params_encoder = nil + @debugging = false + @inject_format = false + @force_ending_format = false + @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) + + yield(self) if block_given? + end + + # The default Configuration object. + def self.default + @@default ||= Configuration.new + end + + def configure + yield(self) if block_given? + end + + def scheme=(scheme) + # remove :// from scheme + @scheme = scheme.sub(/:\/\//, '') + end + + def host=(host) + # remove http(s):// and anything after a slash + @host = host.sub(/https?:\/\//, '').split('/').first + end + + def base_path=(base_path) + # Add leading and trailing slashes to base_path + @base_path = "/#{base_path}".gsub(/\/+/, '/') + @base_path = '' if @base_path == '/' + end + + # Returns base URL for specified operation based on server settings + def base_url(operation = nil) + if operation_server_settings.key?(operation) then + index = server_operation_index.fetch(operation, server_index) + server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation]) + else + server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil) + end + end + + # Gets API key (with prefix if set). + # @param [String] param_name the parameter name of API key auth + def api_key_with_prefix(param_name, param_alias = nil) + key = @api_key[param_name] + key = @api_key.fetch(param_alias, key) unless param_alias.nil? + if @api_key_prefix[param_name] + "#{@api_key_prefix[param_name]} #{key}" + else + key + end + end + + # Gets access_token using access_token_getter or uses the static access_token + def access_token_with_refresh + return access_token if access_token_getter.nil? + access_token_getter.call + end + + # Gets Basic Auth token string + def basic_auth_token + 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n") + end + + # Returns Auth Settings hash for api client. + def auth_settings + { + 'Basic' => + { + type: 'basic', + in: 'header', + key: 'Authorization', + value: basic_auth_token + }, + } + end + + # Returns an array of Server setting + def server_settings + [ + { + url: "", + description: "No description provided", + } + ] + end + + def operation_server_settings + { + "CallsApi.create_call": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "CallsApi.get_call_state": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "CallsApi.update_call": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "CallsApi.update_call_bxml": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.download_conference_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.get_conference": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.get_conference_member": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.get_conference_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.list_conference_recordings": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.list_conferences": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.update_conference": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.update_conference_bxml": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "ConferencesApi.update_conference_member": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "MFAApi.generate_messaging_code": [ + { + url: "https://mfa.bandwidth.com/api/v1", + description: "Production", + } + ], + "MFAApi.generate_voice_code": [ + { + url: "https://mfa.bandwidth.com/api/v1", + description: "Production", + } + ], + "MFAApi.verify_code": [ + { + url: "https://mfa.bandwidth.com/api/v1", + description: "Production", + } + ], + "MediaApi.delete_media": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "MediaApi.get_media": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "MediaApi.list_media": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "MediaApi.upload_media": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "MessagesApi.create_message": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "MessagesApi.list_messages": [ + { + url: "https://messaging.bandwidth.com/api/v2", + description: "Production", + } + ], + "PhoneNumberLookupApi.create_lookup": [ + { + url: "https://numbers.bandwidth.com/api/v1", + description: "Production", + } + ], + "PhoneNumberLookupApi.get_lookup_status": [ + { + url: "https://numbers.bandwidth.com/api/v1", + description: "Production", + } + ], + "RecordingsApi.delete_call_transcription": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.delete_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.delete_recording_media": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.download_call_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.get_call_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.get_call_transcription": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.list_account_call_recordings": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.list_call_recordings": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.transcribe_call_recording": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "RecordingsApi.update_call_recording_state": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + "StatisticsApi.get_statistics": [ + { + url: "https://voice.bandwidth.com/api/v2", + description: "Production", + } + ], + } + end + + # Returns URL based on server settings + # + # @param index array index of the server settings + # @param variables hash of variable and the corresponding value + def server_url(index, variables = {}, servers = nil) + servers = server_settings if servers == nil + + # check array index out of bound + if (index.nil? || index < 0 || index >= servers.size) + fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}" + end + + server = servers[index] + url = server[:url] + + return url unless server.key? :variables + + # go through variable and assign a value + server[:variables].each do |name, variable| + if variables.key?(name) + if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name])) + url.gsub! "{" + name.to_s + "}", variables[name] + else + fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}." + end + else + # use default value + url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value] + end + end + + url + end + + # Configure Faraday connection directly. + # + # ``` + # c.configure_faraday_connection do |conn| + # conn.use Faraday::HttpCache, shared_cache: false, logger: logger + # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger| + # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]') + # end + # end + # + # c.configure_faraday_connection do |conn| + # conn.adapter :typhoeus + # end + # ``` + # + # @param block [Proc] `#call`able object that takes one arg, the connection + def configure_faraday_connection(&block) + @configure_connection_blocks << block + end + + def configure_connection(conn) + @configure_connection_blocks.each do |block| + block.call(conn) + end + end + + # Adds middleware to the stack + def use(*middleware) + set_faraday_middleware(:use, *middleware) + end + + # Adds request middleware to the stack + def request(*middleware) + set_faraday_middleware(:request, *middleware) + end + + # Adds response middleware to the stack + def response(*middleware) + set_faraday_middleware(:response, *middleware) + end + + # Adds Faraday middleware setting information to the stack + # + # @example Use the `set_faraday_middleware` method to set middleware information + # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503]) + # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug }) + # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false) + # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 }) + # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger) + # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware) + # + # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143 + def set_faraday_middleware(operation, key, *args, &block) + unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation) + fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \ + " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete." + end + + @middlewares[operation] << [key, args, block] + end + ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true) + + # Set up middleware on the connection + def configure_middleware(connection) + return if @middlewares.empty? + + [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation| + next unless @middlewares.key?(operation) + + @middlewares[operation].each do |key, args, block| + connection.builder.send(operation, key, *args, &block) + end + end + + if @middlewares.key?(:delete) + @middlewares[:delete].each do |key, _args, _block| + connection.builder.delete(key) + end + end + end + end +end diff --git a/lib/bandwidth-sdk/models/account_statistics.rb b/lib/bandwidth-sdk/models/account_statistics.rb new file mode 100644 index 00000000..592530f4 --- /dev/null +++ b/lib/bandwidth-sdk/models/account_statistics.rb @@ -0,0 +1,223 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class AccountStatistics + # The number of calls currently enqueued. + attr_accessor :current_call_queue_size + + # The maximum size of the queue before outgoing calls start being rejected. + attr_accessor :max_call_queue_size + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'current_call_queue_size' => :'currentCallQueueSize', + :'max_call_queue_size' => :'maxCallQueueSize' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'current_call_queue_size' => :'Integer', + :'max_call_queue_size' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AccountStatistics` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AccountStatistics`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'current_call_queue_size') + self.current_call_queue_size = attributes[:'current_call_queue_size'] + end + + if attributes.key?(:'max_call_queue_size') + self.max_call_queue_size = attributes[:'max_call_queue_size'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + current_call_queue_size == o.current_call_queue_size && + max_call_queue_size == o.max_call_queue_size + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [current_call_queue_size, max_call_queue_size].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/answer_callback.rb b/lib/bandwidth-sdk/models/answer_callback.rb new file mode 100644 index 00000000..a1df3331 --- /dev/null +++ b/lib/bandwidth-sdk/models/answer_callback.rb @@ -0,0 +1,368 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Answer event is sent to the answerUrl specified in the createCall request when an outbound call is answered. + class AnswerCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + attr_accessor :machine_detection_result + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'machine_detection_result' => :'machineDetectionResult' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'machine_detection_result' => :'MachineDetectionResult' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'machine_detection_result' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::AnswerCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::AnswerCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'machine_detection_result') + self.machine_detection_result = attributes[:'machine_detection_result'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + machine_detection_result == o.machine_detection_result + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, machine_detection_result].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bridge_complete_callback.rb b/lib/bandwidth-sdk/models/bridge_complete_callback.rb new file mode 100644 index 00000000..8a7cbc79 --- /dev/null +++ b/lib/bandwidth-sdk/models/bridge_complete_callback.rb @@ -0,0 +1,390 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # If the target call leaves the , then this callback is sent to the bridgeCompleteUrl, and the BXML returned in it is executed on the call. If this webhook is sent, the Bridge Target Complete webhook is NOT sent. This callback is also sent if any problem occurs that prevents the calls to be bridged. + class BridgeCompleteCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. + attr_accessor :cause + + # Text explaining the reason that caused the call to fail in case of errors. + attr_accessor :error_message + + # Bandwidth's internal id that references the error event. + attr_accessor :error_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'cause' => :'cause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'error_message', + :'error_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BridgeCompleteCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BridgeCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + cause == o.cause && + error_message == o.error_message && + error_id == o.error_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, cause, error_message, error_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb b/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb new file mode 100644 index 00000000..8150a36f --- /dev/null +++ b/lib/bandwidth-sdk/models/bridge_target_complete_callback.rb @@ -0,0 +1,358 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # If the originating call leaves the , then this callback is sent to the bridgeTargetCompleteUrl, and the BXML returned in it is executed on the target call. If this webhook is sent, the Bridge Complete webhook is NOT sent. + class BridgeTargetCompleteCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::BridgeTargetCompleteCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::BridgeTargetCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/bxml.rb b/lib/bandwidth-sdk/models/bxml/bxml.rb new file mode 100644 index 00000000..cd8c6b10 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/bxml.rb @@ -0,0 +1,11 @@ +module Bandwidth + module Bxml + class Bxml < Bandwidth::Bxml::Root + # Initializer + # @param nested_verbs [Array] XML element children. Defaults to an empty array. + def initialize(nested_verbs = []) + super(tag = 'Bxml', nested_verbs) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/nestable_verb.rb b/lib/bandwidth-sdk/models/bxml/nestable_verb.rb new file mode 100644 index 00000000..bc0793d3 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/nestable_verb.rb @@ -0,0 +1,46 @@ +require 'ox' + +module Bandwidth + module Bxml + class NestableVerb < Bandwidth::Bxml::Verb + # Initializer + # @param tag [String] Name of the XML element. + # @param content [String] XML element content. Defaults to nil. + # @param nested_verbs [Array] XML element children. Defaults to an empty array. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(tag, content = nil, nested_verbs = [], attributes = {}) + @tag = tag + @content = content + @nested_verbs = nested_verbs + @attributes = attributes + end + + # Generate an XML element for the verb + # @return [Node] The XML element. + def generate_xml + root = Ox::Element.new(@tag) + if @content + root << @content + end + + if @nested_verbs.length > 0 + @nested_verbs.each do |verb| + root << verb.generate_xml + end + end + + if !@attributes.empty? && !@attribute_map.nil? + @attributes.each do |key, value| + if @attribute_map.include? key.to_sym + root[@attribute_map[key.to_sym]] = value + else + raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb") + end + end + end + + root + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/response.rb b/lib/bandwidth-sdk/models/bxml/response.rb new file mode 100644 index 00000000..e0bbb7e4 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/response.rb @@ -0,0 +1,11 @@ +module Bandwidth + module Bxml + class Response < Bandwidth::Bxml::Root + # Initializer + # @param nested_verbs [Array] XML element children. Defaults to an empty array. + def initialize(nested_verbs = []) + super(tag = 'Response', nested_verbs) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/root.rb b/lib/bandwidth-sdk/models/bxml/root.rb new file mode 100644 index 00000000..1b1ee9a5 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/root.rb @@ -0,0 +1,47 @@ +require 'ox' + +module Bandwidth + module Bxml + SPEAK_SENTENCE_REGEX = /(.*?)<\/SpeakSentence>/ + SSML_REGEX = /<([a-zA-Z\/\/].*?)>/ + + class Root + # Initializer + # @param tag [String] Name of the XML element. + # @param nested_verbs [Array] XML element children. Defaults to an empty array. + def initialize(tag, nested_verbs = []) + @tag = tag + @nested_verbs = nested_verbs + end + + # Generate an XML element for the BXML response + # @return [Document] The XML element. + def generate_xml + xml = Ox::Document.new + instruct = Ox::Instruct.new(:xml) + instruct[:version] = '1.0' + instruct[:encoding] = 'UTF-8' + xml << instruct + root = Ox::Element.new(@tag) + @nested_verbs.each do |verb| + root << verb.generate_xml + end + xml << root + xml + end + + # Add a verb to the nested verbs array + # @param *nested_verbs [Verb] or [Array] Verb or verbs to add to the array. + def add_verb(nested_verbs) + @nested_verbs.push(*nested_verbs) + end + + # Return BXML representaion of this response + # @return [String] The XML response in string format. + def to_bxml + bxml = Ox.dump(generate_xml) + bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verb.rb b/lib/bandwidth-sdk/models/bxml/verb.rb new file mode 100644 index 00000000..f16b9a44 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verb.rb @@ -0,0 +1,50 @@ +require 'ox' + +module Bandwidth + module Bxml + class Verb + # Initializer + # @param tag [String] Name of the XML element. + # @param content [String] XML element content. Defaults to nil. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(tag, content = nil, attributes = {}) + @tag = tag + @content = content + @attributes = attributes + end + + # Set XML attributes for the verb + # @param attributes [Hash] The attributes to add to the element. + def set_attributes(attributes) + @attributes = attributes + end + + # Generate an XML element for the verb + # @return [Node] The XML element. + def generate_xml + root = Ox::Element.new(@tag) + if @content + root << @content + end + + if !@attributes.empty? && !@attribute_map.nil? + @attributes.each do |key, value| + if @attribute_map.include? key.to_sym + root[@attribute_map[key.to_sym]] = value + else + raise NoMethodError.new("attribute '#{key}' is not a valid attribute for this verb") + end + end + end + + root + end + + # Return BXML representaion of this element + # @return [String] The XML element in string format. + def to_bxml + Ox.dump(generate_xml) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/bridge.rb b/lib/bandwidth-sdk/models/bxml/verbs/bridge.rb new file mode 100644 index 00000000..e456404e --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/bridge.rb @@ -0,0 +1,28 @@ +module Bandwidth + module Bxml + class Bridge < Bandwidth::Bxml::Verb + # Initializer + # @param target_call [String] The callId of the call to be bridged. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(target_call, attributes = {}) + super('Bridge', target_call, attributes) + + @attribute_map = { + bridge_complete_url: 'bridgeCompleteUrl', # Optional [String]: URL to send the Bridge Complete event to and request new BXML. If this attribute is specified, then Verbs following the verb will be ignored and the BXML returned in this webhook is executed on the call. If this attribute is not specified then no webhook will be sent, and execution of the verbs following the verb continues. May be a relative URL. Defaults to None. + bridge_complete_method: 'bridgeCompleteMethod', # Optional [String]: The HTTP method to use for the request to bridgeCompleteUrl. GET or POST. Default value is POST. + bridge_complete_fallback_url: 'bridgeCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Bridge Complete webhook delivery in case bridgeCompleteUrl fails to respond. Defaults to None. + bridge_complete_fallback_method: 'bridgeCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Bridge Complete webhook to bridgeCompleteFallbackUrl. GET or POST. Default value is POST. + bridge_target_complete_url: 'bridgeTargetCompleteUrl', # Optional [String]: URL to send the Bridge Target Complete event to and request new BXML. If this attribute is specified, then the BXML returned in this webhook is executed on the target call. If this attribute is not specified then no webhook will be sent, and the target call will be hung up. May be a relative URL. Defaults to None. + bridge_target_complete_method: 'bridgeTargetCompleteMethod', # Optional [String]: The HTTP method to use for the request to bridgeTargetCompleteUrl. GET or POST. Default value is POST. + bridge_target_complete_fallback_url: 'bridgeTargetCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Bridge Target Complete webhook delivery in case bridgeTargetCompleteUrl fails to respond. Defaults to None. + bridge_target_complete_fallback_method: 'bridgeTargetCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Bridge Target Complete webhook to bridgeTargetCompleteFallbackUrl. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to bridgeCompleteUrl and to bridgeTargetCompleteUrl. Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to bridgeCompleteFallbackUrl and to bridgeTargetCompleteFallbackUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with the bridgeComplete webhook and all future webhooks of the call unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/conference.rb b/lib/bandwidth-sdk/models/bxml/verbs/conference.rb new file mode 100644 index 00000000..3f38c91a --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/conference.rb @@ -0,0 +1,28 @@ +module Bandwidth + module Bxml + class Conference < Bandwidth::Bxml::Verb + # Initializer + # @param name [String] The name of the conference. Can contain up to 100 characters of letters, numbers, and the symbols -, _, and . + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(name, attributes = {}) + super('Conference', name, attributes) + + @attribute_map = { + mute: 'mute', # Optional [Boolean]: A boolean value to indicate whether the member should be on mute in the conference. When muted, a member can hear others speak, but others cannot hear them speak. Defaults to false. + hold: 'hold', # Optional [Boolean]: A boolean value to indicate whether the member should be on hold in the conference. When on hold, a member cannot hear others, and they cannot be heard. Defaults to false. + call_ids_to_coach: 'callIdsToCoach', # Optional [String]: A comma-separated list of call ids to coach. When a call joins a conference with this attribute set, it will coach the listed calls. Those calls will be able to hear and be heard by the coach, but other calls in the conference will not hear the coach. + conference_event_url: 'conferenceEventUrl', # Optional [String]: URL to send Conference events to. The URL, method, username, and password are set by the BXML document that creates the conference, and all events related to that conference will be delivered to that same endpoint. If more calls join afterwards and also have this property (or any other webhook related properties like username and password), they will be ignored and the original webhook information will be used. This URL may be a relative endpoint. + conference_event_method: 'conferenceEventMethod', # Optional [String]: The HTTP method to use for the request to conferenceEventUrl. GET or POST. Default value is POST. + conference_event_fallback_url: 'conferenceEventFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the conference webhook deliveries in case conferenceEventUrl fails to respond. + conference_event_fallback_method: 'conferenceEventFallbackMethod', # Optional [String]: The HTTP method to use to deliver the conference webhooks to conferenceEventFallbackUrl. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to conferenceEventUrl. + password: 'password', # Optional [String]: The password to send in the HTTP request to conferenceEventUrl. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to conferenceEventFallbackUrl. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to conferenceEventFallbackUrl. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. + callback_timeout: 'callbackTimeout', # Optional [Number]: This is the timeout (in seconds) to use when delivering webhooks for the conference. If not set, it will inherit the webhook timeout from the call that creates the conference. Can be any numeric value (including decimals) between 1 and 25. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb b/lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb new file mode 100644 index 00000000..caee962f --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/custom_param.rb @@ -0,0 +1,16 @@ +module Bandwidth + module Bxml + class CustomParam < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('CustomParam', nil, attributes) + + @attribute_map = { + name: 'name', # [String]: The name of this parameter, up to 256 characters. + value: 'value', # [String]: The value of this parameter, up to 2048 characters. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/forward.rb b/lib/bandwidth-sdk/models/bxml/verbs/forward.rb new file mode 100644 index 00000000..5f63110f --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/forward.rb @@ -0,0 +1,20 @@ +module Bandwidth + module Bxml + class Forward < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('Forward', nil, attributes) + + @attribute_map = { + to: 'to', # [String]: The phone number destination of the call. + from: 'from', # Optional [String]: The phone number that the recipient will receive the call from. + call_timeout: 'callTimeout', # Optional [Number]: The number of seconds to wait before timing out the call. + diversion_treatment: 'diversionTreatment', # Optional [String]: Can be any of the following: - none: No diversion headers are sent on the outbound leg of the transferred call. - propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. - stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None. + diversion_reason: 'diversionReason', # Optional [String]: Can be any of the following values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. This parameter is considered only when diversionTreatment is set to stack. Defaults to None. + uui: 'uui', # Optional [String]: The value of the User-To-User header to send within the outbound INVITE when forwarding to a SIP URI. Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/gather.rb b/lib/bandwidth-sdk/models/bxml/verbs/gather.rb new file mode 100644 index 00000000..4fc76458 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/gather.rb @@ -0,0 +1,42 @@ +module Bandwidth + module Bxml + class Gather < Bandwidth::Bxml::NestableVerb + # Initializer + # @param audio_verbs [Array] XML element children. Defaults to an empty array. Valid nested audio verbs are: SpeakSentence, PlayAudio. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(audio_verbs = [], attributes = {}) + super('Gather', nil, audio_verbs, attributes) + + @attribute_map = { + gather_url: 'gatherUrl', # Optional [String]: URL to send Gather event to and request new BXML. May be a relative URL. + gather_method: 'gatherMethod', # Optional [String]: The HTTP method to use for the request to gather_url. GET or POST. Default value is POST. + gather_fallback_url: 'gatherFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Gather event callback delivery in case gather_url fails to respond. + gather_fallback_method: 'gatherFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Gather event callback to gather_fallback_url. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to gather_url. + password: 'password', # Optional [String]: The password to send in the HTTP request to gather_url. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to gather_fallback_url. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to gather_fallback_url. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. + terminating_digits: 'terminatingDigits', # Optional [String]: When any of these digits are pressed, it will terminate the Gather. Default value is "", which disables this feature. + max_digits: 'maxDigits', # Optional [Number]: Max number of digits to collect. Default value is 50. Range: decimal values between 1 - 50. + inter_digit_timeout: 'interDigitTimeout', # Optional [Number]: Time (in seconds) allowed between digit presses before automatically terminating the Gather. Default value is 5. Range: decimal values between 1 - 60. + first_digit_timeout: 'firstDigitTimeout', # Optional [Number]: Time (in seconds) to pause after any audio from nested or verb is played (in seconds) before terminating the Gather. Default value is 5. Range: decimal values between 0 - 60. + repeat_count: 'repeat_count', # Optional [Number]: The number of times the audio prompt should be played if no digits are pressed. For example, if this value is 3, the nested audio clip will be played a maximum of three times. The delay between repetitions will be equal to first_digit_timeout. Default value is 1. repeat_count * number of verbs must not be greater than 20. + } + end + + # Return BXML representaion of this response + # @return [String] The XML response in string format. + def to_bxml + bxml = Ox.dump(generate_xml) + bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') } + end + + # Add audio verb/s to the nested verbs array + # @param audio_verbs [SpeakSentence] || [PlayAudio] or [Array] Verb or verbs to add to the array. + def add_audio_verb(audio_verbs) + @nested_verbs.push(*audio_verbs) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/hangup.rb b/lib/bandwidth-sdk/models/bxml/verbs/hangup.rb new file mode 100644 index 00000000..51d50565 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/hangup.rb @@ -0,0 +1,10 @@ +module Bandwidth + module Bxml + class Hangup < Bandwidth::Bxml::Verb + # Initializer + def initialize + super('Hangup', nil, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/pause.rb b/lib/bandwidth-sdk/models/bxml/verbs/pause.rb new file mode 100644 index 00000000..d41a513d --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/pause.rb @@ -0,0 +1,15 @@ +module Bandwidth + module Bxml + class Pause < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('Pause', nil, attributes) + + @attribute_map = { + duration: 'duration', # Optional [Number]: The time in seconds to pause. Default value is 1. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb b/lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb new file mode 100644 index 00000000..a0e52c2a --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/pause_recording.rb @@ -0,0 +1,10 @@ +module Bandwidth + module Bxml + class PauseRecording < Bandwidth::Bxml::Verb + # Initializer + def initialize + super('PauseRecording', nil, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb b/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb new file mode 100644 index 00000000..db47f2c9 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/phone_number.rb @@ -0,0 +1,26 @@ +module Bandwidth + module Bxml + class PhoneNumber < Bandwidth::Bxml::Verb + # Initializer + # @param number [String] A phone number to transfer the call to. Value must be in E.164 format (e.g. +15555555555). + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(number, attributes = {}) + super('PhoneNumber', number, attributes) + + @attribute_map = { + transfer_answer_url: 'transferAnswerUrl', # Optional [String]: URL, if any, to send the Transfer Answer event to and request BXML to be executed for the called party before the call is bridged. May be a relative URL. Defaults to None. + transfer_answer_method: 'transferAnswerMethod', # Optional [String]: The HTTP method to use for the request to transferAnswerUrl. GET or POST. Default value is POST. Defaults to None. + transfer_answer_fallback_url: 'transferAnswerFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Answer callback delivery in case transferAnswerUrl fails to respond. Defaults to None. + transfer_answer_fallback_method: 'transferAnswerFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Answer callback to transferAnswerFallbackUrl. GET or POST. Default value is POST. Defaults to None. + transfer_disconnect_url: 'transferDisconnectUrl', # Optional [String]: URL, if any, to send the Transfer Disconnect event to. This event will be sent regardless of how the transfer ends and may not be responded to with BXML. May be a relative URL. Defaults to None. + transfer_disconnect_method: 'transferDisconnectMethod', # Optional [String]: The HTTP method to use for the request to transferDisconnectUrl. GET or POST. Default value is POST. Defaults to Defaults to Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb b/lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb new file mode 100644 index 00000000..d178400b --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/play_audio.rb @@ -0,0 +1,17 @@ +module Bandwidth + module Bxml + class PlayAudio < Bandwidth::Bxml::Verb + # Initializer + # @param audio_uri [String] The URL of the audio file to play. May be a relative URL. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(audio_uri, attributes = {}) + super('PlayAudio', audio_uri, attributes) + + @attribute_map = { + username: 'username', # Optional [String]: The username to send in the HTTP request to audio_uri. + password: 'password', # Optional [String]: The password to send in the HTTP request to audio_uri. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/record.rb b/lib/bandwidth-sdk/models/bxml/verbs/record.rb new file mode 100644 index 00000000..c3bbb728 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/record.rb @@ -0,0 +1,32 @@ +module Bandwidth + module Bxml + class Record < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('Record', nil, attributes) + + @attribute_map = { + record_complete_url: 'recordCompleteUrl', # Optional [String]: URL to send the Record Complete event to once the recording has ended. Accepts BXML, and may be a relative URL. This callback will not be sent if the recording ended due to the call hanging up. Defaults to None. + record_complete_method: 'recordCompleteMethod', # Optional [String]: The HTTP method to use for the request to recordCompleteUrl. GET or POST. Default value is POST. Defaults to None. + record_complete_fallback_url: 'recordCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Record Complete callback delivery in case recordCompleteUrl fails to respond. Defaults to None. + record_complete_fallback_method: 'recordCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Record Complete callback to recordCompleteFallbackUrl. GET or POST. Default value is POST. Defaults to None. + recording_available_url: 'recordingAvailableUrl', # Optional [String]: URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None. + recording_available_method: 'recordingAvailableMethod', # Optional [String]: The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST. Defaults to None. + transcribe: 'transcribe', # Optional [Boolean]: A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None. + transcription_available_url: 'transcriptionAvailableUrl', # Optional [String]: URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None. + transcription_available_method: 'transcriptionAvailableMethod', # Optional [String]: The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to recordCompleteUrl, recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to recordCompleteFallbackUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to recordCompleteFallbackUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. + terminating_digits: 'terminatingDigits', # Optional [String]: When pressed, this digit will terminate the recording. Default value is “#”. This feature can be disabled with "". Defaults to None. + max_duration: 'maxDuration', # Optional [Number]: Maximum length of recording (in seconds). Max 10800 (3 hours). Default value is 60. Defaults to None. + silence_timeout: 'silenceTimeout', # Optional [Number]: Length of silence after which to end the recording (in seconds). Max is equivalent to the maximum maxDuration value. Default value is 0, which means no timeout. Defaults to None. + file_format: 'fileFormat', # Optional [String]: The audio format that the recording will be saved as: mp3 or wav. Default value is wav. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/redirect.rb b/lib/bandwidth-sdk/models/bxml/verbs/redirect.rb new file mode 100644 index 00000000..5b65fdbc --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/redirect.rb @@ -0,0 +1,23 @@ +module Bandwidth + module Bxml + class Redirect < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('Redirect', nil, attributes) + + @attribute_map = { + redirect_url: 'redirectUrl', # [String]: URL to request new BXML from. A Redirect event will be sent to this endpoint. May be a relative URL. Defaults to None. + redirect_method: 'redirectMethod', # Optional [String]: The HTTP method to use for the request to redirectUrl. GET or POST. Defaults to None. + redirect_fallback_url: 'redirectFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Redirect callback delivery in case redirectUrl fails to respond. Defaults to None. + redirect_fallback_method: 'redirectFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Redirect callback to redirectFallbackUrl. GET or POST. Default value is POST. Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to redirectUrl. Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to redirectUrl. Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to redirectFallbackUrl. Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to redirectFallbackUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb b/lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb new file mode 100644 index 00000000..05eed0fc --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/resume_recording.rb @@ -0,0 +1,10 @@ +module Bandwidth + module Bxml + class ResumeRecording < Bandwidth::Bxml::Verb + # Initializer + def initialize + super('ResumeRecording', nil, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/ring.rb b/lib/bandwidth-sdk/models/bxml/verbs/ring.rb new file mode 100644 index 00000000..67f91ea3 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/ring.rb @@ -0,0 +1,16 @@ +module Bandwidth + module Bxml + class Ring < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('Ring', nil, attributes) + + @attribute_map = { + duration: 'duration', # Optional [Number]: How many seconds to play ringing on the call. Default value is 5. Range: decimal values between 0.1 - 86400. + answer_call: 'answerCall', # Optional [Boolean]: A boolean indicating whether or not to answer the call when Ring is executed on an unanswered incoming call. Default value is 'true'. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb b/lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb new file mode 100644 index 00000000..f0e84390 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/send_dtmf.rb @@ -0,0 +1,17 @@ +module Bandwidth + module Bxml + class SendDtmf < Bandwidth::Bxml::Verb + # Initializer + # @param digits [String] String containing the DTMF characters to be sent in a call. Allows a maximum of 50 characters. The digits will be sent one-by-one with a marginal delay. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(digits, attributes = {}) + super('SendDtmf', digits, attributes) + + @attribute_map = { + tone_duration: 'toneDuration', # Optional [Number]: The length (in milliseconds) of each DTMF tone. Default value is 200. Range: decimal values between 50 - 5000. + tone_interval: 'toneInterval', # Optional [Number]: The duration of silence (in milliseconds) following each DTMF tone. Default value is 400. Range: decimal values between 50 - 5000. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb b/lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb new file mode 100644 index 00000000..6f123a91 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/sip_uri.rb @@ -0,0 +1,27 @@ +module Bandwidth + module Bxml + class SipUri < Bandwidth::Bxml::Verb + # Initializer + # @param uri [String] A SIP URI to transfer the call to (e.g. sip:user@server.com) + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(uri, attributes = {}) + super('SipUri', uri, attributes) + + @attribute_map = { + uui: 'uui', # Optional [String]: The value of the User-To-User header to send within the initial INVITE. Must include the encoding parameter as specified in RFC 7433. Only base64 and jwt encoding are currently allowed. This value, including the encoding specifier, may not exceed 256 characters. Defaults to None. + transfer_answer_url: 'transferAnswerUrl', # Optional [String]: URL, if any, to send the Transfer Answer event to and request BXML to be executed for the called party before the call is bridged. May be a relative URL. Defaults to None. + transfer_answer_method: 'transferAnswerMethod', # Optional [String]: The HTTP method to use for the request to transferAnswerUrl. GET or POST. Default value is POST. Defaults to None. + transfer_answer_fallback_url: 'transferAnswerFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Answer callback delivery in case transferAnswerUrl fails to respond. Defaults to None. + transfer_answer_fallback_method: 'transferAnswerFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Answer callback to transferAnswerFallbackUrl. GET or POST. Default value is POST. Defaults to None. + transfer_disconnect_url: 'transferDisconnectUrl', # Optional [String]: URL, if any, to send the Transfer Disconnect event to. This event will be sent regardless of how the transfer ends and may not be responded to with BXML. May be a relative URL. Defaults to None. + transfer_disconnect_method: 'transferDisconnectMethod', # Optional [String]: The HTTP method to use for the request to transferDisconnectUrl. GET or POST. Default value is POST. Defaults to Defaults to Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to transferAnswerUrl and transferDisconnectUrl. Defaults to Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferAnswerFallbackUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb b/lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb new file mode 100644 index 00000000..ff3982ef --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/speak_sentence.rb @@ -0,0 +1,25 @@ +module Bandwidth + module Bxml + class SpeakSentence < Bandwidth::Bxml::Verb + # Initializer + # @param text [String] The text to speak. Cannot be blank. Can be a mixture of plain text and SSML tags. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(text, attributes = {}) + super('SpeakSentence', text, attributes) + + @attribute_map = { + voice: 'voice', # Optional [String]: Selects the voice of the speaker. If the voice attribute is present, gender and locale are ignored. You can find a list of supported voices here: https://dev.bandwidth.com/docs/voice/bxml/speakSentence/#supported-voices + gender: 'gender', # Optional [String]: Selects the gender of the speaker. Valid values are "male" or "female". Default "female". + locale: 'locale', # Optional [String]: Selects the locale of the speaker. Default "en_US" + } + end + + # Return BXML representaion of this response + # @return [String] The XML response in string format. + def to_bxml + bxml = Ox.dump(generate_xml) + bxml.gsub(SPEAK_SENTENCE_REGEX) { |text| text.gsub(SSML_REGEX, '<\1>') } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb b/lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb new file mode 100644 index 00000000..26644574 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/start_gather.rb @@ -0,0 +1,19 @@ +module Bandwidth + module Bxml + class StartGather < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('StartGather', nil, attributes) + + @attribute_map = { + dtmf_url: 'dtmfUrl', # [String]: URL to send the DTMF event to. May be a relative URL. + dtmf_method: 'dtmfMethod', # Optional [String]: The HTTP method to use for the request to dtmfUrl. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to dtmfUrl. Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to dtmfUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb b/lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb new file mode 100644 index 00000000..0db4f0c0 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/start_recording.rb @@ -0,0 +1,24 @@ +module Bandwidth + module Bxml + class StartRecording < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('StartRecording', nil, attributes) + + @attribute_map = { + recording_available_url: 'recordingAvailableUrl', # Optional [String]: URL to send the Recording Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None. + recording_available_method: 'recordingAvailableMethod', # Optional [String]: The HTTP method to use for the request to recordingAvailableUrl. GET or POST. Default value is POST. + transcribe: 'transcribe', # Optional [Boolean]: A boolean value to indicate that recording should be transcribed. Transcription can succeed only for recordings of length greater than 500 milliseconds and less than 4 hours. Default is false. Defaults to None. + transcription_available_url: 'transcriptionAvailableUrl', # Optional [String]: URL to send the Transcription Available event to once it has been processed. Does not accept BXML. May be a relative URL. Defaults to None. + transcription_available_method: 'transcriptionAvailableMethod', # Optional [String]: The HTTP method to use for the request to transcriptionAvailableUrl. GET or POST. Default value is POST. Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to recordingAvailableUrl or transcriptionAvailableUrl. If specified, the URLs must be TLS-encrypted (i.e., https). Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or verb, or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. + file_format: 'fileFormat', # Optional [String]: The audio format that the recording will be saved as: mp3 or wav. Default value is wav. + multi_channel: 'multiChannel', # Optional [Boolean]: A boolean value indicating whether or not the recording file should separate each side of the call into its own audio channel. Default value is false. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb b/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb new file mode 100644 index 00000000..95b444a8 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/start_stream.rb @@ -0,0 +1,28 @@ +module Bandwidth + module Bxml + class StartStream < Bandwidth::Bxml::NestableVerb + # Initializer + # @param stream_params [Array] XML element children. Defaults to an empty array. Valid nested stream params are: StreamParam. You may specify up to 12 elements nested within a tag. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(stream_params = [], attributes = {}) + super('StartStream', nil, stream_params, attributes) + + @attribute_map = { + name: 'name', # Optional [String]: A name to refer to this stream by. Used when sending . If not provided, it will default to the generated stream id as sent in the Media Stream Started webhook. + tracks: 'tracks', # Optional [String]: The part of the call to send a stream from. inbound, outbound or both. Default is inbound. + destination: 'destination', # Optional [String]: A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL as base64-encoded PCMU/G711 audio. + stream_event_url: 'streamEventUrl', # Optional [String]: URL to send the associated Webhook events to during this stream's lifetime. Does not accept BXML. May be a relative URL. + stream_event_method: 'streamEventMethod', # Optional [String]: The HTTP method to use for the request to streamEventUrl. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). + password: 'password', # Optional [String]: The password to send in the HTTP request to streamEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). + } + end + + # Add stream param/s to the nested verbs array + # @param stream_params [StreamParam] or [Array] Verb or verbs to add to the array. + def add_stream_param(stream_params) + @nested_verbs.push(*stream_params) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb b/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb new file mode 100644 index 00000000..e7661532 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/start_transcription.rb @@ -0,0 +1,29 @@ +module Bandwidth + module Bxml + class StartTranscription < Bandwidth::Bxml::NestableVerb + # Initializer + # @param custom_params [Array] XML element children. Defaults to an empty array. Valid nested custom params are: CustomParam. You may specify up to 12 elements nested within a tag. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(custom_params = [], attributes = {}) + super('StartTranscription', nil, custom_params, attributes) + + @attribute_map = { + name: 'name', # Optional [String]: A name to refer to this transcription by. Used when sending . If not provided, it will default to the generated transcription id as sent in the Real-Time Transcription Started webhook. + tracks: 'tracks', # Optional [String]: The part of the call to send a transcription from. inbound, outbound or both. Default is inbound. + transcription_event_url: 'transcriptionEventUrl', # Optional [String]: URL to send the associated Webhook events to during this real-time transcription's lifetime. Does not accept BXML. May be a relative URL. + transcription_event_method: 'transcriptionEventMethod', # Optional [String]: The HTTP method to use for the request to transcriptionEventUrl. GET or POST. Default value is POST. + username: 'username', # Optional [String]: The username to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https). + password: 'password', # Optional [String]: The password to send in the HTTP request to transcriptionEventUrl. If specified, the transcriptionEventUrl must be TLS-encrypted (i.e., https). + destination: 'destination', # Optional [String]: A websocket URI to send the transcription to. A transcription of the specified tracks will be sent via websocket to this URL as a series of JSON messages. See below for more details on the websocket packet format. + stabilized: 'stabilized', # Optional [Boolean]: Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true. + } + end + + # Add custom param/s to the nested verbs array + # @param custom_params [CustomParam] or [Array] Verb or verbs to add to the array. + def add_custom_param(custom_params) + @nested_verbs.push(*custom_params) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb b/lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb new file mode 100644 index 00000000..1377846a --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/stop_gather.rb @@ -0,0 +1,10 @@ +module Bandwidth + module Bxml + class StopGather < Bandwidth::Bxml::Verb + # Initializer + def initialize + super('StopGather', nil, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb b/lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb new file mode 100644 index 00000000..dfb690ac --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/stop_recording.rb @@ -0,0 +1,10 @@ +module Bandwidth + module Bxml + class StopRecording < Bandwidth::Bxml::Verb + # Initializer + def initialize + super('StopRecording', nil, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb b/lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb new file mode 100644 index 00000000..770420ad --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/stop_stream.rb @@ -0,0 +1,15 @@ +module Bandwidth + module Bxml + class StopStream < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('StopStream', nil, attributes) + + @attribute_map = { + name: 'name' # [String]: The name of the stream to stop. This is either the user selected name when sending the verb, or the system generated name returned in the Media Stream Started webhook if was sent with no name attribute. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb b/lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb new file mode 100644 index 00000000..59bdc4f0 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/stop_transcription.rb @@ -0,0 +1,15 @@ +module Bandwidth + module Bxml + class StopTranscription < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('StopTranscription', nil, attributes) + + @attribute_map = { + name: 'name' # [String]: The name of the real-time transcription to stop. This is either the user selected name when sending the verb, or the system generated name returned in the Real-Time Transcription Started webhook if was sent with no name attribute. If no name is specified, then all active call transcriptions will be stopped. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb b/lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb new file mode 100644 index 00000000..5aa0bb0d --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/stream_param.rb @@ -0,0 +1,16 @@ +module Bandwidth + module Bxml + class StreamParam < Bandwidth::Bxml::Verb + # Initializer + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(attributes = {}) + super('StreamParam', nil, attributes) + + @attribute_map = { + name: 'name', # [String]: The name of this parameter, up to 256 characters. + value: 'value', # [String]: The value of this parameter, up to 2048 characters. + } + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/tag.rb b/lib/bandwidth-sdk/models/bxml/verbs/tag.rb new file mode 100644 index 00000000..ec6ca9d0 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/tag.rb @@ -0,0 +1,11 @@ +module Bandwidth + module Bxml + class Tag < Bandwidth::Bxml::Verb + # Initializer + # @param content [String] Custom tag value. Defaults to nil. + def initialize(content = nil) + super('Tag', content, {}) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb b/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb new file mode 100644 index 00000000..ed913dd8 --- /dev/null +++ b/lib/bandwidth-sdk/models/bxml/verbs/transfer.rb @@ -0,0 +1,34 @@ +module Bandwidth + module Bxml + class Transfer < Bandwidth::Bxml::NestableVerb + # Initializer + # @param transfer_to [Array] XML element children. Defaults to an empty array. Valid nested transfer verbs are: PhoneNumber, SipUri. + # @param attributes [Hash] The attributes to add to the element. Defaults to an empty hash. + def initialize(transfer_to = [], attributes = {}) + super('Transfer', nil, transfer_to, attributes) + + @attribute_map = { + transfer_caller_id: 'transferCallerId', # Optional [String]: The caller ID to use when the call is transferred, if different. Must be in E.164 format (e.g. +15555555555) or be one of the following strings Restricted, Anonymous, Private, or Unavailable. Leave as default to pass along the number of the remote party. Defaults to None. + call_timeout: 'callTimeout', # Optional [Number]:The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Range: decimal values between 1 - 300. Default value is 30 seconds. Defaults to None. + transfer_complete_url: 'transferCompleteUrl', # Optional [String]: URL to send the Transfer Complete event to and request new BXML. Optional but recommended. See below for further details. May be a relative URL. Defaults to None. + transfer_complete_method: 'transferCompleteMethod', # Optional [String]: The HTTP method to use for the request to transferCompleteUrl. GET or POST. Default value is POST. Defaults to None. + transfer_complete_fallback_url: 'transferCompleteFallbackUrl', # Optional [String]: A fallback url which, if provided, will be used to retry the Transfer Complete callback delivery in case transferCompleteUrl fails to respond. Defaults to None. + transfer_complete_fallback_method: 'transferCompleteFallbackMethod', # Optional [String]: The HTTP method to use to deliver the Transfer Complete callback to transferCompleteFallbackUrl. GET or POST. Default value is POST. Defaults to None. + username: 'username', # Optional [String]: The username to send in the HTTP request to transferCompleteUrl. Defaults to None. + password: 'password', # Optional [String]: The password to send in the HTTP request to transferCompleteUrl. Defaults to None. + fallback_username: 'fallbackUsername', # Optional [String]: The username to send in the HTTP request to transferCompleteFallbackUrl. Defaults to None. + fallback_password: 'fallbackPassword', # Optional [String]: The password to send in the HTTP request to transferCompleteFallbackUrl. Defaults to None. + tag: 'tag', # Optional [String]: A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None. + diversion_treatment: 'diversionTreatment', # Optional [String]: Can be any of the following: - none: No diversion headers are sent on the outbound leg of the transferred call. - propagate: Copy the Diversion header from the inbound leg to the outbound leg. Ignored if there is no Diversion header present on the inbound leg. - stack: After propagating any Diversion header from the inbound leg to the outbound leg, stack on top another Diversion header based on the Request-URI of the inbound call. If diversionTreatment is not specified, no diversion header will be included for the transfer even if one came with the inbound call. Defaults to None. + diversion_reason: 'diversionReason', # Optional [String]: Can be any of the following values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. This parameter is considered only when diversionTreatment is set to stack. Defaults to None. + } + end + + # Add transfer recipient/s to the nested verbs array + # @param recipients [PhoneNumber] || [SipUri] or [Array] Verb or verbs to add to the array. + def add_transfer_recipient(recipients) + @nested_verbs.push(*recipients) + end + end + end +end diff --git a/lib/bandwidth-sdk/models/call_direction_enum.rb b/lib/bandwidth-sdk/models/call_direction_enum.rb new file mode 100644 index 00000000..3208d340 --- /dev/null +++ b/lib/bandwidth-sdk/models/call_direction_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CallDirectionEnum + INBOUND = 'inbound'.freeze + OUTBOUND = 'outbound'.freeze + + def self.all_vars + @all_vars ||= [INBOUND, OUTBOUND].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CallDirectionEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CallDirectionEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/call_recording_metadata.rb b/lib/bandwidth-sdk/models/call_recording_metadata.rb new file mode 100644 index 00000000..b475737a --- /dev/null +++ b/lib/bandwidth-sdk/models/call_recording_metadata.rb @@ -0,0 +1,404 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CallRecordingMetadata + # The id of the application associated with the call. + attr_accessor :application_id + + # The user account associated with the call. + attr_accessor :account_id + + # The call id associated with the event. + attr_accessor :call_id + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # The unique ID of this recording + attr_accessor :recording_id + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + attr_accessor :direction + + # Always `1` for conference recordings; multi-channel recordings are not supported on conferences. + attr_accessor :channels + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + attr_accessor :file_format + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :status + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + attr_accessor :transcription + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'application_id' => :'applicationId', + :'account_id' => :'accountId', + :'call_id' => :'callId', + :'parent_call_id' => :'parentCallId', + :'recording_id' => :'recordingId', + :'to' => :'to', + :'from' => :'from', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo', + :'duration' => :'duration', + :'direction' => :'direction', + :'channels' => :'channels', + :'start_time' => :'startTime', + :'end_time' => :'endTime', + :'file_format' => :'fileFormat', + :'status' => :'status', + :'media_url' => :'mediaUrl', + :'transcription' => :'transcription' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'application_id' => :'String', + :'account_id' => :'String', + :'call_id' => :'String', + :'parent_call_id' => :'String', + :'recording_id' => :'String', + :'to' => :'String', + :'from' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String', + :'duration' => :'String', + :'direction' => :'CallDirectionEnum', + :'channels' => :'Integer', + :'start_time' => :'Time', + :'end_time' => :'Time', + :'file_format' => :'FileFormatEnum', + :'status' => :'String', + :'media_url' => :'String', + :'transcription' => :'TranscriptionMetadata' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url', + :'transcription' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallRecordingMetadata` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallRecordingMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'channels') + self.channels = attributes[:'channels'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + + if attributes.key?(:'transcription') + self.transcription = attributes[:'transcription'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + application_id == o.application_id && + account_id == o.account_id && + call_id == o.call_id && + parent_call_id == o.parent_call_id && + recording_id == o.recording_id && + to == o.to && + from == o.from && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to && + duration == o.duration && + direction == o.direction && + channels == o.channels && + start_time == o.start_time && + end_time == o.end_time && + file_format == o.file_format && + status == o.status && + media_url == o.media_url && + transcription == o.transcription + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [application_id, account_id, call_id, parent_call_id, recording_id, to, from, transfer_caller_id, transfer_to, duration, direction, channels, start_time, end_time, file_format, status, media_url, transcription].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/call_state.rb b/lib/bandwidth-sdk/models/call_state.rb new file mode 100644 index 00000000..e5e735cc --- /dev/null +++ b/lib/bandwidth-sdk/models/call_state.rb @@ -0,0 +1,416 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CallState + # The application id associated with the call. + attr_accessor :application_id + + # The account id associated with the call. + attr_accessor :account_id + + # The programmable voice API call ID. + attr_accessor :call_id + + # The A-leg call id, set only if this call is the B-leg of a [``](/docs/voice/bxml/transfer). + attr_accessor :parent_call_id + + # The phone number that received the call, in E.164 format (e.g. +15555555555), or if the call was to a SIP URI, the SIP URI. + attr_accessor :to + + # The phone number that made the call, in E.164 format (e.g. +15555555555). + attr_accessor :from + + attr_accessor :direction + + # The current state of the call. Current possible values are `queued`, `initiated`, `answered` and `disconnected`. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :state + + # For inbound calls, the Bandwidth STIR/SHAKEN implementation will verify the information provided in the inbound invite request `Identity` header. The verification status is stored in the call state `stirShaken` property as follows. | Property | Description | |:------------------|:------------| | verstat | (optional) The verification status indicating whether the verification was successful or not. Possible values are `TN-Verification-Passed` or `TN-Verification-Failed`. | | attestationIndicator | (optional) The attestation level verified by Bandwidth. Possible values are `A` (full), `B` (partial) or `C` (gateway). | | originatingId | (optional) A unique origination identifier. | Note that these are common properties but that the `stirShaken` object is free form and can contain other key-value pairs. More information: [Understanding STIR/SHAKEN](https://www.bandwidth.com/regulations/stir-shaken). + attr_accessor :stir_shaken + + # The value of the `Identity` header from the inbound invite request. Only present for inbound calls and if the account is configured to forward this header. + attr_accessor :identity + + # The time this call was placed in queue. + attr_accessor :enqueued_time + + # The time the call was initiated, in ISO 8601 format. `null` if the call is still in your queue. + attr_accessor :start_time + + # Populated once the call has been answered, with the time in ISO 8601 format. + attr_accessor :answer_time + + # Populated once the call has ended, with the time in ISO 8601 format. + attr_accessor :end_time + + # | Cause | Description | |:------|:------------| | `hangup`| One party hung up the call, a [``](../../bxml/verbs/hangup.md) verb was executed, or there was no more BXML to execute; it indicates that the call ended normally. | | `busy` | Callee was busy. | | `timeout` | Call wasn't answered before the `callTimeout` was reached. | | `cancel` | Call was cancelled by its originator while it was ringing. | | `rejected` | Call was rejected by the callee. | | `callback-error` | BXML callback couldn't be delivered to your callback server. | | `invalid-bxml` | Invalid BXML was returned in response to a callback. | | `application-error` | An unsupported action was tried on the call, e.g. trying to play a .ogg audio. | | `account-limit` | Account rate limits were reached. | | `node-capacity-exceeded` | System maximum capacity was reached. | | `error` | Some error not described in any of the other causes happened on the call. | | `unknown` | Unknown error happened on the call. | Note: This list is not exhaustive and other values can appear in the future. + attr_accessor :disconnect_cause + + # Populated only if the call ended with an error, with text explaining the reason. + attr_accessor :error_message + + # Populated only if the call ended with an error, with a Bandwidth internal id that references the error event. + attr_accessor :error_id + + # The last time the call had a state update, in ISO 8601 format. + attr_accessor :last_update + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'application_id' => :'applicationId', + :'account_id' => :'accountId', + :'call_id' => :'callId', + :'parent_call_id' => :'parentCallId', + :'to' => :'to', + :'from' => :'from', + :'direction' => :'direction', + :'state' => :'state', + :'stir_shaken' => :'stirShaken', + :'identity' => :'identity', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'end_time' => :'endTime', + :'disconnect_cause' => :'disconnectCause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId', + :'last_update' => :'lastUpdate' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'application_id' => :'String', + :'account_id' => :'String', + :'call_id' => :'String', + :'parent_call_id' => :'String', + :'to' => :'String', + :'from' => :'String', + :'direction' => :'CallDirectionEnum', + :'state' => :'String', + :'stir_shaken' => :'Hash', + :'identity' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'end_time' => :'Time', + :'disconnect_cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String', + :'last_update' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'parent_call_id', + :'stir_shaken', + :'identity', + :'enqueued_time', + :'start_time', + :'answer_time', + :'end_time', + :'disconnect_cause', + :'error_message', + :'error_id', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CallState` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CallState`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'state') + self.state = attributes[:'state'] + end + + if attributes.key?(:'stir_shaken') + if (value = attributes[:'stir_shaken']).is_a?(Hash) + self.stir_shaken = value + end + end + + if attributes.key?(:'identity') + self.identity = attributes[:'identity'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'disconnect_cause') + self.disconnect_cause = attributes[:'disconnect_cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + + if attributes.key?(:'last_update') + self.last_update = attributes[:'last_update'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + application_id == o.application_id && + account_id == o.account_id && + call_id == o.call_id && + parent_call_id == o.parent_call_id && + to == o.to && + from == o.from && + direction == o.direction && + state == o.state && + stir_shaken == o.stir_shaken && + identity == o.identity && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + end_time == o.end_time && + disconnect_cause == o.disconnect_cause && + error_message == o.error_message && + error_id == o.error_id && + last_update == o.last_update + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [application_id, account_id, call_id, parent_call_id, to, from, direction, state, stir_shaken, identity, enqueued_time, start_time, answer_time, end_time, disconnect_cause, error_message, error_id, last_update].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/call_state_enum.rb b/lib/bandwidth-sdk/models/call_state_enum.rb new file mode 100644 index 00000000..16f757f5 --- /dev/null +++ b/lib/bandwidth-sdk/models/call_state_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CallStateEnum + ACTIVE = 'active'.freeze + COMPLETED = 'completed'.freeze + + def self.all_vars + @all_vars ||= [ACTIVE, COMPLETED].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CallStateEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CallStateEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/callback_method_enum.rb b/lib/bandwidth-sdk/models/callback_method_enum.rb new file mode 100644 index 00000000..9face145 --- /dev/null +++ b/lib/bandwidth-sdk/models/callback_method_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CallbackMethodEnum + GET = 'GET'.freeze + POST = 'POST'.freeze + + def self.all_vars + @all_vars ||= [GET, POST].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CallbackMethodEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CallbackMethodEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/code_request.rb b/lib/bandwidth-sdk/models/code_request.rb new file mode 100644 index 00000000..c6501549 --- /dev/null +++ b/lib/bandwidth-sdk/models/code_request.rb @@ -0,0 +1,434 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CodeRequest + # The phone number to send the mfa code to. + attr_accessor :to + + # The application phone number, the sender of the mfa code. + attr_accessor :from + + # The application unique ID, obtained from Bandwidth. + attr_accessor :application_id + + # An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\". + attr_accessor :scope + + # The message format of the mfa code. There are three values that the system will replace \"{CODE}\", \"{NAME}\", \"{SCOPE}\". The \"{SCOPE}\" and \"{NAME} value template are optional, while \"{CODE}\" must be supplied. As the name would suggest, code will be replace with the actual mfa code. Name is replaced with the application name, configured during provisioning of mfa. The scope value is the same value sent during the call and partitioned by the server. + attr_accessor :message + + # The number of digits for your mfa code. The valid number ranges from 2 to 8, inclusively. + attr_accessor :digits + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'to' => :'to', + :'from' => :'from', + :'application_id' => :'applicationId', + :'scope' => :'scope', + :'message' => :'message', + :'digits' => :'digits' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'to' => :'String', + :'from' => :'String', + :'application_id' => :'String', + :'scope' => :'String', + :'message' => :'String', + :'digits' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CodeRequest` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CodeRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + + if attributes.key?(:'digits') + self.digits = attributes[:'digits'] + else + self.digits = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if @to !~ pattern + invalid_properties.push("invalid value for \"to\", must conform to the pattern #{pattern}.") + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @from.to_s.length > 32 + invalid_properties.push('invalid value for "from", the character length must be smaller than or equal to 32.') + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if @from !~ pattern + invalid_properties.push("invalid value for \"from\", must conform to the pattern #{pattern}.") + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @application_id.to_s.length > 50 + invalid_properties.push('invalid value for "application_id", the character length must be smaller than or equal to 50.') + end + + if !@scope.nil? && @scope.to_s.length > 25 + invalid_properties.push('invalid value for "scope", the character length must be smaller than or equal to 25.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + if @message.to_s.length > 2048 + invalid_properties.push('invalid value for "message", the character length must be smaller than or equal to 2048.') + end + + if @digits.nil? + invalid_properties.push('invalid value for "digits", digits cannot be nil.') + end + + if @digits > 8 + invalid_properties.push('invalid value for "digits", must be smaller than or equal to 8.') + end + + if @digits < 4 + invalid_properties.push('invalid value for "digits", must be greater than or equal to 4.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @to.nil? + return false if @to !~ Regexp.new(/^\+[1-9]\d{1,14}$/) + return false if @from.nil? + return false if @from.to_s.length > 32 + return false if @from !~ Regexp.new(/^\+[1-9]\d{1,14}$/) + return false if @application_id.nil? + return false if @application_id.to_s.length > 50 + return false if !@scope.nil? && @scope.to_s.length > 25 + return false if @message.nil? + return false if @message.to_s.length > 2048 + return false if @digits.nil? + return false if @digits > 8 + return false if @digits < 4 + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if to !~ pattern + fail ArgumentError, "invalid value for \"to\", must conform to the pattern #{pattern}." + end + + @to = to + end + + # Custom attribute writer method with validation + # @param [Object] from Value to be assigned + def from=(from) + if from.nil? + fail ArgumentError, 'from cannot be nil' + end + + if from.to_s.length > 32 + fail ArgumentError, 'invalid value for "from", the character length must be smaller than or equal to 32.' + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if from !~ pattern + fail ArgumentError, "invalid value for \"from\", must conform to the pattern #{pattern}." + end + + @from = from + end + + # Custom attribute writer method with validation + # @param [Object] application_id Value to be assigned + def application_id=(application_id) + if application_id.nil? + fail ArgumentError, 'application_id cannot be nil' + end + + if application_id.to_s.length > 50 + fail ArgumentError, 'invalid value for "application_id", the character length must be smaller than or equal to 50.' + end + + @application_id = application_id + end + + # Custom attribute writer method with validation + # @param [Object] scope Value to be assigned + def scope=(scope) + if scope.nil? + fail ArgumentError, 'scope cannot be nil' + end + + if scope.to_s.length > 25 + fail ArgumentError, 'invalid value for "scope", the character length must be smaller than or equal to 25.' + end + + @scope = scope + end + + # Custom attribute writer method with validation + # @param [Object] message Value to be assigned + def message=(message) + if message.nil? + fail ArgumentError, 'message cannot be nil' + end + + if message.to_s.length > 2048 + fail ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 2048.' + end + + @message = message + end + + # Custom attribute writer method with validation + # @param [Object] digits Value to be assigned + def digits=(digits) + if digits.nil? + fail ArgumentError, 'digits cannot be nil' + end + + if digits > 8 + fail ArgumentError, 'invalid value for "digits", must be smaller than or equal to 8.' + end + + if digits < 4 + fail ArgumentError, 'invalid value for "digits", must be greater than or equal to 4.' + end + + @digits = digits + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + to == o.to && + from == o.from && + application_id == o.application_id && + scope == o.scope && + message == o.message && + digits == o.digits + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [to, from, application_id, scope, message, digits].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference.rb b/lib/bandwidth-sdk/models/conference.rb new file mode 100644 index 00000000..1f239ef6 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference.rb @@ -0,0 +1,313 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Conference + # The Bandwidth-generated conference ID. + attr_accessor :id + + # The name of the conference, as specified by your application. + attr_accessor :name + + # The time the conference was initiated, in ISO 8601 format. + attr_accessor :created_time + + # The time the conference was terminated, in ISO 8601 format. + attr_accessor :completed_time + + # The URL to send the conference-related events. + attr_accessor :conference_event_url + + attr_accessor :conference_event_method + + # The custom string attached to the conference that will be sent with callbacks. + attr_accessor :tag + + # A list of active members of the conference. Omitted if this is a response to the [Get Conferences endpoint](/apis/voice#tag/Conferences/operation/listConferences). + attr_accessor :active_members + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'name' => :'name', + :'created_time' => :'createdTime', + :'completed_time' => :'completedTime', + :'conference_event_url' => :'conferenceEventUrl', + :'conference_event_method' => :'conferenceEventMethod', + :'tag' => :'tag', + :'active_members' => :'activeMembers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'name' => :'String', + :'created_time' => :'Time', + :'completed_time' => :'Time', + :'conference_event_url' => :'String', + :'conference_event_method' => :'CallbackMethodEnum', + :'tag' => :'String', + :'active_members' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'completed_time', + :'conference_event_url', + :'conference_event_method', + :'tag', + :'active_members' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Conference` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Conference`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'created_time') + self.created_time = attributes[:'created_time'] + end + + if attributes.key?(:'completed_time') + self.completed_time = attributes[:'completed_time'] + end + + if attributes.key?(:'conference_event_url') + self.conference_event_url = attributes[:'conference_event_url'] + end + + if attributes.key?(:'conference_event_method') + self.conference_event_method = attributes[:'conference_event_method'] + else + self.conference_event_method = 'POST' + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'active_members') + if (value = attributes[:'active_members']).is_a?(Array) + self.active_members = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + name == o.name && + created_time == o.created_time && + completed_time == o.completed_time && + conference_event_url == o.conference_event_url && + conference_event_method == o.conference_event_method && + tag == o.tag && + active_members == o.active_members + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, name, created_time, completed_time, conference_event_url, conference_event_method, tag, active_members].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_completed_callback.rb b/lib/bandwidth-sdk/models/conference_completed_callback.rb new file mode 100644 index 00000000..8074fc50 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_completed_callback.rb @@ -0,0 +1,255 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Completed event is fired when the last member leaves the conference. The response to this event may not contain BXML. + class ConferenceCompletedCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceCompletedCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceCompletedCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_created_callback.rb b/lib/bandwidth-sdk/models/conference_created_callback.rb new file mode 100644 index 00000000..7142732a --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_created_callback.rb @@ -0,0 +1,255 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Created event is fired whenever a new conference that specified a callbackUrl is created. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference. + class ConferenceCreatedCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceCreatedCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceCreatedCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_member.rb b/lib/bandwidth-sdk/models/conference_member.rb new file mode 100644 index 00000000..ed5fe582 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_member.rb @@ -0,0 +1,266 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class ConferenceMember + # The call id associated with the event. + attr_accessor :call_id + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # A URL that may be used to retrieve information about or update the state of this conference member. This is the URL of this member's [Get Conference Member](/apis/voice/#operation/getConferenceMember) endpoint and [Modify Conference Member](/apis/voice/#operation/updateConferenceMember) endpoint. + attr_accessor :member_url + + # Whether or not this member is currently muted. Members who are muted are still able to hear other participants. If used in a PUT request, updates this member's mute status. Has no effect if omitted. + attr_accessor :mute + + # Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. If used in a PUT request, updates this member's hold status. Has no effect if omitted. + attr_accessor :hold + + # If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. If present in a PUT request, modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join. + attr_accessor :call_ids_to_coach + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'call_id' => :'callId', + :'conference_id' => :'conferenceId', + :'member_url' => :'memberUrl', + :'mute' => :'mute', + :'hold' => :'hold', + :'call_ids_to_coach' => :'callIdsToCoach' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'call_id' => :'String', + :'conference_id' => :'String', + :'member_url' => :'String', + :'mute' => :'Boolean', + :'hold' => :'Boolean', + :'call_ids_to_coach' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'call_ids_to_coach' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMember` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMember`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'member_url') + self.member_url = attributes[:'member_url'] + end + + if attributes.key?(:'mute') + self.mute = attributes[:'mute'] + end + + if attributes.key?(:'hold') + self.hold = attributes[:'hold'] + end + + if attributes.key?(:'call_ids_to_coach') + if (value = attributes[:'call_ids_to_coach']).is_a?(Array) + self.call_ids_to_coach = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + call_id == o.call_id && + conference_id == o.conference_id && + member_url == o.member_url && + mute == o.mute && + hold == o.hold && + call_ids_to_coach == o.call_ids_to_coach + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [call_id, conference_id, member_url, mute, hold, call_ids_to_coach].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_member_exit_callback.rb b/lib/bandwidth-sdk/models/conference_member_exit_callback.rb new file mode 100644 index 00000000..a3e4a5d7 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_member_exit_callback.rb @@ -0,0 +1,285 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Member Exit event is fired whenever a caller exits a conference that specified a callbackUrl. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference. + class ConferenceMemberExitCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The call id associated with the event. + attr_accessor :call_id + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'from' => :'from', + :'to' => :'to', + :'call_id' => :'callId', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'from' => :'String', + :'to' => :'String', + :'call_id' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMemberExitCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMemberExitCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + from == o.from && + to == o.to && + call_id == o.call_id && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, from, to, call_id, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_member_join_callback.rb b/lib/bandwidth-sdk/models/conference_member_join_callback.rb new file mode 100644 index 00000000..f8352171 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_member_join_callback.rb @@ -0,0 +1,285 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Member Join event is fired whenever a caller joins a conference that specified a callbackUrl. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference. + class ConferenceMemberJoinCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The call id associated with the event. + attr_accessor :call_id + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'from' => :'from', + :'to' => :'to', + :'call_id' => :'callId', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'from' => :'String', + :'to' => :'String', + :'call_id' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceMemberJoinCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceMemberJoinCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + from == o.from && + to == o.to && + call_id == o.call_id && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, from, to, call_id, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_recording_available_callback.rb b/lib/bandwidth-sdk/models/conference_recording_available_callback.rb new file mode 100644 index 00000000..695007d1 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_recording_available_callback.rb @@ -0,0 +1,367 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Recording Available event is sent after a conference recording has been processed. It indicates that the recording is available for download. + class ConferenceRecordingAvailableCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # The user account associated with the call. + attr_accessor :account_id + + # The unique ID of this recording + attr_accessor :recording_id + + # Always `1` for conference recordings; multi-channel recordings are not supported on conferences. + attr_accessor :channels + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + attr_accessor :file_format + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :status + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'account_id' => :'accountId', + :'recording_id' => :'recordingId', + :'channels' => :'channels', + :'start_time' => :'startTime', + :'end_time' => :'endTime', + :'duration' => :'duration', + :'file_format' => :'fileFormat', + :'media_url' => :'mediaUrl', + :'tag' => :'tag', + :'status' => :'status' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'account_id' => :'String', + :'recording_id' => :'String', + :'channels' => :'Integer', + :'start_time' => :'Time', + :'end_time' => :'Time', + :'duration' => :'String', + :'file_format' => :'FileFormatEnum', + :'media_url' => :'String', + :'tag' => :'String', + :'status' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRecordingAvailableCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRecordingAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'channels') + self.channels = attributes[:'channels'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + account_id == o.account_id && + recording_id == o.recording_id && + channels == o.channels && + start_time == o.start_time && + end_time == o.end_time && + duration == o.duration && + file_format == o.file_format && + media_url == o.media_url && + tag == o.tag && + status == o.status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, account_id, recording_id, channels, start_time, end_time, duration, file_format, media_url, tag, status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_recording_metadata.rb b/lib/bandwidth-sdk/models/conference_recording_metadata.rb new file mode 100644 index 00000000..365d04b3 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_recording_metadata.rb @@ -0,0 +1,335 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class ConferenceRecordingMetadata + # The user account associated with the call. + attr_accessor :account_id + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # The unique ID of this recording + attr_accessor :recording_id + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + # Always `1` for conference recordings; multi-channel recordings are not supported on conferences. + attr_accessor :channels + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + attr_accessor :file_format + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :status + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'account_id' => :'accountId', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'recording_id' => :'recordingId', + :'duration' => :'duration', + :'channels' => :'channels', + :'start_time' => :'startTime', + :'end_time' => :'endTime', + :'file_format' => :'fileFormat', + :'status' => :'status', + :'media_url' => :'mediaUrl' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'account_id' => :'String', + :'conference_id' => :'String', + :'name' => :'String', + :'recording_id' => :'String', + :'duration' => :'String', + :'channels' => :'Integer', + :'start_time' => :'Time', + :'end_time' => :'Time', + :'file_format' => :'FileFormatEnum', + :'status' => :'String', + :'media_url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRecordingMetadata` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRecordingMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'channels') + self.channels = attributes[:'channels'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + account_id == o.account_id && + conference_id == o.conference_id && + name == o.name && + recording_id == o.recording_id && + duration == o.duration && + channels == o.channels && + start_time == o.start_time && + end_time == o.end_time && + file_format == o.file_format && + status == o.status && + media_url == o.media_url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [account_id, conference_id, name, recording_id, duration, channels, start_time, end_time, file_format, status, media_url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_redirect_callback.rb b/lib/bandwidth-sdk/models/conference_redirect_callback.rb new file mode 100644 index 00000000..a0252fc3 --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_redirect_callback.rb @@ -0,0 +1,255 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Conference Redirect event is fired whenever an existing conference is modified via a POST request made to the /conferences/{conferenceId} endpoint. The response may be either empty or a BXML document. Only the following verbs are valid for conferences: PlayAudio, SpeakSentence, StartRecording, StopRecording, PauseRecording, ResumeRecording. Audio verbs will be heard by all members of the conference. Recordings capture audio from all members who are not muted or on hold, as well as any audio verbs that are played into the conference. + class ConferenceRedirectCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The unique, Bandwidth-generated ID of the conference that was recorded + attr_accessor :conference_id + + # The user-specified name of the conference that was recorded + attr_accessor :name + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'conference_id' => :'conferenceId', + :'name' => :'name', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'conference_id' => :'String', + :'name' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ConferenceRedirectCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ConferenceRedirectCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'conference_id') + self.conference_id = attributes[:'conference_id'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + conference_id == o.conference_id && + name == o.name && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, conference_id, name, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/conference_state_enum.rb b/lib/bandwidth-sdk/models/conference_state_enum.rb new file mode 100644 index 00000000..19b83f0f --- /dev/null +++ b/lib/bandwidth-sdk/models/conference_state_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class ConferenceStateEnum + ACTIVE = 'active'.freeze + COMPLETED = 'completed'.freeze + + def self.all_vars + @all_vars ||= [ACTIVE, COMPLETED].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ConferenceStateEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ConferenceStateEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/create_call.rb b/lib/bandwidth-sdk/models/create_call.rb new file mode 100644 index 00000000..70853754 --- /dev/null +++ b/lib/bandwidth-sdk/models/create_call.rb @@ -0,0 +1,687 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CreateCall + # The destination to call (must be an E.164 formatted number (e.g. `+15555551212`) or a SIP URI (e.g. `sip:user@server.example`)). + attr_accessor :to + + # A Bandwidth phone number on your account the call should come from (must be in E.164 format, like `+15555551212`, or be one of the following strings: `Restricted`, `Anonymous`, `Private`, or `Unavailable`). + attr_accessor :from + + # The caller display name to use when the call is created. May not exceed 256 characters nor contain control characters such as new lines. + attr_accessor :display_name + + # A comma-separated list of 'User-To-User' headers to be sent in the INVITE when calling a SIP URI. Each value must end with an 'encoding' parameter as described in RFC 7433. Only 'jwt' and 'base64' encodings are allowed. The entire value cannot exceed 350 characters, including parameters and separators. + attr_accessor :uui + + # The id of the application associated with the `from` number. + attr_accessor :application_id + + # The full URL to send the Answer event to when the called party answers. This endpoint should return the first BXML document to be executed in the call. Must use `https` if specifying `username` and `password`. + attr_accessor :answer_url + + attr_accessor :answer_method + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # A fallback url which, if provided, will be used to retry the `answer` webhook delivery in case `answerUrl` fails to respond Must use `https` if specifying `fallbackUsername` and `fallbackPassword`. + attr_accessor :answer_fallback_url + + attr_accessor :answer_fallback_method + + # Basic auth username. + attr_accessor :fallback_username + + # Basic auth password. + attr_accessor :fallback_password + + # The URL to send the Disconnect event to when the call ends. This event does not expect a BXML response. + attr_accessor :disconnect_url + + attr_accessor :disconnect_method + + # The timeout (in seconds) for the callee to answer the call after it starts ringing. If the call does not start ringing within 30s, the call will be cancelled regardless of this value. Can be any numeric value (including decimals) between 1 and 300. + attr_accessor :call_timeout + + # This is the timeout (in seconds) to use when delivering webhooks for the call. Can be any numeric value (including decimals) between 1 and 25. + attr_accessor :callback_timeout + + attr_accessor :machine_detection + + # The priority of this call over other calls from your account. For example, if during a call your application needs to place a new call and bridge it with the current call, you might want to create the call with priority 1 so that it will be the next call picked off your queue, ahead of other less time sensitive calls. A lower value means higher priority, so a priority 1 call takes precedence over a priority 2 call. + attr_accessor :priority + + # A custom string that will be sent with all webhooks for this call unless overwritten by a future `` verb or `tag` attribute on another verb, or cleared. May be cleared by setting `tag=\"\"` Max length 256 characters. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'to' => :'to', + :'from' => :'from', + :'display_name' => :'displayName', + :'uui' => :'uui', + :'application_id' => :'applicationId', + :'answer_url' => :'answerUrl', + :'answer_method' => :'answerMethod', + :'username' => :'username', + :'password' => :'password', + :'answer_fallback_url' => :'answerFallbackUrl', + :'answer_fallback_method' => :'answerFallbackMethod', + :'fallback_username' => :'fallbackUsername', + :'fallback_password' => :'fallbackPassword', + :'disconnect_url' => :'disconnectUrl', + :'disconnect_method' => :'disconnectMethod', + :'call_timeout' => :'callTimeout', + :'callback_timeout' => :'callbackTimeout', + :'machine_detection' => :'machineDetection', + :'priority' => :'priority', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'to' => :'String', + :'from' => :'String', + :'display_name' => :'String', + :'uui' => :'String', + :'application_id' => :'String', + :'answer_url' => :'String', + :'answer_method' => :'CallbackMethodEnum', + :'username' => :'String', + :'password' => :'String', + :'answer_fallback_url' => :'String', + :'answer_fallback_method' => :'CallbackMethodEnum', + :'fallback_username' => :'String', + :'fallback_password' => :'String', + :'disconnect_url' => :'String', + :'disconnect_method' => :'CallbackMethodEnum', + :'call_timeout' => :'Float', + :'callback_timeout' => :'Float', + :'machine_detection' => :'MachineDetectionConfiguration', + :'priority' => :'Integer', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'display_name', + :'uui', + :'answer_method', + :'username', + :'password', + :'answer_fallback_url', + :'answer_fallback_method', + :'fallback_username', + :'fallback_password', + :'disconnect_url', + :'disconnect_method', + :'call_timeout', + :'callback_timeout', + :'priority', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateCall` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateCall`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'display_name') + self.display_name = attributes[:'display_name'] + end + + if attributes.key?(:'uui') + self.uui = attributes[:'uui'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'answer_url') + self.answer_url = attributes[:'answer_url'] + else + self.answer_url = nil + end + + if attributes.key?(:'answer_method') + self.answer_method = attributes[:'answer_method'] + else + self.answer_method = 'POST' + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'answer_fallback_url') + self.answer_fallback_url = attributes[:'answer_fallback_url'] + end + + if attributes.key?(:'answer_fallback_method') + self.answer_fallback_method = attributes[:'answer_fallback_method'] + else + self.answer_fallback_method = 'POST' + end + + if attributes.key?(:'fallback_username') + self.fallback_username = attributes[:'fallback_username'] + end + + if attributes.key?(:'fallback_password') + self.fallback_password = attributes[:'fallback_password'] + end + + if attributes.key?(:'disconnect_url') + self.disconnect_url = attributes[:'disconnect_url'] + end + + if attributes.key?(:'disconnect_method') + self.disconnect_method = attributes[:'disconnect_method'] + else + self.disconnect_method = 'POST' + end + + if attributes.key?(:'call_timeout') + self.call_timeout = attributes[:'call_timeout'] + else + self.call_timeout = 30 + end + + if attributes.key?(:'callback_timeout') + self.callback_timeout = attributes[:'callback_timeout'] + else + self.callback_timeout = 15 + end + + if attributes.key?(:'machine_detection') + self.machine_detection = attributes[:'machine_detection'] + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + else + self.priority = 5 + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if !@display_name.nil? && @display_name.to_s.length > 256 + invalid_properties.push('invalid value for "display_name", the character length must be smaller than or equal to 256.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @answer_url.nil? + invalid_properties.push('invalid value for "answer_url", answer_url cannot be nil.') + end + + if @answer_url.to_s.length > 2048 + invalid_properties.push('invalid value for "answer_url", the character length must be smaller than or equal to 2048.') + end + + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@answer_fallback_url.nil? && @answer_fallback_url.to_s.length > 2048 + invalid_properties.push('invalid value for "answer_fallback_url", the character length must be smaller than or equal to 2048.') + end + + if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.') + end + + if !@disconnect_url.nil? && @disconnect_url.to_s.length > 2048 + invalid_properties.push('invalid value for "disconnect_url", the character length must be smaller than or equal to 2048.') + end + + if !@call_timeout.nil? && @call_timeout > 300 + invalid_properties.push('invalid value for "call_timeout", must be smaller than or equal to 300.') + end + + if !@call_timeout.nil? && @call_timeout < 1 + invalid_properties.push('invalid value for "call_timeout", must be greater than or equal to 1.') + end + + if !@callback_timeout.nil? && @callback_timeout > 25 + invalid_properties.push('invalid value for "callback_timeout", must be smaller than or equal to 25.') + end + + if !@callback_timeout.nil? && @callback_timeout < 1 + invalid_properties.push('invalid value for "callback_timeout", must be greater than or equal to 1.') + end + + if !@priority.nil? && @priority > 5 + invalid_properties.push('invalid value for "priority", must be smaller than or equal to 5.') + end + + if !@priority.nil? && @priority < 1 + invalid_properties.push('invalid value for "priority", must be greater than or equal to 1.') + end + + if !@tag.nil? && @tag.to_s.length > 256 + invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 256.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @to.nil? + return false if @from.nil? + return false if !@display_name.nil? && @display_name.to_s.length > 256 + return false if @application_id.nil? + return false if @answer_url.nil? + return false if @answer_url.to_s.length > 2048 + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@answer_fallback_url.nil? && @answer_fallback_url.to_s.length > 2048 + return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + return false if !@disconnect_url.nil? && @disconnect_url.to_s.length > 2048 + return false if !@call_timeout.nil? && @call_timeout > 300 + return false if !@call_timeout.nil? && @call_timeout < 1 + return false if !@callback_timeout.nil? && @callback_timeout > 25 + return false if !@callback_timeout.nil? && @callback_timeout < 1 + return false if !@priority.nil? && @priority > 5 + return false if !@priority.nil? && @priority < 1 + return false if !@tag.nil? && @tag.to_s.length > 256 + true + end + + # Custom attribute writer method with validation + # @param [Object] display_name Value to be assigned + def display_name=(display_name) + if !display_name.nil? && display_name.to_s.length > 256 + fail ArgumentError, 'invalid value for "display_name", the character length must be smaller than or equal to 256.' + end + + @display_name = display_name + end + + # Custom attribute writer method with validation + # @param [Object] answer_url Value to be assigned + def answer_url=(answer_url) + if answer_url.nil? + fail ArgumentError, 'answer_url cannot be nil' + end + + if answer_url.to_s.length > 2048 + fail ArgumentError, 'invalid value for "answer_url", the character length must be smaller than or equal to 2048.' + end + + @answer_url = answer_url + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] answer_fallback_url Value to be assigned + def answer_fallback_url=(answer_fallback_url) + if !answer_fallback_url.nil? && answer_fallback_url.to_s.length > 2048 + fail ArgumentError, 'invalid value for "answer_fallback_url", the character length must be smaller than or equal to 2048.' + end + + @answer_fallback_url = answer_fallback_url + end + + # Custom attribute writer method with validation + # @param [Object] fallback_username Value to be assigned + def fallback_username=(fallback_username) + if !fallback_username.nil? && fallback_username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.' + end + + @fallback_username = fallback_username + end + + # Custom attribute writer method with validation + # @param [Object] fallback_password Value to be assigned + def fallback_password=(fallback_password) + if !fallback_password.nil? && fallback_password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.' + end + + @fallback_password = fallback_password + end + + # Custom attribute writer method with validation + # @param [Object] disconnect_url Value to be assigned + def disconnect_url=(disconnect_url) + if !disconnect_url.nil? && disconnect_url.to_s.length > 2048 + fail ArgumentError, 'invalid value for "disconnect_url", the character length must be smaller than or equal to 2048.' + end + + @disconnect_url = disconnect_url + end + + # Custom attribute writer method with validation + # @param [Object] call_timeout Value to be assigned + def call_timeout=(call_timeout) + if !call_timeout.nil? && call_timeout > 300 + fail ArgumentError, 'invalid value for "call_timeout", must be smaller than or equal to 300.' + end + + if !call_timeout.nil? && call_timeout < 1 + fail ArgumentError, 'invalid value for "call_timeout", must be greater than or equal to 1.' + end + + @call_timeout = call_timeout + end + + # Custom attribute writer method with validation + # @param [Object] callback_timeout Value to be assigned + def callback_timeout=(callback_timeout) + if !callback_timeout.nil? && callback_timeout > 25 + fail ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.' + end + + if !callback_timeout.nil? && callback_timeout < 1 + fail ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.' + end + + @callback_timeout = callback_timeout + end + + # Custom attribute writer method with validation + # @param [Object] priority Value to be assigned + def priority=(priority) + if !priority.nil? && priority > 5 + fail ArgumentError, 'invalid value for "priority", must be smaller than or equal to 5.' + end + + if !priority.nil? && priority < 1 + fail ArgumentError, 'invalid value for "priority", must be greater than or equal to 1.' + end + + @priority = priority + end + + # Custom attribute writer method with validation + # @param [Object] tag Value to be assigned + def tag=(tag) + if !tag.nil? && tag.to_s.length > 256 + fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 256.' + end + + @tag = tag + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + to == o.to && + from == o.from && + display_name == o.display_name && + uui == o.uui && + application_id == o.application_id && + answer_url == o.answer_url && + answer_method == o.answer_method && + username == o.username && + password == o.password && + answer_fallback_url == o.answer_fallback_url && + answer_fallback_method == o.answer_fallback_method && + fallback_username == o.fallback_username && + fallback_password == o.fallback_password && + disconnect_url == o.disconnect_url && + disconnect_method == o.disconnect_method && + call_timeout == o.call_timeout && + callback_timeout == o.callback_timeout && + machine_detection == o.machine_detection && + priority == o.priority && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [to, from, display_name, uui, application_id, answer_url, answer_method, username, password, answer_fallback_url, answer_fallback_method, fallback_username, fallback_password, disconnect_url, disconnect_method, call_timeout, callback_timeout, machine_detection, priority, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/create_call_response.rb b/lib/bandwidth-sdk/models/create_call_response.rb new file mode 100644 index 00000000..a93608fa --- /dev/null +++ b/lib/bandwidth-sdk/models/create_call_response.rb @@ -0,0 +1,559 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CreateCallResponse + # The id of the application associated with the `from` number. + attr_accessor :application_id + + # The bandwidth account ID associated with the call. + attr_accessor :account_id + + # Programmable Voice API Call ID. + attr_accessor :call_id + + # Recipient of the outgoing call. + attr_accessor :to + + # Phone number that created the outbound call. + attr_accessor :from + + # The time at which the call was accepted into the queue. + attr_accessor :enqueued_time + + # The URL to update this call's state. + attr_accessor :call_url + + # The timeout (in seconds) for the callee to answer the call after it starts ringing. + attr_accessor :call_timeout + + # This is the timeout (in seconds) to use when delivering webhooks for the call. + attr_accessor :callback_timeout + + # Custom tag value. + attr_accessor :tag + + attr_accessor :answer_method + + # URL to deliver the `answer` event webhook. + attr_accessor :answer_url + + attr_accessor :answer_fallback_method + + # Fallback URL to deliver the `answer` event webhook. + attr_accessor :answer_fallback_url + + attr_accessor :disconnect_method + + # URL to deliver the `disconnect` event webhook. + attr_accessor :disconnect_url + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # Basic auth username. + attr_accessor :fallback_username + + # Basic auth password. + attr_accessor :fallback_password + + # The priority of this call over other calls from your account. + attr_accessor :priority + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'application_id' => :'applicationId', + :'account_id' => :'accountId', + :'call_id' => :'callId', + :'to' => :'to', + :'from' => :'from', + :'enqueued_time' => :'enqueuedTime', + :'call_url' => :'callUrl', + :'call_timeout' => :'callTimeout', + :'callback_timeout' => :'callbackTimeout', + :'tag' => :'tag', + :'answer_method' => :'answerMethod', + :'answer_url' => :'answerUrl', + :'answer_fallback_method' => :'answerFallbackMethod', + :'answer_fallback_url' => :'answerFallbackUrl', + :'disconnect_method' => :'disconnectMethod', + :'disconnect_url' => :'disconnectUrl', + :'username' => :'username', + :'password' => :'password', + :'fallback_username' => :'fallbackUsername', + :'fallback_password' => :'fallbackPassword', + :'priority' => :'priority' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'application_id' => :'String', + :'account_id' => :'String', + :'call_id' => :'String', + :'to' => :'String', + :'from' => :'String', + :'enqueued_time' => :'Time', + :'call_url' => :'String', + :'call_timeout' => :'Float', + :'callback_timeout' => :'Float', + :'tag' => :'String', + :'answer_method' => :'CallbackMethodEnum', + :'answer_url' => :'String', + :'answer_fallback_method' => :'CallbackMethodEnum', + :'answer_fallback_url' => :'String', + :'disconnect_method' => :'CallbackMethodEnum', + :'disconnect_url' => :'String', + :'username' => :'String', + :'password' => :'String', + :'fallback_username' => :'String', + :'fallback_password' => :'String', + :'priority' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'tag', + :'answer_method', + :'answer_fallback_method', + :'answer_fallback_url', + :'disconnect_method', + :'disconnect_url', + :'username', + :'password', + :'fallback_username', + :'fallback_password', + :'priority' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateCallResponse` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateCallResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + else + self.account_id = nil + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + else + self.call_id = nil + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + else + self.call_url = nil + end + + if attributes.key?(:'call_timeout') + self.call_timeout = attributes[:'call_timeout'] + end + + if attributes.key?(:'callback_timeout') + self.callback_timeout = attributes[:'callback_timeout'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'answer_method') + self.answer_method = attributes[:'answer_method'] + else + self.answer_method = 'POST' + end + + if attributes.key?(:'answer_url') + self.answer_url = attributes[:'answer_url'] + else + self.answer_url = nil + end + + if attributes.key?(:'answer_fallback_method') + self.answer_fallback_method = attributes[:'answer_fallback_method'] + else + self.answer_fallback_method = 'POST' + end + + if attributes.key?(:'answer_fallback_url') + self.answer_fallback_url = attributes[:'answer_fallback_url'] + end + + if attributes.key?(:'disconnect_method') + self.disconnect_method = attributes[:'disconnect_method'] + else + self.disconnect_method = 'POST' + end + + if attributes.key?(:'disconnect_url') + self.disconnect_url = attributes[:'disconnect_url'] + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'fallback_username') + self.fallback_username = attributes[:'fallback_username'] + end + + if attributes.key?(:'fallback_password') + self.fallback_password = attributes[:'fallback_password'] + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @account_id.nil? + invalid_properties.push('invalid value for "account_id", account_id cannot be nil.') + end + + if @call_id.nil? + invalid_properties.push('invalid value for "call_id", call_id cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @call_url.nil? + invalid_properties.push('invalid value for "call_url", call_url cannot be nil.') + end + + if @answer_url.nil? + invalid_properties.push('invalid value for "answer_url", answer_url cannot be nil.') + end + + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @application_id.nil? + return false if @account_id.nil? + return false if @call_id.nil? + return false if @to.nil? + return false if @from.nil? + return false if @call_url.nil? + return false if @answer_url.nil? + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + true + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] fallback_username Value to be assigned + def fallback_username=(fallback_username) + if !fallback_username.nil? && fallback_username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.' + end + + @fallback_username = fallback_username + end + + # Custom attribute writer method with validation + # @param [Object] fallback_password Value to be assigned + def fallback_password=(fallback_password) + if !fallback_password.nil? && fallback_password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.' + end + + @fallback_password = fallback_password + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + application_id == o.application_id && + account_id == o.account_id && + call_id == o.call_id && + to == o.to && + from == o.from && + enqueued_time == o.enqueued_time && + call_url == o.call_url && + call_timeout == o.call_timeout && + callback_timeout == o.callback_timeout && + tag == o.tag && + answer_method == o.answer_method && + answer_url == o.answer_url && + answer_fallback_method == o.answer_fallback_method && + answer_fallback_url == o.answer_fallback_url && + disconnect_method == o.disconnect_method && + disconnect_url == o.disconnect_url && + username == o.username && + password == o.password && + fallback_username == o.fallback_username && + fallback_password == o.fallback_password && + priority == o.priority + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [application_id, account_id, call_id, to, from, enqueued_time, call_url, call_timeout, callback_timeout, tag, answer_method, answer_url, answer_fallback_method, answer_fallback_url, disconnect_method, disconnect_url, username, password, fallback_username, fallback_password, priority].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/create_lookup_response.rb b/lib/bandwidth-sdk/models/create_lookup_response.rb new file mode 100644 index 00000000..ce6f0892 --- /dev/null +++ b/lib/bandwidth-sdk/models/create_lookup_response.rb @@ -0,0 +1,245 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The request has been accepted for processing but not yet finished and in a terminal state (COMPLETE, PARTIAL_COMPLETE, or FAILED). + class CreateLookupResponse + # The phone number lookup request ID from Bandwidth. + attr_accessor :request_id + + attr_accessor :status + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'request_id' => :'requestId', + :'status' => :'status' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'request_id' => :'String', + :'status' => :'LookupStatusEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateLookupResponse` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateLookupResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'request_id') + self.request_id = attributes[:'request_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + request_id == o.request_id && + status == o.status + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [request_id, status].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/create_message_request_error.rb b/lib/bandwidth-sdk/models/create_message_request_error.rb new file mode 100644 index 00000000..10dd2032 --- /dev/null +++ b/lib/bandwidth-sdk/models/create_message_request_error.rb @@ -0,0 +1,246 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class CreateMessageRequestError + attr_accessor :type + + attr_accessor :description + + attr_accessor :field_errors + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'description' => :'description', + :'field_errors' => :'fieldErrors' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'description' => :'String', + :'field_errors' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::CreateMessageRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::CreateMessageRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + + if attributes.key?(:'field_errors') + if (value = attributes[:'field_errors']).is_a?(Array) + self.field_errors = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + return false if @description.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + description == o.description && + field_errors == o.field_errors + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, description, field_errors].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/deferred_result.rb b/lib/bandwidth-sdk/models/deferred_result.rb new file mode 100644 index 00000000..9aa5a732 --- /dev/null +++ b/lib/bandwidth-sdk/models/deferred_result.rb @@ -0,0 +1,221 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class DeferredResult + attr_accessor :result + + attr_accessor :set_or_expired + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'result' => :'result', + :'set_or_expired' => :'setOrExpired' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'result' => :'Object', + :'set_or_expired' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DeferredResult` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DeferredResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'result') + self.result = attributes[:'result'] + end + + if attributes.key?(:'set_or_expired') + self.set_or_expired = attributes[:'set_or_expired'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + result == o.result && + set_or_expired == o.set_or_expired + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [result, set_or_expired].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/disconenct_callback.rb b/lib/bandwidth-sdk/models/disconenct_callback.rb new file mode 100644 index 00000000..b6b16e44 --- /dev/null +++ b/lib/bandwidth-sdk/models/disconenct_callback.rb @@ -0,0 +1,405 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 6.3.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Disconnect event is fired when a call ends, for any reason. + class DisconenctCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The call id associated with the event. + attr_accessor :call_id + + attr_accessor :direction + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. + attr_accessor :cause + + # Text explaining the reason that caused the call to fail in case of errors. + attr_accessor :error_message + + # Bandwidth's internal id that references the error event. + attr_accessor :error_id + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'call_id' => :'callId', + :'direction' => :'direction', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'end_time' => :'endTime', + :'cause' => :'cause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'String', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'call_id' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'end_time' => :'Time', + :'cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'error_message', + :'error_id', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DisconenctCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DisconenctCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + call_id == o.call_id && + direction == o.direction && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + end_time == o.end_time && + cause == o.cause && + error_message == o.error_message && + error_id == o.error_id && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, call_id, direction, call_url, enqueued_time, start_time, answer_time, end_time, cause, error_message, error_id, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/disconnect_callback.rb b/lib/bandwidth-sdk/models/disconnect_callback.rb new file mode 100644 index 00000000..9363c0f9 --- /dev/null +++ b/lib/bandwidth-sdk/models/disconnect_callback.rb @@ -0,0 +1,400 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Disconnect event is fired when a call ends, for any reason. + class DisconnectCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The call id associated with the event. + attr_accessor :call_id + + attr_accessor :direction + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. + attr_accessor :cause + + # Text explaining the reason that caused the call to fail in case of errors. + attr_accessor :error_message + + # Bandwidth's internal id that references the error event. + attr_accessor :error_id + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'call_id' => :'callId', + :'direction' => :'direction', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'end_time' => :'endTime', + :'cause' => :'cause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'call_id' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'end_time' => :'Time', + :'cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'error_message', + :'error_id', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DisconnectCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DisconnectCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + call_id == o.call_id && + direction == o.direction && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + end_time == o.end_time && + cause == o.cause && + error_message == o.error_message && + error_id == o.error_id && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, call_id, direction, call_url, enqueued_time, start_time, answer_time, end_time, cause, error_message, error_id, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/diversion.rb b/lib/bandwidth-sdk/models/diversion.rb new file mode 100644 index 00000000..cc055774 --- /dev/null +++ b/lib/bandwidth-sdk/models/diversion.rb @@ -0,0 +1,273 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Diversion + # The reason for the diversion. Common values: unknown, user-busy, no-answer, unavailable, unconditional, time-of-day, do-not-disturb, deflection, follow-me, out-of-service, away. + attr_accessor :reason + + # off or full + attr_accessor :privacy + + # No if the number was provided by the user, yes if the number was provided by the network + attr_accessor :screen + + # The number of diversions that have occurred + attr_accessor :counter + + # The maximum number of diversions allowed for this session + attr_accessor :limit + + # The normal list of values is not exhaustive. Your application must be tolerant of unlisted keys and unlisted values of those keys. + attr_accessor :unknown + + # Always present. Indicates the last telephone number that the call was diverted from. + attr_accessor :orig_to + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'reason' => :'reason', + :'privacy' => :'privacy', + :'screen' => :'screen', + :'counter' => :'counter', + :'limit' => :'limit', + :'unknown' => :'unknown', + :'orig_to' => :'origTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'reason' => :'String', + :'privacy' => :'String', + :'screen' => :'String', + :'counter' => :'String', + :'limit' => :'String', + :'unknown' => :'String', + :'orig_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Diversion` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Diversion`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'reason') + self.reason = attributes[:'reason'] + end + + if attributes.key?(:'privacy') + self.privacy = attributes[:'privacy'] + end + + if attributes.key?(:'screen') + self.screen = attributes[:'screen'] + end + + if attributes.key?(:'counter') + self.counter = attributes[:'counter'] + end + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + end + + if attributes.key?(:'unknown') + self.unknown = attributes[:'unknown'] + end + + if attributes.key?(:'orig_to') + self.orig_to = attributes[:'orig_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + reason == o.reason && + privacy == o.privacy && + screen == o.screen && + counter == o.counter && + limit == o.limit && + unknown == o.unknown && + orig_to == o.orig_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [reason, privacy, screen, counter, limit, unknown, orig_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/dtmf_callback.rb b/lib/bandwidth-sdk/models/dtmf_callback.rb new file mode 100644 index 00000000..3578643d --- /dev/null +++ b/lib/bandwidth-sdk/models/dtmf_callback.rb @@ -0,0 +1,398 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The DTMF event is sent for every digit detected after a verb is executed. You may not respond to this event with BXML. + class DtmfCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + # The call id associated with the event. + attr_accessor :call_id + + attr_accessor :direction + + # The digit collected in the call. + attr_accessor :digit + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'call_id' => :'callId', + :'direction' => :'direction', + :'digit' => :'digit', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'parent_call_id' => :'parentCallId', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'call_id' => :'String', + :'direction' => :'CallDirectionEnum', + :'digit' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'parent_call_id' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::DtmfCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::DtmfCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'digit') + self.digit = attributes[:'digit'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + call_id == o.call_id && + direction == o.direction && + digit == o.digit && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + parent_call_id == o.parent_call_id && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, call_id, direction, digit, call_url, enqueued_time, start_time, answer_time, parent_call_id, transfer_caller_id, transfer_to, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/field_error.rb b/lib/bandwidth-sdk/models/field_error.rb new file mode 100644 index 00000000..f5f50356 --- /dev/null +++ b/lib/bandwidth-sdk/models/field_error.rb @@ -0,0 +1,223 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class FieldError + # The name of the field that contains the error + attr_accessor :field_name + + # The error associated with the field + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'field_name' => :'fieldName', + :'description' => :'description' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'field_name' => :'String', + :'description' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::FieldError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::FieldError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'field_name') + self.field_name = attributes[:'field_name'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + field_name == o.field_name && + description == o.description + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [field_name, description].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/file_format_enum.rb b/lib/bandwidth-sdk/models/file_format_enum.rb new file mode 100644 index 00000000..30cbaeac --- /dev/null +++ b/lib/bandwidth-sdk/models/file_format_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class FileFormatEnum + MP3 = 'mp3'.freeze + WAV = 'wav'.freeze + + def self.all_vars + @all_vars ||= [MP3, WAV].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if FileFormatEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #FileFormatEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/gather_callback.rb b/lib/bandwidth-sdk/models/gather_callback.rb new file mode 100644 index 00000000..167475f9 --- /dev/null +++ b/lib/bandwidth-sdk/models/gather_callback.rb @@ -0,0 +1,408 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The gather event is sent after a verb is executed. Its purpose is to report the gathered digits to the calling application. + class GatherCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # (optional) The digits, letters, and/or symbols entered by the user. The string is empty if a timeout occurred before any buttons were pressed. + attr_accessor :digits + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # (optional) The digit the user pressed to end the gather. Empty string value if no terminating digit was pressed. + attr_accessor :terminating_digit + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'digits' => :'digits', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'parent_call_id' => :'parentCallId', + :'terminating_digit' => :'terminatingDigit', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'digits' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'parent_call_id' => :'String', + :'terminating_digit' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::GatherCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::GatherCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'digits') + self.digits = attributes[:'digits'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'terminating_digit') + self.terminating_digit = attributes[:'terminating_digit'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + digits == o.digits && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + parent_call_id == o.parent_call_id && + terminating_digit == o.terminating_digit && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, digits, call_url, enqueued_time, start_time, answer_time, parent_call_id, terminating_digit, transfer_caller_id, transfer_to, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/inbound_message_callback.rb b/lib/bandwidth-sdk/models/inbound_message_callback.rb new file mode 100644 index 00000000..b886eb62 --- /dev/null +++ b/lib/bandwidth-sdk/models/inbound_message_callback.rb @@ -0,0 +1,284 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Inbound Message Callback + class InboundMessageCallback + attr_accessor :time + + attr_accessor :type + + attr_accessor :to + + attr_accessor :description + + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'time' => :'time', + :'type' => :'type', + :'to' => :'to', + :'description' => :'description', + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'time' => :'Time', + :'type' => :'String', + :'to' => :'String', + :'description' => :'String', + :'message' => :'InboundMessageCallbackMessage' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InboundMessageCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InboundMessageCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @time.nil? + return false if @type.nil? + return false if @to.nil? + return false if @description.nil? + return false if @message.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + time == o.time && + type == o.type && + to == o.to && + description == o.description && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [time, type, to, description, message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/inbound_message_callback_message.rb b/lib/bandwidth-sdk/models/inbound_message_callback_message.rb new file mode 100644 index 00000000..3ae2890f --- /dev/null +++ b/lib/bandwidth-sdk/models/inbound_message_callback_message.rb @@ -0,0 +1,411 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Inbound Message Callback Message Schema + class InboundMessageCallbackMessage + attr_accessor :id + + attr_accessor :owner + + attr_accessor :application_id + + attr_accessor :time + + attr_accessor :segment_count + + attr_accessor :direction + + attr_accessor :to + + attr_accessor :from + + attr_accessor :text + + attr_accessor :tag + + attr_accessor :media + + attr_accessor :priority + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'owner' => :'owner', + :'application_id' => :'applicationId', + :'time' => :'time', + :'segment_count' => :'segmentCount', + :'direction' => :'direction', + :'to' => :'to', + :'from' => :'from', + :'text' => :'text', + :'tag' => :'tag', + :'media' => :'media', + :'priority' => :'priority' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'owner' => :'String', + :'application_id' => :'String', + :'time' => :'Time', + :'segment_count' => :'Integer', + :'direction' => :'MessageDirectionEnum', + :'to' => :'Array', + :'from' => :'String', + :'text' => :'String', + :'tag' => :'String', + :'media' => :'Array', + :'priority' => :'PriorityEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InboundMessageCallbackMessage` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InboundMessageCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + else + self.segment_count = nil + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + else + self.direction = nil + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + else + self.text = nil + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @segment_count.nil? + invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.') + end + + if @direction.nil? + invalid_properties.push('invalid value for "direction", direction cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @text.nil? + invalid_properties.push('invalid value for "text", text cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @owner.nil? + return false if @application_id.nil? + return false if @time.nil? + return false if @segment_count.nil? + return false if @direction.nil? + return false if @to.nil? + return false if @from.nil? + return false if @text.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + owner == o.owner && + application_id == o.application_id && + time == o.time && + segment_count == o.segment_count && + direction == o.direction && + to == o.to && + from == o.from && + text == o.text && + tag == o.tag && + media == o.media && + priority == o.priority + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/initiate_callback.rb b/lib/bandwidth-sdk/models/initiate_callback.rb new file mode 100644 index 00000000..af7c4d1f --- /dev/null +++ b/lib/bandwidth-sdk/models/initiate_callback.rb @@ -0,0 +1,343 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Initiate event is fired when an inbound call is received for a Telephone Number on your Account. It is sent to the URL specified in the application associated with the location (sip-peer) that the called telephone number belongs to. + class InitiateCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + attr_accessor :diversion + + attr_accessor :stir_shaken + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'start_time' => :'startTime', + :'diversion' => :'diversion', + :'stir_shaken' => :'stirShaken' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'start_time' => :'Time', + :'diversion' => :'Diversion', + :'stir_shaken' => :'StirShaken' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::InitiateCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::InitiateCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'diversion') + self.diversion = attributes[:'diversion'] + end + + if attributes.key?(:'stir_shaken') + self.stir_shaken = attributes[:'stir_shaken'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + start_time == o.start_time && + diversion == o.diversion && + stir_shaken == o.stir_shaken + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, start_time, diversion, stir_shaken].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/list_message_direction_enum.rb b/lib/bandwidth-sdk/models/list_message_direction_enum.rb new file mode 100644 index 00000000..443b9e96 --- /dev/null +++ b/lib/bandwidth-sdk/models/list_message_direction_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class ListMessageDirectionEnum + INBOUND = 'INBOUND'.freeze + OUTBOUND = 'OUTBOUND'.freeze + + def self.all_vars + @all_vars ||= [INBOUND, OUTBOUND].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ListMessageDirectionEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ListMessageDirectionEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/list_message_item.rb b/lib/bandwidth-sdk/models/list_message_item.rb new file mode 100644 index 00000000..014fb7b1 --- /dev/null +++ b/lib/bandwidth-sdk/models/list_message_item.rb @@ -0,0 +1,398 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class ListMessageItem + # The message id + attr_accessor :message_id + + # The account id associated with this message. + attr_accessor :account_id + + # The source phone number of the message. + attr_accessor :source_tn + + # The recipient phone number of the message. + attr_accessor :destination_tn + + attr_accessor :message_status + + attr_accessor :message_direction + + attr_accessor :message_type + + # The number of segments the message was sent as. + attr_accessor :segment_count + + # The numeric error code of the message. + attr_accessor :error_code + + # The ISO 8601 datetime of the message. + attr_accessor :receive_time + + # The name of the carrier. Not currently supported for MMS coming soon. + attr_accessor :carrier_name + + # The size of the message including message content and headers. + attr_accessor :message_size + + # The length of the message content. + attr_accessor :message_length + + # The number of attachments the message has. + attr_accessor :attachment_count + + # The number of recipients the message has. + attr_accessor :recipient_count + + # The campaign class of the message if it has one. + attr_accessor :campaign_class + + # The campaign ID of the message if it has one. + attr_accessor :campaign_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message_id' => :'messageId', + :'account_id' => :'accountId', + :'source_tn' => :'sourceTn', + :'destination_tn' => :'destinationTn', + :'message_status' => :'messageStatus', + :'message_direction' => :'messageDirection', + :'message_type' => :'messageType', + :'segment_count' => :'segmentCount', + :'error_code' => :'errorCode', + :'receive_time' => :'receiveTime', + :'carrier_name' => :'carrierName', + :'message_size' => :'messageSize', + :'message_length' => :'messageLength', + :'attachment_count' => :'attachmentCount', + :'recipient_count' => :'recipientCount', + :'campaign_class' => :'campaignClass', + :'campaign_id' => :'campaignId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message_id' => :'String', + :'account_id' => :'String', + :'source_tn' => :'String', + :'destination_tn' => :'String', + :'message_status' => :'MessageStatusEnum', + :'message_direction' => :'ListMessageDirectionEnum', + :'message_type' => :'MessageTypeEnum', + :'segment_count' => :'Integer', + :'error_code' => :'Integer', + :'receive_time' => :'Time', + :'carrier_name' => :'String', + :'message_size' => :'Integer', + :'message_length' => :'Integer', + :'attachment_count' => :'Integer', + :'recipient_count' => :'Integer', + :'campaign_class' => :'String', + :'campaign_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'carrier_name', + :'message_size', + :'attachment_count', + :'recipient_count', + :'campaign_class', + :'campaign_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::ListMessageItem` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::ListMessageItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message_id') + self.message_id = attributes[:'message_id'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'source_tn') + self.source_tn = attributes[:'source_tn'] + end + + if attributes.key?(:'destination_tn') + self.destination_tn = attributes[:'destination_tn'] + end + + if attributes.key?(:'message_status') + self.message_status = attributes[:'message_status'] + end + + if attributes.key?(:'message_direction') + self.message_direction = attributes[:'message_direction'] + end + + if attributes.key?(:'message_type') + self.message_type = attributes[:'message_type'] + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + end + + if attributes.key?(:'error_code') + self.error_code = attributes[:'error_code'] + end + + if attributes.key?(:'receive_time') + self.receive_time = attributes[:'receive_time'] + end + + if attributes.key?(:'carrier_name') + self.carrier_name = attributes[:'carrier_name'] + end + + if attributes.key?(:'message_size') + self.message_size = attributes[:'message_size'] + end + + if attributes.key?(:'message_length') + self.message_length = attributes[:'message_length'] + end + + if attributes.key?(:'attachment_count') + self.attachment_count = attributes[:'attachment_count'] + end + + if attributes.key?(:'recipient_count') + self.recipient_count = attributes[:'recipient_count'] + end + + if attributes.key?(:'campaign_class') + self.campaign_class = attributes[:'campaign_class'] + end + + if attributes.key?(:'campaign_id') + self.campaign_id = attributes[:'campaign_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message_id == o.message_id && + account_id == o.account_id && + source_tn == o.source_tn && + destination_tn == o.destination_tn && + message_status == o.message_status && + message_direction == o.message_direction && + message_type == o.message_type && + segment_count == o.segment_count && + error_code == o.error_code && + receive_time == o.receive_time && + carrier_name == o.carrier_name && + message_size == o.message_size && + message_length == o.message_length && + attachment_count == o.attachment_count && + recipient_count == o.recipient_count && + campaign_class == o.campaign_class && + campaign_id == o.campaign_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message_id, account_id, source_tn, destination_tn, message_status, message_direction, message_type, segment_count, error_code, receive_time, carrier_name, message_size, message_length, attachment_count, recipient_count, campaign_class, campaign_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/lookup_request.rb b/lib/bandwidth-sdk/models/lookup_request.rb new file mode 100644 index 00000000..38b5cda4 --- /dev/null +++ b/lib/bandwidth-sdk/models/lookup_request.rb @@ -0,0 +1,222 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Create phone number lookup request. + class LookupRequest + attr_accessor :tns + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tns' => :'tns' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'tns' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupRequest` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'tns') + if (value = attributes[:'tns']).is_a?(Array) + self.tns = value + end + else + self.tns = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @tns.nil? + invalid_properties.push('invalid value for "tns", tns cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @tns.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + tns == o.tns + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [tns].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/lookup_result.rb b/lib/bandwidth-sdk/models/lookup_result.rb new file mode 100644 index 00000000..159a0e92 --- /dev/null +++ b/lib/bandwidth-sdk/models/lookup_result.rb @@ -0,0 +1,294 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Carrier information results for the specified telephone number. + class LookupResult + # Our vendor's response code. + attr_accessor :response_code + + # Message associated with the response code. + attr_accessor :message + + # The telephone number in E.164 format. + attr_accessor :e_164_format + + # The formatted version of the telephone number. + attr_accessor :formatted + + # The country of the telephone number. + attr_accessor :country + + # The line type of the telephone number. + attr_accessor :line_type + + # The messaging service provider of the telephone number. + attr_accessor :line_provider + + # The first half of the Home Network Identity (HNI). + attr_accessor :mobile_country_code + + # The second half of the HNI. + attr_accessor :mobile_network_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'response_code' => :'Response Code', + :'message' => :'Message', + :'e_164_format' => :'E.164 Format', + :'formatted' => :'Formatted', + :'country' => :'Country', + :'line_type' => :'Line Type', + :'line_provider' => :'Line Provider', + :'mobile_country_code' => :'Mobile Country Code', + :'mobile_network_code' => :'Mobile Network Code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'response_code' => :'Integer', + :'message' => :'String', + :'e_164_format' => :'String', + :'formatted' => :'String', + :'country' => :'String', + :'line_type' => :'String', + :'line_provider' => :'String', + :'mobile_country_code' => :'String', + :'mobile_network_code' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupResult` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'response_code') + self.response_code = attributes[:'response_code'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + + if attributes.key?(:'e_164_format') + self.e_164_format = attributes[:'e_164_format'] + end + + if attributes.key?(:'formatted') + self.formatted = attributes[:'formatted'] + end + + if attributes.key?(:'country') + self.country = attributes[:'country'] + end + + if attributes.key?(:'line_type') + self.line_type = attributes[:'line_type'] + end + + if attributes.key?(:'line_provider') + self.line_provider = attributes[:'line_provider'] + end + + if attributes.key?(:'mobile_country_code') + self.mobile_country_code = attributes[:'mobile_country_code'] + end + + if attributes.key?(:'mobile_network_code') + self.mobile_network_code = attributes[:'mobile_network_code'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + response_code == o.response_code && + message == o.message && + e_164_format == o.e_164_format && + formatted == o.formatted && + country == o.country && + line_type == o.line_type && + line_provider == o.line_provider && + mobile_country_code == o.mobile_country_code && + mobile_network_code == o.mobile_network_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [response_code, message, e_164_format, formatted, country, line_type, line_provider, mobile_country_code, mobile_network_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/lookup_status.rb b/lib/bandwidth-sdk/models/lookup_status.rb new file mode 100644 index 00000000..4aca5818 --- /dev/null +++ b/lib/bandwidth-sdk/models/lookup_status.rb @@ -0,0 +1,269 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # If requestId exists, the result for that request is returned. See the Examples for details on the various responses that you can receive. Generally, if you see a Response Code of 0 in a result for a TN, information will be available for it. Any other Response Code will indicate no information was available for the TN. + class LookupStatus + # The requestId. + attr_accessor :request_id + + attr_accessor :status + + # The carrier information results for the specified telephone number. + attr_accessor :result + + # The telephone numbers whose lookup failed. + attr_accessor :failed_telephone_numbers + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'request_id' => :'requestId', + :'status' => :'status', + :'result' => :'result', + :'failed_telephone_numbers' => :'failedTelephoneNumbers' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'request_id' => :'String', + :'status' => :'LookupStatusEnum', + :'result' => :'Array', + :'failed_telephone_numbers' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::LookupStatus` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::LookupStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'request_id') + self.request_id = attributes[:'request_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'result') + if (value = attributes[:'result']).is_a?(Array) + self.result = value + end + end + + if attributes.key?(:'failed_telephone_numbers') + if (value = attributes[:'failed_telephone_numbers']).is_a?(Array) + self.failed_telephone_numbers = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + request_id == o.request_id && + status == o.status && + result == o.result && + failed_telephone_numbers == o.failed_telephone_numbers + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [request_id, status, result, failed_telephone_numbers].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/lookup_status_enum.rb b/lib/bandwidth-sdk/models/lookup_status_enum.rb new file mode 100644 index 00000000..d78b65a4 --- /dev/null +++ b/lib/bandwidth-sdk/models/lookup_status_enum.rb @@ -0,0 +1,42 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class LookupStatusEnum + IN_PROGRESS = 'IN_PROGRESS'.freeze + COMPLETE = 'COMPLETE'.freeze + PARTIAL_COMPLETE = 'PARTIAL_COMPLETE'.freeze + FAILED = 'FAILED'.freeze + + def self.all_vars + @all_vars ||= [IN_PROGRESS, COMPLETE, PARTIAL_COMPLETE, FAILED].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if LookupStatusEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #LookupStatusEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb b/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb new file mode 100644 index 00000000..58c31254 --- /dev/null +++ b/lib/bandwidth-sdk/models/machine_detection_complete_callback.rb @@ -0,0 +1,368 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # This event is sent to the url informed when requesting a machine detection operation. It contains the machine detection operation result, which can be: human, answering-machine, silence, timeout, error. This event is not sent when sync answering machine detection mode is chosen. + class MachineDetectionCompleteCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + attr_accessor :machine_detection_result + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'machine_detection_result' => :'machineDetectionResult' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'machine_detection_result' => :'MachineDetectionResult' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'machine_detection_result' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionCompleteCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'machine_detection_result') + self.machine_detection_result = attributes[:'machine_detection_result'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + machine_detection_result == o.machine_detection_result + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, machine_detection_result].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/machine_detection_configuration.rb b/lib/bandwidth-sdk/models/machine_detection_configuration.rb new file mode 100644 index 00000000..c7fc87ae --- /dev/null +++ b/lib/bandwidth-sdk/models/machine_detection_configuration.rb @@ -0,0 +1,493 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The machine detection request used to perform machine detection on the call. + class MachineDetectionConfiguration + attr_accessor :mode + + # The timeout used for the whole operation, in seconds. If no result is determined in this period, a callback with a `timeout` result is sent. + attr_accessor :detection_timeout + + # If no speech is detected in this period, a callback with a 'silence' result is sent. + attr_accessor :silence_timeout + + # When speech has ended and a result couldn't be determined based on the audio content itself, this value is used to determine if the speaker is a machine based on the speech duration. If the length of the speech detected is greater than or equal to this threshold, the result will be 'answering-machine'. If the length of speech detected is below this threshold, the result will be 'human'. + attr_accessor :speech_threshold + + # Amount of silence (in seconds) before assuming the callee has finished speaking. + attr_accessor :speech_end_threshold + + # When an answering machine is detected, the amount of silence (in seconds) before assuming the message has finished playing. If not provided it will default to the speechEndThreshold value. + attr_accessor :machine_speech_end_threshold + + # If set to 'true' and if an answering machine is detected, the 'answering-machine' callback will be delayed until the machine is done speaking, or an end of message tone is detected, or until the 'detectionTimeout' is exceeded. If false, the 'answering-machine' result is sent immediately. + attr_accessor :delay_result + + # The URL to send the 'machineDetectionComplete' webhook when the detection is completed. Only for 'async' mode. + attr_accessor :callback_url + + attr_accessor :callback_method + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # A fallback URL which, if provided, will be used to retry the machine detection complete webhook delivery in case `callbackUrl` fails to respond + attr_accessor :fallback_url + + attr_accessor :fallback_method + + # Basic auth username. + attr_accessor :fallback_username + + # Basic auth password. + attr_accessor :fallback_password + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'mode' => :'mode', + :'detection_timeout' => :'detectionTimeout', + :'silence_timeout' => :'silenceTimeout', + :'speech_threshold' => :'speechThreshold', + :'speech_end_threshold' => :'speechEndThreshold', + :'machine_speech_end_threshold' => :'machineSpeechEndThreshold', + :'delay_result' => :'delayResult', + :'callback_url' => :'callbackUrl', + :'callback_method' => :'callbackMethod', + :'username' => :'username', + :'password' => :'password', + :'fallback_url' => :'fallbackUrl', + :'fallback_method' => :'fallbackMethod', + :'fallback_username' => :'fallbackUsername', + :'fallback_password' => :'fallbackPassword' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'mode' => :'MachineDetectionModeEnum', + :'detection_timeout' => :'Float', + :'silence_timeout' => :'Float', + :'speech_threshold' => :'Float', + :'speech_end_threshold' => :'Float', + :'machine_speech_end_threshold' => :'Float', + :'delay_result' => :'Boolean', + :'callback_url' => :'String', + :'callback_method' => :'CallbackMethodEnum', + :'username' => :'String', + :'password' => :'String', + :'fallback_url' => :'String', + :'fallback_method' => :'CallbackMethodEnum', + :'fallback_username' => :'String', + :'fallback_password' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'detection_timeout', + :'silence_timeout', + :'speech_threshold', + :'speech_end_threshold', + :'machine_speech_end_threshold', + :'delay_result', + :'callback_url', + :'callback_method', + :'username', + :'password', + :'fallback_url', + :'fallback_method', + :'fallback_username', + :'fallback_password' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionConfiguration` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionConfiguration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'mode') + self.mode = attributes[:'mode'] + else + self.mode = 'async' + end + + if attributes.key?(:'detection_timeout') + self.detection_timeout = attributes[:'detection_timeout'] + else + self.detection_timeout = 15 + end + + if attributes.key?(:'silence_timeout') + self.silence_timeout = attributes[:'silence_timeout'] + else + self.silence_timeout = 10 + end + + if attributes.key?(:'speech_threshold') + self.speech_threshold = attributes[:'speech_threshold'] + else + self.speech_threshold = 10 + end + + if attributes.key?(:'speech_end_threshold') + self.speech_end_threshold = attributes[:'speech_end_threshold'] + else + self.speech_end_threshold = 5 + end + + if attributes.key?(:'machine_speech_end_threshold') + self.machine_speech_end_threshold = attributes[:'machine_speech_end_threshold'] + end + + if attributes.key?(:'delay_result') + self.delay_result = attributes[:'delay_result'] + else + self.delay_result = false + end + + if attributes.key?(:'callback_url') + self.callback_url = attributes[:'callback_url'] + end + + if attributes.key?(:'callback_method') + self.callback_method = attributes[:'callback_method'] + else + self.callback_method = 'POST' + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'fallback_url') + self.fallback_url = attributes[:'fallback_url'] + end + + if attributes.key?(:'fallback_method') + self.fallback_method = attributes[:'fallback_method'] + else + self.fallback_method = 'POST' + end + + if attributes.key?(:'fallback_username') + self.fallback_username = attributes[:'fallback_username'] + end + + if attributes.key?(:'fallback_password') + self.fallback_password = attributes[:'fallback_password'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@callback_url.nil? && @callback_url.to_s.length > 2048 + invalid_properties.push('invalid value for "callback_url", the character length must be smaller than or equal to 2048.') + end + + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_url.nil? && @fallback_url.to_s.length > 2048 + invalid_properties.push('invalid value for "fallback_url", the character length must be smaller than or equal to 2048.') + end + + if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@callback_url.nil? && @callback_url.to_s.length > 2048 + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@fallback_url.nil? && @fallback_url.to_s.length > 2048 + return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + true + end + + # Custom attribute writer method with validation + # @param [Object] callback_url Value to be assigned + def callback_url=(callback_url) + if !callback_url.nil? && callback_url.to_s.length > 2048 + fail ArgumentError, 'invalid value for "callback_url", the character length must be smaller than or equal to 2048.' + end + + @callback_url = callback_url + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] fallback_url Value to be assigned + def fallback_url=(fallback_url) + if !fallback_url.nil? && fallback_url.to_s.length > 2048 + fail ArgumentError, 'invalid value for "fallback_url", the character length must be smaller than or equal to 2048.' + end + + @fallback_url = fallback_url + end + + # Custom attribute writer method with validation + # @param [Object] fallback_username Value to be assigned + def fallback_username=(fallback_username) + if !fallback_username.nil? && fallback_username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.' + end + + @fallback_username = fallback_username + end + + # Custom attribute writer method with validation + # @param [Object] fallback_password Value to be assigned + def fallback_password=(fallback_password) + if !fallback_password.nil? && fallback_password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.' + end + + @fallback_password = fallback_password + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + mode == o.mode && + detection_timeout == o.detection_timeout && + silence_timeout == o.silence_timeout && + speech_threshold == o.speech_threshold && + speech_end_threshold == o.speech_end_threshold && + machine_speech_end_threshold == o.machine_speech_end_threshold && + delay_result == o.delay_result && + callback_url == o.callback_url && + callback_method == o.callback_method && + username == o.username && + password == o.password && + fallback_url == o.fallback_url && + fallback_method == o.fallback_method && + fallback_username == o.fallback_username && + fallback_password == o.fallback_password + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [mode, detection_timeout, silence_timeout, speech_threshold, speech_end_threshold, machine_speech_end_threshold, delay_result, callback_url, callback_method, username, password, fallback_url, fallback_method, fallback_username, fallback_password].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb b/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb new file mode 100644 index 00000000..3ae4845c --- /dev/null +++ b/lib/bandwidth-sdk/models/machine_detection_mode_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MachineDetectionModeEnum + SYNC = 'sync'.freeze + ASYNC = 'async'.freeze + + def self.all_vars + @all_vars ||= [SYNC, ASYNC].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MachineDetectionModeEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MachineDetectionModeEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/machine_detection_result.rb b/lib/bandwidth-sdk/models/machine_detection_result.rb new file mode 100644 index 00000000..8a2eb71b --- /dev/null +++ b/lib/bandwidth-sdk/models/machine_detection_result.rb @@ -0,0 +1,224 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # (optional) if machine detection was requested in sync mode, the result will be specified here. Possible values are the same as the async counterpart: Machine Detection Complete + class MachineDetectionResult + # Possible values are answering-machine, human, silence, timeout, or error. + attr_accessor :value + + # The amount of time it took to determine the result. + attr_accessor :duration + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'value' => :'value', + :'duration' => :'duration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'value' => :'String', + :'duration' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MachineDetectionResult` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MachineDetectionResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + value == o.value && + duration == o.duration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [value, duration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/media.rb b/lib/bandwidth-sdk/models/media.rb new file mode 100644 index 00000000..37da6588 --- /dev/null +++ b/lib/bandwidth-sdk/models/media.rb @@ -0,0 +1,230 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Media + attr_accessor :content + + attr_accessor :content_length + + attr_accessor :media_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'content' => :'content', + :'content_length' => :'contentLength', + :'media_name' => :'mediaName' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'content' => :'String', + :'content_length' => :'Integer', + :'media_name' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Media` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Media`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'content') + self.content = attributes[:'content'] + end + + if attributes.key?(:'content_length') + self.content_length = attributes[:'content_length'] + end + + if attributes.key?(:'media_name') + self.media_name = attributes[:'media_name'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + content == o.content && + content_length == o.content_length && + media_name == o.media_name + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [content, content_length, media_name].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message.rb b/lib/bandwidth-sdk/models/message.rb new file mode 100644 index 00000000..2f551d49 --- /dev/null +++ b/lib/bandwidth-sdk/models/message.rb @@ -0,0 +1,377 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Message + # The id of the message. + attr_accessor :id + + # The Bandwidth phone number associated with the message. + attr_accessor :owner + + # The application ID associated with the message. + attr_accessor :application_id + + # The datetime stamp of the message in ISO 8601 + attr_accessor :time + + # The number of segments the original message from the user is broken into before sending over to carrier networks. + attr_accessor :segment_count + + attr_accessor :direction + + # The phone number recipients of the message. + attr_accessor :to + + # The phone number the message was sent from. + attr_accessor :from + + # The list of media URLs sent in the message. Including a `filename` field in the `Content-Disposition` header of the media linked with a URL will set the displayed file name. This is a best practice to ensure that your media has a readable file name. + attr_accessor :media + + # The contents of the message. + attr_accessor :text + + # The custom string set by the user. + attr_accessor :tag + + attr_accessor :priority + + # The expiration date-time set by the user. + attr_accessor :expiration + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'owner' => :'owner', + :'application_id' => :'applicationId', + :'time' => :'time', + :'segment_count' => :'segmentCount', + :'direction' => :'direction', + :'to' => :'to', + :'from' => :'from', + :'media' => :'media', + :'text' => :'text', + :'tag' => :'tag', + :'priority' => :'priority', + :'expiration' => :'expiration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'owner' => :'String', + :'application_id' => :'String', + :'time' => :'Time', + :'segment_count' => :'Integer', + :'direction' => :'MessageDirectionEnum', + :'to' => :'Array', + :'from' => :'String', + :'media' => :'Array', + :'text' => :'String', + :'tag' => :'String', + :'priority' => :'PriorityEnum', + :'expiration' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Message` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Message`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + end + + if attributes.key?(:'expiration') + self.expiration = attributes[:'expiration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Custom attribute writer method with validation + # @param [Object] media Value to be assigned + def media=(media) + if media.nil? + fail ArgumentError, 'media cannot be nil' + end + + @media = media + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + owner == o.owner && + application_id == o.application_id && + time == o.time && + segment_count == o.segment_count && + direction == o.direction && + to == o.to && + from == o.from && + media == o.media && + text == o.text && + tag == o.tag && + priority == o.priority && + expiration == o.expiration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, owner, application_id, time, segment_count, direction, to, from, media, text, tag, priority, expiration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_delivered_callback.rb b/lib/bandwidth-sdk/models/message_delivered_callback.rb new file mode 100644 index 00000000..ef3143db --- /dev/null +++ b/lib/bandwidth-sdk/models/message_delivered_callback.rb @@ -0,0 +1,284 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Delivered Callback + class MessageDeliveredCallback + attr_accessor :time + + attr_accessor :type + + attr_accessor :to + + attr_accessor :description + + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'time' => :'time', + :'type' => :'type', + :'to' => :'to', + :'description' => :'description', + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'time' => :'Time', + :'type' => :'String', + :'to' => :'String', + :'description' => :'String', + :'message' => :'MessageDeliveredCallbackMessage' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageDeliveredCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageDeliveredCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @time.nil? + return false if @type.nil? + return false if @to.nil? + return false if @description.nil? + return false if @message.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + time == o.time && + type == o.type && + to == o.to && + description == o.description && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [time, type, to, description, message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_delivered_callback_message.rb b/lib/bandwidth-sdk/models/message_delivered_callback_message.rb new file mode 100644 index 00000000..e467706d --- /dev/null +++ b/lib/bandwidth-sdk/models/message_delivered_callback_message.rb @@ -0,0 +1,418 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Delivered Callback Message Schema + class MessageDeliveredCallbackMessage + attr_accessor :id + + attr_accessor :owner + + attr_accessor :application_id + + attr_accessor :time + + attr_accessor :segment_count + + attr_accessor :direction + + attr_accessor :to + + attr_accessor :from + + attr_accessor :text + + attr_accessor :tag + + attr_accessor :media + + attr_accessor :priority + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'owner' => :'owner', + :'application_id' => :'applicationId', + :'time' => :'time', + :'segment_count' => :'segmentCount', + :'direction' => :'direction', + :'to' => :'to', + :'from' => :'from', + :'text' => :'text', + :'tag' => :'tag', + :'media' => :'media', + :'priority' => :'priority' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'owner' => :'String', + :'application_id' => :'String', + :'time' => :'Time', + :'segment_count' => :'Integer', + :'direction' => :'MessageDirectionEnum', + :'to' => :'Array', + :'from' => :'String', + :'text' => :'String', + :'tag' => :'String', + :'media' => :'Array', + :'priority' => :'PriorityEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageDeliveredCallbackMessage` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageDeliveredCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + else + self.segment_count = nil + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + else + self.direction = nil + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + else + self.text = nil + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + else + self.tag = nil + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @segment_count.nil? + invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.') + end + + if @direction.nil? + invalid_properties.push('invalid value for "direction", direction cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @text.nil? + invalid_properties.push('invalid value for "text", text cannot be nil.') + end + + if @tag.nil? + invalid_properties.push('invalid value for "tag", tag cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @owner.nil? + return false if @application_id.nil? + return false if @time.nil? + return false if @segment_count.nil? + return false if @direction.nil? + return false if @to.nil? + return false if @from.nil? + return false if @text.nil? + return false if @tag.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + owner == o.owner && + application_id == o.application_id && + time == o.time && + segment_count == o.segment_count && + direction == o.direction && + to == o.to && + from == o.from && + text == o.text && + tag == o.tag && + media == o.media && + priority == o.priority + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_direction_enum.rb b/lib/bandwidth-sdk/models/message_direction_enum.rb new file mode 100644 index 00000000..0195a462 --- /dev/null +++ b/lib/bandwidth-sdk/models/message_direction_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessageDirectionEnum + IN = 'in'.freeze + OUT = 'out'.freeze + + def self.all_vars + @all_vars ||= [IN, OUT].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MessageDirectionEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MessageDirectionEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/message_failed_callback.rb b/lib/bandwidth-sdk/models/message_failed_callback.rb new file mode 100644 index 00000000..e1f55acf --- /dev/null +++ b/lib/bandwidth-sdk/models/message_failed_callback.rb @@ -0,0 +1,300 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Failed Callback + class MessageFailedCallback + attr_accessor :time + + attr_accessor :type + + attr_accessor :to + + attr_accessor :description + + attr_accessor :message + + attr_accessor :error_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'time' => :'time', + :'type' => :'type', + :'to' => :'to', + :'description' => :'description', + :'message' => :'message', + :'error_code' => :'errorCode' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'time' => :'Time', + :'type' => :'String', + :'to' => :'String', + :'description' => :'String', + :'message' => :'MessageFailedCallbackMessage', + :'error_code' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageFailedCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageFailedCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + + if attributes.key?(:'error_code') + self.error_code = attributes[:'error_code'] + else + self.error_code = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + if @error_code.nil? + invalid_properties.push('invalid value for "error_code", error_code cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @time.nil? + return false if @type.nil? + return false if @to.nil? + return false if @description.nil? + return false if @message.nil? + return false if @error_code.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + time == o.time && + type == o.type && + to == o.to && + description == o.description && + message == o.message && + error_code == o.error_code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [time, type, to, description, message, error_code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_failed_callback_message.rb b/lib/bandwidth-sdk/models/message_failed_callback_message.rb new file mode 100644 index 00000000..0c3ab2c7 --- /dev/null +++ b/lib/bandwidth-sdk/models/message_failed_callback_message.rb @@ -0,0 +1,425 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Failed Callback Message Schema + class MessageFailedCallbackMessage + attr_accessor :id + + attr_accessor :owner + + attr_accessor :application_id + + attr_accessor :time + + attr_accessor :segment_count + + attr_accessor :direction + + attr_accessor :to + + attr_accessor :from + + attr_accessor :text + + attr_accessor :tag + + attr_accessor :media + + attr_accessor :priority + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'owner' => :'owner', + :'application_id' => :'applicationId', + :'time' => :'time', + :'segment_count' => :'segmentCount', + :'direction' => :'direction', + :'to' => :'to', + :'from' => :'from', + :'text' => :'text', + :'tag' => :'tag', + :'media' => :'media', + :'priority' => :'priority' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'owner' => :'String', + :'application_id' => :'String', + :'time' => :'Time', + :'segment_count' => :'Integer', + :'direction' => :'MessageDirectionEnum', + :'to' => :'Array', + :'from' => :'String', + :'text' => :'String', + :'tag' => :'String', + :'media' => :'Array', + :'priority' => :'PriorityEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageFailedCallbackMessage` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageFailedCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + else + self.segment_count = nil + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + else + self.direction = nil + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + else + self.text = nil + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + else + self.tag = nil + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + else + self.priority = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @segment_count.nil? + invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.') + end + + if @direction.nil? + invalid_properties.push('invalid value for "direction", direction cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @text.nil? + invalid_properties.push('invalid value for "text", text cannot be nil.') + end + + if @tag.nil? + invalid_properties.push('invalid value for "tag", tag cannot be nil.') + end + + if @priority.nil? + invalid_properties.push('invalid value for "priority", priority cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @owner.nil? + return false if @application_id.nil? + return false if @time.nil? + return false if @segment_count.nil? + return false if @direction.nil? + return false if @to.nil? + return false if @from.nil? + return false if @text.nil? + return false if @tag.nil? + return false if @priority.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + owner == o.owner && + application_id == o.application_id && + time == o.time && + segment_count == o.segment_count && + direction == o.direction && + to == o.to && + from == o.from && + text == o.text && + tag == o.tag && + media == o.media && + priority == o.priority + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_request.rb b/lib/bandwidth-sdk/models/message_request.rb new file mode 100644 index 00000000..d72e8070 --- /dev/null +++ b/lib/bandwidth-sdk/models/message_request.rb @@ -0,0 +1,358 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessageRequest + # The ID of the Application your from number is associated with in the Bandwidth Phone Number Dashboard. + attr_accessor :application_id + + # The phone number(s) the message should be sent to in E164 format. + attr_accessor :to + + # One of your telephone numbers the message should come from in E164 format. + attr_accessor :from + + # The contents of the text message. Must be 2048 characters or less. + attr_accessor :text + + # A list of URLs to include as media attachments as part of the message. Each URL can be at most 4096 characters. + attr_accessor :media + + # A custom string that will be included in callback events of the message. Max 1024 characters. + attr_accessor :tag + + attr_accessor :priority + + # A string with the date/time value that the message will automatically expire by. This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. Must be a date-time in the future. Not supported on MMS. + attr_accessor :expiration + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'application_id' => :'applicationId', + :'to' => :'to', + :'from' => :'from', + :'text' => :'text', + :'media' => :'media', + :'tag' => :'tag', + :'priority' => :'priority', + :'expiration' => :'expiration' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'application_id' => :'String', + :'to' => :'Array', + :'from' => :'String', + :'text' => :'String', + :'media' => :'Array', + :'tag' => :'String', + :'priority' => :'PriorityEnum', + :'expiration' => :'Time' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageRequest` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + end + + if attributes.key?(:'expiration') + self.expiration = attributes[:'expiration'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if !@text.nil? && @text.to_s.length > 2048 + invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 2048.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @application_id.nil? + return false if @to.nil? + return false if @from.nil? + return false if !@text.nil? && @text.to_s.length > 2048 + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Custom attribute writer method with validation + # @param [Object] text Value to be assigned + def text=(text) + if text.nil? + fail ArgumentError, 'text cannot be nil' + end + + if text.to_s.length > 2048 + fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 2048.' + end + + @text = text + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + application_id == o.application_id && + to == o.to && + from == o.from && + text == o.text && + media == o.media && + tag == o.tag && + priority == o.priority && + expiration == o.expiration + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [application_id, to, from, text, media, tag, priority, expiration].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_sending_callback.rb b/lib/bandwidth-sdk/models/message_sending_callback.rb new file mode 100644 index 00000000..5f662c1f --- /dev/null +++ b/lib/bandwidth-sdk/models/message_sending_callback.rb @@ -0,0 +1,284 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Sending Callback + class MessageSendingCallback + attr_accessor :time + + attr_accessor :type + + attr_accessor :to + + attr_accessor :description + + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'time' => :'time', + :'type' => :'type', + :'to' => :'to', + :'description' => :'description', + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'time' => :'Time', + :'type' => :'String', + :'to' => :'String', + :'description' => :'String', + :'message' => :'MessageSendingCallbackMessage' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageSendingCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageSendingCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + else + self.message = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + if @message.nil? + invalid_properties.push('invalid value for "message", message cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @time.nil? + return false if @type.nil? + return false if @to.nil? + return false if @description.nil? + return false if @message.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + time == o.time && + type == o.type && + to == o.to && + description == o.description && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [time, type, to, description, message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_sending_callback_message.rb b/lib/bandwidth-sdk/models/message_sending_callback_message.rb new file mode 100644 index 00000000..f1a7529b --- /dev/null +++ b/lib/bandwidth-sdk/models/message_sending_callback_message.rb @@ -0,0 +1,425 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # Message Sending Callback Message Schema + class MessageSendingCallbackMessage + attr_accessor :id + + attr_accessor :owner + + attr_accessor :application_id + + attr_accessor :time + + attr_accessor :segment_count + + attr_accessor :direction + + attr_accessor :to + + attr_accessor :from + + attr_accessor :text + + attr_accessor :tag + + attr_accessor :media + + attr_accessor :priority + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'owner' => :'owner', + :'application_id' => :'applicationId', + :'time' => :'time', + :'segment_count' => :'segmentCount', + :'direction' => :'direction', + :'to' => :'to', + :'from' => :'from', + :'text' => :'text', + :'tag' => :'tag', + :'media' => :'media', + :'priority' => :'priority' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'owner' => :'String', + :'application_id' => :'String', + :'time' => :'Time', + :'segment_count' => :'Integer', + :'direction' => :'MessageDirectionEnum', + :'to' => :'Array', + :'from' => :'String', + :'text' => :'String', + :'tag' => :'String', + :'media' => :'Array', + :'priority' => :'PriorityEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessageSendingCallbackMessage` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessageSendingCallbackMessage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end + + if attributes.key?(:'owner') + self.owner = attributes[:'owner'] + else + self.owner = nil + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + else + self.application_id = nil + end + + if attributes.key?(:'time') + self.time = attributes[:'time'] + else + self.time = nil + end + + if attributes.key?(:'segment_count') + self.segment_count = attributes[:'segment_count'] + else + self.segment_count = nil + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + else + self.direction = nil + end + + if attributes.key?(:'to') + if (value = attributes[:'to']).is_a?(Array) + self.to = value + end + else + self.to = nil + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = nil + end + + if attributes.key?(:'text') + self.text = attributes[:'text'] + else + self.text = nil + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'media') + if (value = attributes[:'media']).is_a?(Array) + self.media = value + end + else + self.media = nil + end + + if attributes.key?(:'priority') + self.priority = attributes[:'priority'] + else + self.priority = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @id.nil? + invalid_properties.push('invalid value for "id", id cannot be nil.') + end + + if @owner.nil? + invalid_properties.push('invalid value for "owner", owner cannot be nil.') + end + + if @application_id.nil? + invalid_properties.push('invalid value for "application_id", application_id cannot be nil.') + end + + if @time.nil? + invalid_properties.push('invalid value for "time", time cannot be nil.') + end + + if @segment_count.nil? + invalid_properties.push('invalid value for "segment_count", segment_count cannot be nil.') + end + + if @direction.nil? + invalid_properties.push('invalid value for "direction", direction cannot be nil.') + end + + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + if @from.nil? + invalid_properties.push('invalid value for "from", from cannot be nil.') + end + + if @text.nil? + invalid_properties.push('invalid value for "text", text cannot be nil.') + end + + if @media.nil? + invalid_properties.push('invalid value for "media", media cannot be nil.') + end + + if @priority.nil? + invalid_properties.push('invalid value for "priority", priority cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @id.nil? + return false if @owner.nil? + return false if @application_id.nil? + return false if @time.nil? + return false if @segment_count.nil? + return false if @direction.nil? + return false if @to.nil? + return false if @from.nil? + return false if @text.nil? + return false if @media.nil? + return false if @priority.nil? + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + @to = to + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + owner == o.owner && + application_id == o.application_id && + time == o.time && + segment_count == o.segment_count && + direction == o.direction && + to == o.to && + from == o.from && + text == o.text && + tag == o.tag && + media == o.media && + priority == o.priority + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, owner, application_id, time, segment_count, direction, to, from, text, tag, media, priority].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/message_status_enum.rb b/lib/bandwidth-sdk/models/message_status_enum.rb new file mode 100644 index 00000000..9a426842 --- /dev/null +++ b/lib/bandwidth-sdk/models/message_status_enum.rb @@ -0,0 +1,46 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessageStatusEnum + RECEIVED = 'RECEIVED'.freeze + QUEUED = 'QUEUED'.freeze + SENDING = 'SENDING'.freeze + SENT = 'SENT'.freeze + FAILED = 'FAILED'.freeze + DELIVERED = 'DELIVERED'.freeze + ACCEPTED = 'ACCEPTED'.freeze + UNDELIVERED = 'UNDELIVERED'.freeze + + def self.all_vars + @all_vars ||= [RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, ACCEPTED, UNDELIVERED].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MessageStatusEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MessageStatusEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/message_type_enum.rb b/lib/bandwidth-sdk/models/message_type_enum.rb new file mode 100644 index 00000000..7e6e91ea --- /dev/null +++ b/lib/bandwidth-sdk/models/message_type_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessageTypeEnum + SMS = 'sms'.freeze + MMS = 'mms'.freeze + + def self.all_vars + @all_vars ||= [SMS, MMS].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MessageTypeEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MessageTypeEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/messages_list.rb b/lib/bandwidth-sdk/models/messages_list.rb new file mode 100644 index 00000000..ff7d3adf --- /dev/null +++ b/lib/bandwidth-sdk/models/messages_list.rb @@ -0,0 +1,233 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessagesList + # The total number of messages matched by the search. When the request has limitTotalCount set to true this value is limited to 10,000. + attr_accessor :total_count + + attr_accessor :page_info + + attr_accessor :messages + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total_count' => :'totalCount', + :'page_info' => :'pageInfo', + :'messages' => :'messages' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'total_count' => :'Integer', + :'page_info' => :'PageInfo', + :'messages' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagesList` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagesList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'total_count') + self.total_count = attributes[:'total_count'] + end + + if attributes.key?(:'page_info') + self.page_info = attributes[:'page_info'] + end + + if attributes.key?(:'messages') + if (value = attributes[:'messages']).is_a?(Array) + self.messages = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_count == o.total_count && + page_info == o.page_info && + messages == o.messages + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [total_count, page_info, messages].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/messaging_code_response.rb b/lib/bandwidth-sdk/models/messaging_code_response.rb new file mode 100644 index 00000000..1f469f6d --- /dev/null +++ b/lib/bandwidth-sdk/models/messaging_code_response.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessagingCodeResponse + # Messaging API Message ID. + attr_accessor :message_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message_id' => :'messageId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagingCodeResponse` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagingCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message_id') + self.message_id = attributes[:'message_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message_id == o.message_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/messaging_request_error.rb b/lib/bandwidth-sdk/models/messaging_request_error.rb new file mode 100644 index 00000000..26b738a0 --- /dev/null +++ b/lib/bandwidth-sdk/models/messaging_request_error.rb @@ -0,0 +1,235 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MessagingRequestError + attr_accessor :type + + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'description' => :'description' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'description' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MessagingRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MessagingRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + else + self.description = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @type.nil? + invalid_properties.push('invalid value for "type", type cannot be nil.') + end + + if @description.nil? + invalid_properties.push('invalid value for "description", description cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @type.nil? + return false if @description.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + description == o.description + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, description].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb b/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb new file mode 100644 index 00000000..53374d88 --- /dev/null +++ b/lib/bandwidth-sdk/models/mfa_forbidden_request_error.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MfaForbiddenRequestError + # The message containing the reason behind the request being forbidden. + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaForbiddenRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaForbiddenRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/mfa_request_error.rb b/lib/bandwidth-sdk/models/mfa_request_error.rb new file mode 100644 index 00000000..44f5706a --- /dev/null +++ b/lib/bandwidth-sdk/models/mfa_request_error.rb @@ -0,0 +1,223 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MfaRequestError + # A message describing the error with your request. + attr_accessor :error + + # The associated requestId from AWS. + attr_accessor :request_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'error' => :'error', + :'request_id' => :'requestId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'error' => :'String', + :'request_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'error') + self.error = attributes[:'error'] + end + + if attributes.key?(:'request_id') + self.request_id = attributes[:'request_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error == o.error && + request_id == o.request_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error, request_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb b/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb new file mode 100644 index 00000000..244f18f4 --- /dev/null +++ b/lib/bandwidth-sdk/models/mfa_unauthorized_request_error.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class MfaUnauthorizedRequestError + # Unauthorized + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::MfaUnauthorizedRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::MfaUnauthorizedRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/page_info.rb b/lib/bandwidth-sdk/models/page_info.rb new file mode 100644 index 00000000..655b916c --- /dev/null +++ b/lib/bandwidth-sdk/models/page_info.rb @@ -0,0 +1,243 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class PageInfo + # The link to the previous page for pagination. + attr_accessor :prev_page + + # The link to the next page for pagination. + attr_accessor :next_page + + # The isolated pagination token for the previous page. + attr_accessor :prev_page_token + + # The isolated pagination token for the next page. + attr_accessor :next_page_token + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'prev_page' => :'prevPage', + :'next_page' => :'nextPage', + :'prev_page_token' => :'prevPageToken', + :'next_page_token' => :'nextPageToken' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'prev_page' => :'String', + :'next_page' => :'String', + :'prev_page_token' => :'String', + :'next_page_token' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::PageInfo` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::PageInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'prev_page') + self.prev_page = attributes[:'prev_page'] + end + + if attributes.key?(:'next_page') + self.next_page = attributes[:'next_page'] + end + + if attributes.key?(:'prev_page_token') + self.prev_page_token = attributes[:'prev_page_token'] + end + + if attributes.key?(:'next_page_token') + self.next_page_token = attributes[:'next_page_token'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + prev_page == o.prev_page && + next_page == o.next_page && + prev_page_token == o.prev_page_token && + next_page_token == o.next_page_token + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [prev_page, next_page, prev_page_token, next_page_token].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/priority_enum.rb b/lib/bandwidth-sdk/models/priority_enum.rb new file mode 100644 index 00000000..cd7a1ba6 --- /dev/null +++ b/lib/bandwidth-sdk/models/priority_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class PriorityEnum + DEFAULT = 'default'.freeze + HIGH = 'high'.freeze + + def self.all_vars + @all_vars ||= [DEFAULT, HIGH].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if PriorityEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #PriorityEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/recording_available_callback.rb b/lib/bandwidth-sdk/models/recording_available_callback.rb new file mode 100644 index 00000000..9378ee80 --- /dev/null +++ b/lib/bandwidth-sdk/models/recording_available_callback.rb @@ -0,0 +1,447 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Recording Available event is sent after a recording has been processed. It indicates that the recording is available for download. + class RecordingAvailableCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # The unique ID of this recording + attr_accessor :recording_id + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + attr_accessor :file_format + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :channels + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :status + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'parent_call_id' => :'parentCallId', + :'recording_id' => :'recordingId', + :'media_url' => :'mediaUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'end_time' => :'endTime', + :'duration' => :'duration', + :'file_format' => :'fileFormat', + :'channels' => :'channels', + :'tag' => :'tag', + :'status' => :'status', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'parent_call_id' => :'String', + :'recording_id' => :'String', + :'media_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'end_time' => :'Time', + :'duration' => :'String', + :'file_format' => :'FileFormatEnum', + :'channels' => :'String', + :'tag' => :'String', + :'status' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url', + :'enqueued_time', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingAvailableCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'channels') + self.channels = attributes[:'channels'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + parent_call_id == o.parent_call_id && + recording_id == o.recording_id && + media_url == o.media_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + end_time == o.end_time && + duration == o.duration && + file_format == o.file_format && + channels == o.channels && + tag == o.tag && + status == o.status && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, recording_id, media_url, enqueued_time, start_time, end_time, duration, file_format, channels, tag, status, transfer_caller_id, transfer_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/recording_complete_callback.rb b/lib/bandwidth-sdk/models/recording_complete_callback.rb new file mode 100644 index 00000000..026f497f --- /dev/null +++ b/lib/bandwidth-sdk/models/recording_complete_callback.rb @@ -0,0 +1,448 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Record Complete event is sent after a verb has executed if the call is still active. The BXML returned by this callback is executed next. When the recording is available for download, a Recording Available event will be sent. + class RecordingCompleteCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # The unique ID of this recording + attr_accessor :recording_id + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + attr_accessor :file_format + + # Always `1` for conference recordings; multi-channel recordings are not supported on conferences. + attr_accessor :channels + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'parent_call_id' => :'parentCallId', + :'recording_id' => :'recordingId', + :'media_url' => :'mediaUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'end_time' => :'endTime', + :'duration' => :'duration', + :'file_format' => :'fileFormat', + :'channels' => :'channels', + :'tag' => :'tag', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'parent_call_id' => :'String', + :'recording_id' => :'String', + :'media_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'end_time' => :'Time', + :'duration' => :'String', + :'file_format' => :'FileFormatEnum', + :'channels' => :'Integer', + :'tag' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url', + :'enqueued_time', + :'answer_time', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RecordingCompleteCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RecordingCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'channels') + self.channels = attributes[:'channels'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + parent_call_id == o.parent_call_id && + recording_id == o.recording_id && + media_url == o.media_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + end_time == o.end_time && + duration == o.duration && + file_format == o.file_format && + channels == o.channels && + tag == o.tag && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, recording_id, media_url, enqueued_time, start_time, answer_time, end_time, duration, file_format, channels, tag, transfer_caller_id, transfer_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/recording_state_enum.rb b/lib/bandwidth-sdk/models/recording_state_enum.rb new file mode 100644 index 00000000..376e3503 --- /dev/null +++ b/lib/bandwidth-sdk/models/recording_state_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class RecordingStateEnum + PAUSED = 'paused'.freeze + RECORDING = 'recording'.freeze + + def self.all_vars + @all_vars ||= [PAUSED, RECORDING].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if RecordingStateEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #RecordingStateEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/redirect_callback.rb b/lib/bandwidth-sdk/models/redirect_callback.rb new file mode 100644 index 00000000..28aaf5b9 --- /dev/null +++ b/lib/bandwidth-sdk/models/redirect_callback.rb @@ -0,0 +1,388 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Redirect event is fired when a verb is executed. Its purpose is to get the next set of verbs from the calling application. + class RedirectCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'parent_call_id' => :'parentCallId', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'parent_call_id' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::RedirectCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::RedirectCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + parent_call_id == o.parent_call_id && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/redirect_method_enum.rb b/lib/bandwidth-sdk/models/redirect_method_enum.rb new file mode 100644 index 00000000..5755080d --- /dev/null +++ b/lib/bandwidth-sdk/models/redirect_method_enum.rb @@ -0,0 +1,40 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class RedirectMethodEnum + GET = 'GET'.freeze + POST = 'POST'.freeze + + def self.all_vars + @all_vars ||= [GET, POST].freeze + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if RedirectMethodEnum.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #RedirectMethodEnum" + end + end +end diff --git a/lib/bandwidth-sdk/models/stir_shaken.rb b/lib/bandwidth-sdk/models/stir_shaken.rb new file mode 100644 index 00000000..6d496cf8 --- /dev/null +++ b/lib/bandwidth-sdk/models/stir_shaken.rb @@ -0,0 +1,233 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class StirShaken + # (optional) The verification status indicating whether the verification was successful or not. Possible values are TN-Verification-Passed and TN-Verification-Failed. + attr_accessor :verstat + + # (optional) The attestation level verified by Bandwidth. Possible values are A (full), B (partial) or C (gateway). + attr_accessor :attestation_indicator + + # (optional) A unique origination identifier. + attr_accessor :originating_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'verstat' => :'verstat', + :'attestation_indicator' => :'attestationIndicator', + :'originating_id' => :'originatingId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'verstat' => :'String', + :'attestation_indicator' => :'String', + :'originating_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::StirShaken` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::StirShaken`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'verstat') + self.verstat = attributes[:'verstat'] + end + + if attributes.key?(:'attestation_indicator') + self.attestation_indicator = attributes[:'attestation_indicator'] + end + + if attributes.key?(:'originating_id') + self.originating_id = attributes[:'originating_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + verstat == o.verstat && + attestation_indicator == o.attestation_indicator && + originating_id == o.originating_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [verstat, attestation_indicator, originating_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/tag.rb b/lib/bandwidth-sdk/models/tag.rb new file mode 100644 index 00000000..889bbcf3 --- /dev/null +++ b/lib/bandwidth-sdk/models/tag.rb @@ -0,0 +1,221 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Tag + attr_accessor :key + + attr_accessor :value + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'key' => :'key', + :'value' => :'value' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'key' => :'String', + :'value' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Tag` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Tag`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'key') + self.key = attributes[:'key'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + key == o.key && + value == o.value + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [key, value].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/tn_lookup_request_error.rb b/lib/bandwidth-sdk/models/tn_lookup_request_error.rb new file mode 100644 index 00000000..c03e3106 --- /dev/null +++ b/lib/bandwidth-sdk/models/tn_lookup_request_error.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class TnLookupRequestError + # A description of what validation error occurred. + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TnLookupRequestError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TnLookupRequestError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transcribe_recording.rb b/lib/bandwidth-sdk/models/transcribe_recording.rb new file mode 100644 index 00000000..d61d09c3 --- /dev/null +++ b/lib/bandwidth-sdk/models/transcribe_recording.rb @@ -0,0 +1,360 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class TranscribeRecording + # The URL to send the [TranscriptionAvailable](/docs/voice/webhooks/transcriptionAvailable) event to. You should not include sensitive or personally-identifiable information in the callbackUrl field! Always use the proper username and password fields for authorization. + attr_accessor :callback_url + + attr_accessor :callback_method + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # This is the timeout (in seconds) to use when delivering the webhook to `callbackUrl`. Can be any numeric value (including decimals) between 1 and 25. + attr_accessor :callback_timeout + + # A boolean value to indicate that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish. + attr_accessor :detect_language + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'callback_url' => :'callbackUrl', + :'callback_method' => :'callbackMethod', + :'username' => :'username', + :'password' => :'password', + :'tag' => :'tag', + :'callback_timeout' => :'callbackTimeout', + :'detect_language' => :'detectLanguage' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'callback_url' => :'String', + :'callback_method' => :'CallbackMethodEnum', + :'username' => :'String', + :'password' => :'String', + :'tag' => :'String', + :'callback_timeout' => :'Float', + :'detect_language' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'callback_method', + :'username', + :'password', + :'tag', + :'callback_timeout', + :'detect_language' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscribeRecording` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscribeRecording`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'callback_url') + self.callback_url = attributes[:'callback_url'] + end + + if attributes.key?(:'callback_method') + self.callback_method = attributes[:'callback_method'] + else + self.callback_method = 'POST' + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'callback_timeout') + self.callback_timeout = attributes[:'callback_timeout'] + else + self.callback_timeout = 15 + end + + if attributes.key?(:'detect_language') + self.detect_language = attributes[:'detect_language'] + else + self.detect_language = false + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@callback_timeout.nil? && @callback_timeout > 25 + invalid_properties.push('invalid value for "callback_timeout", must be smaller than or equal to 25.') + end + + if !@callback_timeout.nil? && @callback_timeout < 1 + invalid_properties.push('invalid value for "callback_timeout", must be greater than or equal to 1.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@callback_timeout.nil? && @callback_timeout > 25 + return false if !@callback_timeout.nil? && @callback_timeout < 1 + true + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] callback_timeout Value to be assigned + def callback_timeout=(callback_timeout) + if !callback_timeout.nil? && callback_timeout > 25 + fail ArgumentError, 'invalid value for "callback_timeout", must be smaller than or equal to 25.' + end + + if !callback_timeout.nil? && callback_timeout < 1 + fail ArgumentError, 'invalid value for "callback_timeout", must be greater than or equal to 1.' + end + + @callback_timeout = callback_timeout + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + callback_url == o.callback_url && + callback_method == o.callback_method && + username == o.username && + password == o.password && + tag == o.tag && + callback_timeout == o.callback_timeout && + detect_language == o.detect_language + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [callback_url, callback_method, username, password, tag, callback_timeout, detect_language].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transcription.rb b/lib/bandwidth-sdk/models/transcription.rb new file mode 100644 index 00000000..1570c2e9 --- /dev/null +++ b/lib/bandwidth-sdk/models/transcription.rb @@ -0,0 +1,223 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class Transcription + # The transcribed text + attr_accessor :text + + # The confidence on the recognized content, ranging from `0.0` to `1.0` with `1.0` being the highest confidence. + attr_accessor :confidence + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'text' => :'text', + :'confidence' => :'confidence' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'text' => :'String', + :'confidence' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::Transcription` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::Transcription`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'text') + self.text = attributes[:'text'] + end + + if attributes.key?(:'confidence') + self.confidence = attributes[:'confidence'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + text == o.text && + confidence == o.confidence + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [text, confidence].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transcription_available_callback.rb b/lib/bandwidth-sdk/models/transcription_available_callback.rb new file mode 100644 index 00000000..88f4fa9d --- /dev/null +++ b/lib/bandwidth-sdk/models/transcription_available_callback.rb @@ -0,0 +1,436 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # The Transcription Available event is sent when the recording transcription is available to be downloaded. + class TranscriptionAvailableCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # The URL that can be used to download the recording. Only present if the recording is finished and may be downloaded. + attr_accessor :media_url + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # The unique ID of this recording + attr_accessor :recording_id + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # The duration of the recording in ISO-8601 format + attr_accessor :duration + + attr_accessor :file_format + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + attr_accessor :transcription + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'media_url' => :'mediaUrl', + :'parent_call_id' => :'parentCallId', + :'recording_id' => :'recordingId', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'end_time' => :'endTime', + :'duration' => :'duration', + :'file_format' => :'fileFormat', + :'tag' => :'tag', + :'transcription' => :'transcription', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'media_url' => :'String', + :'parent_call_id' => :'String', + :'recording_id' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'end_time' => :'Time', + :'duration' => :'String', + :'file_format' => :'FileFormatEnum', + :'tag' => :'String', + :'transcription' => :'Transcription', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'media_url', + :'enqueued_time', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscriptionAvailableCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscriptionAvailableCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'media_url') + self.media_url = attributes[:'media_url'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'recording_id') + self.recording_id = attributes[:'recording_id'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'duration') + self.duration = attributes[:'duration'] + end + + if attributes.key?(:'file_format') + self.file_format = attributes[:'file_format'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transcription') + self.transcription = attributes[:'transcription'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + media_url == o.media_url && + parent_call_id == o.parent_call_id && + recording_id == o.recording_id && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + end_time == o.end_time && + duration == o.duration && + file_format == o.file_format && + tag == o.tag && + transcription == o.transcription && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, media_url, parent_call_id, recording_id, enqueued_time, start_time, end_time, duration, file_format, tag, transcription, transfer_caller_id, transfer_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transcription_list.rb b/lib/bandwidth-sdk/models/transcription_list.rb new file mode 100644 index 00000000..c638a60f --- /dev/null +++ b/lib/bandwidth-sdk/models/transcription_list.rb @@ -0,0 +1,214 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class TranscriptionList + attr_accessor :transcripts + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'transcripts' => :'transcripts' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'transcripts' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscriptionList` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscriptionList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'transcripts') + if (value = attributes[:'transcripts']).is_a?(Array) + self.transcripts = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + transcripts == o.transcripts + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [transcripts].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transcription_metadata.rb b/lib/bandwidth-sdk/models/transcription_metadata.rb new file mode 100644 index 00000000..1a341e70 --- /dev/null +++ b/lib/bandwidth-sdk/models/transcription_metadata.rb @@ -0,0 +1,244 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # If the recording was transcribed, metadata about the transcription + class TranscriptionMetadata + # The unique transcription ID + attr_accessor :id + + # The current status of the process. For recording, current possible values are 'processing', 'partial', 'complete', 'deleted', and 'error'. For transcriptions, current possible values are 'none', 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and 'file-size-too-small'. Additional states may be added in the future, so your application must be tolerant of unknown values. + attr_accessor :status + + # The time that the transcription was completed + attr_accessor :completed_time + + # The URL of the [transcription](#operation/getCallTranscription) + attr_accessor :url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'status' => :'status', + :'completed_time' => :'completedTime', + :'url' => :'url' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'status' => :'String', + :'completed_time' => :'String', + :'url' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TranscriptionMetadata` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TranscriptionMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'completed_time') + self.completed_time = attributes[:'completed_time'] + end + + if attributes.key?(:'url') + self.url = attributes[:'url'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + status == o.status && + completed_time == o.completed_time && + url == o.url + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, status, completed_time, url].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transfer_answer_callback.rb b/lib/bandwidth-sdk/models/transfer_answer_callback.rb new file mode 100644 index 00000000..bdc73fea --- /dev/null +++ b/lib/bandwidth-sdk/models/transfer_answer_callback.rb @@ -0,0 +1,378 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # When processing a verb, this event is sent when a called party (B-leg) answers. The event is sent to the endpoint specified in the transferAnswerUrl attribute of the tag that answered. BXML returned by this callback will be executed for the called party only. After all BXML has been executed, the called party will be bridged to the original call. Most BXML verbs are allowed in response to a transferAnswer event, but some are not allowed. + class TransferAnswerCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferAnswerCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferAnswerCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transfer_complete_callback.rb b/lib/bandwidth-sdk/models/transfer_complete_callback.rb new file mode 100644 index 00000000..480ae847 --- /dev/null +++ b/lib/bandwidth-sdk/models/transfer_complete_callback.rb @@ -0,0 +1,410 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # This event is sent to the transferCompleteUrl of the A-leg's verb when the transferred call (B-leg) completes. In a simultaneous ringing scenario, only one B-leg succeeds and this event corresponds to that successful leg. If none of the calls were answered, the transferComplete event corresponds to one of the legs. + class TransferCompleteCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. + attr_accessor :cause + + # Text explaining the reason that caused the call to fail in case of errors. + attr_accessor :error_message + + # Bandwidth's internal id that references the error event. + attr_accessor :error_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'tag' => :'tag', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo', + :'cause' => :'cause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'tag' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String', + :'cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'error_message', + :'error_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferCompleteCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferCompleteCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + + if attributes.key?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + tag == o.tag && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to && + cause == o.cause && + error_message == o.error_message && + error_id == o.error_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, enqueued_time, start_time, answer_time, tag, transfer_caller_id, transfer_to, cause, error_message, error_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb b/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb new file mode 100644 index 00000000..a38711a6 --- /dev/null +++ b/lib/bandwidth-sdk/models/transfer_disconnect_callback.rb @@ -0,0 +1,430 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + # This event is sent to the transferDisconnectUrl of each tag when its respective call leg ends for any reason. The event is sent in the normal case, when the transferred leg is answered and later hung up, but is also sent if the new leg was never answered in the first place, if it was rejected, and if the original call leg hung up before the transferred leg. + class TransferDisconnectCallback + # The event type, value can be one of the following: answer, bridgeComplete, bridgeTargetComplete, conferenceCreated, conferenceRedirect, conferenceMemberJoin, conferenceMemberExit, conferenceCompleted, conferenceRecordingAvailable, disconnect, dtmf, gather, initiate, machineDetectionComplete, recordingComplete, recordingAvailable, redirect, transcriptionAvailable, transferAnswer, transferComplete, transferDisconnect. + attr_accessor :event_type + + # The approximate UTC date and time when the event was generated by the Bandwidth server, in ISO 8601 format. This may not be exactly the time of event execution. + attr_accessor :event_time + + # The user account associated with the call. + attr_accessor :account_id + + # The id of the application associated with the call. + attr_accessor :application_id + + # The provided identifier of the caller: can be a phone number in E.164 format (e.g. +15555555555) or one of Private, Restricted, Unavailable, or Anonymous. + attr_accessor :from + + # The phone number that received the call, in E.164 format (e.g. +15555555555). + attr_accessor :to + + attr_accessor :direction + + # The call id associated with the event. + attr_accessor :call_id + + # The URL of the call associated with the event. + attr_accessor :call_url + + # (optional) If the event is related to the B leg of a , the call id of the original call leg that executed the . Otherwise, this field will not be present. + attr_accessor :parent_call_id + + # (optional) If call queueing is enabled and this is an outbound call, time the call was queued, in ISO 8601 format. + attr_accessor :enqueued_time + + # Time the call was started, in ISO 8601 format. + attr_accessor :start_time + + # Time the call was answered, in ISO 8601 format. + attr_accessor :answer_time + + # The time that the recording ended in ISO-8601 format + attr_accessor :end_time + + # (optional) The tag specified on call creation. If no tag was specified or it was previously cleared, this field will not be present. + attr_accessor :tag + + # The phone number used as the from field of the B-leg call, in E.164 format (e.g. +15555555555) or one of Restricted, Anonymous, Private, or Unavailable. + attr_accessor :transfer_caller_id + + # The phone number used as the to field of the B-leg call, in E.164 format (e.g. +15555555555). + attr_accessor :transfer_to + + # Reason the call failed - hangup, busy, timeout, cancel, rejected, callback-error, invalid-bxml, application-error, account-limit, node-capacity-exceeded, error, or unknown. + attr_accessor :cause + + # Text explaining the reason that caused the call to fail in case of errors. + attr_accessor :error_message + + # Bandwidth's internal id that references the error event. + attr_accessor :error_id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'event_type' => :'eventType', + :'event_time' => :'eventTime', + :'account_id' => :'accountId', + :'application_id' => :'applicationId', + :'from' => :'from', + :'to' => :'to', + :'direction' => :'direction', + :'call_id' => :'callId', + :'call_url' => :'callUrl', + :'parent_call_id' => :'parentCallId', + :'enqueued_time' => :'enqueuedTime', + :'start_time' => :'startTime', + :'answer_time' => :'answerTime', + :'end_time' => :'endTime', + :'tag' => :'tag', + :'transfer_caller_id' => :'transferCallerId', + :'transfer_to' => :'transferTo', + :'cause' => :'cause', + :'error_message' => :'errorMessage', + :'error_id' => :'errorId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'event_type' => :'String', + :'event_time' => :'Time', + :'account_id' => :'String', + :'application_id' => :'String', + :'from' => :'String', + :'to' => :'String', + :'direction' => :'CallDirectionEnum', + :'call_id' => :'String', + :'call_url' => :'String', + :'parent_call_id' => :'String', + :'enqueued_time' => :'Time', + :'start_time' => :'Time', + :'answer_time' => :'Time', + :'end_time' => :'Time', + :'tag' => :'String', + :'transfer_caller_id' => :'String', + :'transfer_to' => :'String', + :'cause' => :'String', + :'error_message' => :'String', + :'error_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'enqueued_time', + :'answer_time', + :'tag', + :'error_message', + :'error_id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::TransferDisconnectCallback` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::TransferDisconnectCallback`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'event_type') + self.event_type = attributes[:'event_type'] + end + + if attributes.key?(:'event_time') + self.event_time = attributes[:'event_time'] + end + + if attributes.key?(:'account_id') + self.account_id = attributes[:'account_id'] + end + + if attributes.key?(:'application_id') + self.application_id = attributes[:'application_id'] + end + + if attributes.key?(:'from') + self.from = attributes[:'from'] + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + end + + if attributes.key?(:'direction') + self.direction = attributes[:'direction'] + end + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + + if attributes.key?(:'call_url') + self.call_url = attributes[:'call_url'] + end + + if attributes.key?(:'parent_call_id') + self.parent_call_id = attributes[:'parent_call_id'] + end + + if attributes.key?(:'enqueued_time') + self.enqueued_time = attributes[:'enqueued_time'] + end + + if attributes.key?(:'start_time') + self.start_time = attributes[:'start_time'] + end + + if attributes.key?(:'answer_time') + self.answer_time = attributes[:'answer_time'] + end + + if attributes.key?(:'end_time') + self.end_time = attributes[:'end_time'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + + if attributes.key?(:'transfer_caller_id') + self.transfer_caller_id = attributes[:'transfer_caller_id'] + end + + if attributes.key?(:'transfer_to') + self.transfer_to = attributes[:'transfer_to'] + end + + if attributes.key?(:'cause') + self.cause = attributes[:'cause'] + end + + if attributes.key?(:'error_message') + self.error_message = attributes[:'error_message'] + end + + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + event_type == o.event_type && + event_time == o.event_time && + account_id == o.account_id && + application_id == o.application_id && + from == o.from && + to == o.to && + direction == o.direction && + call_id == o.call_id && + call_url == o.call_url && + parent_call_id == o.parent_call_id && + enqueued_time == o.enqueued_time && + start_time == o.start_time && + answer_time == o.answer_time && + end_time == o.end_time && + tag == o.tag && + transfer_caller_id == o.transfer_caller_id && + transfer_to == o.transfer_to && + cause == o.cause && + error_message == o.error_message && + error_id == o.error_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [event_type, event_time, account_id, application_id, from, to, direction, call_id, call_url, parent_call_id, enqueued_time, start_time, answer_time, end_time, tag, transfer_caller_id, transfer_to, cause, error_message, error_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/update_call.rb b/lib/bandwidth-sdk/models/update_call.rb new file mode 100644 index 00000000..57b1396c --- /dev/null +++ b/lib/bandwidth-sdk/models/update_call.rb @@ -0,0 +1,413 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class UpdateCall + attr_accessor :state + + # The URL to send the [Redirect](/docs/voice/bxml/redirect) event to which will provide new BXML. Required if `state` is `active`. Not allowed if `state` is `completed`. + attr_accessor :redirect_url + + attr_accessor :redirect_method + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # A fallback url which, if provided, will be used to retry the redirect callback delivery in case `redirectUrl` fails to respond. + attr_accessor :redirect_fallback_url + + attr_accessor :redirect_fallback_method + + # Basic auth username. + attr_accessor :fallback_username + + # Basic auth password. + attr_accessor :fallback_password + + # A custom string that will be sent with this and all future callbacks unless overwritten by a future `tag` attribute or [``](/docs/voice/bxml/tag) verb, or cleared. May be cleared by setting `tag=\"\"`. Max length 256 characters. Not allowed if `state` is `completed`. + attr_accessor :tag + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'state' => :'state', + :'redirect_url' => :'redirectUrl', + :'redirect_method' => :'redirectMethod', + :'username' => :'username', + :'password' => :'password', + :'redirect_fallback_url' => :'redirectFallbackUrl', + :'redirect_fallback_method' => :'redirectFallbackMethod', + :'fallback_username' => :'fallbackUsername', + :'fallback_password' => :'fallbackPassword', + :'tag' => :'tag' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'state' => :'CallStateEnum', + :'redirect_url' => :'String', + :'redirect_method' => :'RedirectMethodEnum', + :'username' => :'String', + :'password' => :'String', + :'redirect_fallback_url' => :'String', + :'redirect_fallback_method' => :'RedirectMethodEnum', + :'fallback_username' => :'String', + :'fallback_password' => :'String', + :'tag' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'state', + :'redirect_url', + :'redirect_method', + :'username', + :'password', + :'redirect_fallback_url', + :'redirect_fallback_method', + :'fallback_username', + :'fallback_password', + :'tag' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateCall` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateCall`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'state') + self.state = attributes[:'state'] + else + self.state = 'active' + end + + if attributes.key?(:'redirect_url') + self.redirect_url = attributes[:'redirect_url'] + end + + if attributes.key?(:'redirect_method') + self.redirect_method = attributes[:'redirect_method'] + else + self.redirect_method = 'POST' + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'redirect_fallback_url') + self.redirect_fallback_url = attributes[:'redirect_fallback_url'] + end + + if attributes.key?(:'redirect_fallback_method') + self.redirect_fallback_method = attributes[:'redirect_fallback_method'] + else + self.redirect_fallback_method = 'POST' + end + + if attributes.key?(:'fallback_username') + self.fallback_username = attributes[:'fallback_username'] + end + + if attributes.key?(:'fallback_password') + self.fallback_password = attributes[:'fallback_password'] + end + + if attributes.key?(:'tag') + self.tag = attributes[:'tag'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.') + end + + if !@tag.nil? && @tag.to_s.length > 256 + invalid_properties.push('invalid value for "tag", the character length must be smaller than or equal to 256.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + return false if !@tag.nil? && @tag.to_s.length > 256 + true + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] fallback_username Value to be assigned + def fallback_username=(fallback_username) + if !fallback_username.nil? && fallback_username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.' + end + + @fallback_username = fallback_username + end + + # Custom attribute writer method with validation + # @param [Object] fallback_password Value to be assigned + def fallback_password=(fallback_password) + if !fallback_password.nil? && fallback_password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.' + end + + @fallback_password = fallback_password + end + + # Custom attribute writer method with validation + # @param [Object] tag Value to be assigned + def tag=(tag) + if !tag.nil? && tag.to_s.length > 256 + fail ArgumentError, 'invalid value for "tag", the character length must be smaller than or equal to 256.' + end + + @tag = tag + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + state == o.state && + redirect_url == o.redirect_url && + redirect_method == o.redirect_method && + username == o.username && + password == o.password && + redirect_fallback_url == o.redirect_fallback_url && + redirect_fallback_method == o.redirect_fallback_method && + fallback_username == o.fallback_username && + fallback_password == o.fallback_password && + tag == o.tag + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [state, redirect_url, redirect_method, username, password, redirect_fallback_url, redirect_fallback_method, fallback_username, fallback_password, tag].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/update_call_recording.rb b/lib/bandwidth-sdk/models/update_call_recording.rb new file mode 100644 index 00000000..06b6300b --- /dev/null +++ b/lib/bandwidth-sdk/models/update_call_recording.rb @@ -0,0 +1,241 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class UpdateCallRecording + attr_accessor :state + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'state' => :'state' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'state' => :'RecordingStateEnum' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateCallRecording` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateCallRecording`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'state') + self.state = attributes[:'state'] + else + self.state = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @state.nil? + invalid_properties.push('invalid value for "state", state cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @state.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + state == o.state + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [state].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/update_conference.rb b/lib/bandwidth-sdk/models/update_conference.rb new file mode 100644 index 00000000..c15c034b --- /dev/null +++ b/lib/bandwidth-sdk/models/update_conference.rb @@ -0,0 +1,387 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class UpdateConference + attr_accessor :status + + # The URL to send the [conferenceRedirect](/docs/voice/webhooks/conferenceRedirect) event which will provide new BXML. Not allowed if `state` is `completed`, but required if `state` is `active`. + attr_accessor :redirect_url + + attr_accessor :redirect_method + + # Basic auth username. + attr_accessor :username + + # Basic auth password. + attr_accessor :password + + # A fallback url which, if provided, will be used to retry the `conferenceRedirect` webhook delivery in case `redirectUrl` fails to respond. Not allowed if `state` is `completed`. + attr_accessor :redirect_fallback_url + + attr_accessor :redirect_fallback_method + + # Basic auth username. + attr_accessor :fallback_username + + # Basic auth password. + attr_accessor :fallback_password + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'status' => :'status', + :'redirect_url' => :'redirectUrl', + :'redirect_method' => :'redirectMethod', + :'username' => :'username', + :'password' => :'password', + :'redirect_fallback_url' => :'redirectFallbackUrl', + :'redirect_fallback_method' => :'redirectFallbackMethod', + :'fallback_username' => :'fallbackUsername', + :'fallback_password' => :'fallbackPassword' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'status' => :'ConferenceStateEnum', + :'redirect_url' => :'String', + :'redirect_method' => :'RedirectMethodEnum', + :'username' => :'String', + :'password' => :'String', + :'redirect_fallback_url' => :'String', + :'redirect_fallback_method' => :'RedirectMethodEnum', + :'fallback_username' => :'String', + :'fallback_password' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'status', + :'redirect_url', + :'redirect_method', + :'username', + :'password', + :'redirect_fallback_url', + :'redirect_fallback_method', + :'fallback_username', + :'fallback_password' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateConference` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateConference`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'status') + self.status = attributes[:'status'] + else + self.status = 'active' + end + + if attributes.key?(:'redirect_url') + self.redirect_url = attributes[:'redirect_url'] + end + + if attributes.key?(:'redirect_method') + self.redirect_method = attributes[:'redirect_method'] + else + self.redirect_method = 'POST' + end + + if attributes.key?(:'username') + self.username = attributes[:'username'] + end + + if attributes.key?(:'password') + self.password = attributes[:'password'] + end + + if attributes.key?(:'redirect_fallback_url') + self.redirect_fallback_url = attributes[:'redirect_fallback_url'] + end + + if attributes.key?(:'redirect_fallback_method') + self.redirect_fallback_method = attributes[:'redirect_fallback_method'] + else + self.redirect_fallback_method = 'POST' + end + + if attributes.key?(:'fallback_username') + self.fallback_username = attributes[:'fallback_username'] + end + + if attributes.key?(:'fallback_password') + self.fallback_password = attributes[:'fallback_password'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if !@username.nil? && @username.to_s.length > 1024 + invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 1024.') + end + + if !@password.nil? && @password.to_s.length > 1024 + invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_username", the character length must be smaller than or equal to 1024.') + end + + if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + invalid_properties.push('invalid value for "fallback_password", the character length must be smaller than or equal to 1024.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if !@username.nil? && @username.to_s.length > 1024 + return false if !@password.nil? && @password.to_s.length > 1024 + return false if !@fallback_username.nil? && @fallback_username.to_s.length > 1024 + return false if !@fallback_password.nil? && @fallback_password.to_s.length > 1024 + true + end + + # Custom attribute writer method with validation + # @param [Object] username Value to be assigned + def username=(username) + if !username.nil? && username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 1024.' + end + + @username = username + end + + # Custom attribute writer method with validation + # @param [Object] password Value to be assigned + def password=(password) + if !password.nil? && password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 1024.' + end + + @password = password + end + + # Custom attribute writer method with validation + # @param [Object] fallback_username Value to be assigned + def fallback_username=(fallback_username) + if !fallback_username.nil? && fallback_username.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_username", the character length must be smaller than or equal to 1024.' + end + + @fallback_username = fallback_username + end + + # Custom attribute writer method with validation + # @param [Object] fallback_password Value to be assigned + def fallback_password=(fallback_password) + if !fallback_password.nil? && fallback_password.to_s.length > 1024 + fail ArgumentError, 'invalid value for "fallback_password", the character length must be smaller than or equal to 1024.' + end + + @fallback_password = fallback_password + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + status == o.status && + redirect_url == o.redirect_url && + redirect_method == o.redirect_method && + username == o.username && + password == o.password && + redirect_fallback_url == o.redirect_fallback_url && + redirect_fallback_method == o.redirect_fallback_method && + fallback_username == o.fallback_username && + fallback_password == o.fallback_password + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [status, redirect_url, redirect_method, username, password, redirect_fallback_url, redirect_fallback_method, fallback_username, fallback_password].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/update_conference_member.rb b/lib/bandwidth-sdk/models/update_conference_member.rb new file mode 100644 index 00000000..59782916 --- /dev/null +++ b/lib/bandwidth-sdk/models/update_conference_member.rb @@ -0,0 +1,236 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class UpdateConferenceMember + # Whether or not this member is currently muted. Members who are muted are still able to hear other participants. Updates this member's mute status. Has no effect if omitted. + attr_accessor :mute + + # Whether or not this member is currently on hold. Members who are on hold are not able to hear or speak in the conference. Updates this member's hold status. Has no effect if omitted. + attr_accessor :hold + + # If this member had a value set for `callIdsToCoach` in its [Conference](/docs/voice/bxml/conference) verb or this list was added with a previous PUT request to modify the member, this is that list of calls. Modifies the calls that this member is coaching. Has no effect if omitted. See the documentation for the [Conference](/docs/voice/bxml/conference) verb for more details about coaching. Note that this will not add the matching calls to the conference; each call must individually execute a Conference verb to join. + attr_accessor :call_ids_to_coach + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'mute' => :'mute', + :'hold' => :'hold', + :'call_ids_to_coach' => :'callIdsToCoach' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'mute' => :'Boolean', + :'hold' => :'Boolean', + :'call_ids_to_coach' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'call_ids_to_coach' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::UpdateConferenceMember` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::UpdateConferenceMember`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'mute') + self.mute = attributes[:'mute'] + end + + if attributes.key?(:'hold') + self.hold = attributes[:'hold'] + end + + if attributes.key?(:'call_ids_to_coach') + if (value = attributes[:'call_ids_to_coach']).is_a?(Array) + self.call_ids_to_coach = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + mute == o.mute && + hold == o.hold && + call_ids_to_coach == o.call_ids_to_coach + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [mute, hold, call_ids_to_coach].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/verify_code_request.rb b/lib/bandwidth-sdk/models/verify_code_request.rb new file mode 100644 index 00000000..e2324364 --- /dev/null +++ b/lib/bandwidth-sdk/models/verify_code_request.rb @@ -0,0 +1,341 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class VerifyCodeRequest + # The phone number to send the mfa code to. + attr_accessor :to + + # An optional field to denote what scope or action the mfa code is addressing. If not supplied, defaults to \"2FA\". + attr_accessor :scope + + # The time period, in minutes, to validate the mfa code. By setting this to 3 minutes, it will mean any code generated within the last 3 minutes are still valid. The valid range for expiration time is between 0 and 15 minutes, exclusively and inclusively, respectively. + attr_accessor :expiration_time_in_minutes + + # The generated mfa code to check if valid. + attr_accessor :code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'to' => :'to', + :'scope' => :'scope', + :'expiration_time_in_minutes' => :'expirationTimeInMinutes', + :'code' => :'code' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'to' => :'String', + :'scope' => :'String', + :'expiration_time_in_minutes' => :'Float', + :'code' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerifyCodeRequest` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerifyCodeRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = nil + end + + if attributes.key?(:'scope') + self.scope = attributes[:'scope'] + end + + if attributes.key?(:'expiration_time_in_minutes') + self.expiration_time_in_minutes = attributes[:'expiration_time_in_minutes'] + else + self.expiration_time_in_minutes = nil + end + + if attributes.key?(:'code') + self.code = attributes[:'code'] + else + self.code = nil + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + if @to.nil? + invalid_properties.push('invalid value for "to", to cannot be nil.') + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if @to !~ pattern + invalid_properties.push("invalid value for \"to\", must conform to the pattern #{pattern}.") + end + + if @expiration_time_in_minutes.nil? + invalid_properties.push('invalid value for "expiration_time_in_minutes", expiration_time_in_minutes cannot be nil.') + end + + if @expiration_time_in_minutes > 15 + invalid_properties.push('invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.') + end + + if @expiration_time_in_minutes < 1 + invalid_properties.push('invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.') + end + + if @code.nil? + invalid_properties.push('invalid value for "code", code cannot be nil.') + end + + if @code.to_s.length > 8 + invalid_properties.push('invalid value for "code", the character length must be smaller than or equal to 8.') + end + + if @code.to_s.length < 4 + invalid_properties.push('invalid value for "code", the character length must be great than or equal to 4.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + return false if @to.nil? + return false if @to !~ Regexp.new(/^\+[1-9]\d{1,14}$/) + return false if @expiration_time_in_minutes.nil? + return false if @expiration_time_in_minutes > 15 + return false if @expiration_time_in_minutes < 1 + return false if @code.nil? + return false if @code.to_s.length > 8 + return false if @code.to_s.length < 4 + true + end + + # Custom attribute writer method with validation + # @param [Object] to Value to be assigned + def to=(to) + if to.nil? + fail ArgumentError, 'to cannot be nil' + end + + pattern = Regexp.new(/^\+[1-9]\d{1,14}$/) + if to !~ pattern + fail ArgumentError, "invalid value for \"to\", must conform to the pattern #{pattern}." + end + + @to = to + end + + # Custom attribute writer method with validation + # @param [Object] expiration_time_in_minutes Value to be assigned + def expiration_time_in_minutes=(expiration_time_in_minutes) + if expiration_time_in_minutes.nil? + fail ArgumentError, 'expiration_time_in_minutes cannot be nil' + end + + if expiration_time_in_minutes > 15 + fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.' + end + + if expiration_time_in_minutes < 1 + fail ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.' + end + + @expiration_time_in_minutes = expiration_time_in_minutes + end + + # Custom attribute writer method with validation + # @param [Object] code Value to be assigned + def code=(code) + if code.nil? + fail ArgumentError, 'code cannot be nil' + end + + if code.to_s.length > 8 + fail ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.' + end + + if code.to_s.length < 4 + fail ArgumentError, 'invalid value for "code", the character length must be great than or equal to 4.' + end + + @code = code + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + to == o.to && + scope == o.scope && + expiration_time_in_minutes == o.expiration_time_in_minutes && + code == o.code + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [to, scope, expiration_time_in_minutes, code].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/verify_code_response.rb b/lib/bandwidth-sdk/models/verify_code_response.rb new file mode 100644 index 00000000..5ab58b75 --- /dev/null +++ b/lib/bandwidth-sdk/models/verify_code_response.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class VerifyCodeResponse + # Whether or not the supplied code is valid. + attr_accessor :valid + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'valid' => :'valid' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'valid' => :'Boolean' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VerifyCodeResponse` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VerifyCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'valid') + self.valid = attributes[:'valid'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + valid == o.valid + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [valid].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/voice_api_error.rb b/lib/bandwidth-sdk/models/voice_api_error.rb new file mode 100644 index 00000000..f577959b --- /dev/null +++ b/lib/bandwidth-sdk/models/voice_api_error.rb @@ -0,0 +1,231 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class VoiceApiError + attr_accessor :type + + attr_accessor :description + + attr_accessor :id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'description' => :'description', + :'id' => :'id' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'description' => :'String', + :'id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + :'id' + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VoiceApiError` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VoiceApiError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + description == o.description && + id == o.id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, description, id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/models/voice_code_response.rb b/lib/bandwidth-sdk/models/voice_code_response.rb new file mode 100644 index 00000000..7f6c07c4 --- /dev/null +++ b/lib/bandwidth-sdk/models/voice_code_response.rb @@ -0,0 +1,213 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +require 'date' +require 'time' + +module Bandwidth + class VoiceCodeResponse + # Programmable Voice API Call ID. + attr_accessor :call_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'call_id' => :'callId' + } + end + + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + def self.openapi_types + { + :'call_id' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, 'The input argument (attributes) must be a hash in `Bandwidth::VoiceCodeResponse` initialize method' + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Bandwidth::VoiceCodeResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'call_id') + self.call_id = attributes[:'call_id'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + warn '[DEPRECATED] the `valid?` method is obsolete' + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + call_id == o.call_id + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [call_id].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end + end + new(transformed_hash) + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = Bandwidth.const_get(type) + klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/bandwidth-sdk/version.rb b/lib/bandwidth-sdk/version.rb new file mode 100644 index 00000000..baeb051c --- /dev/null +++ b/lib/bandwidth-sdk/version.rb @@ -0,0 +1,15 @@ +=begin +#Bandwidth + +#Bandwidth's Communication APIs + +The version of the OpenAPI document: 1.0.0 +Contact: letstalk@bandwidth.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 7.0.0 + +=end + +module Bandwidth + VERSION = '11.0.0' +end diff --git a/lib/bandwidth.rb b/lib/bandwidth.rb deleted file mode 100644 index d461d13c..00000000 --- a/lib/bandwidth.rb +++ /dev/null @@ -1,72 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -require 'json' -require 'faraday' -require 'logging' - -require_relative 'bandwidth/api_helper' -require_relative 'bandwidth/client' - -# Utilities -require_relative 'bandwidth/utilities/file_wrapper' -require_relative 'bandwidth/utilities/date_time_helper' - -# Http -require_relative 'bandwidth/http/api_response' -require_relative 'bandwidth/http/http_call_back' -require_relative 'bandwidth/http/http_client' -require_relative 'bandwidth/http/faraday_client' -require_relative 'bandwidth/http/http_method_enum' -require_relative 'bandwidth/http/http_request' -require_relative 'bandwidth/http/http_response' - -# Models -require_relative 'bandwidth/models/base_model' - -# Exceptions -require_relative 'bandwidth/exceptions/api_exception' - -require_relative 'bandwidth/configuration' - -# Namespaces -require_relative 'bandwidth/messaging_lib/messaging' -require_relative 'bandwidth/http/auth/messaging_basic_auth' -require_relative 'bandwidth/multi_factor_auth_lib/multi_factor_auth' -require_relative 'bandwidth/http/auth/multi_factor_auth_basic_auth' -require_relative 'bandwidth/phone_number_lookup_lib/phone_number_lookup' -require_relative 'bandwidth/http/auth/phone_number_lookup_basic_auth' -require_relative 'bandwidth/voice_lib/voice' -require_relative 'bandwidth/http/auth/voice_basic_auth' -require_relative 'bandwidth/web_rtc_lib/web_rtc' -require_relative 'bandwidth/http/auth/web_rtc_basic_auth' -require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb' - -# External Files -require_relative 'bandwidth/voice_lib/bxml/response.rb' -require_relative 'bandwidth/voice_lib/bxml/bxml.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/bridge.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/conference.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/forward.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/gather.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/hangup.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/pause.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/pause_recording.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/phone_number.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/play_audio.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/record.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/redirect.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/resume_recording.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/ring.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/send_dtmf.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/speak_sentence.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/start_gather.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/start_recording.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/stop_gather.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/stop_recording.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/transfer.rb' -require_relative 'bandwidth/voice_lib/bxml/verbs/xml_verb.rb' -require_relative 'bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb' diff --git a/lib/bandwidth/api_helper.rb b/lib/bandwidth/api_helper.rb deleted file mode 100644 index 8020e453..00000000 --- a/lib/bandwidth/api_helper.rb +++ /dev/null @@ -1,280 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # API utility class - class APIHelper - # Serializes an array parameter (creates key value pairs). - # @param [String] The name of the parameter. - # @param [Array] The value of the parameter. - # @param [String] The format of the serialization. - def self.serialize_array(key, array, formatting: 'indexed') - tuples = [] - - case formatting - when 'unindexed' - tuples += array.map { |element| ["#{key}[]", element] } - when 'indexed' - tuples += array.map.with_index do |element, index| - ["#{key}[#{index}]", element] - end - when 'plain' - tuples += array.map { |element| [key, element] } - else - raise ArgumentError, 'Invalid format provided.' - end - tuples - end - - # Replaces template parameters in the given url. - # @param [String] The query string builder to replace the template - # parameters. - # @param [Hash] The parameters to replace in the url. - def self.append_url_with_template_parameters(query_builder, parameters) - # perform parameter validation - unless query_builder.instance_of? String - raise ArgumentError, 'Given value for parameter \"query_builder\" is - invalid.' - end - - # Return if there are no parameters to replace. - return query_builder if parameters.nil? - - parameters.each do |key, val| - if val.nil? - replace_value = '' - elsif val['value'].instance_of? Array - if val['encode'] == true - val['value'].map! { |element| CGI.escape(element.to_s) } - else - val['value'].map!(&:to_s) - end - replace_value = val['value'].join('/') - else - replace_value = if val['encode'] == true - CGI.escape(val['value'].to_s) - else - val['value'].to_s - end - end - - # Find the template parameter and replace it with its value. - query_builder = query_builder.gsub("{#{key}}", replace_value) - end - query_builder - end - - # Appends the given set of parameters to the given query string. - # @param [String] The query string builder to add the query parameters to. - # @param [Hash] The parameters to append. - def self.append_url_with_query_parameters(query_builder, parameters) - # Perform parameter validation. - unless query_builder.instance_of? String - raise ArgumentError, 'Given value for parameter \"query_builder\" - is invalid.' - end - - # Return if there are no parameters to replace. - return query_builder if parameters.nil? - - array_serialization = 'indexed' - - parameters.each do |key, value| - seperator = query_builder.include?('?') ? '&' : '?' - unless value.nil? - if value.instance_of? Array - value.compact! - query_builder += case array_serialization - when 'csv' - "#{seperator}#{key}=#{value.map do |element| - CGI.escape(element.to_s) - end.join(',')}" - when 'psv' - "#{seperator}#{key}=#{value.map do |element| - CGI.escape(element.to_s) - end.join('|')}" - when 'tsv' - "#{seperator}#{key}=#{value.map do |element| - CGI.escape(element.to_s) - end.join("\t")}" - else - "#{seperator}#{APIHelper.serialize_array( - key, value, formatting: array_serialization - ).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" } - .join('&')}" - end - else - query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}" - end - end - end - query_builder - end - - # Validates and processes the given Url. - # @param [String] The given Url to process. - # @return [String] Pre-processed Url as string. - def self.clean_url(url) - # Perform parameter validation. - raise ArgumentError, 'Invalid Url.' unless url.instance_of? String - - # Ensure that the urls are absolute. - matches = url.match(%r{^(https?://[^/]+)}) - raise ArgumentError, 'Invalid Url format.' if matches.nil? - - # Get the http protocol match. - protocol = matches[1] - - # Check if parameters exist. - index = url.index('?') - - # Remove redundant forward slashes. - query = url[protocol.length...(!index.nil? ? index : url.length)] - query.gsub!(%r{//+}, '/') - - # Get the parameters. - parameters = !index.nil? ? url[url.index('?')...url.length] : '' - - # Return processed url. - protocol + query + parameters - end - - # Parses JSON string. - # @param [String] A JSON string. - def self.json_deserialize(json) - return {} if json.nil? || json.empty? - JSON.parse(json) - rescue StandardError - raise TypeError, 'Server responded with invalid JSON.' - end - - # Removes elements with empty values from a hash. - # @param [Hash] The hash to clean. - def self.clean_hash(hash) - hash.delete_if { |_key, value| value.to_s.strip.empty? } - end - - # Form encodes a hash of parameters. - # @param [Hash] The hash of parameters to encode. - # @return [Hash] A hash with the same parameters form encoded. - def self.form_encode_parameters(form_parameters) - array_serialization = 'indexed' - encoded = {} - form_parameters.each do |key, value| - encoded.merge!(APIHelper.form_encode(value, key, formatting: - array_serialization)) - end - encoded - end - - def self.custom_merge(a, b) - x = {} - a.each do |key, value_a| - b.each do |k, value_b| - next unless key == k - - x[k] = [] - if value_a.instance_of? Array - value_a.each do |v| - x[k].push(v) - end - else - x[k].push(value_a) - end - if value_b.instance_of? Array - value_b.each do |v| - x[k].push(v) - end - else - x[k].push(value_b) - end - a.delete(k) - b.delete(k) - end - end - x.merge!(a) - x.merge!(b) - x - end - - # Form encodes an object. - # @param [Dynamic] An object to form encode. - # @param [String] The name of the object. - # @return [Hash] A form encoded representation of the object in the form - # of a hash. - def self.form_encode(obj, instance_name, formatting: 'indexed') - retval = {} - - serializable_types = [String, Numeric, TrueClass, - FalseClass, Date, DateTime] - - # If this is a structure, resolve it's field names. - obj = obj.to_hash if obj.is_a? BaseModel - - # Create a form encoded hash for this object. - if obj.nil? - nil - elsif obj.instance_of? Array - if formatting == 'indexed' - obj.each_with_index do |value, index| - retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]")) - end - elsif serializable_types.map { |x| obj[0].is_a? x }.any? - obj.each do |value| - abc = if formatting == 'unindexed' - APIHelper.form_encode(value, "#{instance_name}[]", - formatting: formatting) - else - APIHelper.form_encode(value, instance_name, - formatting: formatting) - end - retval = APIHelper.custom_merge(retval, abc) - end - else - obj.each_with_index do |value, index| - retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]", - formatting: formatting)) - end - end - elsif obj.instance_of? Hash - obj.each do |key, value| - retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{key}]", - formatting: formatting)) - end - elsif obj.instance_of? File - retval[instance_name] = UploadIO.new( - obj, 'application/octet-stream', File.basename(obj.path) - ) - else - retval[instance_name] = obj - end - retval - end - - # Retrieves a field from a Hash/Array based on an Array of keys/indexes - # @param [Hash, Array] The hash to extract data from - # @param [Array] The keys/indexes to use - # @return [Object] The extracted value - def self.map_response(obj, keys) - val = obj - begin - keys.each do |key| - val = if val.is_a? Array - if key.to_i.to_s == key - val[key.to_i] - else - val = nil - end - else - val.fetch(key.to_sym) - end - end - rescue NoMethodError, TypeError, IndexError - val = nil - end - val - end - end -end diff --git a/lib/bandwidth/client.rb b/lib/bandwidth/client.rb deleted file mode 100644 index da27ae0f..00000000 --- a/lib/bandwidth/client.rb +++ /dev/null @@ -1,75 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # bandwidth client class. - class Client - attr_reader :config - # Access to messaging_client controller. - # @return [Messaging::Client] Returns the client instance. - def messaging_client - @messaging_client ||= Messaging::Client.new(config: config) - end - # Access to multi_factor_auth_client controller. - # @return [MultiFactorAuth::Client] Returns the client instance. - def multi_factor_auth_client - @multi_factor_auth_client ||= MultiFactorAuth::Client.new(config: config) - end - # Access to phone_number_lookup_client controller. - # @return [PhoneNumberLookup::Client] Returns the client instance. - def phone_number_lookup_client - @phone_number_lookup_client ||= PhoneNumberLookup::Client.new(config: config) - end - # Access to voice_client controller. - # @return [Voice::Client] Returns the client instance. - def voice_client - @voice_client ||= Voice::Client.new(config: config) - end - # Access to web_rtc_client controller. - # @return [WebRtc::Client] Returns the client instance. - def web_rtc_client - @web_rtc_client ||= WebRtc::Client.new(config: config) - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end diff --git a/lib/bandwidth/configuration.rb b/lib/bandwidth/configuration.rb deleted file mode 100644 index 5c7aef48..00000000 --- a/lib/bandwidth/configuration.rb +++ /dev/null @@ -1,209 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # An enum for SDK environments. - class Environment - ENVIRONMENT = [ - PRODUCTION = 'production'.freeze, - CUSTOM = 'custom'.freeze - ].freeze - end - - # An enum for API servers. - class Server - SERVER = [ - DEFAULT = 'default'.freeze, - MESSAGINGDEFAULT = 'MessagingDefault'.freeze, - MULTIFACTORAUTHDEFAULT = 'MultiFactorAuthDefault'.freeze, - PHONENUMBERLOOKUPDEFAULT = 'PhoneNumberLookupDefault'.freeze, - VOICEDEFAULT = 'VoiceDefault'.freeze, - WEBRTCDEFAULT = 'WebRtcDefault'.freeze - ].freeze - end - - # All configuration including auth info and base URI for the API access - # are configured in this class. - class Configuration - # The attribute readers for properties. - attr_reader :http_client, :timeout, :max_retries, :retry_interval, :backoff_factor, - :retry_statuses, :retry_methods, :environment, :base_url, - :messaging_basic_auth_user_name, :messaging_basic_auth_password, - :multi_factor_auth_basic_auth_user_name, :multi_factor_auth_basic_auth_password, - :phone_number_lookup_basic_auth_user_name, :phone_number_lookup_basic_auth_password, - :voice_basic_auth_user_name, :voice_basic_auth_password, - :web_rtc_basic_auth_user_name, :web_rtc_basic_auth_password - - class << self - attr_reader :environments - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace') - # The value to use for connection timeout - @timeout = timeout - - # The number of times to retry an endpoint call if it fails - @max_retries = max_retries - - # Pause in seconds between retries - @retry_interval = retry_interval - - # The amount to multiply each successive retry's interval amount - # by in order to provide backoff - @backoff_factor = backoff_factor - - # A list of HTTP statuses to retry - @retry_statuses = retry_statuses - - # A list of HTTP methods to retry - @retry_methods = retry_methods - - # Current API environment - @environment = String(environment) - - # baseUrl value - @base_url = base_url - - # The username to use with basic authentication - @messaging_basic_auth_user_name = messaging_basic_auth_user_name - - # The password to use with basic authentication - @messaging_basic_auth_password = messaging_basic_auth_password - - # The username to use with basic authentication - @multi_factor_auth_basic_auth_user_name = multi_factor_auth_basic_auth_user_name - - # The password to use with basic authentication - @multi_factor_auth_basic_auth_password = multi_factor_auth_basic_auth_password - - # The username to use with basic authentication - @phone_number_lookup_basic_auth_user_name = phone_number_lookup_basic_auth_user_name - - # The password to use with basic authentication - @phone_number_lookup_basic_auth_password = phone_number_lookup_basic_auth_password - - # The username to use with basic authentication - @voice_basic_auth_user_name = voice_basic_auth_user_name - - # The password to use with basic authentication - @voice_basic_auth_password = voice_basic_auth_password - - # The username to use with basic authentication - @web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name - - # The password to use with basic authentication - @web_rtc_basic_auth_password = web_rtc_basic_auth_password - - # The Http Client to use for making requests. - @http_client = create_http_client - end - - def clone_with(timeout: nil, max_retries: nil, retry_interval: nil, - backoff_factor: nil, retry_statuses: nil, retry_methods: nil, - environment: nil, base_url: nil, - messaging_basic_auth_user_name: nil, - messaging_basic_auth_password: nil, - multi_factor_auth_basic_auth_user_name: nil, - multi_factor_auth_basic_auth_password: nil, - phone_number_lookup_basic_auth_user_name: nil, - phone_number_lookup_basic_auth_password: nil, - voice_basic_auth_user_name: nil, - voice_basic_auth_password: nil, - web_rtc_basic_auth_user_name: nil, - web_rtc_basic_auth_password: nil) - timeout ||= self.timeout - max_retries ||= self.max_retries - retry_interval ||= self.retry_interval - backoff_factor ||= self.backoff_factor - retry_statuses ||= self.retry_statuses - retry_methods ||= self.retry_methods - environment ||= self.environment - base_url ||= self.base_url - messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name - messaging_basic_auth_password ||= self.messaging_basic_auth_password - multi_factor_auth_basic_auth_user_name ||= self.multi_factor_auth_basic_auth_user_name - multi_factor_auth_basic_auth_password ||= self.multi_factor_auth_basic_auth_password - phone_number_lookup_basic_auth_user_name ||= self.phone_number_lookup_basic_auth_user_name - phone_number_lookup_basic_auth_password ||= self.phone_number_lookup_basic_auth_password - voice_basic_auth_user_name ||= self.voice_basic_auth_user_name - voice_basic_auth_password ||= self.voice_basic_auth_password - web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name - web_rtc_basic_auth_password ||= self.web_rtc_basic_auth_password - - Configuration.new( - timeout: timeout, max_retries: max_retries, - retry_interval: retry_interval, backoff_factor: backoff_factor, - retry_statuses: retry_statuses, retry_methods: retry_methods, - environment: environment, base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password - ) - end - - def create_http_client - FaradayClient.new(timeout: timeout, max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods) - end - - # All the environments the SDK can run in. - ENVIRONMENTS = { - Environment::PRODUCTION => { - Server::DEFAULT => 'api.bandwidth.com', - Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2', - Server::MULTIFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1', - Server::PHONENUMBERLOOKUPDEFAULT => 'https://numbers.bandwidth.com/api/v1', - Server::VOICEDEFAULT => 'https://voice.bandwidth.com', - Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1' - }, - Environment::CUSTOM => { - Server::DEFAULT => '{base_url}', - Server::MESSAGINGDEFAULT => '{base_url}', - Server::MULTIFACTORAUTHDEFAULT => '{base_url}', - Server::PHONENUMBERLOOKUPDEFAULT => '{base_url}', - Server::VOICEDEFAULT => '{base_url}', - Server::WEBRTCDEFAULT => '{base_url}' - } - }.freeze - - # Generates the appropriate base URI for the environment and the server. - # @param [Configuration::Server] The server enum for which the base URI is - # required. - # @return [String] The base URI. - def get_base_uri(server = Server::DEFAULT) - parameters = { - 'base_url' => { 'value' => base_url, 'encode' => false } - } - APIHelper.append_url_with_template_parameters( - ENVIRONMENTS[environment][server], parameters - ) - end - end -end diff --git a/lib/bandwidth/exceptions/api_exception.rb b/lib/bandwidth/exceptions/api_exception.rb deleted file mode 100644 index 47c08f34..00000000 --- a/lib/bandwidth/exceptions/api_exception.rb +++ /dev/null @@ -1,20 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Class for exceptions when there is a network error, status code error, etc. - class APIException < StandardError - attr_reader :response, :response_code - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason) - @response = response - @response_code = response.status_code - end - end -end diff --git a/lib/bandwidth/http/api_response.rb b/lib/bandwidth/http/api_response.rb deleted file mode 100644 index caf58c5e..00000000 --- a/lib/bandwidth/http/api_response.rb +++ /dev/null @@ -1,38 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Http response received. - class ApiResponse - attr_reader(:status_code, :reason_phrase, :headers, :raw_body, :request, - :data, :errors) - - # The constructor - # @param [HttpResponse] The original, raw response from the api. - # @param [Object] The data field specified for the response. - # @param [Array] Any errors returned by the server. - def initialize(http_response, - data: nil, - errors: nil) - @status_code = http_response.status_code - @reason_phrase = http_response.reason_phrase - @headers = http_response.headers - @raw_body = http_response.raw_body - @request = http_response.request - @data = data - @errors = errors - end - - # returns true if status_code is between 200-300 - def success? - status_code >= 200 && status_code < 300 - end - - # returns true if status_code is between 400-600 - def error? - status_code >= 400 && status_code < 600 - end - end -end diff --git a/lib/bandwidth/http/auth/messaging_basic_auth.rb b/lib/bandwidth/http/auth/messaging_basic_auth.rb deleted file mode 100644 index b5da20c1..00000000 --- a/lib/bandwidth/http/auth/messaging_basic_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'base64' - -module Bandwidth - # Utility class for basic authorization. - class MessagingBasicAuth - # Add basic authentication to the request. - # @param [HttpRequest] The HttpRequest object to which authentication will - # be added. - def self.apply(config, http_request) - username = config.messaging_basic_auth_user_name - password = config.messaging_basic_auth_password - value = Base64.strict_encode64("#{username}:#{password}") - header_value = "Basic #{value}" - http_request.headers['Authorization'] = header_value - end - end -end diff --git a/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb b/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb deleted file mode 100644 index 0498e099..00000000 --- a/lib/bandwidth/http/auth/multi_factor_auth_basic_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'base64' - -module Bandwidth - # Utility class for basic authorization. - class MultiFactorAuthBasicAuth - # Add basic authentication to the request. - # @param [HttpRequest] The HttpRequest object to which authentication will - # be added. - def self.apply(config, http_request) - username = config.multi_factor_auth_basic_auth_user_name - password = config.multi_factor_auth_basic_auth_password - value = Base64.strict_encode64("#{username}:#{password}") - header_value = "Basic #{value}" - http_request.headers['Authorization'] = header_value - end - end -end diff --git a/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb b/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb deleted file mode 100644 index a06d14e8..00000000 --- a/lib/bandwidth/http/auth/phone_number_lookup_basic_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'base64' - -module Bandwidth - # Utility class for basic authorization. - class PhoneNumberLookupBasicAuth - # Add basic authentication to the request. - # @param [HttpRequest] The HttpRequest object to which authentication will - # be added. - def self.apply(config, http_request) - username = config.phone_number_lookup_basic_auth_user_name - password = config.phone_number_lookup_basic_auth_password - value = Base64.strict_encode64("#{username}:#{password}") - header_value = "Basic #{value}" - http_request.headers['Authorization'] = header_value - end - end -end diff --git a/lib/bandwidth/http/auth/voice_basic_auth.rb b/lib/bandwidth/http/auth/voice_basic_auth.rb deleted file mode 100644 index e1cd3caa..00000000 --- a/lib/bandwidth/http/auth/voice_basic_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'base64' - -module Bandwidth - # Utility class for basic authorization. - class VoiceBasicAuth - # Add basic authentication to the request. - # @param [HttpRequest] The HttpRequest object to which authentication will - # be added. - def self.apply(config, http_request) - username = config.voice_basic_auth_user_name - password = config.voice_basic_auth_password - value = Base64.strict_encode64("#{username}:#{password}") - header_value = "Basic #{value}" - http_request.headers['Authorization'] = header_value - end - end -end diff --git a/lib/bandwidth/http/auth/web_rtc_basic_auth.rb b/lib/bandwidth/http/auth/web_rtc_basic_auth.rb deleted file mode 100644 index b90dbe62..00000000 --- a/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'base64' - -module Bandwidth - # Utility class for basic authorization. - class WebRtcBasicAuth - # Add basic authentication to the request. - # @param [HttpRequest] The HttpRequest object to which authentication will - # be added. - def self.apply(config, http_request) - username = config.web_rtc_basic_auth_user_name - password = config.web_rtc_basic_auth_password - value = Base64.strict_encode64("#{username}:#{password}") - header_value = "Basic #{value}" - http_request.headers['Authorization'] = header_value - end - end -end diff --git a/lib/bandwidth/http/faraday_client.rb b/lib/bandwidth/http/faraday_client.rb deleted file mode 100644 index 7b9193aa..00000000 --- a/lib/bandwidth/http/faraday_client.rb +++ /dev/null @@ -1,70 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'faraday/follow_redirects' -require 'faraday/http_cache' -require 'faraday/multipart' -require 'faraday/retry' - -module Bandwidth - # An implementation of HttpClient. - class FaradayClient < HttpClient - # The constructor. - def initialize(timeout:, max_retries:, retry_interval:, - backoff_factor:, retry_statuses:, retry_methods:, - cache: false, verify: true) - @connection = Faraday.new do |faraday| - faraday.use Faraday::HttpCache, serializer: Marshal if cache - faraday.use Faraday::FollowRedirects::Middleware - faraday.request :multipart - faraday.request :url_encoded - faraday.ssl[:verify] = verify - faraday.request :retry, max: max_retries, interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - methods: retry_methods - faraday.adapter Faraday.default_adapter - faraday.options[:params_encoder] = Faraday::FlatParamsEncoder - faraday.options[:timeout] = timeout if timeout.positive? - end - end - - # Method overridden from HttpClient. - def execute_as_string(http_request) - response = @connection.send( - http_request.http_method.downcase, - http_request.query_url - ) do |request| - request.headers = http_request.headers - unless http_request.http_method == HttpMethodEnum::GET && - http_request.parameters.empty? - request.body = http_request.parameters - end - end - convert_response(response, http_request) - end - - # Method overridden from HttpClient. - def execute_as_binary(http_request) - response = @connection.send( - http_request.http_method.downcase, - http_request.query_url - ) do |request| - request.headers = http_request.headers - unless http_request.http_method == HttpMethodEnum::GET && - http_request.parameters.empty? - request.body = http_request.parameters - end - end - convert_response(response, http_request) - end - - # Method overridden from HttpClient. - def convert_response(response, http_request) - HttpResponse.new(response.status, response.reason_phrase, - response.headers, response.body, http_request) - end - end -end diff --git a/lib/bandwidth/http/http_call_back.rb b/lib/bandwidth/http/http_call_back.rb deleted file mode 100644 index 0777c697..00000000 --- a/lib/bandwidth/http/http_call_back.rb +++ /dev/null @@ -1,24 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # HttpCallBack allows defining callables for pre and post API calls. - class HttpCallBack - # A controller will call this method before making an HTTP Request. - # @param [HttpRequest] The HttpRequest object which the HttpClient - # will execute. - def on_before_request(_http_request) - raise NotImplementedError, 'This method needs - to be implemented in a child class.' - end - - # A controller will call this method after making an HTTP Request. - # @param [HttpResponse] The HttpReponse of the API call. - def on_after_response(_http_response) - raise NotImplementedError, 'This method needs - to be implemented in a child class.' - end - end -end diff --git a/lib/bandwidth/http/http_client.rb b/lib/bandwidth/http/http_client.rb deleted file mode 100644 index 0a6cef35..00000000 --- a/lib/bandwidth/http/http_client.rb +++ /dev/null @@ -1,104 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # An interface for the methods that an HTTP Client must implement. - # - # This class should not be instantiated but should be used as a base class - # for HTTP Client classes. - class HttpClient - # Execute an HttpRequest when the response is expected to be a string. - # @param [HttpRequest] The HttpRequest to be executed. - def execute_as_string(_http_request) - raise NotImplementedError, 'This method needs - to be implemented in a child class.' - end - - # Execute an HttpRequest when the response is expected to be binary. - # @param [HttpRequest] The HttpRequest to be executed. - def execute_as_binary(_http_request) - raise NotImplementedError, 'This method needs - to be implemented in a child class.' - end - - # Converts the HTTP Response from the client to an HttpResponse object. - # @param [Dynamic] The response object received from the client. - def convert_response(_response) - raise NotImplementedError, 'This method needs - to be implemented in a child class.' - end - - # Get a GET HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - def get(query_url, - headers: {}) - HttpRequest.new(HttpMethodEnum::GET, - query_url, - headers: headers) - end - - # Get a HEAD HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - def head(query_url, - headers: {}) - HttpRequest.new(HttpMethodEnum::HEAD, - query_url, - headers: headers) - end - - # Get a POST HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - # @param [Hash, Optional] The parameters for the HTTP Request. - def post(query_url, - headers: {}, - parameters: {}) - HttpRequest.new(HttpMethodEnum::POST, - query_url, - headers: headers, - parameters: parameters) - end - - # Get a PUT HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - # @param [Hash, Optional] The parameters for the HTTP Request. - def put(query_url, - headers: {}, - parameters: {}) - HttpRequest.new(HttpMethodEnum::PUT, - query_url, - headers: headers, - parameters: parameters) - end - - # Get a PATCH HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - # @param [Hash, Optional] The parameters for the HTTP Request. - def patch(query_url, - headers: {}, - parameters: {}) - HttpRequest.new(HttpMethodEnum::PATCH, - query_url, - headers: headers, - parameters: parameters) - end - - # Get a DELETE HttpRequest object. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - def delete(query_url, - headers: {}, - parameters: {}) - HttpRequest.new(HttpMethodEnum::DELETE, - query_url, - headers: headers, - parameters: parameters) - end - end -end diff --git a/lib/bandwidth/http/http_method_enum.rb b/lib/bandwidth/http/http_method_enum.rb deleted file mode 100644 index 2cf88c57..00000000 --- a/lib/bandwidth/http/http_method_enum.rb +++ /dev/null @@ -1,13 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # HTTP Methods Enumeration. - class HttpMethodEnum - HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze, - PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze, - DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze - end -end diff --git a/lib/bandwidth/http/http_request.rb b/lib/bandwidth/http/http_request.rb deleted file mode 100644 index 89e73c67..00000000 --- a/lib/bandwidth/http/http_request.rb +++ /dev/null @@ -1,50 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Represents a single Http Request. - class HttpRequest - attr_accessor :http_method, :query_url, :headers, - :parameters, :username, :password - - # The constructor. - # @param [HttpMethodEnum] The HTTP method. - # @param [String] The URL to send the request to. - # @param [Hash, Optional] The headers for the HTTP Request. - # @param [Hash, Optional] The parameters for the HTTP Request. - def initialize(http_method, - query_url, - headers: {}, - parameters: {}) - @http_method = http_method - @query_url = query_url - @headers = headers - @parameters = parameters - end - - # Add a header to the HttpRequest. - # @param [String] The name of the header. - # @param [String] The value of the header. - def add_header(name, value) - @headers[name] = value - end - - # Add a parameter to the HttpRequest. - # @param [String] The name of the parameter. - # @param [String] The value of the parameter. - def add_parameter(name, value) - @parameters[name] = value - end - - # Add a query parameter to the HttpRequest. - # @param [String] The name of the query parameter. - # @param [String] The value of the query parameter. - def add_query_parameter(name, value) - @query_url = APIHelper.append_url_with_query_parameters(@query_url, - name => value) - @query_url = APIHelper.clean_url(@query_url) - end - end -end diff --git a/lib/bandwidth/http/http_response.rb b/lib/bandwidth/http/http_response.rb deleted file mode 100644 index 5362a3f3..00000000 --- a/lib/bandwidth/http/http_response.rb +++ /dev/null @@ -1,29 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Http response received. - class HttpResponse - attr_reader :status_code, :reason_phrase, :headers, :raw_body, :request - - # The constructor - # @param [Integer] The status code returned by the server. - # @param [String] The reason phrase returned by the server. - # @param [Hash] The headers sent by the server in the response. - # @param [String] The raw body of the response. - # @param [HttpRequest] The request that resulted in this response. - def initialize(status_code, - reason_phrase, - headers, - raw_body, - request) - @status_code = status_code - @reason_phrase = reason_phrase - @headers = headers - @raw_body = raw_body - @request = request - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging.rb b/lib/bandwidth/messaging_lib/messaging.rb deleted file mode 100644 index bc62ef83..00000000 --- a/lib/bandwidth/messaging_lib/messaging.rb +++ /dev/null @@ -1,25 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'messaging/client.rb' - -# Models -require_relative 'messaging/models/bandwidth_messages_list.rb' -require_relative 'messaging/models/bandwidth_message_item.rb' -require_relative 'messaging/models/page_info.rb' -require_relative 'messaging/models/media.rb' -require_relative 'messaging/models/tag.rb' -require_relative 'messaging/models/deferred_result.rb' -require_relative 'messaging/models/bandwidth_callback_message.rb' -require_relative 'messaging/models/bandwidth_message.rb' -require_relative 'messaging/models/message_request.rb' -require_relative 'messaging/models/priority_enum.rb' - -# Exceptions -require_relative 'messaging/exceptions/messaging_exception.rb' -# Controllers -require_relative 'messaging/controllers/base_controller.rb' -require_relative 'messaging/controllers/api_controller.rb' diff --git a/lib/bandwidth/messaging_lib/messaging/client.rb b/lib/bandwidth/messaging_lib/messaging/client.rb deleted file mode 100644 index bb34f7d8..00000000 --- a/lib/bandwidth/messaging_lib/messaging/client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - module Messaging - # bandwidth client class. - class Client - attr_reader :config - - # Access to client controller. - # @return [APIController] Returns the controller instance. - def client - @client ||= APIController.new config - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', - config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, - max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end -end diff --git a/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb b/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb deleted file mode 100644 index f6ca0261..00000000 --- a/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +++ /dev/null @@ -1,491 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth -module Messaging - # APIController - class APIController < BaseController - def initialize(config, http_call_back: nil) - super(config, http_call_back: http_call_back) - end - - # Gets a list of your media files. No query parameters are supported. - # @param [String] account_id Required parameter: User's account ID - # @param [String] continuation_token Optional parameter: Continuation token - # used to retrieve subsequent media. - # @return [List of Media] response from the API call - def list_media(account_id, - continuation_token: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/media' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'Continuation-Token' => continuation_token - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| Media.from_hash(element) } - ) - end - - # Downloads a media file you previously uploaded. - # @param [String] account_id Required parameter: User's account ID - # @param [String] media_id Required parameter: Media ID to retrieve - # @return [Binary] response from the API call - def get_media(account_id, - media_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/media/{mediaId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'mediaId' => { 'value' => media_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request, binary: true) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new( - _response, data: _response.raw_body - ) - end - - # Uploads a file the normal HTTP way. You may add headers to the request in - # order to provide some control to your media-file. - # @param [String] account_id Required parameter: User's account ID - # @param [String] media_id Required parameter: The user supplied custom - # media ID - # @param [File | UploadIO] body Required parameter: Example: - # @param [String] content_type Optional parameter: The media type of the - # entity-body - # @param [String] cache_control Optional parameter: General-header field is - # used to specify directives that MUST be obeyed by all caching mechanisms - # along the request/response chain. - # @return [void] response from the API call - def upload_media(account_id, - media_id, - body, - content_type: 'application/octet-stream', - cache_control: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/media/{mediaId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'mediaId' => { 'value' => media_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - if body.is_a? FileWrapper - body_wrapper = body.file - body_content_type = body.content_type - else - body_wrapper = body - body_content_type = content_type - end - - # Prepare headers. - _headers = { - 'content-type' => body_content_type, - 'content-length' => body_wrapper.size.to_s, - 'Cache-Control' => cache_control - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body_wrapper - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Deletes a media file from Bandwidth API server. Make sure you don't have - # any application scripts still using the media before you delete. If you - # accidentally delete a media file, you can immediately upload a new file - # with the same name. - # @param [String] account_id Required parameter: User's account ID - # @param [String] media_id Required parameter: The media ID to delete - # @return [void] response from the API call - def delete_media(account_id, - media_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/media/{mediaId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'mediaId' => { 'value' => media_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Gets a list of messages based on query parameters. - # @param [String] account_id Required parameter: User's account ID - # @param [String] message_id Optional parameter: The ID of the message to - # search for. Special characters need to be encoded using URL encoding - # @param [String] source_tn Optional parameter: The phone number that sent - # the message - # @param [String] destination_tn Optional parameter: The phone number that - # received the message - # @param [String] message_status Optional parameter: The status of the - # message. One of RECEIVED, QUEUED, SENDING, SENT, FAILED, DELIVERED, - # ACCEPTED, UNDELIVERED - # @param [Integer] error_code Optional parameter: The error code of the - # message - # @param [String] from_date_time Optional parameter: The start of the date - # range to search in ISO 8601 format. Uses the message receive time. The - # date range to search in is currently 14 days. - # @param [String] to_date_time Optional parameter: The end of the date range - # to search in ISO 8601 format. Uses the message receive time. The date - # range to search in is currently 14 days. - # @param [String] page_token Optional parameter: A base64 encoded value used - # for pagination of results - # @param [Integer] limit Optional parameter: The maximum records requested - # in search result. Default 100. The sum of limit and after cannot be more - # than 10000 - # @return [BandwidthMessagesList] response from the API call - def get_messages(account_id, - message_id: nil, - source_tn: nil, - destination_tn: nil, - message_status: nil, - error_code: nil, - from_date_time: nil, - to_date_time: nil, - page_token: nil, - limit: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/messages' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_builder = APIHelper.append_url_with_query_parameters( - _query_builder, - 'messageId' => message_id, - 'sourceTn' => source_tn, - 'destinationTn' => destination_tn, - 'messageStatus' => message_status, - 'errorCode' => error_code, - 'fromDateTime' => from_date_time, - 'toDateTime' => to_date_time, - 'pageToken' => page_token, - 'limit' => limit - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: BandwidthMessagesList.from_hash(decoded) - ) - end - - # Endpoint for sending text messages and picture messages using V2 - # messaging. - # @param [String] account_id Required parameter: User's account ID - # @param [MessageRequest] body Required parameter: Example: - # @return [BandwidthMessage] response from the API call - def create_message(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT) - _query_builder << '/users/{accountId}/messages' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - MessagingBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise MessagingException.new( - '400 Request is malformed or invalid', - _response - ) - when 401 - raise MessagingException.new( - '401 The specified user does not have access to the account', - _response - ) - when 403 - raise MessagingException.new( - '403 The user does not have access to this API', - _response - ) - when 404 - raise MessagingException.new( - '404 Path not found', - _response - ) - when 415 - raise MessagingException.new( - '415 The content-type of the request is incorrect', - _response - ) - when 429 - raise MessagingException.new( - '429 The rate limit has been reached', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: BandwidthMessage.from_hash(decoded) - ) - end - end -end -end diff --git a/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb b/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb deleted file mode 100644 index 17e3cbc6..00000000 --- a/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BaseController. - class BaseController - attr_accessor :config, :http_call_back - - def initialize(config, http_call_back: nil) - @config = config - @http_call_back = http_call_back - - @global_headers = { - 'user-agent' => 'ruby-sdk' - } - end - - def validate_parameters(args) - args.each do |_name, value| - raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil? - end - end - - def execute_request(request, binary: false) - @http_call_back&.on_before_request(request) - - APIHelper.clean_hash(request.headers) - request.headers.merge!(@global_headers) - - response = if binary - config.http_client.execute_as_binary(request) - else - config.http_client.execute_as_string(request) - end - @http_call_back&.on_after_response(response) - - response - end - - def validate_response(response) - raise APIException.new 'HTTP Response Not OK', response unless - response.status_code.between?(200, 208) # [200,208] = HTTP OK - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb b/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb deleted file mode 100644 index 1fe3997e..00000000 --- a/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +++ /dev/null @@ -1,37 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # MessagingException class. - class MessagingException < APIException - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :type - - # TODO: Write general description for this method - # @return [String] - attr_accessor :description - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @type = hash.key?('type') ? hash['type'] : SKIP - @description = hash.key?('description') ? hash['description'] : SKIP - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb deleted file mode 100644 index f2aee105..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +++ /dev/null @@ -1,100 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BandwidthCallbackMessage Model. - class BandwidthCallbackMessage < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :type - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :error_code - - # TODO: Write general description for this method - # @return [String] - attr_accessor :description - - # TODO: Write general description for this method - # @return [BandwidthMessage] - attr_accessor :message - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['time'] = 'time' - @_hash['type'] = 'type' - @_hash['to'] = 'to' - @_hash['error_code'] = 'errorCode' - @_hash['description'] = 'description' - @_hash['message'] = 'message' - @_hash - end - - # An array for optional fields - def optionals - %w[ - time - type - to - error_code - description - message - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(time = nil, - type = nil, - to = nil, - error_code = nil, - description = nil, - message = nil) - @time = time unless time == SKIP - @type = type unless type == SKIP - @to = to unless to == SKIP - @error_code = error_code unless error_code == SKIP - @description = description unless description == SKIP - @message = message unless message == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - time = hash.key?('time') ? hash['time'] : SKIP - type = hash.key?('type') ? hash['type'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - error_code = hash.key?('errorCode') ? hash['errorCode'] : SKIP - description = hash.key?('description') ? hash['description'] : SKIP - message = BandwidthMessage.from_hash(hash['message']) if hash['message'] - - # Create object from extracted values. - BandwidthCallbackMessage.new(time, - type, - to, - error_code, - description, - message) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb deleted file mode 100644 index 044a6646..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +++ /dev/null @@ -1,174 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BandwidthMessage Model. - class BandwidthMessage < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The id of the message - # @return [String] - attr_accessor :id - - # The Bandwidth phone number associated with the message - # @return [String] - attr_accessor :owner - - # The application ID associated with the message - # @return [String] - attr_accessor :application_id - - # The datetime stamp of the message in ISO 8601 - # @return [String] - attr_accessor :time - - # The number of segments the original message from the user is broken into - # before sending over to carrier networks - # @return [Integer] - attr_accessor :segment_count - - # The direction of the message relative to Bandwidth. Can be in or out - # @return [String] - attr_accessor :direction - - # The phone number recipients of the message - # @return [List of String] - attr_accessor :to - - # The phone number the message was sent from - # @return [String] - attr_accessor :from - - # The list of media URLs sent in the message. Including a `filename` field - # in the `Content-Disposition` header of the media linked with a URL will - # set the displayed file name. This is a best practice to ensure that your - # media has a readable file name. - # @return [List of String] - attr_accessor :media - - # The contents of the message - # @return [String] - attr_accessor :text - - # The custom string set by the user - # @return [String] - attr_accessor :tag - - # The priority specified by the user - # @return [String] - attr_accessor :priority - - # A string with the date/time value that the message will automatically expire by. - # @return [String] - attr_accessor :expiration - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['owner'] = 'owner' - @_hash['application_id'] = 'applicationId' - @_hash['time'] = 'time' - @_hash['segment_count'] = 'segmentCount' - @_hash['direction'] = 'direction' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['media'] = 'media' - @_hash['text'] = 'text' - @_hash['tag'] = 'tag' - @_hash['priority'] = 'priority' - @_hash['expiration'] = 'expiration' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - owner - application_id - time - segment_count - direction - to - from - media - text - tag - priority - expiration - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(id = nil, - owner = nil, - application_id = nil, - time = nil, - segment_count = nil, - direction = nil, - to = nil, - from = nil, - media = nil, - text = nil, - tag = nil, - priority = nil, - expiration = nil) - @id = id unless id == SKIP - @owner = owner unless owner == SKIP - @application_id = application_id unless application_id == SKIP - @time = time unless time == SKIP - @segment_count = segment_count unless segment_count == SKIP - @direction = direction unless direction == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @media = media unless media == SKIP - @text = text unless text == SKIP - @tag = tag unless tag == SKIP - @priority = priority unless priority == SKIP - @expiration = expiration unless expiration == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - owner = hash.key?('owner') ? hash['owner'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - time = hash.key?('time') ? hash['time'] : SKIP - segment_count = hash.key?('segmentCount') ? hash['segmentCount'] : SKIP - direction = hash.key?('direction') ? hash['direction'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - media = hash.key?('media') ? hash['media'] : SKIP - text = hash.key?('text') ? hash['text'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - priority = hash.key?('priority') ? hash['priority'] : SKIP - expiration = hash.key?('expiration') ? hash['expiration'] : SKIP - - # Create object from extracted values. - BandwidthMessage.new(id, - owner, - application_id, - time, - segment_count, - direction, - to, - from, - media, - text, - tag, - priority, - expiration) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb deleted file mode 100644 index 68bd7f4f..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +++ /dev/null @@ -1,203 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BandwidthMessageItem Model. - class BandwidthMessageItem < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The message id - # @return [String] - attr_accessor :message_id - - # The account id of the message - # @return [String] - attr_accessor :account_id - - # The source phone number of the message - # @return [String] - attr_accessor :source_tn - - # The recipient phone number of the message - # @return [String] - attr_accessor :destination_tn - - # The status of the message - # @return [String] - attr_accessor :message_status - - # The direction of the message relative to Bandwidth. INBOUND or OUTBOUND - # @return [String] - attr_accessor :message_direction - - # The type of message. sms or mms - # @return [String] - attr_accessor :message_type - - # The number of segments the message was sent as - # @return [Integer] - attr_accessor :segment_count - - # The numeric error code of the message - # @return [Integer] - attr_accessor :error_code - - # The ISO 8601 datetime of the message - # @return [String] - attr_accessor :receive_time - - # The name of the carrier. Not currently supported for MMS, coming soon - # @return [String] - attr_accessor :carrier_name - - # The size of the message including message content and headers - # @return [Integer] - attr_accessor :message_size - - # The length of the message content - # @return [Integer] - attr_accessor :message_length - - # The number of attachments the message has - # @return [Integer] - attr_accessor :attachment_count - - # The number of recipients the message has - # @return [Integer] - attr_accessor :recipient_count - - # The campaign class of the message, if it has one - # @return [String] - attr_accessor :campaign_class - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['message_id'] = 'messageId' - @_hash['account_id'] = 'accountId' - @_hash['source_tn'] = 'sourceTn' - @_hash['destination_tn'] = 'destinationTn' - @_hash['message_status'] = 'messageStatus' - @_hash['message_direction'] = 'messageDirection' - @_hash['message_type'] = 'messageType' - @_hash['segment_count'] = 'segmentCount' - @_hash['error_code'] = 'errorCode' - @_hash['receive_time'] = 'receiveTime' - @_hash['carrier_name'] = 'carrierName' - @_hash['message_size'] = 'messageSize' - @_hash['message_length'] = 'messageLength' - @_hash['attachment_count'] = 'attachmentCount' - @_hash['recipient_count'] = 'recipientCount' - @_hash['campaign_class'] = 'campaignClass' - @_hash - end - - # An array for optional fields - def optionals - %w[ - message_id - account_id - source_tn - destination_tn - message_status - message_direction - message_type - segment_count - error_code - receive_time - carrier_name - message_size - message_length - attachment_count - recipient_count - campaign_class - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(message_id = nil, - account_id = nil, - source_tn = nil, - destination_tn = nil, - message_status = nil, - message_direction = nil, - message_type = nil, - segment_count = nil, - error_code = nil, - receive_time = nil, - carrier_name = nil, - message_size = nil, - message_length = nil, - attachment_count = nil, - recipient_count = nil, - campaign_class = nil) - @message_id = message_id unless message_id == SKIP - @account_id = account_id unless account_id == SKIP - @source_tn = source_tn unless source_tn == SKIP - @destination_tn = destination_tn unless destination_tn == SKIP - @message_status = message_status unless message_status == SKIP - @message_direction = message_direction unless message_direction == SKIP - @message_type = message_type unless message_type == SKIP - @segment_count = segment_count unless segment_count == SKIP - @error_code = error_code unless error_code == SKIP - @receive_time = receive_time unless receive_time == SKIP - @carrier_name = carrier_name unless carrier_name == SKIP - @message_size = message_size unless message_size == SKIP - @message_length = message_length unless message_length == SKIP - @attachment_count = attachment_count unless attachment_count == SKIP - @recipient_count = recipient_count unless recipient_count == SKIP - @campaign_class = campaign_class unless campaign_class == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - message_id = hash.key?('messageId') ? hash['messageId'] : SKIP - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - source_tn = hash.key?('sourceTn') ? hash['sourceTn'] : SKIP - destination_tn = hash.key?('destinationTn') ? hash['destinationTn'] : SKIP - message_status = hash.key?('messageStatus') ? hash['messageStatus'] : SKIP - message_direction = - hash.key?('messageDirection') ? hash['messageDirection'] : SKIP - message_type = hash.key?('messageType') ? hash['messageType'] : SKIP - segment_count = hash.key?('segmentCount') ? hash['segmentCount'] : SKIP - error_code = hash.key?('errorCode') ? hash['errorCode'] : SKIP - receive_time = hash.key?('receiveTime') ? hash['receiveTime'] : SKIP - carrier_name = hash.key?('carrierName') ? hash['carrierName'] : SKIP - message_size = hash.key?('messageSize') ? hash['messageSize'] : SKIP - message_length = hash.key?('messageLength') ? hash['messageLength'] : SKIP - attachment_count = - hash.key?('attachmentCount') ? hash['attachmentCount'] : SKIP - recipient_count = - hash.key?('recipientCount') ? hash['recipientCount'] : SKIP - campaign_class = hash.key?('campaignClass') ? hash['campaignClass'] : SKIP - - # Create object from extracted values. - BandwidthMessageItem.new(message_id, - account_id, - source_tn, - destination_tn, - message_status, - message_direction, - message_type, - segment_count, - error_code, - receive_time, - carrier_name, - message_size, - message_length, - attachment_count, - recipient_count, - campaign_class) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb b/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb deleted file mode 100644 index a03052db..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +++ /dev/null @@ -1,79 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BandwidthMessagesList Model. - class BandwidthMessagesList < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Total number of messages matched by the search - # @return [Integer] - attr_accessor :total_count - - # Total number of messages matched by the search - # @return [PageInfo] - attr_accessor :page_info - - # Total number of messages matched by the search - # @return [List of BandwidthMessageItem] - attr_accessor :messages - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['total_count'] = 'totalCount' - @_hash['page_info'] = 'pageInfo' - @_hash['messages'] = 'messages' - @_hash - end - - # An array for optional fields - def optionals - %w[ - total_count - page_info - messages - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(total_count = nil, - page_info = nil, - messages = nil) - @total_count = total_count unless total_count == SKIP - @page_info = page_info unless page_info == SKIP - @messages = messages unless messages == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - total_count = hash.key?('totalCount') ? hash['totalCount'] : SKIP - page_info = PageInfo.from_hash(hash['pageInfo']) if hash['pageInfo'] - # Parameter is an array, so we need to iterate through it - messages = nil - unless hash['messages'].nil? - messages = [] - hash['messages'].each do |structure| - messages << (BandwidthMessageItem.from_hash(structure) if structure) - end - end - - messages = SKIP unless hash.key?('messages') - - # Create object from extracted values. - BandwidthMessagesList.new(total_count, - page_info, - messages) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb b/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb deleted file mode 100644 index ecff110c..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # DeferredResult Model. - class DeferredResult < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [Object] - attr_accessor :result - - # TODO: Write general description for this method - # @return [Boolean] - attr_accessor :set_or_expired - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['result'] = 'result' - @_hash['set_or_expired'] = 'setOrExpired' - @_hash - end - - # An array for optional fields - def optionals - %w[ - result - set_or_expired - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(result = nil, - set_or_expired = nil) - @result = result unless result == SKIP - @set_or_expired = set_or_expired unless set_or_expired == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - result = hash.key?('result') ? hash['result'] : SKIP - set_or_expired = hash.key?('setOrExpired') ? hash['setOrExpired'] : SKIP - - # Create object from extracted values. - DeferredResult.new(result, - set_or_expired) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/media.rb b/lib/bandwidth/messaging_lib/messaging/models/media.rb deleted file mode 100644 index 578db560..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/media.rb +++ /dev/null @@ -1,70 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Media Model. - class Media < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :content - - # TODO: Write general description for this method - # @return [Integer] - attr_accessor :content_length - - # TODO: Write general description for this method - # @return [String] - attr_accessor :media_name - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['content'] = 'content' - @_hash['content_length'] = 'contentLength' - @_hash['media_name'] = 'mediaName' - @_hash - end - - # An array for optional fields - def optionals - %w[ - content - content_length - media_name - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(content = nil, - content_length = nil, - media_name = nil) - @content = content unless content == SKIP - @content_length = content_length unless content_length == SKIP - @media_name = media_name unless media_name == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - content = hash.key?('content') ? hash['content'] : SKIP - content_length = hash.key?('contentLength') ? hash['contentLength'] : SKIP - media_name = hash.key?('mediaName') ? hash['mediaName'] : SKIP - - # Create object from extracted values. - Media.new(content, - content_length, - media_name) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/message_request.rb b/lib/bandwidth/messaging_lib/messaging/models/message_request.rb deleted file mode 100644 index b9055f5e..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +++ /dev/null @@ -1,122 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # MessageRequest Model. - class MessageRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The ID of the Application your from number is associated with in the - # Bandwidth Phone Number Dashboard. - # @return [String] - attr_accessor :application_id - - # The phone number(s) the message should be sent to in E164 format - # @return [List of String] - attr_accessor :to - - # One of your telephone numbers the message should come from in E164 format - # @return [String] - attr_accessor :from - - # The contents of the text message. Must be 2048 characters or less. - # @return [String] - attr_accessor :text - - # A list of URLs to include as media attachments as part of the message. - # @return [List of String] - attr_accessor :media - - # A custom string that will be included in callback events of the message. - # Max 1024 characters - # @return [String] - attr_accessor :tag - - # The message's priority, currently for toll-free or short code SMS only. - # Messages with a priority value of `"high"` are given preference over your - # other traffic. - # @return [PriorityEnum] - attr_accessor :priority - - # A string with the date/time value that the message will automatically expire by. - # This must be a valid RFC-3339 value, e.g., 2021-03-14T01:59:26Z or 2021-03-13T20:59:26-05:00. - # @return [String] - attr_accessor :expiration - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['application_id'] = 'applicationId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['text'] = 'text' - @_hash['media'] = 'media' - @_hash['tag'] = 'tag' - @_hash['priority'] = 'priority' - @_hash['expiration'] = 'expiration' - @_hash - end - - # An array for optional fields - def optionals - %w[ - text - media - tag - priority - expiration - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(application_id = nil, - to = nil, - from = nil, - text = nil, - media = nil, - tag = nil, - priority = nil, - expiration = nil) - @application_id = application_id unless application_id == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @text = text unless text == SKIP - @media = media unless media == SKIP - @tag = tag unless tag == SKIP - @priority = priority unless priority == SKIP - @expiration = expiration unless expiration == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - text = hash.key?('text') ? hash['text'] : SKIP - media = hash.key?('media') ? hash['media'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - priority = hash.key?('priority') ? hash['priority'] : SKIP - expiration = hash.key?('expiration') ? hash['expiration'] : SKIP - - # Create object from extracted values. - MessageRequest.new(application_id, - to, - from, - text, - media, - tag, - priority, - expiration) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/page_info.rb b/lib/bandwidth/messaging_lib/messaging/models/page_info.rb deleted file mode 100644 index 3c9faaaf..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +++ /dev/null @@ -1,82 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # PageInfo Model. - class PageInfo < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The link to the previous page for pagination - # @return [String] - attr_accessor :prev_page - - # The link to the next page for pagination - # @return [String] - attr_accessor :next_page - - # The isolated pagination token for the previous page - # @return [String] - attr_accessor :prev_page_token - - # The isolated pagination token for the next page - # @return [String] - attr_accessor :next_page_token - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['prev_page'] = 'prevPage' - @_hash['next_page'] = 'nextPage' - @_hash['prev_page_token'] = 'prevPageToken' - @_hash['next_page_token'] = 'nextPageToken' - @_hash - end - - # An array for optional fields - def optionals - %w[ - prev_page - next_page - prev_page_token - next_page_token - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(prev_page = nil, - next_page = nil, - prev_page_token = nil, - next_page_token = nil) - @prev_page = prev_page unless prev_page == SKIP - @next_page = next_page unless next_page == SKIP - @prev_page_token = prev_page_token unless prev_page_token == SKIP - @next_page_token = next_page_token unless next_page_token == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - prev_page = hash.key?('prevPage') ? hash['prevPage'] : SKIP - next_page = hash.key?('nextPage') ? hash['nextPage'] : SKIP - prev_page_token = - hash.key?('prevPageToken') ? hash['prevPageToken'] : SKIP - next_page_token = - hash.key?('nextPageToken') ? hash['nextPageToken'] : SKIP - - # Create object from extracted values. - PageInfo.new(prev_page, - next_page, - prev_page_token, - next_page_token) - end - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb b/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb deleted file mode 100644 index 73b83e87..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +++ /dev/null @@ -1,19 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # The message's priority, currently for toll-free or short code SMS only. - # Messages with a priority value of `"high"` are given preference over your - # other traffic. - class PriorityEnum - PRIORITY_ENUM = [ - # TODO: Write general description for DEFAULT - DEFAULT = 'default'.freeze, - - # TODO: Write general description for HIGH - HIGH = 'high'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/messaging_lib/messaging/models/tag.rb b/lib/bandwidth/messaging_lib/messaging/models/tag.rb deleted file mode 100644 index 72e885b2..00000000 --- a/lib/bandwidth/messaging_lib/messaging/models/tag.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Tag Model. - class Tag < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :key - - # TODO: Write general description for this method - # @return [String] - attr_accessor :value - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['key'] = 'key' - @_hash['value'] = 'value' - @_hash - end - - # An array for optional fields - def optionals - %w[ - key - value - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(key = nil, - value = nil) - @key = key unless key == SKIP - @value = value unless value == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - key = hash.key?('key') ? hash['key'] : SKIP - value = hash.key?('value') ? hash['value'] : SKIP - - # Create object from extracted values. - Tag.new(key, - value) - end - end -end diff --git a/lib/bandwidth/models/base_model.rb b/lib/bandwidth/models/base_model.rb deleted file mode 100644 index 54038eae..00000000 --- a/lib/bandwidth/models/base_model.rb +++ /dev/null @@ -1,58 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Base model. - class BaseModel - # Returns a Hash representation of the current object. - def to_hash - hash = {} - instance_variables.each do |name| - value = instance_variable_get(name) - name = name[1..-1] - key = self.class.names.key?(name) ? self.class.names[name] : name - - optional_fields = optionals if respond_to? 'optionals' - nullable_fields = nullables if respond_to? 'nullables' - if value.nil? - next unless nullable_fields.include?(name) - - if !optional_fields.include?(name) && !nullable_fields.include?(name) - raise ArgumentError, - "`#{name}` cannot be nil in `#{self.class}`. Please specify a valid value." - end - end - - hash[key] = nil - unless value.nil? - if respond_to?("to_#{name}") - if (value.instance_of? Array) || (value.instance_of? Hash) - params = [hash, key] - hash[key] = send("to_#{name}", *params) - else - hash[key] = send("to_#{name}") - end - elsif value.instance_of? Array - hash[key] = value.map { |v| v.is_a?(BaseModel) ? v.to_hash : v } - elsif value.instance_of? Hash - hash[key] = {} - value.each do |k, v| - hash[key][k] = v.is_a?(BaseModel) ? v.to_hash : v - end - else - hash[key] = value.is_a?(BaseModel) ? value.to_hash : value - end - end - end - hash - end - - # Returns a JSON representation of the curent object. - def to_json(options = {}) - hash = to_hash.reject { |k, v| v.nil? } - hash.to_json(options) - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb deleted file mode 100644 index e7fe82c1..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +++ /dev/null @@ -1,23 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'multi_factor_auth/client.rb' - -# Models -require_relative 'multi_factor_auth/models/two_factor_code_request_schema.rb' -require_relative 'multi_factor_auth/models/two_factor_voice_response.rb' -require_relative 'multi_factor_auth/models/two_factor_messaging_response.rb' -require_relative 'multi_factor_auth/models/two_factor_verify_request_schema.rb' -require_relative 'multi_factor_auth/models/two_factor_verify_code_response.rb' - -# Exceptions -require_relative 'multi_factor_auth/exceptions/error_with_request_exception.rb' -require_relative 'multi_factor_auth/exceptions/unauthorized_request' \ - '_exception.rb' -require_relative 'multi_factor_auth/exceptions/forbidden_request_exception.rb' -# Controllers -require_relative 'multi_factor_auth/controllers/base_controller.rb' -require_relative 'multi_factor_auth/controllers/mfa_controller.rb' diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb deleted file mode 100644 index 9bf860c5..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - module MultiFactorAuth - # bandwidth client class. - class Client - attr_reader :config - - # Access to mfa controller. - # @return [MFAController] Returns the controller instance. - def mfa - @mfa ||= MFAController.new config - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', - config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, - max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb deleted file mode 100644 index 17e3cbc6..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BaseController. - class BaseController - attr_accessor :config, :http_call_back - - def initialize(config, http_call_back: nil) - @config = config - @http_call_back = http_call_back - - @global_headers = { - 'user-agent' => 'ruby-sdk' - } - end - - def validate_parameters(args) - args.each do |_name, value| - raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil? - end - end - - def execute_request(request, binary: false) - @http_call_back&.on_before_request(request) - - APIHelper.clean_hash(request.headers) - request.headers.merge!(@global_headers) - - response = if binary - config.http_client.execute_as_binary(request) - else - config.http_client.execute_as_string(request) - end - @http_call_back&.on_after_response(response) - - response - end - - def validate_response(response) - raise APIException.new 'HTTP Response Not OK', response unless - response.status_code.between?(200, 208) # [200,208] = HTTP OK - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb deleted file mode 100644 index 20b77c37..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +++ /dev/null @@ -1,214 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth -module MultiFactorAuth - # MFAController - class MFAController < BaseController - def initialize(config, http_call_back: nil) - super(config, http_call_back: http_call_back) - end - - # Multi-Factor authentication with Bandwidth Voice services. Allows for a - # user to send an MFA code via a phone call. - # @param [String] account_id Required parameter: Bandwidth Account ID with - # Voice service enabled - # @param [TwoFactorCodeRequestSchema] body Required parameter: Example: - # @return [TwoFactorVoiceResponse] response from the API call - def create_voice_two_factor(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) - _query_builder << '/accounts/{accountId}/code/voice' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - MultiFactorAuthBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ErrorWithRequestException.new( - 'If there is any issue with values passed in by the user', - _response - ) - when 401 - raise UnauthorizedRequestException.new( - 'Authentication is either incorrect or not present', - _response - ) - when 403 - raise ForbiddenRequestException.new( - 'The user is not authorized to access this resource', - _response - ) - when 500 - raise ErrorWithRequestException.new( - 'An internal server error occurred', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: TwoFactorVoiceResponse.from_hash(decoded) - ) - end - - # Multi-Factor authentication with Bandwidth Messaging services. Allows a - # user to send an MFA code via a text message (SMS). - # @param [String] account_id Required parameter: Bandwidth Account ID with - # Messaging service enabled - # @param [TwoFactorCodeRequestSchema] body Required parameter: Example: - # @return [TwoFactorMessagingResponse] response from the API call - def create_messaging_two_factor(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) - _query_builder << '/accounts/{accountId}/code/messaging' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - MultiFactorAuthBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ErrorWithRequestException.new( - 'If there is any issue with values passed in by the user', - _response - ) - when 401 - raise UnauthorizedRequestException.new( - 'Authentication is either incorrect or not present', - _response - ) - when 403 - raise ForbiddenRequestException.new( - 'The user is not authorized to access this resource', - _response - ) - when 500 - raise ErrorWithRequestException.new( - 'An internal server error occurred', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: TwoFactorMessagingResponse.from_hash(decoded) - ) - end - - # Allows a user to verify an MFA code. - # @param [String] account_id Required parameter: Bandwidth Account ID with - # Two-Factor enabled - # @param [TwoFactorVerifyRequestSchema] body Required parameter: Example: - # @return [TwoFactorVerifyCodeResponse] response from the API call - def create_verify_two_factor(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::MULTIFACTORAUTHDEFAULT) - _query_builder << '/accounts/{accountId}/code/verify' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - MultiFactorAuthBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ErrorWithRequestException.new( - 'If there is any issue with values passed in by the user', - _response - ) - when 401 - raise UnauthorizedRequestException.new( - 'Authentication is either incorrect or not present', - _response - ) - when 403 - raise ForbiddenRequestException.new( - 'The user is not authorized to access this resource', - _response - ) - when 429 - raise ErrorWithRequestException.new( - 'The user has made too many bad requests and is temporarily locked' \ - ' out', - _response - ) - when 500 - raise ErrorWithRequestException.new( - 'An internal server error occurred', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: TwoFactorVerifyCodeResponse.from_hash(decoded) - ) - end - end -end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb deleted file mode 100644 index 4be5ec46..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +++ /dev/null @@ -1,37 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ErrorWithRequest class. - class ErrorWithRequestException < APIException - SKIP = Object.new - private_constant :SKIP - - # An error message pertaining to what the issue could be - # @return [String] - attr_accessor :error - - # The associated requestId from AWS - # @return [String] - attr_accessor :request_id - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @error = hash.key?('error') ? hash['error'] : SKIP - @request_id = hash.key?('requestId') ? hash['requestId'] : SKIP - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb deleted file mode 100644 index ecad4e7d..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +++ /dev/null @@ -1,32 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ForbiddenRequest class. - class ForbiddenRequestException < APIException - SKIP = Object.new - private_constant :SKIP - - # The message containing the reason behind the request being forbidden - # @return [String] - attr_accessor :message - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @message = hash.key?('Message') ? hash['Message'] : SKIP - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb deleted file mode 100644 index 61773294..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +++ /dev/null @@ -1,32 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # UnauthorizedRequest class. - class UnauthorizedRequestException < APIException - SKIP = Object.new - private_constant :SKIP - - # The message containing the reason behind the request being unauthorized - # @return [String] - attr_accessor :message - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @message = hash.key?('message') ? hash['message'] : SKIP - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb deleted file mode 100644 index 55ece41e..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +++ /dev/null @@ -1,103 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TwoFactorCodeRequestSchema Model. - class TwoFactorCodeRequestSchema < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The phone number to send the 2fa code to. - # @return [String] - attr_accessor :to - - # The application phone number, the sender of the 2fa code. - # @return [String] - attr_accessor :from - - # The application unique ID, obtained from Bandwidth. - # @return [String] - attr_accessor :application_id - - # An optional field to denote what scope or action the 2fa code is - # addressing. If not supplied, defaults to "2FA". - # @return [String] - attr_accessor :scope - - # The message format of the 2fa code. There are three values that the - # system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" and - # "{NAME} value template are optional, while "{CODE}" must be supplied. As - # the name would suggest, code will be replace with the actual 2fa code. - # Name is replaced with the application name, configured during provisioning - # of 2fa. The scope value is the same value sent during the call and - # partitioned by the server. - # @return [String] - attr_accessor :message - - # The number of digits for your 2fa code. The valid number ranges from 2 to - # 8, inclusively. - # @return [Float] - attr_accessor :digits - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['application_id'] = 'applicationId' - @_hash['scope'] = 'scope' - @_hash['message'] = 'message' - @_hash['digits'] = 'digits' - @_hash - end - - # An array for optional fields - def optionals - %w[ - scope - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(to = nil, - from = nil, - application_id = nil, - message = nil, - digits = nil, - scope = nil) - @to = to unless to == SKIP - @from = from unless from == SKIP - @application_id = application_id unless application_id == SKIP - @scope = scope unless scope == SKIP - @message = message unless message == SKIP - @digits = digits unless digits == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - message = hash.key?('message') ? hash['message'] : SKIP - digits = hash.key?('digits') ? hash['digits'] : SKIP - scope = hash.key?('scope') ? hash['scope'] : SKIP - - # Create object from extracted values. - TwoFactorCodeRequestSchema.new(to, - from, - application_id, - message, - digits, - scope) - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb deleted file mode 100644 index a1d2fcd9..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +++ /dev/null @@ -1,50 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TwoFactorMessagingResponse Model. - class TwoFactorMessagingResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :message_id - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['message_id'] = 'messageId' - @_hash - end - - # An array for optional fields - def optionals - %w[ - message_id - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(message_id = nil) - @message_id = message_id unless message_id == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - message_id = hash.key?('messageId') ? hash['messageId'] : SKIP - - # Create object from extracted values. - TwoFactorMessagingResponse.new(message_id) - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb deleted file mode 100644 index b82fe257..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +++ /dev/null @@ -1,50 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TwoFactorVerifyCodeResponse Model. - class TwoFactorVerifyCodeResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [Boolean] - attr_accessor :valid - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['valid'] = 'valid' - @_hash - end - - # An array for optional fields - def optionals - %w[ - valid - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(valid = nil) - @valid = valid unless valid == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - valid = hash.key?('valid') ? hash['valid'] : SKIP - - # Create object from extracted values. - TwoFactorVerifyCodeResponse.new(valid) - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb deleted file mode 100644 index ce78025f..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +++ /dev/null @@ -1,94 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TwoFactorVerifyRequestSchema Model. - class TwoFactorVerifyRequestSchema < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The phone number to send the 2fa code to. - # @return [String] - attr_accessor :to - - # The application unique ID, obtained from Bandwidth. - # @return [String] - attr_accessor :application_id - - # An optional field to denote what scope or action the 2fa code is - # addressing. If not supplied, defaults to "2FA". - # @return [String] - attr_accessor :scope - - # The time period, in minutes, to validate the 2fa code. By setting this to - # 3 minutes, it will mean any code generated within the last 3 minutes are - # still valid. The valid range for expiration time is between 0 and 15 - # minutes, exclusively and inclusively, respectively. - # @return [Float] - attr_accessor :expiration_time_in_minutes - - # The generated 2fa code to check if valid - # @return [String] - attr_accessor :code - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['to'] = 'to' - @_hash['application_id'] = 'applicationId' - @_hash['scope'] = 'scope' - @_hash['expiration_time_in_minutes'] = 'expirationTimeInMinutes' - @_hash['code'] = 'code' - @_hash - end - - # An array for optional fields - def optionals - %w[ - scope - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(to = nil, - application_id = nil, - expiration_time_in_minutes = nil, - code = nil, - scope = nil) - @to = to unless to == SKIP - @application_id = application_id unless application_id == SKIP - @scope = scope unless scope == SKIP - unless expiration_time_in_minutes == SKIP - @expiration_time_in_minutes = - expiration_time_in_minutes - end - @code = code unless code == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - to = hash.key?('to') ? hash['to'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - expiration_time_in_minutes = - hash.key?('expirationTimeInMinutes') ? hash['expirationTimeInMinutes'] : SKIP - code = hash.key?('code') ? hash['code'] : SKIP - scope = hash.key?('scope') ? hash['scope'] : SKIP - - # Create object from extracted values. - TwoFactorVerifyRequestSchema.new(to, - application_id, - expiration_time_in_minutes, - code, - scope) - end - end -end diff --git a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb b/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb deleted file mode 100644 index bf138348..00000000 --- a/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +++ /dev/null @@ -1,50 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TwoFactorVoiceResponse Model. - class TwoFactorVoiceResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['call_id'] = 'callId' - @_hash - end - - # An array for optional fields - def optionals - %w[ - call_id - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(call_id = nil) - @call_id = call_id unless call_id == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - call_id = hash.key?('callId') ? hash['callId'] : SKIP - - # Create object from extracted values. - TwoFactorVoiceResponse.new(call_id) - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb deleted file mode 100644 index 535c959f..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup.rb +++ /dev/null @@ -1,20 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'phone_number_lookup/client.rb' - -# Models -require_relative 'phone_number_lookup/models/order_request.rb' -require_relative 'phone_number_lookup/models/order_response.rb' -require_relative 'phone_number_lookup/models/order_status.rb' -require_relative 'phone_number_lookup/models/result.rb' - -# Exceptions -require_relative 'phone_number_lookup/exceptions/accounts_tnlookup400_error' \ - '_exception.rb' -# Controllers -require_relative 'phone_number_lookup/controllers/base_controller.rb' -require_relative 'phone_number_lookup/controllers/api_controller.rb' diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb deleted file mode 100644 index 81614f5b..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - module PhoneNumberLookup - # bandwidth client class. - class Client - attr_reader :config - - # Access to client controller. - # @return [APIController] Returns the controller instance. - def client - @client ||= APIController.new config - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', - config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, - max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb deleted file mode 100644 index 82fec799..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +++ /dev/null @@ -1,1553 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth -module PhoneNumberLookup - # APIController - class APIController < BaseController - def initialize(config, http_call_back: nil) - super(config, http_call_back: http_call_back) - end - - # Create a TN Lookup Order. - # @param [String] account_id Required parameter: The ID of the Bandwidth - # account that the user belongs to. - # @param [OrderRequest] body Required parameter: Example: - # @return [OrderResponse] response from the API call - def create_lookup_request(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::PHONENUMBERLOOKUPDEFAULT) - _query_builder << '/accounts/{accountId}/tnlookup' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - PhoneNumberLookupBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise AccountsTnlookup400ErrorException.new( - 'Bad Request. Ensure that your request payload is properly' \ - ' formatted and that the telephone numbers used are valid.', - _response - ) - when 401 - raise APIException.new( - 'Unauthorized. Ensure that you are using the proper credentials' \ - ' for the environment you are accessing, your user has' \ - ' the proper role assigned to it, and that your' \ - ' Bandwidth account is enabled for TN Lookup access.', - _response - ) - when 415 - raise APIException.new( - 'Invalid content-type. Ensure that your content-type header is set' \ - ' to application/json.', - _response - ) - when 429 - raise APIException.new( - 'Too Many Requests. Reduce the amount of requests that you are' \ - ' sending in order to avoid receiving this status code.', - _response - ) - when 500 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 501 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 502 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 503 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 504 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 505 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 506 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 507 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 508 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 509 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 510 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 511 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 512 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 513 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 514 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 515 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 516 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 517 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 518 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 519 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 520 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 521 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 522 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 523 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 524 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 525 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 526 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 527 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 528 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 529 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 530 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 531 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 532 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 533 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 534 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 535 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 536 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 537 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 538 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 539 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 540 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 541 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 542 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 543 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 544 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 545 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 546 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 547 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 548 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 549 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 550 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 551 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 552 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 553 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 554 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 555 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 556 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 557 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 558 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 559 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 560 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 561 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 562 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 563 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 564 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 565 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 566 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 567 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 568 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 569 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 570 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 571 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 572 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 573 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 574 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 575 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 576 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 577 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 578 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 579 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 580 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 581 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 582 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 583 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 584 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 585 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 586 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 587 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 588 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 589 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 590 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 591 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 592 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 593 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 594 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 595 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 596 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 597 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 598 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 599 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: OrderResponse.from_hash(decoded) - ) - end - - # Query an existing TN Lookup Order. - # @param [String] account_id Required parameter: The ID of the Bandwidth - # account that the user belongs to. - # @param [String] request_id Required parameter: Example: - # @return [OrderStatus] response from the API call - def get_lookup_request_status(account_id, - request_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::PHONENUMBERLOOKUPDEFAULT) - _query_builder << '/accounts/{accountId}/tnlookup/{requestId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'requestId' => { 'value' => request_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - PhoneNumberLookupBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise APIException.new( - 'Bad Request. Ensure that you have set the requestId as a URL path' \ - ' parameter.', - _response - ) - when 401 - raise APIException.new( - 'Unauthorized. Ensure that you are using the proper credentials' \ - ' for the environment you are accessing, your user has' \ - ' the proper role assigned to it, and that your' \ - ' Bandwidth account is enabled for TN Lookup access.', - _response - ) - when 404 - raise APIException.new( - 'RequestId not found. Ensure that the requestId used in the URL' \ - ' path is valid and maps to a previous request that was' \ - ' submitted.', - _response - ) - when 429 - raise APIException.new( - 'Too Many Requests. Reduce the amount of requests that you are' \ - ' sending in order to avoid receiving this status code.', - _response - ) - when 500 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 501 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 502 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 503 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 504 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 505 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 506 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 507 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 508 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 509 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 510 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 511 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 512 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 513 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 514 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 515 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 516 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 517 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 518 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 519 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 520 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 521 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 522 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 523 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 524 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 525 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 526 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 527 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 528 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 529 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 530 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 531 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 532 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 533 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 534 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 535 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 536 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 537 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 538 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 539 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 540 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 541 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 542 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 543 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 544 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 545 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 546 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 547 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 548 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 549 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 550 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 551 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 552 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 553 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 554 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 555 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 556 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 557 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 558 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 559 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 560 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 561 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 562 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 563 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 564 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 565 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 566 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 567 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 568 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 569 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 570 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 571 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 572 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 573 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 574 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 575 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 576 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 577 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 578 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 579 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 580 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 581 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 582 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 583 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 584 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 585 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 586 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 587 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 588 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 589 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 590 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 591 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 592 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 593 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 594 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 595 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 596 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 597 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 598 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - when 599 - raise APIException.new( - 'Unexpected error. Please contact Bandwidth Support if your' \ - ' requests are receiving this status code for an' \ - ' extended period of time.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: OrderStatus.from_hash(decoded) - ) - end - end -end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb deleted file mode 100644 index 17e3cbc6..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BaseController. - class BaseController - attr_accessor :config, :http_call_back - - def initialize(config, http_call_back: nil) - @config = config - @http_call_back = http_call_back - - @global_headers = { - 'user-agent' => 'ruby-sdk' - } - end - - def validate_parameters(args) - args.each do |_name, value| - raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil? - end - end - - def execute_request(request, binary: false) - @http_call_back&.on_before_request(request) - - APIHelper.clean_hash(request.headers) - request.headers.merge!(@global_headers) - - response = if binary - config.http_client.execute_as_binary(request) - else - config.http_client.execute_as_string(request) - end - @http_call_back&.on_after_response(response) - - response - end - - def validate_response(response) - raise APIException.new 'HTTP Response Not OK', response unless - response.status_code.between?(200, 208) # [200,208] = HTTP OK - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb deleted file mode 100644 index a36001ae..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +++ /dev/null @@ -1,32 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Accounts Tnlookup 400 Error class. - class AccountsTnlookup400ErrorException < APIException - SKIP = Object.new - private_constant :SKIP - - # A description of what validation error occurred. - # @return [String] - attr_accessor :message - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @message = hash.key?('message') ? hash['message'] : SKIP - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb deleted file mode 100644 index 8a6a4333..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +++ /dev/null @@ -1,50 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Create TN Lookup Request - class OrderRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [List of String] - attr_accessor :tns - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['tns'] = 'tns' - @_hash - end - - # An array for optional fields - def optionals - %w[ - tns - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(tns = nil) - @tns = tns unless tns == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - tns = hash.key?('tns') ? hash['tns'] : SKIP - - # Create object from extracted values. - OrderRequest.new(tns) - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb deleted file mode 100644 index 4157ad99..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +++ /dev/null @@ -1,61 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # The request has been accepted for processing but not yet finished and in a - # terminal state (COMPLETE, PARTIAL_COMPLETE, or FAILED) - class OrderResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :request_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :status - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['request_id'] = 'requestId' - @_hash['status'] = 'status' - @_hash - end - - # An array for optional fields - def optionals - %w[ - request_id - status - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(request_id = nil, - status = nil) - @request_id = request_id unless request_id == SKIP - @status = status unless status == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - request_id = hash.key?('requestId') ? hash['requestId'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - - # Create object from extracted values. - OrderResponse.new(request_id, - status) - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb deleted file mode 100644 index c6281931..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +++ /dev/null @@ -1,95 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # If requestId exists, the result for that request is returned. See the - # Examples for details on the various responses that you can receive. - # Generally, if you see a Response Code of 0 in a result for a TN, information - # will be available for it. Any other Response Code will indicate no - # information was available for the TN. - class OrderStatus < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The requestId. - # @return [String] - attr_accessor :request_id - - # The status of the request (IN_PROGRESS, COMPLETE, PARTIAL_COMPLETE, or - # FAILED). - # @return [String] - attr_accessor :status - - # The telephone numbers whose lookup failed - # @return [List of String] - attr_accessor :failed_telephone_numbers - - # The carrier information results for the specified telephone number. - # @return [List of Result] - attr_accessor :result - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['request_id'] = 'requestId' - @_hash['status'] = 'status' - @_hash['failed_telephone_numbers'] = 'failedTelephoneNumbers' - @_hash['result'] = 'result' - @_hash - end - - # An array for optional fields - def optionals - %w[ - request_id - status - failed_telephone_numbers - result - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(request_id = nil, - status = nil, - failed_telephone_numbers = nil, - result = nil) - @request_id = request_id unless request_id == SKIP - @status = status unless status == SKIP - @failed_telephone_numbers = failed_telephone_numbers unless failed_telephone_numbers == SKIP - @result = result unless result == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - request_id = hash.key?('requestId') ? hash['requestId'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - failed_telephone_numbers = - hash.key?('failedTelephoneNumbers') ? hash['failedTelephoneNumbers'] : SKIP - # Parameter is an array, so we need to iterate through it - result = nil - unless hash['result'].nil? - result = [] - hash['result'].each do |structure| - result << (Result.from_hash(structure) if structure) - end - end - - result = SKIP unless hash.key?('result') - - # Create object from extracted values. - OrderStatus.new(request_id, - status, - failed_telephone_numbers, - result) - end - end -end diff --git a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb b/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb deleted file mode 100644 index 470765ca..00000000 --- a/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +++ /dev/null @@ -1,132 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Result Model. - class Result < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Our vendor's response code. - # @return [Integer] - attr_accessor :response_code - - # Message associated with the response code. - # @return [String] - attr_accessor :message - - # The telephone number in E.164 format. - # @return [String] - attr_accessor :e_164_format - - # The formatted version of the telephone number. - # @return [String] - attr_accessor :formatted - - # The country of the telephone number. - # @return [String] - attr_accessor :country - - # The line type of the telephone number. - # @return [String] - attr_accessor :line_type - - # The service provider of the telephone number. - # @return [String] - attr_accessor :line_provider - - # The first half of the Home Network Identity (HNI). - # @return [String] - attr_accessor :mobile_country_code - - # The second half of the HNI. - # @return [String] - attr_accessor :mobile_network_code - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['response_code'] = 'Response Code' - @_hash['message'] = 'Message' - @_hash['e_164_format'] = 'E.164 Format' - @_hash['formatted'] = 'Formatted' - @_hash['country'] = 'Country' - @_hash['line_type'] = 'Line Type' - @_hash['line_provider'] = 'Line Provider' - @_hash['mobile_country_code'] = 'Mobile Country Code' - @_hash['mobile_network_code'] = 'Mobile Network Code' - @_hash - end - - # An array for optional fields - def optionals - %w[ - response_code - message - e_164_format - formatted - country - line_type - line_provider - mobile_country_code - mobile_network_code - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(response_code = nil, - message = nil, - e_164_format = nil, - formatted = nil, - country = nil, - line_type = nil, - line_provider = nil, - mobile_country_code = nil, - mobile_network_code = nil) - @response_code = response_code unless response_code == SKIP - @message = message unless message == SKIP - @e_164_format = e_164_format unless e_164_format == SKIP - @formatted = formatted unless formatted == SKIP - @country = country unless country == SKIP - @line_type = line_type unless line_type == SKIP - @line_provider = line_provider unless line_provider == SKIP - @mobile_country_code = mobile_country_code unless mobile_country_code == SKIP - @mobile_network_code = mobile_network_code unless mobile_network_code == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - response_code = hash.key?('Response Code') ? hash['Response Code'] : SKIP - message = hash.key?('Message') ? hash['Message'] : SKIP - e_164_format = hash.key?('E.164 Format') ? hash['E.164 Format'] : SKIP - formatted = hash.key?('Formatted') ? hash['Formatted'] : SKIP - country = hash.key?('Country') ? hash['Country'] : SKIP - line_type = hash.key?('Line Type') ? hash['Line Type'] : SKIP - line_provider = hash.key?('Line Provider') ? hash['Line Provider'] : SKIP - mobile_country_code = - hash.key?('Mobile Country Code') ? hash['Mobile Country Code'] : SKIP - mobile_network_code = - hash.key?('Mobile Network Code') ? hash['Mobile Network Code'] : SKIP - - # Create object from extracted values. - Result.new(response_code, - message, - e_164_format, - formatted, - country, - line_type, - line_provider, - mobile_country_code, - mobile_network_code) - end - end -end diff --git a/lib/bandwidth/utilities/date_time_helper.rb b/lib/bandwidth/utilities/date_time_helper.rb deleted file mode 100644 index db5dc84b..00000000 --- a/lib/bandwidth/utilities/date_time_helper.rb +++ /dev/null @@ -1,156 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # A utility that supports dateTime conversion to different formats - class DateTimeHelper - # Safely converts a DateTime object into a rfc1123 format string - # @param [DateTime] The DateTime object - # @return [String] The rfc1123 formatted datetime string - def self.to_rfc1123(date_time) - date_time&.httpdate - end - - # Safely converts a map of DateTime objects into a map of rfc1123 format string - # @param [hash] a map of DateTime objects - # @return [hash] a map of rfc1123 formatted datetime string - def self.to_rfc1123_map(date_time, hash, key) - return if date_time.nil? - - hash[key] = {} - date_time.each do |k, v| - hash[key][k] = - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v - end - end - hash[key] - end - - # Safely converts an array of DateTime objects into an array of rfc1123 format string - # @param [Array] an array of DateTime objects - # @return [Array] an array of rfc1123 formatted datetime string - def self.to_rfc1123_array(date_time, hash, key) - return if date_time.nil? - - hash[key] = date_time.map do |v| - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_rfc1123(v) : v - end - end - end - - # Safely converts a DateTime object into a unix format string - # @param [DateTime] The DateTime object - # @return [String] The unix formatted datetime string - def self.to_unix(date_time) - date_time.to_time.utc.to_i unless date_time.nil? - end - - # Safely converts a map of DateTime objects into a map of unix format string - # @param [hash] a map of DateTime objects - # @return [hash] a map of unix formatted datetime string - def self.to_unix_map(date_time, hash, key) - return if date_time.nil? - - hash[key] = {} - date_time.each do |k, v| - hash[key][k] = - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v - end - end - hash[key] - end - - # Safely converts an array of DateTime objects into a map of unix format string - # @param [hash] an array of DateTime objects - # @return [hash] an array of unix formatted datetime string - def self.to_unix_array(date_time, hash, key) - return if date_time.nil? - - hash[key] = date_time.map do |v| - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_unix(v) : v - end - end - end - - # Safely converts a DateTime object into a rfc3339 format string - # @param [DateTime] The DateTime object - # @return [String] The rfc3339 formatted datetime string - def self.to_rfc3339(date_time) - date_time&.rfc3339 - end - - # Safely converts a map of DateTime objects into a map of rfc1123 format string - # @param [hash] a map of DateTime objects - # @return [hash] a map of rfc1123 formatted datetime string - def self.to_rfc3339_map(date_time, hash, key) - return if date_time.nil? - - hash[key] = {} - date_time.each do |k, v| - hash[key][k] = - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v - end - end - hash[key] - end - - # Safely converts an array of DateTime objects into an array of rfc1123 format string - # @param [Array] an array of DateTime objects - # @return [Array] an array of rfc1123 formatted datetime string - def self.to_rfc3339_array(date_time, hash, key) - return if date_time.nil? - - hash[key] = date_time.map do |v| - if v.is_a?(BaseModel) - v.to_hash - else - v.is_a?(DateTime) ? DateTimeHelper.to_rfc3339(v) : v - end - end - end - - # Safely converts a rfc1123 format string into a DateTime object - # @param [String] The rfc1123 formatted datetime string - # @return [DateTime] A DateTime object - def self.from_rfc1123(date_time) - DateTime.httpdate(date_time) - end - - # Safely converts a unix format string into a DateTime object - # @param [String] The unix formatted datetime string - # @return [DateTime] A DateTime object - def self.from_unix(date_time) - Time.at(date_time.to_i).utc.to_datetime - end - - # Safely converts a rfc3339 format string into a DateTime object - # @param [String] The rfc3339 formatted datetime string - # @return [DateTime] A DateTime object - def self.from_rfc3339(date_time) - # missing timezone information - if date_time.end_with?('Z') || date_time.index('+') - DateTime.rfc3339(date_time) - else - DateTime.rfc3339("#{date_time}Z") - end - end - end -end diff --git a/lib/bandwidth/utilities/file_wrapper.rb b/lib/bandwidth/utilities/file_wrapper.rb deleted file mode 100644 index 5c9dc6b9..00000000 --- a/lib/bandwidth/utilities/file_wrapper.rb +++ /dev/null @@ -1,16 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # A utility to allow users to set the content-type for files - class FileWrapper - attr_reader :content_type, :file - - def initialize(file, content_type: 'application/octet-stream') - @file = file - @content_type = content_type - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/bxml.rb b/lib/bandwidth/voice_lib/bxml/bxml.rb deleted file mode 100644 index ffcec42c..00000000 --- a/lib/bandwidth/voice_lib/bxml/bxml.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'builder' -Dir[File.dirname(__FILE__) + '/verbs/*'].each {|file| - require_relative file -} - -module Bandwidth - module Voice - class Bxml - # Initializer - # @param verbs [Array] optional list of verbs to include in the bxml tag - def initialize(verbs = nil) - @verbs = verbs || [] - end - - # Return BXML representaion of this response - def to_bxml() - xml = Builder::XmlMarkup.new() - xml.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8') - xml.Bxml do - @verbs.each {|verb| verb.to_bxml(xml)} - end - xml.target!().gsub(SPEAK_SENTENCE_REGEX){|s|s.gsub(SSML_REGEX, '<\1>')} - end - - # Add one or more verbs to this response - def push(*verbs) - @verbs.push(*verbs) - end - - # Add a verb to this response - def <<(verb) - @verbs << verb - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/response.rb b/lib/bandwidth/voice_lib/bxml/response.rb deleted file mode 100644 index fda1cfe7..00000000 --- a/lib/bandwidth/voice_lib/bxml/response.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'builder' -Dir[File.dirname(__FILE__) + '/verbs/*'].each {|file| - require_relative file -} - -SSML_REGEX = /<([a-zA-Z\/\/].*?)>/ -SPEAK_SENTENCE_REGEX = /.*?<\/SpeakSentence>/ - -module Bandwidth - module Voice - class Response - # Initializer - # @param verbs [Array] optional list of verbs to include into response - def initialize(verbs = nil) - @verbs = verbs || [] - end - - # Return BXML representaion of this response - def to_bxml() - xml = Builder::XmlMarkup.new() - xml.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8') - xml.Response do - @verbs.each {|verb| verb.to_bxml(xml)} - end - xml.target!().gsub(SPEAK_SENTENCE_REGEX){|s|s.gsub(SSML_REGEX, '<\1>')} - end - - # Add one or more verbs to this response - def push(*verbs) - @verbs.push(*verbs) - end - - # Add a verb to this response - def <<(verb) - @verbs << verb - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb b/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb deleted file mode 100644 index 8235ebfc..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +++ /dev/null @@ -1,28 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Bridge verb allows you to connect 2 calls - class Bridge - include XmlVerb - - def to_bxml(xml) - xml.Bridge(call_id, compact_hash({ - 'bridgeCompleteUrl' => bridge_complete_url, - 'bridgeCompleteMethod' => bridge_complete_method, - 'bridgeTargetCompleteUrl' => bridge_target_complete_url, - 'bridgeTargetCompleteMethod' => bridge_target_complete_method, - 'username' => username, - 'password' => password, - 'tag' => tag, - 'bridgeCompleteFallbackUrl' => bridge_complete_fallback_url, - 'bridgeCompleteFallbackMethod' => bridge_complete_fallback_method, - 'bridgeTargetCompleteFallbackUrl' => bridge_target_complete_fallback_url, - 'bridgeTargetCompleteFallbackMethod' => bridge_target_complete_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/conference.rb b/lib/bandwidth/voice_lib/bxml/verbs/conference.rb deleted file mode 100644 index c4147a00..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +++ /dev/null @@ -1,32 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Conference verb is used to add callees to conferences - class Conference - include XmlVerb - - def to_bxml(xml) - if not call_ids_to_coach.nil? - coach_ids = call_ids_to_coach.instance_of?(String) ? call_ids_to_coach : call_ids_to_coach.join(",") - else - coach_ids = nil - end - xml.Conference(conference_name, compact_hash({ - 'mute' => mute, - 'hold' => hold, - 'callIdsToCoach' => coach_ids, - 'conferenceEventUrl' => conference_event_url, - 'conferenceEventMethod' => conference_event_method, - 'username' => username, - 'password' => password, - 'tag' => tag, - 'conferenceEventFallbackUrl' => conference_event_fallback_url, - 'conferenceEventFallbackMethod' => conference_event_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/custom_param.rb b/lib/bandwidth/voice_lib/bxml/verbs/custom_param.rb deleted file mode 100644 index 8b3a4b08..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/custom_param.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # These elements define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started - class CustomParam - include XmlVerb - - def to_bxml(xml) - xml.CustomParam(compact_hash({ - 'name' => name, - 'value' => value - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/forward.rb b/lib/bandwidth/voice_lib/bxml/verbs/forward.rb deleted file mode 100644 index d429ae4a..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/forward.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class Forward - include XmlVerb - def to_bxml(xml) - xml.Forward(compact_hash({ - 'to' => to, - 'from' => from, - 'callTimeout' => call_timeout, - 'diversionTreatment' => diversion_treatment, - 'diversionReason' => diversion_reason - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/gather.rb b/lib/bandwidth/voice_lib/bxml/verbs/gather.rb deleted file mode 100644 index d898f8cd..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +++ /dev/null @@ -1,49 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Gather verb is used to collect digits for some period of time - class Gather - include XmlVerb - - def to_bxml(xml) - xml.Gather(compact_hash({ - 'gatherUrl' => gather_url, - 'gatherMethod' => gather_method, - 'terminatingDigits' => terminating_digits, - 'tag' => tag, - 'maxDigits' => max_digits, - 'interDigitTimeout' => inter_digit_timeout, - 'username' => username, - 'password' => password, - 'firstDigitTimeout' => first_digit_timeout, - 'repeatCount' => repeat_count, - 'gatherFallbackUrl' => gather_fallback_url, - 'gatherFallbackMethod' => gather_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) do - def embedded_xml(xml, property, type) - if property - s = if property.is_a?(type) - then property - else type.new(property) - end - s.to_bxml(xml) - end - end - def nest_verbs_list(xml, property) - if property - property.each do |verb| - verb.to_bxml(xml) - end - end - end - embedded_xml(xml, speak_sentence, SpeakSentence) - embedded_xml(xml, play_audio, PlayAudio) - nest_verbs_list(xml, nested_verbs) - end - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb b/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb deleted file mode 100644 index d316ebfc..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/hangup.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Hangup verb is used to hangup current call - class Hangup - include XmlVerb - - def to_bxml(xml) - xml.Hangup() - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/pause.rb b/lib/bandwidth/voice_lib/bxml/verbs/pause.rb deleted file mode 100644 index 7c6dc966..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/pause.rb +++ /dev/null @@ -1,15 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class Pause - include XmlVerb - - def to_bxml(xml) - xml.Pause(compact_hash({ - 'duration' => duration - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/pause_recording.rb b/lib/bandwidth/voice_lib/bxml/verbs/pause_recording.rb deleted file mode 100644 index 86cd439c..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/pause_recording.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The PauseRecording verb is used to pause recording in a call - class PauseRecording - include XmlVerb - - def to_bxml(xml) - xml.PauseRecording() - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb b/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb deleted file mode 100644 index 725dbdc0..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class PhoneNumber - include XmlVerb - def to_bxml(xml) - xml.PhoneNumber(number, compact_hash({ - 'transferAnswerUrl' => transfer_answer_url, - 'transferAnswerMethod' => transfer_answer_method, - 'transferDisconnectUrl' => transfer_disconnect_url, - 'transferDisconnectMethod' => transfer_disconnect_method, - 'username' => username, - 'password' => password, - 'tag' => tag, - 'transferAnswerFallbackUrl' => transfer_answer_fallback_url, - 'transferAnswerFallbackMethod' => transfer_answer_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb b/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb deleted file mode 100644 index 59e7bfcb..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/play_audio.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The PlayAudio verb is used to play an audio file in the call - class PlayAudio - include XmlVerb - - def to_bxml(xml) - xml.PlayAudio(url, compact_hash({ - 'username' => username, - 'password' => password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/record.rb b/lib/bandwidth/voice_lib/bxml/verbs/record.rb deleted file mode 100644 index c14da583..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/record.rb +++ /dev/null @@ -1,34 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Record verb is used to trigger call recording - class Record - include XmlVerb - - def to_bxml(xml) - xml.Record(compact_hash({ - 'tag' => tag, - 'username' => username, - 'password' => password, - 'recordCompleteUrl' => record_complete_url, - 'recordCompleteMethod' => record_complete_method, - 'recordingAvailableUrl' => recording_available_url, - 'recordingAvailableMethod' => recording_available_method, - 'terminatingDigits' => terminating_digits, - 'maxDuration' => max_duration, - 'fileFormat' => file_format, - 'transcribe' => transcribe, - 'detectLanguage' => detect_language, - 'transcriptionAvailableUrl' => transcription_available_url, - 'transcriptionAvailableMethod' => transcription_available_method, - 'silenceTimeout' => silence_timeout, - 'recordCompleteFallbackUrl' => record_complete_fallback_url, - 'recordCompleteFallbackMethod' => record_complete_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb b/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb deleted file mode 100644 index 80112e0b..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +++ /dev/null @@ -1,24 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Redirect verb is used to redirect the current XML execution to another URL - class Redirect - include XmlVerb - - def to_bxml(xml) - xml.Redirect(compact_hash({ - 'redirectUrl' => redirect_url, - 'redirectMethod' => redirect_method, - 'tag' => tag, - 'username' => username, - 'password' => password, - 'redirectFallbackUrl' => redirect_fallback_url, - 'redirectFallbackMethod' => redirect_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/resume_recording.rb b/lib/bandwidth/voice_lib/bxml/verbs/resume_recording.rb deleted file mode 100644 index 09ec5ebf..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/resume_recording.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The ResumeRecording verb is used to resume recording in a call - class ResumeRecording - include XmlVerb - - def to_bxml(xml) - xml.ResumeRecording() - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/ring.rb b/lib/bandwidth/voice_lib/bxml/verbs/ring.rb deleted file mode 100644 index d1a41c14..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class Ring - include XmlVerb - - def to_bxml(xml) - xml.Ring(compact_hash({ - 'duration' => duration, - 'answerCall' => answer_call - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb b/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb deleted file mode 100644 index f2c9a140..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class SendDtmf - include XmlVerb - - def to_bxml(xml) - xml.SendDtmf(dtmf, compact_hash({ - 'toneDuration' => tone_duration, - 'toneInterval' => tone_interval - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb b/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb deleted file mode 100644 index 2465a8b0..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class SipUri - include XmlVerb - def to_bxml(xml) - xml.SipUri(uri, compact_hash({ - 'transferAnswerUrl' => transfer_answer_url, - 'transferAnswerMethod' => transfer_answer_method, - 'transferDisconnectUrl' => transfer_disconnect_url, - 'transferDisconnectMethod' => transfer_disconnect_method, - 'username' => username, - 'password' => password, - 'tag' => tag, - 'uui' => uui, - 'transferAnswerFallbackUrl' => transfer_answer_fallback_url, - 'transferAnswerFallbackMethod' => transfer_answer_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb b/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb deleted file mode 100644 index b43c9795..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/speak_sentence.rb +++ /dev/null @@ -1,18 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The SpeakSentence verb is used to convert any text into speak for the caller - class SpeakSentence - include XmlVerb - - def to_bxml(xml) - xml.SpeakSentence(sentence, compact_hash({ - 'voice' => voice, - 'locale' => locale, - 'gender' => gender - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb b/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb deleted file mode 100644 index 39454343..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StartGather verb is used to start a gather - class StartGather - include XmlVerb - - def to_bxml(xml) - xml.StartGather(compact_hash({ - 'username' => username, - 'password' => password, - 'tag' => tag, - 'dtmfUrl' => dtmf_url, - 'dtmfMethod' => dtmf_method, - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb b/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb deleted file mode 100644 index b57d0f52..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +++ /dev/null @@ -1,26 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StartRecording verb is used to trigger call recording - class StartRecording - include XmlVerb - - def to_bxml(xml) - xml.StartRecording(compact_hash({ - 'tag' => tag, - 'username' => username, - 'password' => password, - 'recordingAvailableUrl' => recording_available_url, - 'recordingAvailableMethod' => recording_available_method, - 'fileFormat' => file_format, - 'multiChannel' => multi_channel, - 'transcribe' => transcribe, - 'detectLanguage' => detect_language, - 'transcriptionAvailableUrl' => transcription_available_url, - 'transcriptionAvailableMethod' => transcription_available_method - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/start_stream.rb b/lib/bandwidth/voice_lib/bxml/verbs/start_stream.rb deleted file mode 100644 index 7b5fa526..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/start_stream.rb +++ /dev/null @@ -1,41 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StartStream verb allows a segment of a call to be sent off to another destination for additional processing - class StartStream - include XmlVerb - - def to_bxml(xml) - xml.StartStream(compact_hash({ - 'destination' => destination, - 'name' => name, - 'tracks' => tracks, - 'streamEventUrl' => streamEventUrl, - 'streamEventMethod' => streamEventMethod, - 'username' => username, - 'password' => password - })) do - def embedded_xml(xml, property, type) - if property - s = if property.is_a?(type) - then property - else type.new(property) - end - s.to_bxml(xml) - end - end - def nest_verbs_list(xml, property) - if property - property.each do |verb| - verb.to_bxml(xml) - end - end - end - embedded_xml(xml, stream_params, StreamParam) - nest_verbs_list(xml, nested_verbs) - end - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/start_transcription.rb b/lib/bandwidth/voice_lib/bxml/verbs/start_transcription.rb deleted file mode 100644 index cd5f1f03..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/start_transcription.rb +++ /dev/null @@ -1,42 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StartTranscription verb allows a segment of a call to be transcribed and optionally for the live transcription to be sent off to another destination for additional processing - class StartTranscription - include XmlVerb - - def to_bxml(xml) - xml.StartTranscription(compact_hash({ - 'name' => name, - 'tracks' => tracks, - 'transcriptionEventUrl' => transcriptionEventUrl, - 'transcriptionEventMethod' => transcriptionEventMethod, - 'username' => username, - 'password' => password, - 'destination' => destination, - 'stabilized' => stabilized - })) do - def embedded_xml(xml, property, type) - if property - s = if property.is_a?(type) - then property - else type.new(property) - end - s.to_bxml(xml) - end - end - def nest_verbs_list(xml, property) - if property - property.each do |verb| - verb.to_bxml(xml) - end - end - end - embedded_xml(xml, custom_params, CustomParam) - nest_verbs_list(xml, nested_verbs) - end - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb b/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb deleted file mode 100644 index 0e4c5dae..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StopGather verb is used to complete a gather - class StopGather - include XmlVerb - - def to_bxml(xml) - xml.StopGather() - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb b/lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb deleted file mode 100644 index eececb46..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb +++ /dev/null @@ -1,14 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StopRecording verb is used to stop recording in a call - class StopRecording - include XmlVerb - - def to_bxml(xml) - xml.StopRecording() - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/stop_stream.rb b/lib/bandwidth/voice_lib/bxml/verbs/stop_stream.rb deleted file mode 100644 index 32920835..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/stop_stream.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StopStream verb is used to stop a stream that was started with a previous `` verb - class StopStream - include XmlVerb - - def to_bxml(xml) - xml.StopStream(compact_hash({ - 'name' => name - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/stop_transcription.rb b/lib/bandwidth/voice_lib/bxml/verbs/stop_transcription.rb deleted file mode 100644 index cd7f0bb8..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/stop_transcription.rb +++ /dev/null @@ -1,16 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The StopTranscription verb is used to stop a real-time transcription that was started with a previous `` verb - class StopTranscription - include XmlVerb - - def to_bxml(xml) - xml.StopTranscription(compact_hash({ - 'name' => name - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/stream_param.rb b/lib/bandwidth/voice_lib/bxml/verbs/stream_param.rb deleted file mode 100644 index 84a94622..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/stream_param.rb +++ /dev/null @@ -1,17 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started - class StreamParam - include XmlVerb - - def to_bxml(xml) - xml.StreamParam(compact_hash({ - 'name' => name, - 'value' => value - })) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/tag.rb b/lib/bandwidth/voice_lib/bxml/verbs/tag.rb deleted file mode 100644 index 20e2f7d2..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/tag.rb +++ /dev/null @@ -1,13 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - class Tag - include XmlVerb - - def to_bxml(xml) - xml.Tag(tag) - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb b/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb deleted file mode 100644 index 680da916..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +++ /dev/null @@ -1,48 +0,0 @@ -require_relative 'xml_verb' - -module Bandwidth - module Voice - # The Transfer verb is used to transfer the call to another number - class Transfer - include XmlVerb - - def to_bxml(xml) - xml.Transfer(compact_hash({ - 'transferCallerId' => transfer_caller_id, - 'callTimeout' => call_timeout, - 'tag' => tag, - 'transferCompleteUrl' => transfer_complete_url, - 'transferCompleteMethod' => transfer_complete_method, - 'username' => username, - 'password' => password, - 'diversionTreatment' => diversion_treatment, - 'diversionReason' => diversion_reason, - 'transferCompleteFallbackUrl' => transfer_complete_fallback_url, - 'transferCompleteFallbackMethod' => transfer_complete_fallback_method, - 'fallbackUsername' => fallback_username, - 'fallbackPassword' => fallback_password - })) do - def embedded_xml(xml, property, type) - if property - s = if property.is_a?(type) - then property - else type.new(property) - end - s.to_bxml(xml) - end - end - if not phone_numbers.nil? - phone_numbers.each do |number| - embedded_xml(xml, number, PhoneNumber) - end - end - if not sip_uris.nil? - sip_uris.each do |sip_uri| - embedded_xml(xml, sip_uri, SipUri) - end - end - end - end - end - end -end diff --git a/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb b/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb deleted file mode 100644 index 8233a934..00000000 --- a/lib/bandwidth/voice_lib/bxml/verbs/xml_verb.rb +++ /dev/null @@ -1,26 +0,0 @@ -module Bandwidth - module Voice - module XmlVerb - def initialize(data = nil) - @data = (data || {}).clone() - end - - def method_missing(name, *args, &block) - if name[name.size - 1] == '=' - @data[name[0..-2].to_sym] = args[0] - else - @data[name] - end - end - - def compact_hash(hash) - hash.inject({}) do |new_hash, (k,v)| - if !v.nil? - new_hash[k] = v.class == Hash ? compact_hash(v) : v - end - new_hash - end - end - end - end -end diff --git a/lib/bandwidth/voice_lib/voice.rb b/lib/bandwidth/voice_lib/voice.rb deleted file mode 100644 index 9e0e7e62..00000000 --- a/lib/bandwidth/voice_lib/voice.rb +++ /dev/null @@ -1,48 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'voice/client.rb' - -# Models -require_relative 'voice/models/create_call_request.rb' -require_relative 'voice/models/create_call_response.rb' -require_relative 'voice/models/call_state.rb' -require_relative 'voice/models/modify_call_request.rb' -require_relative 'voice/models/modify_call_recording_request.rb' -require_relative 'voice/models/call_recording_metadata.rb' -require_relative 'voice/models/modify_conference_request.rb' -require_relative 'voice/models/conference_state.rb' -require_relative 'voice/models/conference_member_state.rb' -require_relative 'voice/models/conference_recording_metadata.rb' -require_relative 'voice/models/machine_detection_configuration.rb' -require_relative 'voice/models/transcribe_recording_request.rb' -require_relative 'voice/models/transcription_response.rb' -require_relative 'voice/models/transcription_metadata.rb' -require_relative 'voice/models/transcript.rb' -require_relative 'voice/models/call_callback.rb' -require_relative 'voice/models/transcription.rb' -require_relative 'voice/models/diversion.rb' -require_relative 'voice/models/conference_callback.rb' -require_relative 'voice/models/answer_fallback_method_enum.rb' -require_relative 'voice/models/answer_method_enum.rb' -require_relative 'voice/models/callback_method_enum.rb' -require_relative 'voice/models/conference_event_method_enum.rb' -require_relative 'voice/models/direction_enum.rb' -require_relative 'voice/models/disconnect_method_enum.rb' -require_relative 'voice/models/fallback_method_enum.rb' -require_relative 'voice/models/file_format_enum.rb' -require_relative 'voice/models/mode_enum.rb' -require_relative 'voice/models/redirect_fallback_method_enum.rb' -require_relative 'voice/models/redirect_method_enum.rb' -require_relative 'voice/models/state_enum.rb' -require_relative 'voice/models/state1_enum.rb' -require_relative 'voice/models/status_enum.rb' - -# Exceptions -require_relative 'voice/exceptions/api_error_exception.rb' -# Controllers -require_relative 'voice/controllers/base_controller.rb' -require_relative 'voice/controllers/api_controller.rb' diff --git a/lib/bandwidth/voice_lib/voice/client.rb b/lib/bandwidth/voice_lib/voice/client.rb deleted file mode 100644 index a4324203..00000000 --- a/lib/bandwidth/voice_lib/voice/client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - module Voice - # bandwidth client class. - class Client - attr_reader :config - - # Access to client controller. - # @return [APIController] Returns the controller instance. - def client - @client ||= APIController.new config - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', - config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, - max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end -end diff --git a/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb b/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb deleted file mode 100644 index fbdbbe56..00000000 --- a/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +++ /dev/null @@ -1,1820 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth -module Voice - # APIController - class APIController < BaseController - def initialize(config, http_call_back: nil) - super(config, http_call_back: http_call_back) - end - - # Creates an outbound phone call. - # @param [String] account_id Required parameter: Example: - # @param [CreateCallRequest] body Required parameter: Example: - # @return [CreateCallResponse] response from the API call - def create_call(account_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: CreateCallResponse.from_hash(decoded) - ) - end - - # Returns near-realtime metadata about the specified call. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @return [CallState] response from the API call - def get_call(account_id, - call_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: CallState.from_hash(decoded) - ) - end - - # Interrupts and replaces an active call's BXML document. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [ModifyCallRequest] body Required parameter: Example: - # @return [void] response from the API call - def modify_call(account_id, - call_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Makes a PUT request to /api/v2/accounts/{accountId}/calls/{callId}/bxml - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] body Required parameter: Example: - # @return [void] response from the API call - def modify_call_bxml(account_id, - call_id, - body - ) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/bxml' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/xml; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/xml`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Pauses or resumes a recording. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [ModifyCallRecordingRequest] body Required parameter: Example: - # @return [void] response from the API call - def modify_call_recording_state(account_id, - call_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recording' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Returns a (potentially empty) list of metadata for the recordings that - # took place during the specified call. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @return [List of CallRecordingMetadata] response from the API call - def get_call_recordings(account_id, - call_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| CallRecordingMetadata.from_hash(element) } - ) - end - - # Returns metadata for the specified recording. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [CallRecordingMetadata] response from the API call - def get_call_recording(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: CallRecordingMetadata.from_hash(decoded) - ) - end - - # Deletes the specified recording. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [void] response from the API call - def delete_recording(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Downloads the specified recording. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [Mixed] response from the API call - def get_download_call_recording(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new( - _response, data: _response.raw_body - ) - end - - # Deletes the specified recording's media. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [void] response from the API call - def delete_recording_media(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Downloads the specified transcription. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [TranscriptionResponse] response from the API call - def get_call_transcription(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: TranscriptionResponse.from_hash(decoded) - ) - end - - # Requests that the specified recording be transcribed. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @param [TranscribeRecordingRequest] body Required parameter: Example: - # @return [void] response from the API call - def create_transcribe_call_recording(account_id, - call_id, - recording_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 410 - raise ApiErrorException.new( - 'The media for this recording has been deleted, so we can\'t' \ - ' transcribe it', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Deletes the specified recording's transcription. - # @param [String] account_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [void] response from the API call - def delete_call_transcription(account_id, - call_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Returns information about the conferences in the account. - # @param [String] account_id Required parameter: Example: - # @param [String] name Optional parameter: Example: - # @param [String] min_created_time Optional parameter: Example: - # @param [String] max_created_time Optional parameter: Example: - # @param [Integer] page_size Optional parameter: Example:1000 - # @param [String] page_token Optional parameter: Example: - # @return [List of ConferenceState] response from the API call - def get_conferences(account_id, - name: nil, - min_created_time: nil, - max_created_time: nil, - page_size: 1000, - page_token: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_builder = APIHelper.append_url_with_query_parameters( - _query_builder, - 'name' => name, - 'minCreatedTime' => min_created_time, - 'maxCreatedTime' => max_created_time, - 'pageSize' => page_size, - 'pageToken' => page_token - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| ConferenceState.from_hash(element) } - ) - end - - # Returns information about the specified conference. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @return [ConferenceState] response from the API call - def get_conference(account_id, - conference_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: ConferenceState.from_hash(decoded) - ) - end - - # Modify the conference state. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @param [ModifyConferenceRequest] body Required parameter: Example: - # @return [void] response from the API call - def modify_conference(account_id, - conference_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Updates settings for a particular conference member. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @param [String] call_id Required parameter: Example: - # @param [ConferenceMemberState] body Required parameter: Example: - # @return [void] response from the API call - def modify_conference_member(account_id, - conference_id, - call_id, - body) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{callId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false }, - 'callId' => { 'value' => call_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body.to_json - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Returns information about the specified conference member. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @param [String] member_id Required parameter: Example: - # @return [ConferenceMemberState] response from the API call - def get_conference_member(account_id, - conference_id, - member_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false }, - 'memberId' => { 'value' => member_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: ConferenceMemberState.from_hash(decoded) - ) - end - - # Returns a (potentially empty) list of metadata for the recordings that - # took place during the specified conference - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @return [List of ConferenceRecordingMetadata] response from the API call - def get_conference_recordings(account_id, - conference_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| ConferenceRecordingMetadata.from_hash(element) } - ) - end - - # Returns metadata for the specified recording. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [CallRecordingMetadata] response from the API call - def get_conference_recording(account_id, - conference_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: CallRecordingMetadata.from_hash(decoded) - ) - end - - # Downloads the specified recording. - # @param [String] account_id Required parameter: Example: - # @param [String] conference_id Required parameter: Example: - # @param [String] recording_id Required parameter: Example: - # @return [Mixed] response from the API call - def get_download_conference_recording(account_id, - conference_id, - recording_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'conferenceId' => { 'value' => conference_id, 'encode' => false }, - 'recordingId' => { 'value' => recording_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) unless - _response.raw_body.nil? || - _response.raw_body.to_s.strip.empty? - ApiResponse.new( - _response, data: decoded - ) - end - - # Returns a list of metadata for the recordings associated with the - # specified account. The list can be filtered by the optional from, to, - # minStartTime, and maxStartTime arguments. The list is capped at 1000 - # entries and may be empty if no recordings match the specified criteria. - # @param [String] account_id Required parameter: Example: - # @param [String] from Optional parameter: Example: - # @param [String] to Optional parameter: Example: - # @param [String] min_start_time Optional parameter: Example: - # @param [String] max_start_time Optional parameter: Example: - # @return [List of CallRecordingMetadata] response from the API call - def get_query_call_recordings(account_id, - from: nil, - to: nil, - min_start_time: nil, - max_start_time: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::VOICEDEFAULT) - _query_builder << '/api/v2/accounts/{accountId}/recordings' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_builder = APIHelper.append_url_with_query_parameters( - _query_builder, - 'from' => from, - 'to' => to, - 'minStartTime' => min_start_time, - 'maxStartTime' => max_start_time - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - VoiceBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise ApiErrorException.new( - 'Something\'s not quite right... Your request is invalid. Please' \ - ' fix it before trying again.', - _response - ) - when 401 - raise APIException.new( - 'Your credentials are invalid. Please use your Bandwidth dashboard' \ - ' credentials to authenticate to the API.', - _response - ) - when 403 - raise ApiErrorException.new( - 'User unauthorized to perform this action.', - _response - ) - when 404 - raise ApiErrorException.new( - 'The resource specified cannot be found or does not belong to you.', - _response - ) - when 415 - raise ApiErrorException.new( - 'We don\'t support that media type. If a request body is required,' \ - ' please send it to us as `application/json`.', - _response - ) - when 429 - raise ApiErrorException.new( - 'You\'re sending requests to this endpoint too frequently. Please' \ - ' slow your request rate down and try again.', - _response - ) - when 500 - raise ApiErrorException.new( - 'Something unexpected happened. Please try again.', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| CallRecordingMetadata.from_hash(element) } - ) - end - end -end -end diff --git a/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb b/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb deleted file mode 100644 index 17e3cbc6..00000000 --- a/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BaseController. - class BaseController - attr_accessor :config, :http_call_back - - def initialize(config, http_call_back: nil) - @config = config - @http_call_back = http_call_back - - @global_headers = { - 'user-agent' => 'ruby-sdk' - } - end - - def validate_parameters(args) - args.each do |_name, value| - raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil? - end - end - - def execute_request(request, binary: false) - @http_call_back&.on_before_request(request) - - APIHelper.clean_hash(request.headers) - request.headers.merge!(@global_headers) - - response = if binary - config.http_client.execute_as_binary(request) - else - config.http_client.execute_as_string(request) - end - @http_call_back&.on_after_response(response) - - response - end - - def validate_response(response) - raise APIException.new 'HTTP Response Not OK', response unless - response.status_code.between?(200, 208) # [200,208] = HTTP OK - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb b/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb deleted file mode 100644 index 73ad7ace..00000000 --- a/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +++ /dev/null @@ -1,42 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ApiError class. - class ApiErrorException < APIException - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :type - - # TODO: Write general description for this method - # @return [String] - attr_accessor :description - - # TODO: Write general description for this method - # @return [String] - attr_accessor :id - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @type = hash.key?('type') ? hash['type'] : SKIP - @description = hash.key?('description') ? hash['description'] : SKIP - @id = hash.key?('id') ? hash['id'] : SKIP - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb deleted file mode 100644 index d94a8141..00000000 --- a/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # AnswerFallbackMethod. - class AnswerFallbackMethodEnum - ANSWER_FALLBACK_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb deleted file mode 100644 index 37d74045..00000000 --- a/lib/bandwidth/voice_lib/voice/models/answer_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # AnswerMethod. - class AnswerMethodEnum - ANSWER_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/call_callback.rb b/lib/bandwidth/voice_lib/voice/models/call_callback.rb deleted file mode 100644 index 70e4c83d..00000000 --- a/lib/bandwidth/voice_lib/voice/models/call_callback.rb +++ /dev/null @@ -1,343 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # This object represents all possible fields that may be included in callbacks - # related to call events, including events that come from BXML verbs - class CallCallback < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :event_type - - # TODO: Write general description for this method - # @return [String] - attr_accessor :event_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :application_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :direction - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_url - - # TODO: Write general description for this method - # @return [String] - attr_accessor :start_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :answer_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :transfer_caller_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :transfer_to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :cause - - # TODO: Write general description for this method - # @return [String] - attr_accessor :error_message - - # TODO: Write general description for this method - # @return [String] - attr_accessor :error_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :end_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :digit - - # TODO: Write general description for this method - # @return [String] - attr_accessor :parent_call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :recording_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :duration - - # TODO: Write general description for this method - # @return [String] - attr_accessor :file_format - - # TODO: Write general description for this method - # @return [String] - attr_accessor :media_url - - # TODO: Write general description for this method - # @return [String] - attr_accessor :tag - - # TODO: Write general description for this method - # @return [Integer] - attr_accessor :channels - - # TODO: Write general description for this method - # @return [String] - attr_accessor :status - - # TODO: Write general description for this method - # @return [String] - attr_accessor :digits - - # TODO: Write general description for this method - # @return [String] - attr_accessor :terminating_digit - - # TODO: Write general description for this method - # @return [Transcription] - attr_accessor :transcription - - # TODO: Write general description for this method - # @return [Diversion] - attr_accessor :diversion - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['event_type'] = 'eventType' - @_hash['event_time'] = 'eventTime' - @_hash['account_id'] = 'accountId' - @_hash['application_id'] = 'applicationId' - @_hash['from'] = 'from' - @_hash['to'] = 'to' - @_hash['direction'] = 'direction' - @_hash['call_id'] = 'callId' - @_hash['call_url'] = 'callUrl' - @_hash['start_time'] = 'startTime' - @_hash['answer_time'] = 'answerTime' - @_hash['transfer_caller_id'] = 'transferCallerId' - @_hash['transfer_to'] = 'transferTo' - @_hash['cause'] = 'cause' - @_hash['error_message'] = 'errorMessage' - @_hash['error_id'] = 'errorId' - @_hash['end_time'] = 'endTime' - @_hash['digit'] = 'digit' - @_hash['parent_call_id'] = 'parentCallId' - @_hash['recording_id'] = 'recordingId' - @_hash['duration'] = 'duration' - @_hash['file_format'] = 'fileFormat' - @_hash['media_url'] = 'mediaUrl' - @_hash['tag'] = 'tag' - @_hash['channels'] = 'channels' - @_hash['status'] = 'status' - @_hash['digits'] = 'digits' - @_hash['terminating_digit'] = 'terminatingDigit' - @_hash['transcription'] = 'transcription' - @_hash['diversion'] = 'diversion' - @_hash - end - - # An array for optional fields - def optionals - %w[ - event_type - event_time - account_id - application_id - from - to - direction - call_id - call_url - start_time - answer_time - transfer_caller_id - transfer_to - cause - error_message - error_id - end_time - digit - parent_call_id - recording_id - duration - file_format - media_url - tag - channels - status - digits - terminating_digit - transcription - diversion - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(event_type = nil, - event_time = nil, - account_id = nil, - application_id = nil, - from = nil, - to = nil, - direction = nil, - call_id = nil, - call_url = nil, - start_time = nil, - answer_time = nil, - transfer_caller_id = nil, - transfer_to = nil, - cause = nil, - error_message = nil, - error_id = nil, - end_time = nil, - digit = nil, - parent_call_id = nil, - recording_id = nil, - duration = nil, - file_format = nil, - media_url = nil, - tag = nil, - channels = nil, - status = nil, - digits = nil, - terminating_digit = nil, - transcription = nil, - diversion = nil) - @event_type = event_type unless event_type == SKIP - @event_time = event_time unless event_time == SKIP - @account_id = account_id unless account_id == SKIP - @application_id = application_id unless application_id == SKIP - @from = from unless from == SKIP - @to = to unless to == SKIP - @direction = direction unless direction == SKIP - @call_id = call_id unless call_id == SKIP - @call_url = call_url unless call_url == SKIP - @start_time = start_time unless start_time == SKIP - @answer_time = answer_time unless answer_time == SKIP - @transfer_caller_id = transfer_caller_id unless transfer_caller_id == SKIP - @transfer_to = transfer_to unless transfer_to == SKIP - @cause = cause unless cause == SKIP - @error_message = error_message unless error_message == SKIP - @error_id = error_id unless error_id == SKIP - @end_time = end_time unless end_time == SKIP - @digit = digit unless digit == SKIP - @parent_call_id = parent_call_id unless parent_call_id == SKIP - @recording_id = recording_id unless recording_id == SKIP - @duration = duration unless duration == SKIP - @file_format = file_format unless file_format == SKIP - @media_url = media_url unless media_url == SKIP - @tag = tag unless tag == SKIP - @channels = channels unless channels == SKIP - @status = status unless status == SKIP - @digits = digits unless digits == SKIP - @terminating_digit = terminating_digit unless terminating_digit == SKIP - @transcription = transcription unless transcription == SKIP - @diversion = diversion unless diversion == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - event_type = hash.key?('eventType') ? hash['eventType'] : SKIP - event_time = hash.key?('eventTime') ? hash['eventTime'] : SKIP - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - direction = hash.key?('direction') ? hash['direction'] : SKIP - call_id = hash.key?('callId') ? hash['callId'] : SKIP - call_url = hash.key?('callUrl') ? hash['callUrl'] : SKIP - start_time = hash.key?('startTime') ? hash['startTime'] : SKIP - answer_time = hash.key?('answerTime') ? hash['answerTime'] : SKIP - transfer_caller_id = - hash.key?('transferCallerId') ? hash['transferCallerId'] : SKIP - transfer_to = hash.key?('transferTo') ? hash['transferTo'] : SKIP - cause = hash.key?('cause') ? hash['cause'] : SKIP - error_message = hash.key?('errorMessage') ? hash['errorMessage'] : SKIP - error_id = hash.key?('errorId') ? hash['errorId'] : SKIP - end_time = hash.key?('endTime') ? hash['endTime'] : SKIP - digit = hash.key?('digit') ? hash['digit'] : SKIP - parent_call_id = hash.key?('parentCallId') ? hash['parentCallId'] : SKIP - recording_id = hash.key?('recordingId') ? hash['recordingId'] : SKIP - duration = hash.key?('duration') ? hash['duration'] : SKIP - file_format = hash.key?('fileFormat') ? hash['fileFormat'] : SKIP - media_url = hash.key?('mediaUrl') ? hash['mediaUrl'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - channels = hash.key?('channels') ? hash['channels'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - digits = hash.key?('digits') ? hash['digits'] : SKIP - terminating_digit = - hash.key?('terminatingDigit') ? hash['terminatingDigit'] : SKIP - transcription = Transcription.from_hash(hash['transcription']) if hash['transcription'] - diversion = Diversion.from_hash(hash['diversion']) if hash['diversion'] - - # Create object from extracted values. - CallCallback.new(event_type, - event_time, - account_id, - application_id, - from, - to, - direction, - call_id, - call_url, - start_time, - answer_time, - transfer_caller_id, - transfer_to, - cause, - error_message, - error_id, - end_time, - digit, - parent_call_id, - recording_id, - duration, - file_format, - media_url, - tag, - channels, - status, - digits, - terminating_digit, - transcription, - diversion) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb b/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb deleted file mode 100644 index cafdce2a..00000000 --- a/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +++ /dev/null @@ -1,250 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # CallRecordingMetadata Model. - class CallRecordingMetadata < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :application_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :parent_call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :recording_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [String] - attr_accessor :transfer_caller_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :transfer_to - - # Format is ISO-8601 - # @return [String] - attr_accessor :duration - - # Format is ISO-8601 - # @return [DirectionEnum] - attr_accessor :direction - - # Format is ISO-8601 - # @return [Integer] - attr_accessor :channels - - # Format is ISO-8601 - # @return [DateTime] - attr_accessor :start_time - - # Format is ISO-8601 - # @return [DateTime] - attr_accessor :end_time - - # Format is ISO-8601 - # @return [FileFormatEnum] - attr_accessor :file_format - - # The current status of the recording. Current values are 'processing', - # 'partial', 'complete', 'deleted' and 'error'. Additional states may be - # added in the future, so your application must be tolerant of unknown - # values. - # @return [String] - attr_accessor :status - - # The current status of the recording. Current values are 'processing', - # 'partial', 'complete', 'deleted' and 'error'. Additional states may be - # added in the future, so your application must be tolerant of unknown - # values. - # @return [String] - attr_accessor :media_url - - # The current status of the recording. Current values are 'processing', - # 'partial', 'complete', 'deleted' and 'error'. Additional states may be - # added in the future, so your application must be tolerant of unknown - # values. - # @return [TranscriptionMetadata] - attr_accessor :transcription - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['application_id'] = 'applicationId' - @_hash['account_id'] = 'accountId' - @_hash['call_id'] = 'callId' - @_hash['parent_call_id'] = 'parentCallId' - @_hash['recording_id'] = 'recordingId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['transfer_caller_id'] = 'transferCallerId' - @_hash['transfer_to'] = 'transferTo' - @_hash['duration'] = 'duration' - @_hash['direction'] = 'direction' - @_hash['channels'] = 'channels' - @_hash['start_time'] = 'startTime' - @_hash['end_time'] = 'endTime' - @_hash['file_format'] = 'fileFormat' - @_hash['status'] = 'status' - @_hash['media_url'] = 'mediaUrl' - @_hash['transcription'] = 'transcription' - @_hash - end - - # An array for optional fields - def optionals - %w[ - application_id - account_id - call_id - parent_call_id - recording_id - to - from - transfer_caller_id - transfer_to - duration - direction - channels - start_time - end_time - file_format - status - media_url - transcription - ] - end - - # An array for nullable fields - def nullables - %w[ - parent_call_id - ] - end - - def initialize(application_id = nil, - account_id = nil, - call_id = nil, - parent_call_id = nil, - recording_id = nil, - to = nil, - from = nil, - transfer_caller_id = nil, - transfer_to = nil, - duration = nil, - direction = nil, - channels = nil, - start_time = nil, - end_time = nil, - file_format = nil, - status = nil, - media_url = nil, - transcription = nil) - @application_id = application_id unless application_id == SKIP - @account_id = account_id unless account_id == SKIP - @call_id = call_id unless call_id == SKIP - @parent_call_id = parent_call_id unless parent_call_id == SKIP - @recording_id = recording_id unless recording_id == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @transfer_caller_id = transfer_caller_id unless transfer_caller_id == SKIP - @transfer_to = transfer_to unless transfer_to == SKIP - @duration = duration unless duration == SKIP - @direction = direction unless direction == SKIP - @channels = channels unless channels == SKIP - @start_time = start_time unless start_time == SKIP - @end_time = end_time unless end_time == SKIP - @file_format = file_format unless file_format == SKIP - @status = status unless status == SKIP - @media_url = media_url unless media_url == SKIP - @transcription = transcription unless transcription == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - call_id = hash.key?('callId') ? hash['callId'] : SKIP - parent_call_id = hash.key?('parentCallId') ? hash['parentCallId'] : SKIP - recording_id = hash.key?('recordingId') ? hash['recordingId'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - transfer_caller_id = - hash.key?('transferCallerId') ? hash['transferCallerId'] : SKIP - transfer_to = hash.key?('transferTo') ? hash['transferTo'] : SKIP - duration = hash.key?('duration') ? hash['duration'] : SKIP - direction = hash.key?('direction') ? hash['direction'] : SKIP - channels = hash.key?('channels') ? hash['channels'] : SKIP - start_time = if hash.key?('startTime') - (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime']) - else - SKIP - end - end_time = if hash.key?('endTime') - (DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime']) - else - SKIP - end - file_format = hash.key?('fileFormat') ? hash['fileFormat'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - media_url = hash.key?('mediaUrl') ? hash['mediaUrl'] : SKIP - transcription = TranscriptionMetadata.from_hash(hash['transcription']) if - hash['transcription'] - - # Create object from extracted values. - CallRecordingMetadata.new(application_id, - account_id, - call_id, - parent_call_id, - recording_id, - to, - from, - transfer_caller_id, - transfer_to, - duration, - direction, - channels, - start_time, - end_time, - file_format, - status, - media_url, - transcription) - end - - def to_start_time - DateTimeHelper.to_rfc3339(start_time) - end - - def to_end_time - DateTimeHelper.to_rfc3339(end_time) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/call_state.rb b/lib/bandwidth/voice_lib/voice/models/call_state.rb deleted file mode 100644 index 2af81135..00000000 --- a/lib/bandwidth/voice_lib/voice/models/call_state.rb +++ /dev/null @@ -1,301 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # CallState Model. - class CallState < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :parent_call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :application_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [String] - attr_accessor :direction - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [String] - attr_accessor :state - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [String] - attr_accessor :identity - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [Hash] - attr_accessor :stir_shaken - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [DateTime] - attr_accessor :start_time - - # @return [DateTime] - attr_accessor :enqueued_time - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [DateTime] - attr_accessor :answer_time - - # The current state of the call. Current possible values are 'initiated', - # 'answered' and 'disconnected'. Additional states may be added in the - # future, so your application must be tolerant of unknown values. - # @return [DateTime] - attr_accessor :end_time - - # The reason the call was disconnected, or null if the call is still active. - # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', - # 'invalid-bxml', 'callback-error', 'application-error', 'error', - # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes - # may be added in the future, so your application must be tolerant of - # unknown values. - # @return [String] - attr_accessor :disconnect_cause - - # The reason the call was disconnected, or null if the call is still active. - # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', - # 'invalid-bxml', 'callback-error', 'application-error', 'error', - # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes - # may be added in the future, so your application must be tolerant of - # unknown values. - # @return [String] - attr_accessor :error_message - - # The reason the call was disconnected, or null if the call is still active. - # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', - # 'invalid-bxml', 'callback-error', 'application-error', 'error', - # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes - # may be added in the future, so your application must be tolerant of - # unknown values. - # @return [String] - attr_accessor :error_id - - # The reason the call was disconnected, or null if the call is still active. - # Current values are 'cancel', 'timeout', 'busy', 'rejected', 'hangup', - # 'invalid-bxml', 'callback-error', 'application-error', 'error', - # 'account-limit', 'node-capacity-exceeded' and 'unknown'. Additional causes - # may be added in the future, so your application must be tolerant of - # unknown values. - # @return [DateTime] - attr_accessor :last_update - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['call_id'] = 'callId' - @_hash['parent_call_id'] = 'parentCallId' - @_hash['application_id'] = 'applicationId' - @_hash['account_id'] = 'accountId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['direction'] = 'direction' - @_hash['state'] = 'state' - @_hash['identity'] = 'identity' - @_hash['stir_shaken'] = 'stirShaken' - @_hash['start_time'] = 'startTime' - @_hash['enqueued_time'] = 'enqueuedTime' - @_hash['answer_time'] = 'answerTime' - @_hash['end_time'] = 'endTime' - @_hash['disconnect_cause'] = 'disconnectCause' - @_hash['error_message'] = 'errorMessage' - @_hash['error_id'] = 'errorId' - @_hash['last_update'] = 'lastUpdate' - @_hash - end - - # An array for optional fields - def optionals - %w[ - call_id - parent_call_id - application_id - account_id - to - from - direction - state - identity - stir_shaken - start_time - enqueued_time - answer_time - end_time - disconnect_cause - error_message - error_id - last_update - ] - end - - # An array for nullable fields - def nullables - %w[ - parent_call_id - identity - answer_time - end_time - disconnect_cause - error_message - error_id - ] - end - - def initialize(call_id = nil, - parent_call_id = nil, - application_id = nil, - account_id = nil, - to = nil, - from = nil, - direction = nil, - state = nil, - identity = nil, - stir_shaken = nil, - start_time = nil, - enqueued_time = nil, - answer_time = nil, - end_time = nil, - disconnect_cause = nil, - error_message = nil, - error_id = nil, - last_update = nil) - @call_id = call_id unless call_id == SKIP - @parent_call_id = parent_call_id unless parent_call_id == SKIP - @application_id = application_id unless application_id == SKIP - @account_id = account_id unless account_id == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @direction = direction unless direction == SKIP - @state = state unless state == SKIP - @identity = identity unless identity == SKIP - @stir_shaken = stir_shaken unless stir_shaken == SKIP - @start_time = start_time unless start_time == SKIP - @enqueued_time = enqueued_time unless enqueued_time == SKIP - @answer_time = answer_time unless answer_time == SKIP - @end_time = end_time unless end_time == SKIP - @disconnect_cause = disconnect_cause unless disconnect_cause == SKIP - @error_message = error_message unless error_message == SKIP - @error_id = error_id unless error_id == SKIP - @last_update = last_update unless last_update == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - call_id = hash.key?('callId') ? hash['callId'] : SKIP - parent_call_id = hash.key?('parentCallId') ? hash['parentCallId'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - direction = hash.key?('direction') ? hash['direction'] : SKIP - state = hash.key?('state') ? hash['state'] : SKIP - identity = hash.key?('identity') ? hash['identity'] : SKIP - stir_shaken = hash.key?('stirShaken') ? hash['stirShaken'] : SKIP - start_time = if hash.key?('startTime') - (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime']) - else - SKIP - end - enqueued_time = if hash.key?('enqueuedTime') - (DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime']) - else - SKIP - end - answer_time = if hash.key?('answerTime') - (DateTimeHelper.from_rfc3339(hash['answerTime']) if hash['answerTime']) - else - SKIP - end - end_time = if hash.key?('endTime') - (DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime']) - else - SKIP - end - disconnect_cause = - hash.key?('disconnectCause') ? hash['disconnectCause'] : SKIP - error_message = hash.key?('errorMessage') ? hash['errorMessage'] : SKIP - error_id = hash.key?('errorId') ? hash['errorId'] : SKIP - last_update = if hash.key?('lastUpdate') - (DateTimeHelper.from_rfc3339(hash['lastUpdate']) if hash['lastUpdate']) - else - SKIP - end - - # Create object from extracted values. - CallState.new(call_id, - parent_call_id, - application_id, - account_id, - to, - from, - direction, - state, - identity, - stir_shaken, - start_time, - enqueued_time, - answer_time, - end_time, - disconnect_cause, - error_message, - error_id, - last_update) - end - - def to_start_time - DateTimeHelper.to_rfc3339(start_time) - end - - def to_enqueued_time - DateTimeHelper.to_rfc3339(enqueued_time) - end - - def to_answer_time - DateTimeHelper.to_rfc3339(answer_time) - end - - def to_end_time - DateTimeHelper.to_rfc3339(end_time) - end - - def to_last_update - DateTimeHelper.to_rfc3339(last_update) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb deleted file mode 100644 index f20ffa77..00000000 --- a/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # CallbackMethod. - class CallbackMethodEnum - CALLBACK_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_callback.rb b/lib/bandwidth/voice_lib/voice/models/conference_callback.rb deleted file mode 100644 index c9e5a08a..00000000 --- a/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +++ /dev/null @@ -1,211 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # This object represents all possible fields that may be included in callbacks - # related to conference events - class ConferenceCallback < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :conference_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :name - - # TODO: Write general description for this method - # @return [String] - attr_accessor :event_type - - # TODO: Write general description for this method - # @return [String] - attr_accessor :event_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :tag - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :recording_id - - # TODO: Write general description for this method - # @return [Integer] - attr_accessor :channels - - # TODO: Write general description for this method - # @return [String] - attr_accessor :start_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :end_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :duration - - # TODO: Write general description for this method - # @return [String] - attr_accessor :file_format - - # TODO: Write general description for this method - # @return [String] - attr_accessor :media_url - - # TODO: Write general description for this method - # @return [String] - attr_accessor :status - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['conference_id'] = 'conferenceId' - @_hash['name'] = 'name' - @_hash['event_type'] = 'eventType' - @_hash['event_time'] = 'eventTime' - @_hash['tag'] = 'tag' - @_hash['call_id'] = 'callId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['account_id'] = 'accountId' - @_hash['recording_id'] = 'recordingId' - @_hash['channels'] = 'channels' - @_hash['start_time'] = 'startTime' - @_hash['end_time'] = 'endTime' - @_hash['duration'] = 'duration' - @_hash['file_format'] = 'fileFormat' - @_hash['media_url'] = 'mediaUrl' - @_hash['status'] = 'status' - @_hash - end - - # An array for optional fields - def optionals - %w[ - conference_id - name - event_type - event_time - tag - call_id - to - from - account_id - recording_id - channels - start_time - end_time - duration - file_format - media_url - status - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(conference_id = nil, - name = nil, - event_type = nil, - event_time = nil, - tag = nil, - call_id = nil, - to = nil, - from = nil, - account_id = nil, - recording_id = nil, - channels = nil, - start_time = nil, - end_time = nil, - duration = nil, - file_format = nil, - media_url = nil, - status = nil) - @conference_id = conference_id unless conference_id == SKIP - @name = name unless name == SKIP - @event_type = event_type unless event_type == SKIP - @event_time = event_time unless event_time == SKIP - @tag = tag unless tag == SKIP - @call_id = call_id unless call_id == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @account_id = account_id unless account_id == SKIP - @recording_id = recording_id unless recording_id == SKIP - @channels = channels unless channels == SKIP - @start_time = start_time unless start_time == SKIP - @end_time = end_time unless end_time == SKIP - @duration = duration unless duration == SKIP - @file_format = file_format unless file_format == SKIP - @media_url = media_url unless media_url == SKIP - @status = status unless status == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - conference_id = hash.key?('conferenceId') ? hash['conferenceId'] : SKIP - name = hash.key?('name') ? hash['name'] : SKIP - event_type = hash.key?('eventType') ? hash['eventType'] : SKIP - event_time = hash.key?('eventTime') ? hash['eventTime'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - call_id = hash.key?('callId') ? hash['callId'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - recording_id = hash.key?('recordingId') ? hash['recordingId'] : SKIP - channels = hash.key?('channels') ? hash['channels'] : SKIP - start_time = hash.key?('startTime') ? hash['startTime'] : SKIP - end_time = hash.key?('endTime') ? hash['endTime'] : SKIP - duration = hash.key?('duration') ? hash['duration'] : SKIP - file_format = hash.key?('fileFormat') ? hash['fileFormat'] : SKIP - media_url = hash.key?('mediaUrl') ? hash['mediaUrl'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - - # Create object from extracted values. - ConferenceCallback.new(conference_id, - name, - event_type, - event_time, - tag, - call_id, - to, - from, - account_id, - recording_id, - channels, - start_time, - end_time, - duration, - file_format, - media_url, - status) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb deleted file mode 100644 index 5d1cdc6e..00000000 --- a/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ConferenceEventMethod. - class ConferenceEventMethodEnum - CONFERENCE_EVENT_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb b/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb deleted file mode 100644 index c0822226..00000000 --- a/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +++ /dev/null @@ -1,103 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ConferenceMemberState Model. - class ConferenceMemberState < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :conference_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :member_url - - # TODO: Write general description for this method - # @return [Boolean] - attr_accessor :mute - - # TODO: Write general description for this method - # @return [Boolean] - attr_accessor :hold - - # TODO: Write general description for this method - # @return [List of String] - attr_accessor :call_ids_to_coach - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['call_id'] = 'callId' - @_hash['conference_id'] = 'conferenceId' - @_hash['member_url'] = 'memberUrl' - @_hash['mute'] = 'mute' - @_hash['hold'] = 'hold' - @_hash['call_ids_to_coach'] = 'callIdsToCoach' - @_hash - end - - # An array for optional fields - def optionals - %w[ - call_id - conference_id - member_url - mute - hold - call_ids_to_coach - ] - end - - # An array for nullable fields - def nullables - %w[ - call_ids_to_coach - ] - end - - def initialize(call_id = nil, - conference_id = nil, - member_url = nil, - mute = nil, - hold = nil, - call_ids_to_coach = nil) - @call_id = call_id unless call_id == SKIP - @conference_id = conference_id unless conference_id == SKIP - @member_url = member_url unless member_url == SKIP - @mute = mute unless mute == SKIP - @hold = hold unless hold == SKIP - @call_ids_to_coach = call_ids_to_coach unless call_ids_to_coach == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - call_id = hash.key?('callId') ? hash['callId'] : SKIP - conference_id = hash.key?('conferenceId') ? hash['conferenceId'] : SKIP - member_url = hash.key?('memberUrl') ? hash['memberUrl'] : SKIP - mute = hash.key?('mute') ? hash['mute'] : SKIP - hold = hash.key?('hold') ? hash['hold'] : SKIP - call_ids_to_coach = - hash.key?('callIdsToCoach') ? hash['callIdsToCoach'] : SKIP - - # Create object from extracted values. - ConferenceMemberState.new(call_id, - conference_id, - member_url, - mute, - hold, - call_ids_to_coach) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb b/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb deleted file mode 100644 index 457cdc31..00000000 --- a/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +++ /dev/null @@ -1,173 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # ConferenceRecordingMetadata Model. - class ConferenceRecordingMetadata < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :conference_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :name - - # TODO: Write general description for this method - # @return [String] - attr_accessor :recording_id - - # Format is ISO-8601 - # @return [String] - attr_accessor :duration - - # Format is ISO-8601 - # @return [Integer] - attr_accessor :channels - - # Format is ISO-8601 - # @return [DateTime] - attr_accessor :start_time - - # Format is ISO-8601 - # @return [DateTime] - attr_accessor :end_time - - # Format is ISO-8601 - # @return [FileFormatEnum] - attr_accessor :file_format - - # The current status of the recording. Current possible values are - # 'processing', 'partial', 'complete', 'deleted', and 'error'. Additional - # states may be added in the future, so your application must be tolerant of - # unknown values. - # @return [String] - attr_accessor :status - - # The current status of the recording. Current possible values are - # 'processing', 'partial', 'complete', 'deleted', and 'error'. Additional - # states may be added in the future, so your application must be tolerant of - # unknown values. - # @return [String] - attr_accessor :media_url - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['account_id'] = 'accountId' - @_hash['conference_id'] = 'conferenceId' - @_hash['name'] = 'name' - @_hash['recording_id'] = 'recordingId' - @_hash['duration'] = 'duration' - @_hash['channels'] = 'channels' - @_hash['start_time'] = 'startTime' - @_hash['end_time'] = 'endTime' - @_hash['file_format'] = 'fileFormat' - @_hash['status'] = 'status' - @_hash['media_url'] = 'mediaUrl' - @_hash - end - - # An array for optional fields - def optionals - %w[ - account_id - conference_id - name - recording_id - duration - channels - start_time - end_time - file_format - status - media_url - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(account_id = nil, - conference_id = nil, - name = nil, - recording_id = nil, - duration = nil, - channels = nil, - start_time = nil, - end_time = nil, - file_format = nil, - status = nil, - media_url = nil) - @account_id = account_id unless account_id == SKIP - @conference_id = conference_id unless conference_id == SKIP - @name = name unless name == SKIP - @recording_id = recording_id unless recording_id == SKIP - @duration = duration unless duration == SKIP - @channels = channels unless channels == SKIP - @start_time = start_time unless start_time == SKIP - @end_time = end_time unless end_time == SKIP - @file_format = file_format unless file_format == SKIP - @status = status unless status == SKIP - @media_url = media_url unless media_url == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - conference_id = hash.key?('conferenceId') ? hash['conferenceId'] : SKIP - name = hash.key?('name') ? hash['name'] : SKIP - recording_id = hash.key?('recordingId') ? hash['recordingId'] : SKIP - duration = hash.key?('duration') ? hash['duration'] : SKIP - channels = hash.key?('channels') ? hash['channels'] : SKIP - start_time = if hash.key?('startTime') - (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime']) - else - SKIP - end - end_time = if hash.key?('endTime') - (DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime']) - else - SKIP - end - file_format = hash.key?('fileFormat') ? hash['fileFormat'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - media_url = hash.key?('mediaUrl') ? hash['mediaUrl'] : SKIP - - # Create object from extracted values. - ConferenceRecordingMetadata.new(account_id, - conference_id, - name, - recording_id, - duration, - channels, - start_time, - end_time, - file_format, - status, - media_url) - end - - def to_start_time - DateTimeHelper.to_rfc3339(start_time) - end - - def to_end_time - DateTimeHelper.to_rfc3339(end_time) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/conference_state.rb b/lib/bandwidth/voice_lib/voice/models/conference_state.rb deleted file mode 100644 index 3a54c000..00000000 --- a/lib/bandwidth/voice_lib/voice/models/conference_state.rb +++ /dev/null @@ -1,153 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # ConferenceState Model. - class ConferenceState < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :name - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :created_time - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :completed_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :conference_event_url - - # TODO: Write general description for this method - # @return [ConferenceEventMethodEnum] - attr_accessor :conference_event_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :tag - - # TODO: Write general description for this method - # @return [List of ConferenceMemberState] - attr_accessor :active_members - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['name'] = 'name' - @_hash['created_time'] = 'createdTime' - @_hash['completed_time'] = 'completedTime' - @_hash['conference_event_url'] = 'conferenceEventUrl' - @_hash['conference_event_method'] = 'conferenceEventMethod' - @_hash['tag'] = 'tag' - @_hash['active_members'] = 'activeMembers' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - name - created_time - completed_time - conference_event_url - conference_event_method - tag - active_members - ] - end - - # An array for nullable fields - def nullables - %w[ - completed_time - conference_event_url - conference_event_method - tag - ] - end - - def initialize(id = nil, - name = nil, - created_time = nil, - completed_time = nil, - conference_event_url = nil, - conference_event_method = nil, - tag = nil, - active_members = nil) - @id = id unless id == SKIP - @name = name unless name == SKIP - @created_time = created_time unless created_time == SKIP - @completed_time = completed_time unless completed_time == SKIP - @conference_event_url = conference_event_url unless conference_event_url == SKIP - @conference_event_method = conference_event_method unless conference_event_method == SKIP - @tag = tag unless tag == SKIP - @active_members = active_members unless active_members == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - name = hash.key?('name') ? hash['name'] : SKIP - created_time = if hash.key?('createdTime') - (DateTimeHelper.from_rfc3339(hash['createdTime']) if hash['createdTime']) - else - SKIP - end - completed_time = if hash.key?('completedTime') - (DateTimeHelper.from_rfc3339(hash['completedTime']) if hash['completedTime']) - else - SKIP - end - conference_event_url = - hash.key?('conferenceEventUrl') ? hash['conferenceEventUrl'] : SKIP - conference_event_method = - hash.key?('conferenceEventMethod') ? hash['conferenceEventMethod'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - # Parameter is an array, so we need to iterate through it - active_members = nil - unless hash['activeMembers'].nil? - active_members = [] - hash['activeMembers'].each do |structure| - active_members << (ConferenceMemberState.from_hash(structure) if structure) - end - end - - active_members = SKIP unless hash.key?('activeMembers') - - # Create object from extracted values. - ConferenceState.new(id, - name, - created_time, - completed_time, - conference_event_url, - conference_event_method, - tag, - active_members) - end - - def to_created_time - DateTimeHelper.to_rfc3339(created_time) - end - - def to_completed_time - DateTimeHelper.to_rfc3339(completed_time) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/create_call_request.rb b/lib/bandwidth/voice_lib/voice/models/create_call_request.rb deleted file mode 100644 index 781e2aeb..00000000 --- a/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +++ /dev/null @@ -1,236 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # CreateCallRequest Model. - class CreateCallRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Format is E164 - # @return [String] - attr_accessor :from - - # Format is E164 or SIP URI - # @return [String] - attr_accessor :to - - # A comma-separated list of 'User-To-User' headers to be sent in the INVITE - # when calling a SIP URI. Each value must end with an 'encoding' parameter - # as described in https://tools.ietf.org/html/rfc7433. Only 'jwt' and - # 'base64' encodings are allowed. The entire value cannot exceed 350 - # characters, including parameters and separators. - # @return [String] - attr_accessor :uui - - # @return [Float] - attr_accessor :call_timeout - - # @return [Float] - attr_accessor :callback_timeout - - # @return [String] - attr_accessor :answer_url - - # @return [String] - attr_accessor :answer_fallback_url - - # @return [String] - attr_accessor :username - - # @return [String] - attr_accessor :password - - # @return [String] - attr_accessor :fallback_username - - # @return [String] - attr_accessor :fallback_password - - # @return [AnswerMethodEnum] - attr_accessor :answer_method - - # @return [AnswerFallbackMethodEnum] - attr_accessor :answer_fallback_method - - # @return [String] - attr_accessor :disconnect_url - - # @return [DisconnectMethodEnum] - attr_accessor :disconnect_method - - # @return [String] - attr_accessor :tag - - # @return [String] - attr_accessor :application_id - - # @return [MachineDetectionRequest] - attr_accessor :machine_detection - - # @return [Integer] - attr_accessor :priority - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['from'] = 'from' - @_hash['to'] = 'to' - @_hash['uui'] = 'uui' - @_hash['call_timeout'] = 'callTimeout' - @_hash['callback_timeout'] = 'callbackTimeout' - @_hash['answer_url'] = 'answerUrl' - @_hash['answer_fallback_url'] = 'answerFallbackUrl' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['fallback_username'] = 'fallbackUsername' - @_hash['fallback_password'] = 'fallbackPassword' - @_hash['answer_method'] = 'answerMethod' - @_hash['answer_fallback_method'] = 'answerFallbackMethod' - @_hash['disconnect_url'] = 'disconnectUrl' - @_hash['disconnect_method'] = 'disconnectMethod' - @_hash['tag'] = 'tag' - @_hash['application_id'] = 'applicationId' - @_hash['machine_detection'] = 'machineDetection' - @_hash['priority'] = 'priority' - @_hash - end - - # An array for optional fields - def optionals - %w[ - uui - call_timeout - callback_timeout - answer_fallback_url - username - password - fallback_username - fallback_password - answer_method - answer_fallback_method - disconnect_url - disconnect_method - tag - machine_detection - priority - ] - end - - # An array for nullable fields - def nullables - %w[ - uui - call_timeout - callback_timeout - answer_fallback_url - username - password - fallback_username - fallback_password - answer_method - answer_fallback_method - disconnect_url - disconnect_method - tag - priority - ] - end - - def initialize(from = nil, - to = nil, - answer_url = nil, - application_id = nil, - uui = nil, - call_timeout = nil, - callback_timeout = nil, - answer_fallback_url = nil, - username = nil, - password = nil, - fallback_username = nil, - fallback_password = nil, - answer_method = nil, - answer_fallback_method = nil, - disconnect_url = nil, - disconnect_method = nil, - tag = nil, - machine_detection = nil, - priority = nil) - @from = from unless from == SKIP - @to = to unless to == SKIP - @uui = uui unless uui == SKIP - @call_timeout = call_timeout unless call_timeout == SKIP - @callback_timeout = callback_timeout unless callback_timeout == SKIP - @answer_url = answer_url unless answer_url == SKIP - @answer_fallback_url = answer_fallback_url unless answer_fallback_url == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @fallback_username = fallback_username unless fallback_username == SKIP - @fallback_password = fallback_password unless fallback_password == SKIP - @answer_method = answer_method unless answer_method == SKIP - @answer_fallback_method = answer_fallback_method unless answer_fallback_method == SKIP - @disconnect_url = disconnect_url unless disconnect_url == SKIP - @disconnect_method = disconnect_method unless disconnect_method == SKIP - @tag = tag unless tag == SKIP - @application_id = application_id unless application_id == SKIP - @machine_detection = machine_detection unless machine_detection == SKIP - @priority = priority unless priority == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - from = hash.key?('from') ? hash['from'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - answer_url = hash.key?('answerUrl') ? hash['answerUrl'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - uui = hash.key?('uui') ? hash['uui'] : SKIP - call_timeout = hash.key?('callTimeout') ? hash['callTimeout'] : SKIP - callback_timeout = - hash.key?('callbackTimeout') ? hash['callbackTimeout'] : SKIP - answer_fallback_url = - hash.key?('answerFallbackUrl') ? hash['answerFallbackUrl'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - fallback_username = - hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP - fallback_password = - hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP - answer_method = hash.key?('answerMethod') ? hash['answerMethod'] : SKIP - answer_fallback_method = - hash.key?('answerFallbackMethod') ? hash['answerFallbackMethod'] : SKIP - disconnect_url = hash.key?('disconnectUrl') ? hash['disconnectUrl'] : SKIP - disconnect_method = - hash.key?('disconnectMethod') ? hash['disconnectMethod'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - machine_detection = MachineDetectionConfiguration.from_hash(hash['machineDetection']) if - hash['machineDetection'] - priority = hash.key?('priority') ? hash['priority'] : SKIP - - # Create object from extracted values. - CreateCallRequest.new(from, - to, - answer_url, - application_id, - uui, - call_timeout, - callback_timeout, - answer_fallback_url, - username, - password, - fallback_username, - fallback_password, - answer_method, - answer_fallback_method, - disconnect_url, - disconnect_method, - tag, - machine_detection, - priority) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/create_call_response.rb b/lib/bandwidth/voice_lib/voice/models/create_call_response.rb deleted file mode 100644 index 7c455484..00000000 --- a/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +++ /dev/null @@ -1,266 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'date' -module Bandwidth - # CreateCallResponse Model. - class CreateCallResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :account_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :application_id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :to - - # TODO: Write general description for this method - # @return [String] - attr_accessor :from - - # TODO: Write general description for this method - # @return [DateTime] - attr_accessor :enqueued_time - - # TODO: Write general description for this method - # @return [String] - attr_accessor :call_url - - # TODO: Write general description for this method - # @return [Float] - attr_accessor :call_timeout - - # TODO: Write general description for this method - # @return [Float] - attr_accessor :callback_timeout - - # TODO: Write general description for this method - # @return [String] - attr_accessor :answer_url - - # TODO: Write general description for this method - # @return [AnswerMethodEnum] - attr_accessor :answer_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :answer_fallback_url - - # TODO: Write general description for this method - # @return [AnswerFallbackMethodEnum] - attr_accessor :answer_fallback_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :disconnect_url - - # TODO: Write general description for this method - # @return [DisconnectMethodEnum] - attr_accessor :disconnect_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :username - - # TODO: Write general description for this method - # @return [String] - attr_accessor :password - - # TODO: Write general description for this method - # @return [String] - attr_accessor :fallback_username - - # TODO: Write general description for this method - # @return [String] - attr_accessor :fallback_password - - # TODO: Write general description for this method - # @return [String] - attr_accessor :tag - - # @return [Integer] - attr_accessor :priority - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['account_id'] = 'accountId' - @_hash['call_id'] = 'callId' - @_hash['application_id'] = 'applicationId' - @_hash['to'] = 'to' - @_hash['from'] = 'from' - @_hash['enqueued_time'] = 'enqueuedTime ' - @_hash['call_url'] = 'callUrl' - @_hash['call_timeout'] = 'callTimeout' - @_hash['callback_timeout'] = 'callbackTimeout' - @_hash['answer_url'] = 'answerUrl' - @_hash['answer_method'] = 'answerMethod' - @_hash['answer_fallback_url'] = 'answerFallbackUrl' - @_hash['answer_fallback_method'] = 'answerFallbackMethod' - @_hash['disconnect_url'] = 'disconnectUrl' - @_hash['disconnect_method'] = 'disconnectMethod' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['fallback_username'] = 'fallbackUsername' - @_hash['fallback_password'] = 'fallbackPassword' - @_hash['tag'] = 'tag' - @_hash['priority'] = 'priority' - @_hash - end - - # An array for optional fields - def optionals - %w[ - enqueued_time - call_timeout - callback_timeout - answer_fallback_url - answer_fallback_method - disconnect_url - username - password - fallback_username - fallback_password - tag - priority - ] - end - - # An array for nullable fields - def nullables - %w[ - answer_fallback_url - answer_fallback_method - disconnect_url - disconnect_method - username - password - fallback_username - fallback_password - tag - priority - ] - end - - def initialize(account_id = nil, - call_id = nil, - application_id = nil, - to = nil, - from = nil, - call_url = nil, - answer_url = nil, - answer_method = nil, - disconnect_method = nil, - enqueued_time = nil, - call_timeout = nil, - callback_timeout = nil, - answer_fallback_url = nil, - answer_fallback_method = nil, - disconnect_url = nil, - username = nil, - password = nil, - fallback_username = nil, - fallback_password = nil, - tag = nil, - priority = nil) - @account_id = account_id unless account_id == SKIP - @call_id = call_id unless call_id == SKIP - @application_id = application_id unless application_id == SKIP - @to = to unless to == SKIP - @from = from unless from == SKIP - @enqueued_time = enqueued_time unless enqueued_time == SKIP - @call_url = call_url unless call_url == SKIP - @call_timeout = call_timeout unless call_timeout == SKIP - @callback_timeout = callback_timeout unless callback_timeout == SKIP - @answer_url = answer_url unless answer_url == SKIP - @answer_method = answer_method unless answer_method == SKIP - @answer_fallback_url = answer_fallback_url unless answer_fallback_url == SKIP - @answer_fallback_method = answer_fallback_method unless answer_fallback_method == SKIP - @disconnect_url = disconnect_url unless disconnect_url == SKIP - @disconnect_method = disconnect_method unless disconnect_method == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @fallback_username = fallback_username unless fallback_username == SKIP - @fallback_password = fallback_password unless fallback_password == SKIP - @tag = tag unless tag == SKIP - @priority = priority unless priority == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - account_id = hash.key?('accountId') ? hash['accountId'] : SKIP - call_id = hash.key?('callId') ? hash['callId'] : SKIP - application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP - to = hash.key?('to') ? hash['to'] : SKIP - from = hash.key?('from') ? hash['from'] : SKIP - call_url = hash.key?('callUrl') ? hash['callUrl'] : SKIP - answer_url = hash.key?('answerUrl') ? hash['answerUrl'] : SKIP - answer_method = hash.key?('answerMethod') ? hash['answerMethod'] : SKIP - disconnect_method = - hash.key?('disconnectMethod') ? hash['disconnectMethod'] : SKIP - enqueued_time = if hash.key?('enqueuedTime') - (DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime']) - else - SKIP - end - call_timeout = hash.key?('callTimeout') ? hash['callTimeout'] : SKIP - callback_timeout = - hash.key?('callbackTimeout') ? hash['callbackTimeout'] : SKIP - answer_fallback_url = - hash.key?('answerFallbackUrl') ? hash['answerFallbackUrl'] : SKIP - answer_fallback_method = - hash.key?('answerFallbackMethod') ? hash['answerFallbackMethod'] : SKIP - disconnect_url = hash.key?('disconnectUrl') ? hash['disconnectUrl'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - fallback_username = - hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP - fallback_password = - hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - priority = hash.key?('priority') ? hash['priority'] : SKIP - - # Create object from extracted values. - CreateCallResponse.new(account_id, - call_id, - application_id, - to, - from, - call_url, - answer_url, - answer_method, - disconnect_method, - enqueued_time, - call_timeout, - callback_timeout, - answer_fallback_url, - answer_fallback_method, - disconnect_url, - username, - password, - fallback_username, - fallback_password, - tag, - priority) - end - - def to_enqueued_time - DateTimeHelper.to_rfc3339(enqueued_time) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/direction_enum.rb b/lib/bandwidth/voice_lib/voice/models/direction_enum.rb deleted file mode 100644 index 3af4a481..00000000 --- a/lib/bandwidth/voice_lib/voice/models/direction_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Direction. - class DirectionEnum - DIRECTION_ENUM = [ - # TODO: Write general description for INBOUND - INBOUND = 'inbound'.freeze, - - # TODO: Write general description for OUTBOUND - OUTBOUND = 'outbound'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb deleted file mode 100644 index 7e896077..00000000 --- a/lib/bandwidth/voice_lib/voice/models/disconnect_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # DisconnectMethod. - class DisconnectMethodEnum - DISCONNECT_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/diversion.rb b/lib/bandwidth/voice_lib/voice/models/diversion.rb deleted file mode 100644 index c0b67009..00000000 --- a/lib/bandwidth/voice_lib/voice/models/diversion.rb +++ /dev/null @@ -1,80 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Diversion Model. - class Diversion < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :reason - - # TODO: Write general description for this method - # @return [String] - attr_accessor :privacy - - # TODO: Write general description for this method - # @return [String] - attr_accessor :unknown - - # TODO: Write general description for this method - # @return [String] - attr_accessor :orig_to - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['reason'] = 'reason' - @_hash['privacy'] = 'privacy' - @_hash['unknown'] = 'unknown' - @_hash['orig_to'] = 'origTo' - @_hash - end - - # An array for optional fields - def optionals - %w[ - reason - privacy - unknown - orig_to - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(reason = nil, - privacy = nil, - unknown = nil, - orig_to = nil) - @reason = reason unless reason == SKIP - @privacy = privacy unless privacy == SKIP - @unknown = unknown unless unknown == SKIP - @orig_to = orig_to unless orig_to == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - reason = hash.key?('reason') ? hash['reason'] : SKIP - privacy = hash.key?('privacy') ? hash['privacy'] : SKIP - unknown = hash.key?('unknown') ? hash['unknown'] : SKIP - orig_to = hash.key?('origTo') ? hash['origTo'] : SKIP - - # Create object from extracted values. - Diversion.new(reason, - privacy, - unknown, - orig_to) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb deleted file mode 100644 index fbd22ffe..00000000 --- a/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # FallbackMethod. - class FallbackMethodEnum - FALLBACK_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb b/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb deleted file mode 100644 index 745edaf2..00000000 --- a/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # FileFormat. - class FileFormatEnum - FILE_FORMAT_ENUM = [ - # TODO: Write general description for MP3 - MP3 = 'mp3'.freeze, - - # TODO: Write general description for WAV - WAV = 'wav'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb b/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb deleted file mode 100644 index db90c40e..00000000 --- a/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +++ /dev/null @@ -1,231 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # MachineDetectionConfiguration Model. - class MachineDetectionConfiguration < BaseModel - SKIP = Object.new - private_constant :SKIP - - # The machine detection mode. If set to 'async', the detection result will - # be sent in a 'machineDetectionComplete' callback. If set to 'sync', the - # 'answer' callback will wait for the machine detection to complete and will - # include its result. Default is 'async'. - # @return [ModeEnum] - attr_accessor :mode - - # Total amount of time (in seconds) before giving up. - # @return [Float] - attr_accessor :detection_timeout - - # If no speech is detected in this period, a callback with a 'silence' - # result is sent. Default is 10 seconds. - # @return [Float] - attr_accessor :silence_timeout - - # When speech has ended and a result couldn't be determined based on the - # audio content itself, this value is used to determine if the speaker is a - # machine based on the speech duration. If the length of the speech detected - # is greater than or equal to this threshold, the result will be - # 'answering-machine'. If the length of speech detected is below this - # threshold, the result will be 'human'. Default is 10 seconds. - # @return [Float] - attr_accessor :speech_threshold - - # Amount of silence (in seconds) before assuming the callee has finished - # speaking. - # @return [Float] - attr_accessor :speech_end_threshold - - # If set to 'true' and if an answering machine is detected, the - # 'answering-machine' callback will be delayed until the machine is done - # speaking or until the 'detectionTimeout' is exceeded. If false, the - # 'answering-machine' result is sent immediately. Default is 'false'. - # @return [Boolean] - attr_accessor :delay_result - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :callback_url - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [CallbackMethodEnum] - attr_accessor :callback_method - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :fallback_url - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [FallbackMethodEnum] - attr_accessor :fallback_method - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :username - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :password - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :fallback_username - - # The URL to send the 'machineDetectionComplete' callback when the detection - # is completed. Only for 'async' mode. - # @return [String] - attr_accessor :fallback_password - - # When an answering machine is detected, the amount of silence (in seconds) - # before assuming the message has finished playing. - # return [Float] - attr_accessor :machine_speech_end_threshold - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['mode'] = 'mode' - @_hash['detection_timeout'] = 'detectionTimeout' - @_hash['silence_timeout'] = 'silenceTimeout' - @_hash['speech_threshold'] = 'speechThreshold' - @_hash['speech_end_threshold'] = 'speechEndThreshold' - @_hash['delay_result'] = 'delayResult' - @_hash['callback_url'] = 'callbackUrl' - @_hash['callback_method'] = 'callbackMethod' - @_hash['fallback_url'] = 'fallbackUrl' - @_hash['fallback_method'] = 'fallbackMethod' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['fallback_username'] = 'fallbackUsername' - @_hash['fallback_password'] = 'fallbackPassword' - @_hash['machine_speech_end_threshold'] = 'machineSpeechEndThreshold' - @_hash - end - - # An array for optional fields - def optionals - %w[ - mode - detection_timeout - silence_timeout - speech_threshold - speech_end_threshold - delay_result - callback_url - callback_method - fallback_url - fallback_method - username - password - fallback_username - fallback_password - machine_speech_end_threshold - ] - end - - # An array for nullable fields - def nullables - %w[ - callback_url - callback_method - fallback_url - fallback_method - username - password - fallback_username - fallback_password - machine_speech_end_threshold - ] - end - - def initialize(mode = nil, - detection_timeout = nil, - silence_timeout = nil, - speech_threshold = nil, - speech_end_threshold = nil, - delay_result = nil, - callback_url = nil, - callback_method = nil, - fallback_url = nil, - fallback_method = nil, - username = nil, - password = nil, - fallback_username = nil, - fallback_password = nil, - machine_speech_end_threshold = nil) - @mode = mode unless mode == SKIP - @detection_timeout = detection_timeout unless detection_timeout == SKIP - @silence_timeout = silence_timeout unless silence_timeout == SKIP - @speech_threshold = speech_threshold unless speech_threshold == SKIP - @speech_end_threshold = speech_end_threshold unless speech_end_threshold == SKIP - @delay_result = delay_result unless delay_result == SKIP - @callback_url = callback_url unless callback_url == SKIP - @callback_method = callback_method unless callback_method == SKIP - @fallback_url = fallback_url unless fallback_url == SKIP - @fallback_method = fallback_method unless fallback_method == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @fallback_username = fallback_username unless fallback_username == SKIP - @fallback_password = fallback_password unless fallback_password == SKIP - @machine_speech_end_threshold = machine_speech_end_threshold unless machine_speech_end_threshold == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - mode = hash.key?('mode') ? hash['mode'] : SKIP - detection_timeout = - hash.key?('detectionTimeout') ? hash['detectionTimeout'] : SKIP - silence_timeout = - hash.key?('silenceTimeout') ? hash['silenceTimeout'] : SKIP - speech_threshold = - hash.key?('speechThreshold') ? hash['speechThreshold'] : SKIP - speech_end_threshold = - hash.key?('speechEndThreshold') ? hash['speechEndThreshold'] : SKIP - delay_result = hash.key?('delayResult') ? hash['delayResult'] : SKIP - callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : SKIP - callback_method = - hash.key?('callbackMethod') ? hash['callbackMethod'] : SKIP - fallback_url = hash.key?('fallbackUrl') ? hash['fallbackUrl'] : SKIP - fallback_method = - hash.key?('fallbackMethod') ? hash['fallbackMethod'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - fallback_username = - hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP - fallback_password = - hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP - machine_speech_end_threshold = - hash.key?('machineSpeechEndThreshold') ? hash['machineSpeechEndThreshold'] : SKIP - - # Create object from extracted values. - MachineDetectionConfiguration.new(mode, - detection_timeout, - silence_timeout, - speech_threshold, - speech_end_threshold, - delay_result, - callback_url, - callback_method, - fallback_url, - fallback_method, - username, - password, - fallback_username, - fallback_password, - machine_speech_end_threshold) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/mode_enum.rb b/lib/bandwidth/voice_lib/voice/models/mode_enum.rb deleted file mode 100644 index 680bd2a9..00000000 --- a/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +++ /dev/null @@ -1,20 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # The machine detection mode. If set to 'async', the detection result will be - # sent in a 'machineDetectionComplete' callback. If set to 'sync', the - # 'answer' callback will wait for the machine detection to complete and will - # include its result. Default is 'async'. - class ModeEnum - MODE_ENUM = [ - # TODO: Write general description for SYNC - SYNC = 'sync'.freeze, - - # TODO: Write general description for ASYNC - ASYNC = 'async'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb b/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb deleted file mode 100644 index d3751b06..00000000 --- a/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +++ /dev/null @@ -1,48 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ModifyCallRecordingRequest Model. - class ModifyCallRecordingRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [State1Enum] - attr_accessor :state - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['state'] = 'state' - @_hash - end - - # An array for optional fields - def optionals - [] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(state = nil) - @state = state unless state == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - state = hash.key?('state') ? hash['state'] : SKIP - - # Create object from extracted values. - ModifyCallRecordingRequest.new(state) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb b/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb deleted file mode 100644 index 7b5438b1..00000000 --- a/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +++ /dev/null @@ -1,156 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ModifyCallRequest Model. - class ModifyCallRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [StateEnum] - attr_accessor :state - - # Required if state is 'active' - # @return [String] - attr_accessor :redirect_url - - # Required if state is 'active' - # @return [String] - attr_accessor :redirect_fallback_url - - # Required if state is 'active' - # @return [RedirectMethodEnum] - attr_accessor :redirect_method - - # Required if state is 'active' - # @return [RedirectFallbackMethodEnum] - attr_accessor :redirect_fallback_method - - # Required if state is 'active' - # @return [String] - attr_accessor :username - - # Required if state is 'active' - # @return [String] - attr_accessor :password - - # Required if state is 'active' - # @return [String] - attr_accessor :fallback_username - - # Required if state is 'active' - # @return [String] - attr_accessor :fallback_password - - # Required if state is 'active' - # @return [String] - attr_accessor :tag - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['state'] = 'state' - @_hash['redirect_url'] = 'redirectUrl' - @_hash['redirect_fallback_url'] = 'redirectFallbackUrl' - @_hash['redirect_method'] = 'redirectMethod' - @_hash['redirect_fallback_method'] = 'redirectFallbackMethod' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['fallback_username'] = 'fallbackUsername' - @_hash['fallback_password'] = 'fallbackPassword' - @_hash['tag'] = 'tag' - @_hash - end - - # An array for optional fields - def optionals - %w[ - state - redirect_url - redirect_fallback_url - redirect_method - redirect_fallback_method - username - password - fallback_username - fallback_password - tag - ] - end - - # An array for nullable fields - def nullables - %w[ - state - redirect_url - redirect_fallback_url - redirect_method - redirect_fallback_method - username - password - fallback_username - fallback_password - tag - ] - end - - def initialize(state = StateEnum::ACTIVE, - redirect_url = nil, - redirect_fallback_url = nil, - redirect_method = nil, - redirect_fallback_method = nil, - username = nil, - password = nil, - fallback_username = nil, - fallback_password = nil, - tag = nil) - @state = state unless state == SKIP - @redirect_url = redirect_url unless redirect_url == SKIP - @redirect_fallback_url = redirect_fallback_url unless redirect_fallback_url == SKIP - @redirect_method = redirect_method unless redirect_method == SKIP - @redirect_fallback_method = redirect_fallback_method unless redirect_fallback_method == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @fallback_username = fallback_username unless fallback_username == SKIP - @fallback_password = fallback_password unless fallback_password == SKIP - @tag = tag unless tag == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - state = hash['state'] ||= StateEnum::ACTIVE - redirect_url = hash.key?('redirectUrl') ? hash['redirectUrl'] : SKIP - redirect_fallback_url = - hash.key?('redirectFallbackUrl') ? hash['redirectFallbackUrl'] : SKIP - redirect_method = - hash.key?('redirectMethod') ? hash['redirectMethod'] : SKIP - redirect_fallback_method = - hash.key?('redirectFallbackMethod') ? hash['redirectFallbackMethod'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - fallback_username = - hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP - fallback_password = - hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - - # Create object from extracted values. - ModifyCallRequest.new(state, - redirect_url, - redirect_fallback_url, - redirect_method, - redirect_fallback_method, - username, - password, - fallback_username, - fallback_password, - tag) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb b/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb deleted file mode 100644 index 5fb49ab1..00000000 --- a/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +++ /dev/null @@ -1,144 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ModifyConferenceRequest Model. - class ModifyConferenceRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [StatusEnum] - attr_accessor :status - - # TODO: Write general description for this method - # @return [String] - attr_accessor :redirect_url - - # TODO: Write general description for this method - # @return [String] - attr_accessor :redirect_fallback_url - - # TODO: Write general description for this method - # @return [RedirectMethodEnum] - attr_accessor :redirect_method - - # TODO: Write general description for this method - # @return [RedirectFallbackMethodEnum] - attr_accessor :redirect_fallback_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :username - - # TODO: Write general description for this method - # @return [String] - attr_accessor :password - - # TODO: Write general description for this method - # @return [String] - attr_accessor :fallback_username - - # TODO: Write general description for this method - # @return [String] - attr_accessor :fallback_password - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['status'] = 'status' - @_hash['redirect_url'] = 'redirectUrl' - @_hash['redirect_fallback_url'] = 'redirectFallbackUrl' - @_hash['redirect_method'] = 'redirectMethod' - @_hash['redirect_fallback_method'] = 'redirectFallbackMethod' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['fallback_username'] = 'fallbackUsername' - @_hash['fallback_password'] = 'fallbackPassword' - @_hash - end - - # An array for optional fields - def optionals - %w[ - status - redirect_url - redirect_fallback_url - redirect_method - redirect_fallback_method - username - password - fallback_username - fallback_password - ] - end - - # An array for nullable fields - def nullables - %w[ - redirect_url - redirect_fallback_url - redirect_method - redirect_fallback_method - username - password - fallback_username - fallback_password - ] - end - - def initialize(status = nil, - redirect_url = nil, - redirect_fallback_url = nil, - redirect_method = nil, - redirect_fallback_method = nil, - username = nil, - password = nil, - fallback_username = nil, - fallback_password = nil) - @status = status unless status == SKIP - @redirect_url = redirect_url unless redirect_url == SKIP - @redirect_fallback_url = redirect_fallback_url unless redirect_fallback_url == SKIP - @redirect_method = redirect_method unless redirect_method == SKIP - @redirect_fallback_method = redirect_fallback_method unless redirect_fallback_method == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @fallback_username = fallback_username unless fallback_username == SKIP - @fallback_password = fallback_password unless fallback_password == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - status = hash.key?('status') ? hash['status'] : SKIP - redirect_url = hash.key?('redirectUrl') ? hash['redirectUrl'] : SKIP - redirect_fallback_url = - hash.key?('redirectFallbackUrl') ? hash['redirectFallbackUrl'] : SKIP - redirect_method = - hash.key?('redirectMethod') ? hash['redirectMethod'] : SKIP - redirect_fallback_method = - hash.key?('redirectFallbackMethod') ? hash['redirectFallbackMethod'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - fallback_username = - hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP - fallback_password = - hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP - - # Create object from extracted values. - ModifyConferenceRequest.new(status, - redirect_url, - redirect_fallback_url, - redirect_method, - redirect_fallback_method, - username, - password, - fallback_username, - fallback_password) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb deleted file mode 100644 index 606beea0..00000000 --- a/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # RedirectFallbackMethod. - class RedirectFallbackMethodEnum - REDIRECT_FALLBACK_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb b/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb deleted file mode 100644 index e4d798f4..00000000 --- a/lib/bandwidth/voice_lib/voice/models/redirect_method_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # RedirectMethod. - class RedirectMethodEnum - REDIRECT_METHOD_ENUM = [ - # TODO: Write general description for POST - POST = 'POST'.freeze, - - # TODO: Write general description for GET - GET = 'GET'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/state1_enum.rb b/lib/bandwidth/voice_lib/voice/models/state1_enum.rb deleted file mode 100644 index c23a7d00..00000000 --- a/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +++ /dev/null @@ -1,20 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # State1. - class State1Enum - STATE1_ENUM = [ - # TODO: Write general description for NOT_RECORDING - NOT_RECORDING = 'NOT_RECORDING'.freeze, - - # TODO: Write general description for PAUSED - PAUSED = 'PAUSED'.freeze, - - # TODO: Write general description for RECORDING - RECORDING = 'RECORDING'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/state_enum.rb b/lib/bandwidth/voice_lib/voice/models/state_enum.rb deleted file mode 100644 index da8ed33e..00000000 --- a/lib/bandwidth/voice_lib/voice/models/state_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # State. - class StateEnum - STATE_ENUM = [ - # TODO: Write general description for ACTIVE - ACTIVE = 'active'.freeze, - - # TODO: Write general description for COMPLETED - COMPLETED = 'completed'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/status_enum.rb b/lib/bandwidth/voice_lib/voice/models/status_enum.rb deleted file mode 100644 index cd7e9ba6..00000000 --- a/lib/bandwidth/voice_lib/voice/models/status_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Status. - class StatusEnum - STATUS_ENUM = [ - # TODO: Write general description for ACTIVE - ACTIVE = 'active'.freeze, - - # TODO: Write general description for COMPLETED - COMPLETED = 'completed'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb b/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb deleted file mode 100644 index a84ca10c..00000000 --- a/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +++ /dev/null @@ -1,120 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TranscribeRecordingRequest Model. - class TranscribeRecordingRequest < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :callback_url - - # TODO: Write general description for this method - # @return [CallbackMethodEnum] - attr_accessor :callback_method - - # TODO: Write general description for this method - # @return [String] - attr_accessor :username - - # TODO: Write general description for this method - # @return [String] - attr_accessor :password - - # TODO: Write general description for this method - # @return [String] - attr_accessor :tag - - # TODO: Write general description for this method - # @return [Float] - attr_accessor :callback_timeout - - # TODO: Write general description for this method - # @return [Boolean] - attr_accessor :detect_language - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['callback_url'] = 'callbackUrl' - @_hash['callback_method'] = 'callbackMethod' - @_hash['username'] = 'username' - @_hash['password'] = 'password' - @_hash['tag'] = 'tag' - @_hash['callback_timeout'] = 'callbackTimeout' - @_hash['detect_language'] = 'detectLanguage' - @_hash - end - - # An array for optional fields - def optionals - %w[ - callback_url - callback_method - username - password - tag - callback_timeout - detect_language - ] - end - - # An array for nullable fields - def nullables - %w[ - callback_method - username - password - tag - callback_timeout - detect_language - ] - end - - def initialize(callback_url = nil, - callback_method = nil, - username = nil, - password = nil, - tag = nil, - detect_language = nil, - callback_timeout = nil) - @callback_url = callback_url unless callback_url == SKIP - @callback_method = callback_method unless callback_method == SKIP - @username = username unless username == SKIP - @password = password unless password == SKIP - @tag = tag unless tag == SKIP - @callback_timeout = callback_timeout unless callback_timeout == SKIP - @detect_language = detect_language unless detect_language == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : SKIP - callback_method = - hash.key?('callbackMethod') ? hash['callbackMethod'] : SKIP - username = hash.key?('username') ? hash['username'] : SKIP - password = hash.key?('password') ? hash['password'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - callback_timeout = - hash.key?('callbackTimeout') ? hash['callbackTimeout'] : SKIP - detect_language = - hash.key?('detectLanguage') ? hash['detectLanguage'] : SKIP - - # Create object from extracted values. - TranscribeRecordingRequest.new(callback_url, - callback_method, - username, - password, - tag, - detect_language, - callback_timeout) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/transcript.rb b/lib/bandwidth/voice_lib/voice/models/transcript.rb deleted file mode 100644 index 403789b4..00000000 --- a/lib/bandwidth/voice_lib/voice/models/transcript.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Transcript Model. - class Transcript < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :text - - # TODO: Write general description for this method - # @return [Float] - attr_accessor :confidence - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['text'] = 'text' - @_hash['confidence'] = 'confidence' - @_hash - end - - # An array for optional fields - def optionals - %w[ - text - confidence - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(text = nil, - confidence = nil) - @text = text unless text == SKIP - @confidence = confidence unless confidence == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - text = hash.key?('text') ? hash['text'] : SKIP - confidence = hash.key?('confidence') ? hash['confidence'] : SKIP - - # Create object from extracted values. - Transcript.new(text, - confidence) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/transcription.rb b/lib/bandwidth/voice_lib/voice/models/transcription.rb deleted file mode 100644 index 0d756678..00000000 --- a/lib/bandwidth/voice_lib/voice/models/transcription.rb +++ /dev/null @@ -1,80 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Transcription Model. - class Transcription < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :id - - # TODO: Write general description for this method - # @return [String] - attr_accessor :url - - # TODO: Write general description for this method - # @return [String] - attr_accessor :status - - # TODO: Write general description for this method - # @return [String] - attr_accessor :completed_time - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['url'] = 'url' - @_hash['status'] = 'status' - @_hash['completed_time'] = 'completedTime' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - url - status - completed_time - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(id = nil, - url = nil, - status = nil, - completed_time = nil) - @id = id unless id == SKIP - @url = url unless url == SKIP - @status = status unless status == SKIP - @completed_time = completed_time unless completed_time == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - url = hash.key?('url') ? hash['url'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - completed_time = hash.key?('completedTime') ? hash['completedTime'] : SKIP - - # Create object from extracted values. - Transcription.new(id, - url, - status, - completed_time) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb b/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb deleted file mode 100644 index 354d3c81..00000000 --- a/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +++ /dev/null @@ -1,89 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TranscriptionMetadata Model. - class TranscriptionMetadata < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [String] - attr_accessor :id - - # The current status of the transcription. Current values are 'none', - # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and - # 'file-size-too-small'. Additional states may be added in the future, so - # your application must be tolerant of unknown values. - # @return [String] - attr_accessor :status - - # The current status of the transcription. Current values are 'none', - # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and - # 'file-size-too-small'. Additional states may be added in the future, so - # your application must be tolerant of unknown values. - # @return [String] - attr_accessor :completed_time - - # The current status of the transcription. Current values are 'none', - # 'processing', 'available', 'error', 'timeout', 'file-size-too-big', and - # 'file-size-too-small'. Additional states may be added in the future, so - # your application must be tolerant of unknown values. - # @return [String] - attr_accessor :url - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['status'] = 'status' - @_hash['completed_time'] = 'completedTime' - @_hash['url'] = 'url' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - status - completed_time - url - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(id = nil, - status = nil, - completed_time = nil, - url = nil) - @id = id unless id == SKIP - @status = status unless status == SKIP - @completed_time = completed_time unless completed_time == SKIP - @url = url unless url == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - status = hash.key?('status') ? hash['status'] : SKIP - completed_time = hash.key?('completedTime') ? hash['completedTime'] : SKIP - url = hash.key?('url') ? hash['url'] : SKIP - - # Create object from extracted values. - TranscriptionMetadata.new(id, - status, - completed_time, - url) - end - end -end diff --git a/lib/bandwidth/voice_lib/voice/models/transcription_response.rb b/lib/bandwidth/voice_lib/voice/models/transcription_response.rb deleted file mode 100644 index 42870dd3..00000000 --- a/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +++ /dev/null @@ -1,59 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # TranscriptionResponse Model. - class TranscriptionResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [List of Transcript] - attr_accessor :transcripts - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['transcripts'] = 'transcripts' - @_hash - end - - # An array for optional fields - def optionals - %w[ - transcripts - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(transcripts = nil) - @transcripts = transcripts unless transcripts == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - # Parameter is an array, so we need to iterate through it - transcripts = nil - unless hash['transcripts'].nil? - transcripts = [] - hash['transcripts'].each do |structure| - transcripts << (Transcript.from_hash(structure) if structure) - end - end - - transcripts = SKIP unless hash.key?('transcripts') - - # Create object from extracted values. - TranscriptionResponse.new(transcripts) - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb b/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb deleted file mode 100644 index 569cce5b..00000000 --- a/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +++ /dev/null @@ -1,18 +0,0 @@ -# web_rtc_transfer.rb -# -# Custom transfer BXML for WebRtc -# -# @copyright Bandwidth INC - -module Bandwidth - module WebRtc - def generate_bxml(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060") - return '' + generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri) + '' - end - - def generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060") - voice_call_id = voice_call_id.split("-", 2).last.split("-").join() - return '%s' % [voice_call_id, device_token, sip_uri] - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc.rb b/lib/bandwidth/web_rtc_lib/web_rtc.rb deleted file mode 100644 index f87f6bbf..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc.rb +++ /dev/null @@ -1,22 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - - -require_relative 'web_rtc/client.rb' - -# Models -require_relative 'web_rtc/models/session.rb' -require_relative 'web_rtc/models/participant.rb' -require_relative 'web_rtc/models/subscriptions.rb' -require_relative 'web_rtc/models/participant_subscription.rb' -require_relative 'web_rtc/models/accounts_participants_response.rb' -require_relative 'web_rtc/models/device_api_version_enum.rb' -require_relative 'web_rtc/models/publish_permission_enum.rb' - -# Exceptions -require_relative 'web_rtc/exceptions/error_exception.rb' -# Controllers -require_relative 'web_rtc/controllers/base_controller.rb' -require_relative 'web_rtc/controllers/api_controller.rb' diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/client.rb b/lib/bandwidth/web_rtc_lib/web_rtc/client.rb deleted file mode 100644 index 1549137e..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - module WebRtc - # bandwidth client class. - class Client - attr_reader :config - - # Access to client controller. - # @return [APIController] Returns the controller instance. - def client - @client ||= APIController.new config - end - - def initialize(timeout: 60, max_retries: 0, retry_interval: 1, - backoff_factor: 2, - retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524, 408, 413, 429, 500, 502, 503, 504, 521, 522, 524], - retry_methods: %i[get put get put], - environment: Environment::PRODUCTION, - base_url: 'https://www.example.com', - messaging_basic_auth_user_name: 'TODO: Replace', - messaging_basic_auth_password: 'TODO: Replace', - multi_factor_auth_basic_auth_user_name: 'TODO: Replace', - multi_factor_auth_basic_auth_password: 'TODO: Replace', - phone_number_lookup_basic_auth_user_name: 'TODO: Replace', - phone_number_lookup_basic_auth_password: 'TODO: Replace', - voice_basic_auth_user_name: 'TODO: Replace', - voice_basic_auth_password: 'TODO: Replace', - web_rtc_basic_auth_user_name: 'TODO: Replace', - web_rtc_basic_auth_password: 'TODO: Replace', - config: nil) - @config = if config.nil? - Configuration.new(timeout: timeout, - max_retries: max_retries, - retry_interval: retry_interval, - backoff_factor: backoff_factor, - retry_statuses: retry_statuses, - retry_methods: retry_methods, - environment: environment, - base_url: base_url, - messaging_basic_auth_user_name: messaging_basic_auth_user_name, - messaging_basic_auth_password: messaging_basic_auth_password, - multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name, - multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password, - phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name, - phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password, - voice_basic_auth_user_name: voice_basic_auth_user_name, - voice_basic_auth_password: voice_basic_auth_password, - web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name, - web_rtc_basic_auth_password: web_rtc_basic_auth_password) - else - config - end - end - end -end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb b/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb deleted file mode 100644 index 93dc5d77..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +++ /dev/null @@ -1,703 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth -module WebRtc - # APIController - class APIController < BaseController - def initialize(config, http_call_back: nil) - super(config, http_call_back: http_call_back) - end - - # Create a new participant under this account. - # Participants are idempotent, so relevant parameters must be set in this - # function if desired. - # @param [String] account_id Required parameter: Account ID - # @param [Participant] body Optional parameter: Participant parameters - # @return [AccountsParticipantsResponse] response from the API call - def create_participant(account_id, - body: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/participants' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise APIException.new( - 'Bad Request', - _response - ) - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: AccountsParticipantsResponse.from_hash(decoded) - ) - end - - # Get participant by ID. - # @param [String] account_id Required parameter: Account ID - # @param [String] participant_id Required parameter: Participant ID - # @return [Participant] response from the API call - def get_participant(account_id, - participant_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/participants/{participantId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: Participant.from_hash(decoded) - ) - end - - # Delete participant by ID. - # @param [String] account_id Required parameter: Account ID - # @param [String] participant_id Required parameter: Example: - # @return [void] response from the API call - def delete_participant(account_id, - participant_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/participants/{participantId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Create a new session. - # Sessions are idempotent, so relevant parameters must be set in this - # function if desired. - # @param [String] account_id Required parameter: Account ID - # @param [Session] body Optional parameter: Session parameters - # @return [Session] response from the API call - def create_session(account_id, - body: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json', - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.post( - _query_url, - headers: _headers, - parameters: body.to_json - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise APIException.new( - 'Bad Request', - _response - ) - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: Session.from_hash(decoded) - ) - end - - # Get session by ID. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @return [Session] response from the API call - def get_session(account_id, - session_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: Session.from_hash(decoded) - ) - end - - # Delete session by ID. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @return [void] response from the API call - def delete_session(account_id, - session_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # List participants in a session. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @return [List of Participant] response from the API call - def list_session_participants(account_id, - session_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, - data: decoded.map { |element| Participant.from_hash(element) } - ) - end - - # Add a participant to a session. - # Subscriptions can optionally be provided as part of this call. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @param [String] participant_id Required parameter: Participant ID - # @param [Subscriptions] body Optional parameter: Subscriptions the - # participant should be created with - # @return [void] response from the API call - def add_participant_to_session(account_id, - session_id, - participant_id, - body: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body.to_json - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Remove a participant from a session. - # This will automatically remove any subscriptions the participant has - # associated with this session. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @param [String] participant_id Required parameter: Participant ID - # @return [void] response from the API call - def remove_participant_from_session(account_id, - session_id, - participant_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare and execute HttpRequest. - _request = config.http_client.delete( - _query_url - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - - # Get a participant's subscriptions. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @param [String] participant_id Required parameter: Participant ID - # @return [Subscriptions] response from the API call - def get_participant_subscriptions(account_id, - session_id, - participant_id) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'accept' => 'application/json' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.get( - _query_url, - headers: _headers - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - decoded = APIHelper.json_deserialize(_response.raw_body) - ApiResponse.new( - _response, data: Subscriptions.from_hash(decoded) - ) - end - - # Update a participant's subscriptions. - # This is a full update that will replace the participant's subscriptions. - # First call `getParticipantSubscriptions` if you need the current - # subscriptions. Call this function with no `Subscriptions` object to remove - # all subscriptions. - # @param [String] account_id Required parameter: Account ID - # @param [String] session_id Required parameter: Session ID - # @param [String] participant_id Required parameter: Participant ID - # @param [Subscriptions] body Optional parameter: Initial state - # @return [void] response from the API call - def update_participant_subscriptions(account_id, - session_id, - participant_id, - body: nil) - # Prepare query url. - _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT) - _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions' - _query_builder = APIHelper.append_url_with_template_parameters( - _query_builder, - 'accountId' => { 'value' => account_id, 'encode' => false }, - 'sessionId' => { 'value' => session_id, 'encode' => false }, - 'participantId' => { 'value' => participant_id, 'encode' => false } - ) - _query_url = APIHelper.clean_url _query_builder - - # Prepare headers. - _headers = { - 'content-type' => 'application/json; charset=utf-8' - } - - # Prepare and execute HttpRequest. - _request = config.http_client.put( - _query_url, - headers: _headers, - parameters: body.to_json - ) - WebRtcBasicAuth.apply(config, _request) - _response = execute_request(_request) - - # Validate response against endpoint and global error codes. - case _response.status_code - when 400 - raise APIException.new( - 'Bad Request', - _response - ) - when 401 - raise APIException.new( - 'Unauthorized', - _response - ) - when 403 - raise APIException.new( - 'Access Denied', - _response - ) - when 404 - raise APIException.new( - 'Not Found', - _response - ) - end - unless _response.status_code.between?(200, 208) - raise ErrorException.new( - 'Unexpected Error', - _response - ) - end - validate_response(_response) - - # Return appropriate response type. - ApiResponse.new(_response) - end - end -end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb b/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb deleted file mode 100644 index 17e3cbc6..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # BaseController. - class BaseController - attr_accessor :config, :http_call_back - - def initialize(config, http_call_back: nil) - @config = config - @http_call_back = http_call_back - - @global_headers = { - 'user-agent' => 'ruby-sdk' - } - end - - def validate_parameters(args) - args.each do |_name, value| - raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil? - end - end - - def execute_request(request, binary: false) - @http_call_back&.on_before_request(request) - - APIHelper.clean_hash(request.headers) - request.headers.merge!(@global_headers) - - response = if binary - config.http_client.execute_as_binary(request) - else - config.http_client.execute_as_string(request) - end - @http_call_back&.on_after_response(response) - - response - end - - def validate_response(response) - raise APIException.new 'HTTP Response Not OK', response unless - response.status_code.between?(200, 208) # [200,208] = HTTP OK - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb b/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb deleted file mode 100644 index d9196c30..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +++ /dev/null @@ -1,37 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Error class. - class ErrorException < APIException - SKIP = Object.new - private_constant :SKIP - - # TODO: Write general description for this method - # @return [Integer] - attr_accessor :code - - # TODO: Write general description for this method - # @return [String] - attr_accessor :message - - # The constructor. - # @param [String] The reason for raising an exception. - # @param [HttpResponse] The HttpReponse of the API call. - def initialize(reason, response) - super(reason, response) - hash = APIHelper.json_deserialize(@response.raw_body) - unbox(hash) - end - - # Populates this object by extracting properties from a hash. - # @param [Hash] The deserialized response sent by the server in the - # response body. - def unbox(hash) - @code = hash.key?('code') ? hash['code'] : SKIP - @message = hash.key?('message') ? hash['message'] : SKIP - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb deleted file mode 100644 index 65df293b..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +++ /dev/null @@ -1,62 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # AccountsParticipantsResponse Model. - class AccountsParticipantsResponse < BaseModel - SKIP = Object.new - private_constant :SKIP - - # A participant object - # @return [Participant] - attr_accessor :participant - - # Auth token for the returned participant - # This should be passed to the participant so that they can connect to the - # platform - # @return [String] - attr_accessor :token - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['participant'] = 'participant' - @_hash['token'] = 'token' - @_hash - end - - # An array for optional fields - def optionals - %w[ - participant - token - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(participant = nil, - token = nil) - @participant = participant unless participant == SKIP - @token = token unless token == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - participant = Participant.from_hash(hash['participant']) if hash['participant'] - token = hash.key?('token') ? hash['token'] : SKIP - - # Create object from extracted values. - AccountsParticipantsResponse.new(participant, - token) - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb deleted file mode 100644 index d65d8e26..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Optional field to define the device api version of this participant - class DeviceApiVersionEnum - DEVICE_API_VERSION_ENUM = [ - # TODO: Write general description for V3 - V3 = 'V3'.freeze, - - # TODO: Write general description for V2 - V2 = 'V2'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb deleted file mode 100644 index b88c72b7..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +++ /dev/null @@ -1,115 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # A participant object - class Participant < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Unique id of the participant - # @return [String] - attr_accessor :id - - # Full callback url to use for notifications about this participant - # @return [String] - attr_accessor :callback_url - - # Defines if this participant can publish audio or video - # @return [List of PublishPermissionEnum] - attr_accessor :publish_permissions - - # List of session ids this participant is associated with - # Capped to one - # @return [List of String] - attr_accessor :sessions - - # List of session ids this participant is associated with - # Capped to one - # @return [Subscriptions] - attr_accessor :subscriptions - - # User defined tag to associate with the participant - # @return [String] - attr_accessor :tag - - # Optional field to define the device api version of this participant - # @return [DeviceApiVersionEnum] - attr_accessor :device_api_version - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['callback_url'] = 'callbackUrl' - @_hash['publish_permissions'] = 'publishPermissions' - @_hash['sessions'] = 'sessions' - @_hash['subscriptions'] = 'subscriptions' - @_hash['tag'] = 'tag' - @_hash['device_api_version'] = 'deviceApiVersion' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - callback_url - publish_permissions - sessions - subscriptions - tag - device_api_version - ] - end - - # An array for nullable fields - def nullables - %w[ - callback_url - ] - end - - def initialize(id = nil, - callback_url = nil, - publish_permissions = nil, - sessions = nil, - subscriptions = nil, - tag = nil, - device_api_version = DeviceApiVersionEnum::V2) - @id = id unless id == SKIP - @callback_url = callback_url unless callback_url == SKIP - @publish_permissions = publish_permissions unless publish_permissions == SKIP - @sessions = sessions unless sessions == SKIP - @subscriptions = subscriptions unless subscriptions == SKIP - @tag = tag unless tag == SKIP - @device_api_version = device_api_version unless device_api_version == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : SKIP - publish_permissions = - hash.key?('publishPermissions') ? hash['publishPermissions'] : SKIP - sessions = hash.key?('sessions') ? hash['sessions'] : SKIP - subscriptions = Subscriptions.from_hash(hash['subscriptions']) if hash['subscriptions'] - tag = hash.key?('tag') ? hash['tag'] : SKIP - device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2 - - # Create object from extracted values. - Participant.new(id, - callback_url, - publish_permissions, - sessions, - subscriptions, - tag, - device_api_version) - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb deleted file mode 100644 index 40007b31..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +++ /dev/null @@ -1,48 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # ParticipantSubscription Model. - class ParticipantSubscription < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Participant the subscriber should be subscribed to - # @return [String] - attr_accessor :participant_id - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['participant_id'] = 'participantId' - @_hash - end - - # An array for optional fields - def optionals - [] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(participant_id = nil) - @participant_id = participant_id unless participant_id == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - participant_id = hash.key?('participantId') ? hash['participantId'] : SKIP - - # Create object from extracted values. - ParticipantSubscription.new(participant_id) - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb deleted file mode 100644 index ab4e49a0..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +++ /dev/null @@ -1,17 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # PublishPermission. - class PublishPermissionEnum - PUBLISH_PERMISSION_ENUM = [ - # TODO: Write general description for AUDIO - AUDIO = 'AUDIO'.freeze, - - # TODO: Write general description for VIDEO - VIDEO = 'VIDEO'.freeze - ].freeze - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb deleted file mode 100644 index 64af0743..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +++ /dev/null @@ -1,60 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # A session object - class Session < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Unique id of the session - # @return [String] - attr_accessor :id - - # User defined tag to associate with the session - # @return [String] - attr_accessor :tag - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['id'] = 'id' - @_hash['tag'] = 'tag' - @_hash - end - - # An array for optional fields - def optionals - %w[ - id - tag - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(id = nil, - tag = nil) - @id = id unless id == SKIP - @tag = tag unless tag == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - id = hash.key?('id') ? hash['id'] : SKIP - tag = hash.key?('tag') ? hash['tag'] : SKIP - - # Create object from extracted values. - Session.new(id, - tag) - end - end -end diff --git a/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb b/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb deleted file mode 100644 index 8baefc21..00000000 --- a/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +++ /dev/null @@ -1,71 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -module Bandwidth - # Subscriptions Model. - class Subscriptions < BaseModel - SKIP = Object.new - private_constant :SKIP - - # Session the subscriptions are associated with - # If this is the only field, the subscriber will be subscribed to all - # participants in the session (including any participants that are later - # added to the session) - # @return [String] - attr_accessor :session_id - - # Subset of participants to subscribe to in the session. Optional. - # @return [List of ParticipantSubscription] - attr_accessor :participants - - # A mapping from model property names to API property names. - def self.names - @_hash = {} if @_hash.nil? - @_hash['session_id'] = 'sessionId' - @_hash['participants'] = 'participants' - @_hash - end - - # An array for optional fields - def optionals - %w[ - participants - ] - end - - # An array for nullable fields - def nullables - [] - end - - def initialize(session_id = nil, - participants = nil) - @session_id = session_id unless session_id == SKIP - @participants = participants unless participants == SKIP - end - - # Creates an instance of the object from a hash. - def self.from_hash(hash) - return nil unless hash - - # Extract variables from the hash. - session_id = hash.key?('sessionId') ? hash['sessionId'] : SKIP - # Parameter is an array, so we need to iterate through it - participants = nil - unless hash['participants'].nil? - participants = [] - hash['participants'].each do |structure| - participants << (ParticipantSubscription.from_hash(structure) if structure) - end - end - - participants = SKIP unless hash.key?('participants') - - # Create object from extracted values. - Subscriptions.new(session_id, - participants) - end - end -end diff --git a/openapi-config.yml b/openapi-config.yml new file mode 100644 index 00000000..c19e56ee --- /dev/null +++ b/openapi-config.yml @@ -0,0 +1,12 @@ +gemAuthor: Bandwidth +gemAuthorEmail: dx@bandwidth.com +gemDescription: The official client SDK for Bandwidth's Voice, Messaging, MFA, and WebRTC APIs +gemHomepage: https://github.com/Bandwidth/ruby-sdk +gemLicense: MIT +gemName: bandwidth-sdk +gemRequiredRubyVersion: '>=2.7' +gemSummary: Bandwidth Ruby SDK +gemVersion: 11.0.0 +library: faraday +moduleName: Bandwidth +templateDir: custom_templates diff --git a/openapitools.json b/openapitools.json new file mode 100644 index 00000000..3015568c --- /dev/null +++ b/openapitools.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json", + "spaces": 2, + "generator-cli": { + "version": "7.0.0" + } +} diff --git a/spec/api/calls_api_spec.rb b/spec/api/calls_api_spec.rb new file mode 100644 index 00000000..ac3020c9 --- /dev/null +++ b/spec/api/calls_api_spec.rb @@ -0,0 +1,230 @@ +# Unit tests for Bandwidth::CallsApi +describe 'CallsApi' do + # call info + let(:call_id) { 'c-15ac29a2-006c67ad-060f-4b98-b148-b753d6e5e2ce' } + let(:enqueued_time) { '2023-06-23T18:43:51.248Z' } + let(:call_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}" } + let(:call_timeout) { 30.0 } + let(:callback_timeout) { 15.0 } + let(:display_name) { 'Ruby SDK' } + let(:answer_method) { Bandwidth::CallbackMethodEnum::POST } + let(:answer_url) { BASE_CALLBACK_URL + '/callbacks/answer' } + let(:answer_fallback_url) { BASE_CALLBACK_URL + '/callbacks/answer' } + let(:answer_fallback_method) { Bandwidth::CallbackMethodEnum::POST } + let(:disconnect_method) { Bandwidth::CallbackMethodEnum::GET } + let(:disconnect_url) { BASE_CALLBACK_URL + '/callbacks/disconnect' } + let(:priority) { 5 } + let(:direction) { Bandwidth::CallDirectionEnum::OUTBOUND } + let(:state) { 'disconnected' } + let(:stir_shaken) { {} } + let(:start_time) { '2023-06-23T19:11:06.049Z' } + let(:end_time) { '2023-06-23T19:11:06.175Z' } + let(:disconnect_cause) { 'rejected' } + let(:error_message) { 'Destination not found' } + let(:error_id) { '779941c4-6482-461d-b370-177b4ad0b5a7' } + let(:last_update) { '2023-06-23T19:11:06.175Z' } + let(:tag) { 'test tag' } + + # stubs + let(:create_call_headers_stub) { { 'content-type' => 'application/json' } } + let(:create_call_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"enqueuedTime\":\"#{enqueued_time}\",\"callUrl\":\"#{call_url}\",\"callTimeout\":#{call_timeout},\"callbackTimeout\":#{callback_timeout},\"tag\":\"#{tag}\",\"answerMethod\":\"#{answer_method}\",\"answerUrl\":\"#{answer_url}\",\"answerFallbackUrl\":\"#{answer_fallback_url}\",\"answerFallbackMethod\":\"#{answer_fallback_method}\",\"disconnectMethod\":\"#{disconnect_method}\",\"disconnectUrl\":\"#{disconnect_url}\",\"priority\":#{priority}}" } + let(:create_call_bad_request_stub) { '{"type":"validation","description":"Invalid to: must be a valid SIP URI or an E164 TN"}' } + let(:get_call_state_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_call_state_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"direction\":\"#{direction}\",\"state\":\"#{state}\",\"stirShaken\":#{stir_shaken},\"enqueuedTime\":\"#{enqueued_time}\",\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"disconnectCause\":\"#{disconnect_cause}\",\"errorMessage\":\"#{error_message}\",\"errorId\":\"#{error_id}\",\"lastUpdate\":\"#{last_update}\"}" } + let(:get_call_state_not_found_stub) { '{"type":"validation","description":"Call does-not-exist was not found."}' } + let(:get_call_state_unauthorized_stub) { '{"type":"authentication-error","description":"The credentials provided were invalid"}' } + let(:get_call_state_forbidden_stub) { '{"type":"authorization-error","description":"Access is denied"}' } + let(:update_call_headers_stub) { { 'content-length' => '0' } } + + before(:all) do + Bandwidth.configure do |config| + config.debugging = true + end + @calls_api_instance = Bandwidth::CallsApi.new + end + + describe 'test an instance of CallsApi' do + it 'should create an instance of CallsApi' do + expect(@calls_api_instance).to be_instance_of(Bandwidth::CallsApi) + end + end + + # Create Call + describe '#create_call' do + it 'creates a call with amd' do + stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls"). + to_return(status: 201, headers: create_call_headers_stub, body: create_call_body_stub) + + amd_config = Bandwidth::MachineDetectionConfiguration.new( + mode: 'async', + detection_timeout: 5.0, + silence_timeout: 5.0, + speech_threshold: 5.0, + speech_end_threshold: 5.0, + delay_result: true, + callback_url: BASE_CALLBACK_URL + '/machineDetection', + callback_method: Bandwidth::CallbackMethodEnum::POST + ) + + call_body = Bandwidth::CreateCall.new( + application_id: BW_VOICE_APPLICATION_ID, + to: USER_NUMBER, + from: BW_NUMBER, + display_name: display_name, + answer_url: answer_url, + answer_fallback_url: answer_fallback_url, + answer_method: answer_method, + disconnect_url: disconnect_url, + disconnect_method: disconnect_method, + machine_detection: amd_config, + call_timeout: call_timeout, + callback_timeout: callback_timeout, + tag: tag + ) + + data, status_code, headers = @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body) + + expect(status_code).to eq(201) + expect(headers).to eq(create_call_headers_stub) + expect(data).to be_instance_of(Bandwidth::CreateCallResponse) + expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.call_id).to eq(call_id) + expect(data.to).to eq(USER_NUMBER) + expect(data.from).to eq(BW_NUMBER) + expect(data.enqueued_time).to eq(Time.parse(enqueued_time)) + expect(data.call_url).to eq(call_url) + expect(data.call_timeout).to eq(call_timeout) + expect(data.callback_timeout).to eq(callback_timeout) + expect(data.tag).to eq(tag) + expect(data.answer_method).to eq(answer_method) + expect(data.answer_url).to eq(answer_url) + expect(data.answer_fallback_method).to eq(answer_fallback_method) + expect(data.answer_fallback_url).to eq(answer_fallback_url) + expect(data.disconnect_method).to eq(disconnect_method) + expect(data.disconnect_url).to eq(disconnect_url) + expect(data.priority).to eq(priority) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + @calls_api_instance.create_call(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing create_call' do + expect { + @calls_api_instance.create_call(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Get Call State Information + describe '#get_call_state' do + it 'gets the call state' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}"). + to_return(status: 200, headers: get_call_state_headers_stub, body: get_call_state_body_stub) + + data, status_code, headers = @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, call_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_call_state_headers_stub) + expect(data).to be_instance_of(Bandwidth::CallState) + expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.call_id).to eq(call_id) + expect(data.to).to eq(USER_NUMBER) + expect(data.from).to eq(BW_NUMBER) + expect(data.direction).to eq(direction) + expect(data.stir_shaken).to eq(stir_shaken) + expect(data.state).to eq(state) + expect(data.enqueued_time).to eq(Time.parse(enqueued_time)) + expect(data.start_time).to eq(Time.parse(start_time)) + expect(data.end_time).to eq(Time.parse(end_time)) + expect(data.disconnect_cause).to eq(disconnect_cause) + expect(data.error_message).to eq(error_message) + expect(data.error_id).to eq(error_id) + expect(data.last_update).to eq(Time.parse(last_update)) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @calls_api_instance.get_call_state(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @calls_api_instance.get_call_state(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Update Call + describe '#update_call' do + it 'creates and updates a call' do + stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}"). + to_return(status: 200, headers: update_call_headers_stub) + + update_call_body = Bandwidth::UpdateCall.new( + state: Bandwidth::CallStateEnum::ACTIVE, + redirect_url: MANTECA_BASE_URL + '/bxml/pause' + ) + + data, status_code, headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, call_id, update_call_body) + + expect(status_code).to eq(200) + expect(headers).to eq(update_call_headers_stub) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @calls_api_instance.update_call(nil, '', {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @calls_api_instance.update_call(BW_ACCOUNT_ID, nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing update_call' do + expect { + @calls_api_instance.update_call(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Update Call BXML + describe '#update_call_bxml' do + it 'updates a call using bxml' do + stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/bxml"). + to_return(status: 204) + + update_bxml = 'This is a test bxml response' + + data, status_code, headers = @calls_api_instance.update_call_bxml_with_http_info(BW_ACCOUNT_ID, call_id, update_bxml) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + @calls_api_instance.update_call_bxml(nil, '', {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing body' do + expect { + @calls_api_instance.update_call_bxml(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/conferences_api_spec.rb b/spec/api/conferences_api_spec.rb new file mode 100644 index 00000000..2fba68be --- /dev/null +++ b/spec/api/conferences_api_spec.rb @@ -0,0 +1,393 @@ +# Unit tests for Bandwidth::ConferencesApi +describe 'ConferencesApi' do + # conference info + let(:test_id) { 'ruby-3.1.3_macOS_conference_1687791527' } + let(:conference_id) { 'conf-3f758f24-6711b6d2-0d44-495d-afc8-2555c3ce5f4f' } + let(:created_time) { '2023-06-26T14:58:49.471Z' } + let(:conference_event_url) { 'https://amazonaws.com/prod/conferenceEvents' } + let(:conference_event_method) { 'POST' } + let(:call_id) { 'c-3f758f24-cd77b08f-97c2-4311-965a-a1ac8ed8f340' } + let(:recording_id) { 'r-fbe05094-7bf4b314-91fe-4bdd-a39b-500cdc873d3a' } + let(:start_time) { '2023-06-26T14:58:51.195Z' } + let(:end_time) { '2023-06-26T14:58:57.502Z' } + let(:duration) { 'PT6.3S' } + let(:channels) { 1 } + let(:file_format) { Bandwidth::FileFormatEnum::WAV } + let(:status) { 'complete' } + let(:member_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}" } + let(:media_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media" } + let(:active_members) { "[{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}]" } + + # stubs + let(:list_conferences_headers_stub) { { 'content-type' => 'application/json' } } + let(:list_conferences_body_stub) { "[{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\"}]" } + let(:get_conference_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_conference_body_stub) { "{\"id\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"createdTime\":\"#{created_time}\",\"conferenceEventUrl\":\"#{conference_event_url}\",\"conferenceEventMethod\":\"#{conference_event_method}\",\"tag\":\"#{test_id}\",\"activeMembers\":#{active_members}}" } + let(:get_conference_member_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_conference_member_body_stub) { "{\"callId\":\"#{call_id}\",\"conferenceId\":\"#{conference_id}\",\"memberUrl\":\"#{member_url}\",\"mute\":false,\"hold\":false,\"callIdsToCoach\":[]}" } + let(:list_conference_recordings_headers_stub) { { 'content-type' => 'application/json' } } + let(:list_conference_recordings_body_stub) { "[{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" } + let(:get_conference_recording_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_conference_recording_body_stub) { "{\"accountId\":\"#{BW_ACCOUNT_ID}\",\"conferenceId\":\"#{conference_id}\",\"name\":\"#{test_id}\",\"recordingId\":\"#{recording_id}\",\"duration\":\"#{duration}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}" } + let(:download_conference_recording_body_stub) { 'RIFFWAVEfmtLISTINFOISFTLavf58.45.100data' } + let(:download_conference_recording_headers_stub) { { 'content-type' => 'audio/vnd.wave', 'content-length' => "#{download_conference_recording_body_stub.length}" } } + + before(:all) do + Bandwidth.configure do |config| + config.return_binary_data = true + config.debugging = true + end + @conferences_api_instance = Bandwidth::ConferencesApi.new + end + + describe 'test an instance of ConferencesApi' do + it 'should create an instance of ConferencesApi' do + expect(@conferences_api_instance).to be_instance_of(Bandwidth::ConferencesApi) + end + end + + # Download Conference Recording + describe 'download_conference_recording test' do + it 'should work' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}/media"). + to_return(status: 200, headers: download_conference_recording_headers_stub, body: download_conference_recording_body_stub) + + data, status_code, headers = @conferences_api_instance.download_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id) + + expect(status_code).to eq(200) + expect(headers).to eq(download_conference_recording_headers_stub) + expect(data).to eq(download_conference_recording_body_stub) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.download_conference_recording(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @conferences_api_instance.download_conference_recording(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Conference Information + describe 'get_conference' do + it 'get a conference by id' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}"). + to_return(status: 200, headers: get_conference_headers_stub, body: get_conference_body_stub) + + data, status_code, headers = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, conference_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_conference_headers_stub) + expect(data).to be_instance_of(Bandwidth::Conference) + expect(data.id).to eq(conference_id) + expect(data.name).to eq(test_id) + expect(data.tag).to eq(test_id) + expect(data.created_time).to eq(Time.parse(created_time)) + expect(data.conference_event_url).to eq(conference_event_url) + expect(data.conference_event_method).to eq(conference_event_method) + expect(data.active_members).to be_instance_of(Array) + expect(data.active_members[0]).to be_instance_of(Bandwidth::ConferenceMember) + expect(data.active_members[0].call_id).to eq(call_id) + expect(data.active_members[0].conference_id).to eq(conference_id) + expect(data.active_members[0].member_url).to eq(member_url) + expect(data.active_members[0].mute).to be false + expect(data.active_members[0].hold).to be false + expect(data.active_members[0].call_ids_to_coach).to eq([]) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.get_conference(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.get_conference(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Get Conference Member + describe 'get_conference_member' do + it 'gets a conference member by call id' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}"). + to_return(status: 200, headers: get_conference_member_headers_stub, body: get_conference_member_body_stub) + + data, status_code, headers = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_conference_member_headers_stub) + expect(data).to be_instance_of(Bandwidth::ConferenceMember) + expect(data.conference_id).to eq(conference_id) + expect(data.call_id).to eq(call_id) + expect(data.member_url).to eq(member_url) + expect(data.mute).to be false + expect(data.hold).to be false + expect(data.call_ids_to_coach).to eq([]) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.get_conference_member(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing member_id' do + expect { + @conferences_api_instance.get_conference_member(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Conference Recording Information + describe 'get_conference_recording' do + it 'gets a conference recording by id' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings/#{recording_id}"). + to_return(status: 200, headers: get_conference_recording_headers_stub, body: get_conference_recording_body_stub) + + data, status_code, headers = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, conference_id, recording_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_conference_recording_headers_stub) + expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.conference_id).to eq(conference_id) + expect(data.name).to eq(test_id) + expect(data.recording_id).to eq(recording_id) + expect(data.duration).to eq(duration) + expect(data.channels).to eq(channels) + expect(data.start_time).to eq(Time.parse(start_time)) + expect(data.end_time).to eq(Time.parse(end_time)) + expect(data.file_format).to eq(Bandwidth::FileFormatEnum::WAV) + expect(data.status).to eq('complete') + expect(data.media_url).to eq(media_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.get_conference_recording(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @conferences_api_instance.get_conference_recording(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Conference Recordings + describe 'list_conference_recordings' do + it 'lists recordings for a conference' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/recordings"). + to_return(status: 200, headers: list_conference_recordings_headers_stub, body: list_conference_recordings_body_stub) + + data, status_code, headers = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, conference_id) + + expect(status_code).to eq(200) + expect(headers).to eq(list_conference_recordings_headers_stub) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data[0].conference_id).to eq(conference_id) + expect(data[0].name).to eq(test_id) + expect(data[0].recording_id).to eq(recording_id) + expect(data[0].duration).to eq(duration) + expect(data[0].channels).to eq(channels) + expect(data[0].start_time).to eq(Time.parse(start_time)) + expect(data[0].end_time).to eq(Time.parse(end_time)) + expect(data[0].file_format).to eq(Bandwidth::FileFormatEnum::WAV) + expect(data[0].status).to eq('complete') + expect(data[0].media_url).to eq(media_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.list_conference_recordings(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.list_conference_recordings(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Get Conferences + describe 'list_conferences' do + it 'list all conferences' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences?name=#{test_id}"). + to_return(status: 200, headers: list_conferences_headers_stub, body: list_conferences_body_stub) + + conference_opts = { + name: test_id + } + + data, status_code, headers = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts) + + expect(status_code).to eq(200) + expect(headers).to eq(list_conferences_headers_stub) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::Conference) + expect(data[0].id).to eq(conference_id) + expect(data[0].name).to eq(test_id) + expect(data[0].tag).to eq(test_id) + expect(data[0].created_time).to eq(Time.parse(created_time)) + expect(data[0].conference_event_url).to eq(conference_event_url) + expect(data[0].conference_event_method).to eq(conference_event_method) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.list_conferences(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for an invalid page_size' do + expect { + @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 1001 }) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for an invalid page_size' do + expect { + @conferences_api_instance.list_conferences(BW_ACCOUNT_ID, { page_size: 0 }) + }.to raise_error(ArgumentError) + end + end + + # Update Conference + describe 'update_conference' do + it 'updates a conference' do + stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}"). + to_return(status: 204) + + update_conference_body = Bandwidth::UpdateConference.new( + status: Bandwidth::ConferenceStateEnum::ACTIVE, + redirect_url: BASE_CALLBACK_URL + '/bxml/pause', + redirect_method: Bandwidth::RedirectMethodEnum::POST, + username: 'username', + password: 'password', + redirect_fallback_url: BASE_CALLBACK_URL + '/bxml/pause', + redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST, + fallback_username: 'username', + fallback_password: 'password' + ) + + data, status_code, headers = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, conference_id, update_conference_body) + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.update_conference(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.update_conference(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing update_conference' do + expect { + @conferences_api_instance.update_conference(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Update Conference BXML + describe 'update_conference_bxml' do + it 'updates a conference using bxml' do + stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/bxml"). + to_return(status: 204) + + update_bxml = 'This should be a conference recording.' + + data, status_code, headers = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, conference_id, update_bxml) + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.update_conference_bxml(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing body' do + expect { + @conferences_api_instance.update_conference_bxml(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Update Conference Member + describe 'update_conference_member' do + it 'updates a conference member by call id' do + stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/conferences/#{conference_id}/members/#{call_id}"). + to_return(status: 204) + + update_conference_member = Bandwidth::UpdateConferenceMember.new( + mute: false + ) + + data, status_code, headers = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, conference_id, call_id, update_conference_member) + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @conferences_api_instance.update_conference_member(nil, '', '', {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing conference_id' do + expect { + @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, nil, '', {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing member_id' do + expect { + @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing update_conference_member' do + expect { + @conferences_api_instance.update_conference_member(BW_ACCOUNT_ID, '', '', nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/media_api_spec.rb b/spec/api/media_api_spec.rb new file mode 100644 index 00000000..283e5a25 --- /dev/null +++ b/spec/api/media_api_spec.rb @@ -0,0 +1,129 @@ +# Unit tests for Bandwidth::MediaApi +describe 'MediaApi' do + # media info + let(:media_name) { 'ruby_binary_media' + SecureRandom.uuid } + let(:media_data) { '123456' } + let(:content_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}" } + + # stubs + let(:get_media_headers_stub) { { 'content-type' => 'application/json' } } + let(:list_media_body_stub) { "[{\"contentLength\":#{media_data.length},\"mediaName\":\"#{media_name}\",\"content\":\"#{content_url}\"}]" } + let(:list_media_headers_stub) { { 'content-type' => 'application/json' } } + + before(:all) do + Bandwidth.configure do |config| + config.return_binary_data = true + config.debugging = true + end + @media_api_instance = Bandwidth::MediaApi.new + end + + describe 'test an instance of MediaApi' do + it 'should create an instance of MediaApi' do + expect(@media_api_instance).to be_instance_of(Bandwidth::MediaApi) + end + end + + # Delete Media + describe 'delete_media' do + it 'deletes the binary media' do + stub_request(:delete, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}"). + to_return(status: 204) + + data, status_code, headers = @media_api_instance.delete_media_with_http_info(BW_ACCOUNT_ID, media_name) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @media_api_instance.delete_media(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing media_id' do + expect { + @media_api_instance.delete_media(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Get Media + describe 'get_media' do + it 'gets uploaded binary media' do + stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}"). + to_return(status: 200, headers: get_media_headers_stub, body: media_data) + + data, status_code, headers = @media_api_instance.get_media_with_http_info(BW_ACCOUNT_ID, media_name) + + expect(status_code).to eq(200) + expect(headers).to eq(get_media_headers_stub) + expect(data).to eq(media_data) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @media_api_instance.get_media(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing media_id' do + expect { + @media_api_instance.get_media(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # List Media + describe 'list_media' do + it 'lists media' do + stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media"). + to_return(status: 200, headers: list_media_headers_stub, body: list_media_body_stub) + + data, status_code, headers = @media_api_instance.list_media_with_http_info(BW_ACCOUNT_ID) + + expect(status_code).to eq(200) + expect(headers).to eq(list_media_headers_stub) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::Media) + expect(data[0].content_length).to eq(media_data.length) + expect(data[0].media_name).to eq(media_name) + expect(data[0].content).to eq(content_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @media_api_instance.list_media(nil) + }.to raise_error(ArgumentError) + end + end + + # Upload Media + describe 'upload_media' do + it 'uploads binary media' do + stub_request(:put, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/media/#{media_name}"). + to_return(status: 204) + + data, status_code, headers = @media_api_instance.upload_media_with_http_info(BW_ACCOUNT_ID, media_name, media_data) + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @media_api_instance.upload_media(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing media_id' do + expect { + @media_api_instance.upload_media(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing body' do + expect { + @media_api_instance.upload_media(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/messages_api_spec.rb b/spec/api/messages_api_spec.rb new file mode 100644 index 00000000..3b6a06d8 --- /dev/null +++ b/spec/api/messages_api_spec.rb @@ -0,0 +1,193 @@ +# Unit tests for Bandwidth::MessagesApi +describe 'MessagesApi' do + # message info + let(:mms_id) { '1687899647358cu2t57tczmbzcu2s' } + let(:sms_id) { '1687899647634s46mhdt7ifq5hnjl' } + let(:time) { '2023-06-27T21:00:47.358063Z' } + let(:segment_count) { 1 } + let(:direction) { Bandwidth::MessageDirectionEnum::OUT } + let(:text) { 'test text' } + let(:media_url) { 'https://cdn2.thecatapi.com/images/MTY3ODIyMQ.jpg' } + let(:tag) { 'test tag' } + let(:priority) { Bandwidth::PriorityEnum::HIGH } + let(:expiration_time) { (Time.now + 60).round.to_datetime.rfc3339 } + let(:total_count) { 2 } + let(:next_page_token) { 'YWZ0ZXI9MTAwJmxpbWl0PTEwMA' } + let(:list_message_direction) { Bandwidth::ListMessageDirectionEnum::OUTBOUND } + let(:list_message_status) { Bandwidth::MessageStatusEnum::SENT } + let(:list_message_type_mms) { Bandwidth::MessageTypeEnum::MMS } + let(:list_message_type_sms) { Bandwidth::MessageTypeEnum::SMS } + let(:mms_length) { 45151 } + let(:attachment_count) { 1 } + let(:recipient_count) { 1 } + let(:mms_error_code) { 0 } + let(:sms_error_code) { 4720 } + let(:carrier_name) { 'Other' } + let(:next_page_url) { "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}&pageToken=#{next_page_token}" } + + # stubs + let(:create_message_mms_headers_stub) { { 'content-type' => 'application/json' } } + let(:create_message_mms_body_stub) { "{\"id\":\"#{mms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"media\":[\"#{media_url}\"],\"tag\":\"#{tag}\"}" } + let(:create_message_sms_headers_stub) { { 'content-type' => 'application/json' } } + let(:create_message_sms_body_stub) { "{\"id\":\"#{sms_id}\",\"owner\":\"#{BW_NUMBER}\",\"applicationId\":\"#{BW_MESSAGING_APPLICATION_ID}\",\"time\":\"#{time}\",\"segmentCount\":#{segment_count},\"direction\":\"#{direction}\",\"to\":[\"#{USER_NUMBER}\"],\"from\":\"#{BW_NUMBER}\",\"text\":\"#{text}\",\"tag\":\"#{tag}\",\"priority\":\"#{priority}\",\"expiration\":\"#{expiration_time}\"}" } + let(:list_messages_body_stub) { "{\"totalCount\":#{total_count},\"pageInfo\":{\"nextPage\":\"#{next_page_url}\",\"nextPageToken\":\"#{next_page_token}\"},\"messages\":[{\"messageId\":\"#{mms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_mms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{mms_length},\"messageSize\":#{mms_length},\"attachmentCount\":#{attachment_count},\"recipientCount\":#{recipient_count},\"errorCode\":#{mms_error_code},\"carrierName\":null,\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"},{\"messageId\":\"#{sms_id}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"sourceTn\":\"#{BW_NUMBER}\",\"destinationTn\":\"#{USER_NUMBER}\",\"messageStatus\":\"#{list_message_status}\",\"messageDirection\":\"#{list_message_direction}\",\"messageType\":\"#{list_message_type_sms}\",\"segmentCount\":#{segment_count},\"messageLength\":#{text.length},\"messageSize\":null,\"attachmentCount\":null,\"recipientCount\":null,\"errorCode\":#{sms_error_code},\"carrierName\":\"#{carrier_name}\",\"campaignClass\":null,\"campaignId\":null,\"receiveTime\":\"#{time}\"}]}" } + let(:list_messages_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{list_messages_body_stub.length}" } } + + before(:all) do + Bandwidth.configure do |config| + config.debugging = true + end + @messaging_api_instance = Bandwidth::MessagesApi.new + end + + describe 'test an instance of MessagesApi' do + it 'should create an instance of MessagesApi' do + expect(@messaging_api_instance).to be_instance_of(Bandwidth::MessagesApi) + end + end + + # Create Message + describe 'create_message' do + it 'creates an mms message' do + stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages"). + to_return(status: 202, headers: create_message_mms_headers_stub, body: create_message_mms_body_stub) + + message_request = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: [USER_NUMBER], + from: BW_NUMBER, + text: text, + media: [media_url], + tag: tag + ) + + data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request) + + expect(status_code).to eq(202) + expect(headers).to eq(create_message_mms_headers_stub) + expect(data).to be_instance_of(Bandwidth::Message) + expect(data.id).to eq(mms_id) + expect(data.owner).to eq(BW_NUMBER) + expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID) + expect(data.time).to eq(Time.parse(time)) + expect(data.segment_count).to eq(segment_count) + expect(data.direction).to eq(direction) + expect(data.to).to eq([USER_NUMBER]) + expect(data.from).to eq(BW_NUMBER) + expect(data.text).to eq(text) + expect(data.media).to eq([media_url]) + expect(data.tag).to eq(tag) + end + + it 'creates an sms message' do + stub_request(:post, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages"). + to_return(status: 202, headers: create_message_sms_headers_stub, body: create_message_sms_body_stub) + + message_request = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: [USER_NUMBER], + from: BW_NUMBER, + text: text, + tag: tag, + priority: priority, + expiration: expiration_time + ) + + data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request) + + expect(status_code).to eq(202) + expect(headers).to eq(create_message_sms_headers_stub) + expect(data).to be_instance_of(Bandwidth::Message) + expect(data.id).to eq(sms_id) + expect(data.owner).to eq(BW_NUMBER) + expect(data.application_id).to eq(BW_MESSAGING_APPLICATION_ID) + expect(data.time).to eq(Time.parse(time)) + expect(data.segment_count).to eq(segment_count) + expect(data.direction).to eq(direction) + expect(data.to).to eq([USER_NUMBER]) + expect(data.from).to eq(BW_NUMBER) + expect(data.text).to eq(text) + expect(data.tag).to eq(tag) + expect(data.priority).to eq(priority) + expect(data.expiration).to eq(Time.parse(expiration_time)) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @messaging_api_instance.create_message(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing message_request' do + expect { + @messaging_api_instance.create_message(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # List Messages + describe 'list_messages' do + it 'lists messages' do + stub_request(:get, "https://messaging.bandwidth.com/api/v2/users/#{BW_ACCOUNT_ID}/messages?messageDirection=#{list_message_direction}&sourceTn=%2B#{BW_NUMBER[1..-1]}"). + to_return(status: 200, headers: list_messages_headers_stub, body: list_messages_body_stub) + + get_opts = { + :source_tn => BW_NUMBER, + :message_direction => list_message_direction + } + + data, status_code, headers = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID, get_opts) + + expect(status_code).to eq(200) + expect(headers).to eq(list_messages_headers_stub) + expect(data).to be_instance_of(Bandwidth::MessagesList) + expect(data.total_count).to eq(total_count) + expect(data.page_info.next_page).to eq(next_page_url) + expect(data.page_info.next_page_token).to eq(next_page_token) + expect(data.messages.length).to eq(total_count) + expect(data.messages).to be_instance_of(Array) + expect(data.messages[0]).to be_instance_of(Bandwidth::ListMessageItem) + expect(data.messages[0].message_id).to eq(mms_id) + expect(data.messages[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data.messages[0].source_tn).to eq(BW_NUMBER) + expect(data.messages[0].destination_tn).to eq(USER_NUMBER) + expect(data.messages[0].message_status).to eq(list_message_status) + expect(data.messages[0].message_direction).to eq(list_message_direction) + expect(data.messages[0].message_type).to eq(list_message_type_mms) + expect(data.messages[0].segment_count).to eq(segment_count) + expect(data.messages[0].error_code).to eq(mms_error_code) + expect(data.messages[0].receive_time).to eq(Time.parse(time)) + expect(data.messages[0].carrier_name).to eq(nil) + expect(data.messages[0].message_size).to eq(mms_length) + expect(data.messages[0].message_length).to eq(mms_length) + expect(data.messages[0].attachment_count).to eq(attachment_count) + expect(data.messages[0].recipient_count).to eq(recipient_count) + expect(data.messages[0].campaign_class).to eq(nil) + expect(data.messages[0].campaign_id).to eq(nil) + expect(data.messages[1]).to be_instance_of(Bandwidth::ListMessageItem) + expect(data.messages[1].message_id).to eq(sms_id) + expect(data.messages[1].account_id).to eq(BW_ACCOUNT_ID) + expect(data.messages[1].source_tn).to eq(BW_NUMBER) + expect(data.messages[1].destination_tn).to eq(USER_NUMBER) + expect(data.messages[1].message_status).to eq(list_message_status) + expect(data.messages[1].message_direction).to eq(list_message_direction) + expect(data.messages[1].message_type).to eq(list_message_type_sms) + expect(data.messages[1].segment_count).to eq(segment_count) + expect(data.messages[1].error_code).to eq(sms_error_code) + expect(data.messages[1].receive_time).to eq(Time.parse(time)) + expect(data.messages[1].carrier_name).to eq(carrier_name) + expect(data.messages[1].message_size).to eq(nil) + expect(data.messages[1].message_length).to eq(text.length) + expect(data.messages[1].attachment_count).to eq(nil) + expect(data.messages[1].recipient_count).to eq(nil) + expect(data.messages[1].campaign_class).to eq(nil) + expect(data.messages[1].campaign_id).to eq(nil) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @messaging_api_instance.list_messages(nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/mfa_api_spec.rb b/spec/api/mfa_api_spec.rb new file mode 100644 index 00000000..70486b73 --- /dev/null +++ b/spec/api/mfa_api_spec.rb @@ -0,0 +1,130 @@ +# Unit tests for Bandwidth::MFAApi +describe 'MFAApi' do + # mfa info + let(:message) { 'Your temporary {NAME} {SCOPE} code is: {CODE}' } + let(:message_id) { '1687965513364hx26ky4mpkll3m5a' } + let(:call_id) { 'c-28bba681-cffc7d67-904e-42c8-85c5-b5589ea583b4' } + let(:digits) { 6 } + + # stubs + let(:generate_messaging_code_body_stub) { "{\"messageId\": \"#{message_id}\"}" } + let(:generate_messaging_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_messaging_code_body_stub.length}" } } + let(:generate_voice_code_body_stub) { "{\"callId\": \"#{call_id}\"}" } + let(:generate_voice_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{generate_voice_code_body_stub.length}" } } + let(:verify_code_body_stub) { '{"valid": false}' } + let(:verify_code_headers_stub) { { 'content-type' => 'application/json', 'content-length' => "#{verify_code_body_stub.length}" } } + + before(:all) do + Bandwidth.configure do |config| + config.debugging = true + end + @mfa_api_instance = Bandwidth::MFAApi.new + end + + describe 'test an instance of MFAApi' do + it 'should create an instance of MFAApi' do + expect(@mfa_api_instance).to be_instance_of(Bandwidth::MFAApi) + end + end + + # Messaging Authentication Code + describe 'generate_messaging_code' do + it 'generates messaging mfa code' do + stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/messaging"). + to_return(status: 200, headers: generate_messaging_code_headers_stub, body: generate_messaging_code_body_stub) + + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + message: message, + digits: digits + ) + + data, status_code, headers = @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::MessagingCodeResponse) + expect(data.message_id).to eq(message_id) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @mfa_api_instance.generate_messaging_code(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing code_request' do + expect { + @mfa_api_instance.generate_messaging_code(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Voice Authentication Code + describe 'generate_voice_code' do + it 'generates voice mfa code' do + stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/voice"). + to_return(status: 200, headers: generate_voice_code_headers_stub, body: generate_voice_code_body_stub) + + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: BW_VOICE_APPLICATION_ID, + message: message, + digits: digits + ) + + data, status_code, headers = @mfa_api_instance.generate_voice_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::VoiceCodeResponse) + expect(data.call_id).to eq(call_id) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @mfa_api_instance.generate_voice_code(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing code_request' do + expect { + @mfa_api_instance.generate_voice_code(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Verify Authentication Code + describe 'verify_code' do + it 'verifies mfa code' do + stub_request(:post, "https://mfa.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/code/verify"). + to_return(status: 200, headers: verify_code_headers_stub, body: verify_code_body_stub) + + req_schema = Bandwidth::VerifyCodeRequest.new( + to: '+1000' + rand(1...10000000).to_s, + scope: '2FA', + expiration_time_in_minutes: 3, + code: '12345' + ) + + data, status_code, headers = @mfa_api_instance.verify_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::VerifyCodeResponse) + expect(data.valid).to be false + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @mfa_api_instance.verify_code(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing cvarify_ode_request' do + expect { + @mfa_api_instance.verify_code(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/phone_number_lookup_api_spec.rb b/spec/api/phone_number_lookup_api_spec.rb new file mode 100644 index 00000000..835a7be4 --- /dev/null +++ b/spec/api/phone_number_lookup_api_spec.rb @@ -0,0 +1,100 @@ +# Unit tests for Bandwidth::PhoneNumberLookupApi +describe 'PhoneNumberLookupApi' do + # lookup info + let(:request_id) { '21e6d818-eaa9-4ca9-b1d8-d6085f5c79d4' } + let(:status_in_progress) { Bandwidth::LookupStatusEnum::IN_PROGRESS } + let(:status_complete) { Bandwidth::LookupStatusEnum::COMPLETE } + let(:response_code) { 0 } + let(:message) { 'NOERROR' } + let(:formatted) { "(#{BW_NUMBER[2..4]}) #{BW_NUMBER[5..7]}-#{BW_NUMBER[7..-1]}" } + let(:country) { 'US' } + let(:line_type) { 'Mobile' } + let(:line_provider) { 'AdHoc P2P - Bandwidth - SVR' } + + # stubs + let(:create_lookup_headers_stub) { { 'content-type' => 'application/json' } } + let(:create_lookup_body_stub) { "{\"requestId\":\"#{request_id}\",\"status\":\"#{status_in_progress}\"}" } + let(:get_lookup_status_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_lookup_status_body_stub) { "{\"requestId\":\"#{request_id}\",\"status\":\"#{status_complete}\",\"result\":[{\"Response Code\":#{response_code},\"Message\":\"#{message}\",\"E.164 Format\":\"#{BW_NUMBER}\",\"Formatted\":\"#{formatted}\",\"Country\":\"#{country}\",\"Line Type\":\"#{line_type}\",\"Line Provider\":\"#{line_provider}\"}]}" } + + before(:all) do + Bandwidth.configure do |config| + config.debugging = true + end + @phone_number_lookup_api_instance = Bandwidth::PhoneNumberLookupApi.new + end + + describe 'test an instance of PhoneNumberLookupApi' do + it 'should create an instance of PhoneNumberLookupApi' do + expect(@phone_number_lookup_api_instance).to be_instance_of(Bandwidth::PhoneNumberLookupApi) + end + end + + # Create Lookup + describe 'create_lookup' do + it 'creates a tn lookup request' do + stub_request(:post, "https://numbers.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/tnlookup"). + to_return(status: 202, headers: create_lookup_headers_stub, body: create_lookup_body_stub) + + tn_body = Bandwidth::LookupRequest.new( + tns: [BW_NUMBER] + ) + data, status_code, headers = @phone_number_lookup_api_instance.create_lookup_with_http_info(BW_ACCOUNT_ID, tn_body) + + expect(status_code).to eq(202) + expect(headers).to eq(create_lookup_headers_stub) + expect(data).to be_instance_of(Bandwidth::CreateLookupResponse) + expect(data.request_id).to eq(request_id) + expect(data.status).to eq(status_in_progress) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @phone_number_lookup_api_instance.create_lookup(nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing lookup_request' do + expect { + @phone_number_lookup_api_instance.create_lookup(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Get Lookup Status + describe 'get_lookup_status' do + it 'gets lookup status' do + stub_request(:get, "https://numbers.bandwidth.com/api/v1/accounts/#{BW_ACCOUNT_ID}/tnlookup/#{request_id}"). + to_return(status: 200, headers: get_lookup_status_headers_stub, body: get_lookup_status_body_stub) + + data, status_code, headers = @phone_number_lookup_api_instance.get_lookup_status_with_http_info(BW_ACCOUNT_ID, request_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_lookup_status_headers_stub) + expect(data).to be_instance_of(Bandwidth::LookupStatus) + expect(data.request_id).to eq(request_id) + expect(data.status).to eq(status_complete) + expect(data.result).to be_instance_of(Array) + expect(data.result[0]).to be_instance_of(Bandwidth::LookupResult) + expect(data.result[0].response_code).to eq(response_code) + expect(data.result[0].message).to eq(message) + expect(data.result[0].e_164_format).to eq(BW_NUMBER) + expect(data.result[0].formatted).to eq(formatted) + expect(data.result[0].country).to eq(country) + expect(data.result[0].line_type).to eq(line_type) + expect(data.result[0].line_provider).to eq(line_provider) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @phone_number_lookup_api_instance.get_lookup_status(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing request_id' do + expect { + @phone_number_lookup_api_instance.get_lookup_status(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/recordings_api_spec.rb b/spec/api/recordings_api_spec.rb new file mode 100644 index 00000000..21b44ddb --- /dev/null +++ b/spec/api/recordings_api_spec.rb @@ -0,0 +1,395 @@ +# Unit tests for Bandwidth::RecordingsApi +describe 'RecordingsApi' do + # recording info + let(:call_id) { 'c-3f758f24-40c0bd9f-0a8e-4ab6-88d4-c88a2e961c7d' } + let(:recording_id) { 'r-fbe05094-87f9b821-e110-4bfb-ac57-82b2bf2bb3d5' } + let(:duration) { 'PT4.478S' } + let(:direction) { Bandwidth::CallDirectionEnum::OUTBOUND } + let(:channels) { 1 } + let(:start_time) { '2023-06-26T14:58:51.195Z' } + let(:end_time) { '2023-06-26T14:58:57.502Z' } + let(:file_format) { Bandwidth::FileFormatEnum::WAV } + let(:status) { 'complete' } + let(:media_url) { "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media" } + let(:text) { 'Now a recording, a long pause.' } + let(:confidence) { 0.975 } + let(:test_id) { 'test id' } + + # stubs + let(:download_call_recording_body_stub) { 'RIFFFWAVEfmtLISTINFOISFTLavf58.45.100data' } + let(:download_call_recording_headers_stub) { { 'content-type' => 'audio/vnd.wave', 'content-length' => "#{download_call_recording_body_stub.length}" } } + let(:get_call_recording_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_call_recording_body_stub) { "{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}" } + let(:get_call_transcription_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_call_transcription_body_stub) { "{\"transcripts\":[{\"text\":\"#{text}\",\"confidence\":#{confidence}}]}" } + let(:list_account_call_recordings_headers_stub) { { 'content-type' => 'application/json' } } + let(:list_account_call_recordings_body_stub) { "[{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" } + let(:list_call_recordings_headers_stub) { { 'content-type' => 'application/json' } } + let(:list_call_recordings_body_stub) { "[{\"applicationId\":\"#{BW_VOICE_APPLICATION_ID}\",\"accountId\":\"#{BW_ACCOUNT_ID}\",\"callId\":\"#{call_id}\",\"recordingId\":\"#{recording_id}\",\"to\":\"#{USER_NUMBER}\",\"from\":\"#{BW_NUMBER}\",\"duration\":\"#{duration}\",\"direction\":\"#{direction}\",\"channels\":#{channels},\"startTime\":\"#{start_time}\",\"endTime\":\"#{end_time}\",\"fileFormat\":\"#{file_format}\",\"status\":\"#{status}\",\"mediaUrl\":\"#{media_url}\"}]" } + let(:update_call_recording_state_headers_stub) { { 'content-length' => '0' } } + + before(:all) do + Bandwidth.configure do |config| + config.return_binary_data = true + config.debugging = true + end + @recordings_api_instance = Bandwidth::RecordingsApi.new + end + + describe 'test an instance of RecordingsApi' do + it 'should create an instance of RecordingsApi' do + expect(@recordings_api_instance).to be_instance_of(Bandwidth::RecordingsApi) + end + end + + # Delete Transcription + describe 'delete_call_transcription' do + it 'deletes the completed call recording transcription' do + stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription"). + to_return(status: 204) + + data, status_code, headers = @recordings_api_instance.delete_call_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.delete_call_transcription(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.delete_call_transcription(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.delete_call_transcription(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Delete Recording + describe 'delete_recording' do + it 'deletes the completed call recording data' do + stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}"). + to_return(status: 204) + + data, status_code, headers = @recordings_api_instance.delete_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.delete_recording(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.delete_recording(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.delete_recording(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Delete Recording Media + describe 'delete_recording_media' do + it 'deletes the completed call recording media' do + stub_request(:delete, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media"). + to_return(status: 204) + + data, status_code, headers = @recordings_api_instance.delete_recording_media_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.delete_recording_media(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.delete_recording_media(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Download Recording + describe 'download_call_recording' do + it 'downloads a call recording by id' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/media"). + to_return(status: 200, headers: download_call_recording_headers_stub, body: download_call_recording_body_stub) + + data, status_code, headers = @recordings_api_instance.download_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(200) + expect(headers).to eq(download_call_recording_headers_stub) + expect(data).to eq(download_call_recording_body_stub) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.download_call_recording(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.download_call_recording(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Call Recording + describe 'get_call_recording' do + it 'gets a call recording by id' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}"). + to_return(status: 200, headers: get_call_recording_headers_stub, body: get_call_recording_body_stub) + + data, status_code, headers = @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(200) + expect(headers).to eq(get_call_recording_headers_stub) + expect(data).to be_instance_of(Bandwidth::CallRecordingMetadata) + expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.call_id).to eq(call_id) + expect(data.recording_id).to eq(recording_id) + expect(data.to).to eq(USER_NUMBER) + expect(data.from).to eq(BW_NUMBER) + expect(data.duration).to eq(duration) + expect(data.direction).to eq(direction) + expect(data.channels).to eq(channels) + expect(data.start_time).to eq(Time.parse(start_time)) + expect(data.end_time).to eq(Time.parse(end_time)) + expect(data.file_format).to eq(file_format) + expect(data.status).to eq(status) + expect(data.media_url).to eq(media_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.get_call_recording(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.get_call_recording(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Transcription + describe 'get_call_transcription' do + it 'gets the completed call recording transcription' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription"). + to_return(status: 200, headers: get_call_transcription_headers_stub, body: get_call_transcription_body_stub) + + data, status_code, headers = @recordings_api_instance.get_call_transcription_with_http_info(BW_ACCOUNT_ID, call_id, recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::TranscriptionList) + expect(data.transcripts).to be_instance_of(Array) + expect(data.transcripts[0]).to be_instance_of(Bandwidth::Transcription) + expect(data.transcripts[0].text).to eq(text) + expect(data.transcripts[0].confidence).to eq(confidence) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.get_call_transcription(nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.get_call_transcription(BW_ACCOUNT_ID, nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.get_call_transcription(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end + + # Get Call Recordings + describe 'list_account_call_recordings' do + it 'lists account call recordings' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/recordings"). + to_return(status: 200, headers: list_account_call_recordings_headers_stub, body: list_account_call_recordings_body_stub) + + data, status_code, headers = @recordings_api_instance.list_account_call_recordings_with_http_info(BW_ACCOUNT_ID) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata) + expect(data[0].application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data[0].call_id).to eq(call_id) + expect(data[0].recording_id).to eq(recording_id) + expect(data[0].to).to eq(USER_NUMBER) + expect(data[0].from).to eq(BW_NUMBER) + expect(data[0].duration).to eq(duration) + expect(data[0].direction).to eq(direction) + expect(data[0].channels).to eq(channels) + expect(data[0].start_time).to eq(Time.parse(start_time)) + expect(data[0].end_time).to eq(Time.parse(end_time)) + expect(data[0].file_format).to eq(file_format) + expect(data[0].status).to eq(status) + expect(data[0].media_url).to eq(media_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.list_account_call_recordings(nil) + }.to raise_error(ArgumentError) + end + end + + # List Call Recordings + describe 'list_call_recordings' do + it 'lists all recordings for a single call' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings"). + to_return(status: 200, headers: list_call_recordings_headers_stub, body: list_call_recordings_body_stub) + + data, status_code, headers = @recordings_api_instance.list_call_recordings_with_http_info(BW_ACCOUNT_ID, call_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0].application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data[0].call_id).to eq(call_id) + expect(data[0].recording_id).to eq(recording_id) + expect(data[0].to).to eq(USER_NUMBER) + expect(data[0].from).to eq(BW_NUMBER) + expect(data[0].duration).to eq(duration) + expect(data[0].direction).to eq(direction) + expect(data[0].channels).to eq(channels) + expect(data[0].start_time).to eq(Time.parse(start_time)) + expect(data[0].end_time).to eq(Time.parse(end_time)) + expect(data[0].file_format).to eq(file_format) + expect(data[0].status).to eq(status) + expect(data[0].media_url).to eq(media_url) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.list_call_recordings(nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.list_call_recordings(BW_ACCOUNT_ID, nil) + }.to raise_error(ArgumentError) + end + end + + # Create Transcription Request + describe 'transcribe_call_recording' do + it 'creates a transcription request' do + stub_request(:post, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recordings/#{recording_id}/transcription"). + to_return(status: 204) + + transcribe_recording = Bandwidth::TranscribeRecording.new( + callback_url: BASE_CALLBACK_URL + '/transcriptions', + tag: test_id + ) + + data, status_code, headers = @recordings_api_instance.transcribe_call_recording_with_http_info(BW_ACCOUNT_ID, call_id, recording_id, transcribe_recording) + + expect(status_code).to eq(204) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.transcribe_call_recording(nil, '', '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, nil, '', '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing recording_id' do + expect { + @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', nil, '') + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing transcribe_recording' do + expect { + @recordings_api_instance.transcribe_call_recording(BW_ACCOUNT_ID, '', '', nil) + }.to raise_error(ArgumentError) + end + end + + # Update Recording + describe 'update_call_recording_state' do + it 'updates and ends the manteca call recording' do + stub_request(:put, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/calls/#{call_id}/recording"). + to_return(status: 200, headers: update_call_recording_state_headers_stub) + + pause_recording = Bandwidth::UpdateCallRecording.new( + state: Bandwidth::RecordingStateEnum::PAUSED + ) + + data, status_code, headers = @recordings_api_instance.update_call_recording_state_with_http_info(BW_ACCOUNT_ID, call_id, pause_recording) + + expect(status_code).to eq(200) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @recordings_api_instance.update_call_recording_state(nil, '', {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing call_id' do + expect { + @recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, nil, {}) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError for a missing update_call_recording' do + expect { + @recordings_api_instance.update_call_recording_state(BW_ACCOUNT_ID, '', nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api/statistics_api_spec.rb b/spec/api/statistics_api_spec.rb new file mode 100644 index 00000000..4a5975c6 --- /dev/null +++ b/spec/api/statistics_api_spec.rb @@ -0,0 +1,45 @@ +# Unit tests for Bandwidth::StatisticsApi +describe 'StatisticsApi' do + # statistics info + let(:current_call_queue_size) { 0 } + let(:max_call_queue_size) { 7500 } + + # stubs + let(:get_statistics_headers_stub) { { 'content-type' => 'application/json' } } + let(:get_statistics_body_stub) { "{\"currentCallQueueSize\":#{current_call_queue_size},\"maxCallQueueSize\":#{max_call_queue_size}}" } + + before(:all) do + Bandwidth.configure do |config| + config.debugging = true + end + @statistics_api_instance = Bandwidth::StatisticsApi.new + end + + describe 'test an instance of StatisticsApi' do + it 'should create an instance of StatisticsApi' do + expect(@statistics_api_instance).to be_instance_of(Bandwidth::StatisticsApi) + end + end + + # Get Account Statistics + describe 'get_statistics' do + it 'gets account statistics' do + stub_request(:get, "https://voice.bandwidth.com/api/v2/accounts/#{BW_ACCOUNT_ID}/statistics"). + to_return(status: 200, headers: get_statistics_headers_stub, body: get_statistics_body_stub) + + data, status_code, headers = @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID) + + expect(status_code).to eq(200) + expect(headers).to eq(get_statistics_headers_stub) + expect(data).to be_instance_of(Bandwidth::AccountStatistics) + expect(data.current_call_queue_size).to eq(current_call_queue_size) + expect(data.max_call_queue_size).to eq(max_call_queue_size) + end + + it 'causes an ArgumentError for a missing account_id' do + expect { + resp = @statistics_api_instance.get_statistics(nil) + }.to raise_error(ArgumentError) + end + end +end diff --git a/spec/api_client_spec.rb b/spec/api_client_spec.rb new file mode 100644 index 00000000..9fa7df7a --- /dev/null +++ b/spec/api_client_spec.rb @@ -0,0 +1,377 @@ +# Unit tests for Bandwidth::ApiClient +describe Bandwidth::ApiClient do + let(:api_client_default) { Bandwidth::ApiClient.new } + let(:config) { Bandwidth::Configuration.new } + let(:faraday_connection) { Faraday::Connection.new } + let(:api_client) { Bandwidth::ApiClient.new(config) } + let(:named_media_headers) { { 'content-disposition' => 'filename=test', 'content-type' => 'text/plain' } } + let(:media_data) { '123456' } + let(:media_headers) { { 'content-type' => 'text/plain' } } + let(:json_headers) { { 'content-type' => 'application/json' } } + let(:multipart_headers) { { 'Content-Type' => 'multipart/form-data' } } + let(:form_encoded_headers) { { 'Content-Type' => 'application/x-www-form-urlencoded' } } + let(:error_data) { '{"error": true}' } + + describe '#call_api' do + it 'calls api and returns a tempfile with name from content-disposition header' do + stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 200, headers: media_headers, body: media_data) + + opts = { + operation: :"MediaApi.get_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: nil, + auth_names: ['Basic'], + return_type: 'File' + } + data, status_code, headers = api_client.call_api(:GET, 'path', opts) + + expect(status_code).to eq(200) + expect(headers).to eq(media_headers) + expect(data).to be_a(Tempfile) + end + + it 'calls api and returns a tempfile' do + stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 200, headers: named_media_headers, body: media_data) + + opts = { + operation: :"MediaApi.get_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: nil, + auth_names: ['Basic'], + return_type: 'File' + } + data, status_code, headers = api_client.call_api(:GET, 'path', opts) + + expect(status_code).to eq(200) + expect(headers).to eq(named_media_headers) + expect(data).to be_a(Tempfile) + end + + it 'calls api and returns binary data' do + stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 200, headers: media_headers, body: media_data) + + api_client.config.return_binary_data = true + api_client.config.debugging = true + + opts = { + operation: :"MediaApi.get_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: nil, + auth_names: ['Basic'], + return_type: 'File' + } + data, status_code, headers = api_client.call_api(:GET, 'path', opts) + + expect(status_code).to eq(200) + expect(headers).to eq(media_headers) + expect(data).to eq(media_data) + end + + it 'calls api and returns a hash' do + stub_request(:get, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 200, headers: json_headers, body: '{"id": 1}') + + opts = { + operation: :"MessagesApi.list_messages", + header_params: {}, + query_params: {}, + form_params: {}, + body: nil, + auth_names: ['Basic'], + return_type: 'Hash' + } + data, status_code, headers = api_client.call_api(:GET, 'path', opts) + + expect(status_code).to eq(200) + expect(headers).to eq(json_headers) + expect(data).to eq({ id: 1 }) + end + + it 'posts data and returns nothing' do + stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 204) + + api_client.config.debugging = true + + opts = { + operation: :"MediaApi.upload_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: { id: 1 }, + auth_names: ['Basic'], + return_type: nil + } + data, status_code, headers = api_client.call_api(:POST, 'path', opts) + + expect(status_code).to eq(204) + expect(data).to be nil + end + + it 'posts multipart/form-data and returns nothing' do + stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 204) + + opts = { + operation: :"MediaApi.upload_media", + header_params: multipart_headers, + query_params: {}, + form_params: { file: Tempfile.new('filename'), array: [1, 2, 3], string: '123' }, + body: nil, + auth_names: ['Basic'], + return_type: nil + } + data, status_code, headers = api_client.call_api(:POST, 'path', opts) + + expect(status_code).to eq(204) + expect(data).to be nil + end + + it 'calls api and handles HTTP error' do + stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path'). + to_return(status: 400, headers: json_headers, body: error_data) + + opts = { + operation: :"MediaApi.upload_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: { id: 1 }, + auth_names: ['Basic'], + return_type: nil + } + + expect { + api_client.call_api(:POST, 'path', opts) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(400) + expect(e.response_headers).to eq(json_headers) + expect(e.response_body).to eq('{"error": true}') + } + end + + it 'calls api and handles timeout error' do + stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path'). + to_raise(Faraday::TimeoutError) + + opts = { + operation: :"MediaApi.upload_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: { id: 1 }, + auth_names: ['Basic'], + return_type: nil + } + + expect { + api_client.call_api(:POST, 'path', opts) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.message).to eq('Connection timed out') + } + end + + it 'calls api and handles connection error' do + stub_request(:post, 'https://messaging.bandwidth.com/api/v2/path'). + to_raise(Faraday::ConnectionFailed) + + opts = { + operation: :"MediaApi.upload_media", + header_params: {}, + query_params: {}, + form_params: {}, + body: { id: 1 }, + auth_names: ['Basic'], + return_type: nil + } + + expect { + api_client.call_api(:POST, 'path', opts) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.message).to eq('Connection failed') + } + end + end + + describe '#build_request_body' do + it 'builds application/x-www-form-urlencoded' do + expect(api_client_default.build_request_body(form_encoded_headers, { id: 1 }, nil)).to eq('id=1') + end + + it 'builds empty body' do + expect(api_client_default.build_request_body({}, {}, nil)).to be nil + end + end + + describe '#deserialize' do + it 'throws on invalid JSON when expecting JSON' do + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '{id 1}') + expect { + api_client_default.deserialize(response, 'Hash') + }.to raise_error(JSON::ParserError, 'unexpected token at \'{id 1}]\'') + end + + it 'rescues invalid JSON when expecting non-JSON' do + headers = { 'Content-Type' => 'application/json' } + response = double('response', headers: headers, body: '2022-06-16') + data = api_client_default.deserialize(response, 'Date') + expect(data).to eq(Date.parse('2022-06-16')) + end + end + + describe '#basic_auth' do + it 'sets basic auth for the connection' do + api_client.config.username = 'username' + api_client.config.password = 'password' + api_client.basic_auth(faraday_connection) + expect(api_client.config.username).to eq('username') + expect(api_client.config.password).to eq('password') + end + end + + describe '#json_mime?' do + it 'checks if the given MIME is a JSON MIME' do + expect(api_client_default.json_mime?(nil)).to eq false + expect(api_client_default.json_mime?('')).to eq false + + expect(api_client_default.json_mime?('application/json')).to eq true + expect(api_client_default.json_mime?('application/json; charset=UTF8')).to eq true + expect(api_client_default.json_mime?('APPLICATION/JSON')).to eq true + + expect(api_client_default.json_mime?('application/xml')).to eq false + expect(api_client_default.json_mime?('text/plain')).to eq false + expect(api_client_default.json_mime?('application/jsonp')).to eq false + end + end + + describe '#convert_to_type' do + it 'conversts data to the given return type' do + expect(api_client_default.convert_to_type(1, 'String')).to eq('1') + expect(api_client_default.convert_to_type('1', 'Integer')).to eq(1) + expect(api_client_default.convert_to_type('1', 'Float')).to eq(1.0) + expect(api_client_default.convert_to_type(1, 'Boolean')).to be false + expect(api_client_default.convert_to_type('2022-06-16T13:15:07.160Z', 'Time')).to eq(Time.parse('2022-06-16T13:15:07.160Z')) + expect(api_client_default.convert_to_type('2022-06-16', 'Date')).to eq(Date.parse('2022-06-16')) + expect(api_client_default.convert_to_type({ id: 1 }, 'Object')).to eq({ id: 1 }) + expect(api_client_default.convert_to_type([[12, 34], [56]], 'Array>')).to eq([[12, 34], [56]]) + expect(api_client_default.convert_to_type({ "id": 'test' }, 'Hash')).to eq({ id: 'test' }) + expect(api_client_default.convert_to_type({ set_or_expired: true }, 'DeferredResult')).to be_instance_of(Bandwidth::DeferredResult) + end + end + + describe '#sanitize_filename' do + it 'sanitizes a filename by removing the path' do + expect(api_client_default.sanitize_filename('sun')).to eq('sun') + expect(api_client_default.sanitize_filename('sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('../sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('./sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('..\sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif') + expect(api_client_default.sanitize_filename('.\sun.gif')).to eq('sun.gif') + end + end + + describe '#build_request_url' do + it 'adds leading and trailing slashes to path' do + expect(api_client_default.build_request_url('test/path')).to eq('http://localhost/test/path') + end + end + + describe '#update_params_for_auth' do + it 'updates header and query params based on authentication settings' do + + end + end + + describe '#user_agent=' do + it 'sets user agent in HTTP header' do + api_client_default.user_agent = 'test-user-agent' + expect(api_client_default.default_headers['User-Agent']).to eq('test-user-agent') + end + end + + describe '#select_header_accept' do + it 'returns Accept header based on an array of accepts provided' do + expect(api_client_default.select_header_accept(nil)).to be_nil + expect(api_client_default.select_header_accept([])).to be_nil + + expect(api_client_default.select_header_accept(['application/json'])).to eq('application/json') + expect(api_client_default.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') + expect(api_client_default.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') + + expect(api_client_default.select_header_accept(['application/xml'])).to eq('application/xml') + expect(api_client_default.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml') + end + end + + describe '#select_header_content_type' do + it 'returns Content-Type header based on an array of content types provided' do + expect(api_client_default.select_header_content_type(nil)).to be_nil + expect(api_client_default.select_header_content_type([])).to be_nil + + expect(api_client_default.select_header_content_type(['application/json'])).to eq('application/json') + expect(api_client_default.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8') + expect(api_client_default.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON') + expect(api_client_default.select_header_content_type(['application/xml'])).to eq('application/xml') + expect(api_client_default.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain') + end + end + + describe '#object_to_http_body' do + it 'converts array to JSON string' do + model = [1, 2, 3] + expect(api_client_default.object_to_http_body(model)).to eq('[1,2,3]') + end + + it 'converts hash to JSON string' do + model = { id: 1 } + expect(api_client_default.object_to_http_body(model)).to eq('{"id":1}') + end + end + + describe '#object_to_hash' do + it 'returns object when object cannot be converted to hash' do + model = Object.new + model.instance_variable_set(:@id, 1) + expect(api_client_default.object_to_hash(model)).to be_instance_of(Object) + expect(api_client_default.object_to_hash(model).instance_variable_get('@id')).to eq(1) + end + + it 'returns hash when object can be converted to hash' do + model = Bandwidth::DeferredResult.new({ + set_or_expired: true + }) + expected = { setOrExpired: true } + expect(api_client_default.object_to_hash(model)).to eq(expected) + end + end + + describe '#build_collection_param' do + it 'builds parameter value according to the given collection format' do + param = ['aa', 'bb', 'cc'] + expect(api_client_default.build_collection_param(param, :csv)).to eq('aa,bb,cc') + expect(api_client_default.build_collection_param(param, :ssv)).to eq('aa bb cc') + expect(api_client_default.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") + expect(api_client_default.build_collection_param(param, :pipes)).to eq('aa|bb|cc') + expect(api_client_default.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) + expect { + api_client_default.build_collection_param(param, :INVALID) + }.to raise_error(RuntimeError, 'unknown collection format: :INVALID') + end + end +end diff --git a/spec/api_error_spec.rb b/spec/api_error_spec.rb new file mode 100644 index 00000000..934e5cfb --- /dev/null +++ b/spec/api_error_spec.rb @@ -0,0 +1,23 @@ +# Unit tests for Bandwidth::ApiError +describe Bandwidth::ApiError do + describe '#initialize' do + it 'initializes an instance of ApiError with message' do + api_error = Bandwidth::ApiError.new({ message: 'test' }) + expect(api_error.message).to eq('test') + end + end + + describe '#to_s' do + it 'returns message when to_s is called' do + api_error = Bandwidth::ApiError.new('test') + expect(api_error.to_s).to eq('test') + end + end + + describe '#message' do + it 'returns default error message when none supplied' do + api_error = Bandwidth::ApiError.new + expect(api_error.message).to eq('Error message: the server returns an error') + end + end +end diff --git a/spec/call_utils.rb b/spec/call_utils.rb new file mode 100644 index 00000000..d1ff4131 --- /dev/null +++ b/spec/call_utils.rb @@ -0,0 +1,74 @@ +# Helper functions for voice calls +# These are reused in multiple tests + +def setup_manteca(type) + manteca_body = { + os: OPERATING_SYSTEM, + language: RUBY_VERSION, + type: type + } + manteca_test_url = URI(MANTECA_BASE_URL + '/tests') + manteca_header = { 'Content-Type': 'application/json' } + + begin + test_id = Net::HTTP.post(manteca_test_url, manteca_body.to_json, manteca_header) + test_id.body.to_s + rescue => e + puts e.inspect + end +end + +def create_manteca_call(tag = 'ruby', answer_path = '/bxml/pause', calls_api) + manteca_call_body = Bandwidth::CreateCall.new( + application_id: MANTECA_APPLICATION_ID, + to: MANTECA_IDLE_NUMBER, + from: MANTECA_ACTIVE_NUMBER, + answer_url: MANTECA_BASE_URL + answer_path, + tag: tag + ) + + response = calls_api.create_call(BW_ACCOUNT_ID, manteca_call_body) + $active_calls.append(response.call_id) + response.call_id +end + +def get_manteca_test_status(test_id) + manteca_status_url = URI(MANTECA_BASE_URL + '/tests/' + test_id) + response = JSON.parse(Net::HTTP.get(manteca_status_url)) + response +end + +def cleanup_calls(calls, calls_api) + attempts = 0 + + while (calls.length > 0 && attempts < 10) + calls.delete_if { |call_id| call_ended(call_id, calls_api) } + sleep(SLEEP_TIME_S) + attempts += 1 + end + + if (calls.length > 0) + error_message = 'Failed to terminate all calls' + calls.to_s + raise StandardError.new error_message + end +end + +def call_ended(call_id, calls_api) + begin + response = calls_api.get_call_state(BW_ACCOUNT_ID, call_id) + rescue Bandwidth::ApiError + return false + end + + if !(response.state == 'disconnected') + begin + calls_api.update_call(BW_ACCOUNT_ID, call_id, $complete_call_body) + return true + rescue Bandwidth::ApiError + end + else + return true + end + + false +end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb new file mode 100644 index 00000000..dc65ef63 --- /dev/null +++ b/spec/configuration_spec.rb @@ -0,0 +1,190 @@ +require 'uri' + +# Unit tests for Bandwidth::Configuration +describe Bandwidth::Configuration do + let(:config) { Bandwidth::Configuration.new } + let(:faraday_connection) { Faraday::Connection.new } + let(:uri) { URI.parse(BASE_CALLBACK_URL + '/path') } + let(:token) { 'abcd1234' } + let(:server) { [ + { + url: 'https://voice.bandwidth.com/api/{enum_var}/{default_var}', + description: 'Production', + variables: { + enum_var: { + enum_values: ['v1', 'v2', 'v3'], + default_value: 'v2' + }, + default_var: { + default_value: 'default_value' + } + } + } + ] } + + describe '#configure' do + it 'configures a Configuration instance using a a block' do + config.configure do |c| + c.scheme = uri.scheme + c.host = uri.host + c.base_path = uri.path + end + expect(config.scheme).to eq(uri.scheme) + expect(config.host).to eq(uri.host) + expect(config.base_path).to eq(uri.path) + end + end + + describe 'custom attribute writers' do + it '#scheme=' do + config.scheme = 'scheme://' + expect(config.scheme).to eq('scheme') + end + + it '#host=' do + config.host = 'https://hostname' + expect(config.host).to eq('hostname') + end + + it '#base_path=' do + config.base_path = 'basepath' + expect(config.base_path).to eq('/basepath') + end + end + + describe '#base_url' do + it 'returns default value when invalid operation is passed' do + expect(config.base_url('invalid_operation')).to eq('http://localhost') + end + + it 'returns proper base URL when server index is set' do + operation, server = config.operation_server_settings.first + expect(config.base_url(operation)).to eq(server[0][:url]) + end + + it 'should have the default value' do + expect(config.base_url).to eq('http://localhost') + end + + it 'returns default value when invalid operation is passed' do + expect(config.base_url('invalid_operation')).to eq('http://localhost') + end + + it 'throws argument error when attempting to use a server index that is out of bounds' do + config.server_operation_index = { + :'MediaApi.upload_media' => 10 + } + expect { + config.base_url(:'MediaApi.upload_media') + }.to raise_error(ArgumentError, 'Invalid index 10 when selecting the server. Must not be nil and must be less than 1') + end + end + + describe '#api_key_with_prefix' do + it 'gets API key without prefix' do + config.api_key['Authorization'] = token + expect(config.api_key_with_prefix('Authorization')).to eq(token) + end + + it 'gets API key wit prefix' do + config.api_key_prefix['Authorization'] = 'Token' + config.api_key['Authorization'] = token + expect(config.api_key_with_prefix('Authorization')).to eq("Token #{token}") + end + end + + describe '#access_token_with_refresh' do + it 'gets the static access_token when no access_token_getter is defined' do + config.access_token = token + expect(config.access_token_with_refresh).to eq(token) + end + + it 'gets access_token using access_token_getter' do + config.access_token_getter = proc { token } + expect(config.access_token_with_refresh).to eq(token) + end + end + + describe '#basic_auth_token' do + it 'gets Basic Auth token string' do + config.username = 'username' + config.password = 'password' + expect(config.basic_auth_token).to eq('Basic dXNlcm5hbWU6cGFzc3dvcmQ=') + end + end + + describe '#auth_settings' do + it 'returns Auth Settings hash for api client' do + basic_auth = config.auth_settings['Basic'] + expect(basic_auth[:type]).to eq('basic') + expect(basic_auth[:in]).to eq('header') + expect(basic_auth[:key]).to eq('Authorization') + expect(basic_auth[:value]).to eq('Basic Og==') + end + end + + describe '#server_url' do + it 'returns URL with enum variable substitued' do + expect(config.server_url(0, { enum_var: 'v3' }, server)).to eq('https://voice.bandwidth.com/api/v3/default_value') + end + + it 'causes an ArgumentError by passing an invalid index' do + expect { + config.server_url(100) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid value to an enum variable' do + expect { + config.server_url(0, { enum_var: 'v4' }, server) + }.to raise_error(ArgumentError) + end + end + + describe 'configure faraday connection' do + it '#configure_faraday_connection #configure_connection' do + config.configure_faraday_connection do |c| + config.username = 'username' + end + config.configure_connection(faraday_connection) + expect(config.username).to eq('username') + end + end + + describe '#set_faraday_middleware' do + it '#use' do + config.use(Faraday::Request::UrlEncoded) + expect(config.instance_variable_get('@middlewares')[:use]).to eq([[Faraday::Request::UrlEncoded, [], nil]]) + end + + it '#request' do + config.request(:retry, max: 3, methods: [:get, :post], retry_statuses: [503]) + expect(config.instance_variable_get('@middlewares')[:request]).to eq([[:retry, [{ :max => 3, :methods => [:get, :post], :retry_statuses => [503] }], nil]]) + end + + it '#response' do + config.response(:logger, nil, { bodies: true, log_level: :debug }) + expect(config.instance_variable_get('@middlewares')[:response]).to eq([[:logger, [nil, { :bodies => true, :log_level => :debug }], nil]]) + end + + it 'causes an ArgumentError by passing an invalid middleware operation' do + expect { + config.set_faraday_middleware(:invalid_operation, Faraday::Request::UrlEncoded) + }.to raise_error(ArgumentError) + end + end + + describe '#configure_middleware' do + it 'builds connection using supplied response middleware' do + config.response(:logger) + config.configure_middleware(faraday_connection) + expect(faraday_connection.builder.handlers).to include(Faraday::Response::Logger) + end + + it 'builds connection using deleted middleware' do + config.set_faraday_middleware(:delete, Faraday::Request::UrlEncoded) + config.configure_middleware(faraday_connection) + expect(faraday_connection.builder.handlers).to eq([]) + end + end +end diff --git a/spec/fixtures/ruby_cat.jpeg b/spec/fixtures/ruby_cat.jpeg new file mode 100644 index 00000000..d08a926e Binary files /dev/null and b/spec/fixtures/ruby_cat.jpeg differ diff --git a/spec/integration/calls_api_integration_spec.rb b/spec/integration/calls_api_integration_spec.rb new file mode 100644 index 00000000..0f584882 --- /dev/null +++ b/spec/integration/calls_api_integration_spec.rb @@ -0,0 +1,202 @@ +require_relative '../call_utils' + +# Integration Tests for Bandwidth::CallsApi +describe 'CallsApi Integration Tests' do + # call info + let(:display_name) { 'Ruby SDK' } + let(:answer_method) { Bandwidth::CallbackMethodEnum::POST } + let(:answer_url) { BASE_CALLBACK_URL + '/callbacks/answer' } + let(:answer_fallback_method) { Bandwidth::CallbackMethodEnum::POST } + let(:disconnect_method) { Bandwidth::CallbackMethodEnum::GET } + let(:disconnect_url) { BASE_CALLBACK_URL + '/callbacks/disconnect' } + let(:priority) { 5 } + let(:direction) { Bandwidth::CallDirectionEnum::OUTBOUND } + let(:call_timeout) { 30.0 } + let(:callback_timeout) { 15.0 } + + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + @calls_api_instance = Bandwidth::CallsApi.new + + # call id + $call_info_id = '' + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Create Call + describe 'create_call' do + it 'creates a call with amd' do + amd_config = Bandwidth::MachineDetectionConfiguration.new( + mode: 'async', + detection_timeout: 5.0, + silence_timeout: 5.0, + speech_threshold: 5.0, + speech_end_threshold: 5.0, + delay_result: true, + callback_url: BASE_CALLBACK_URL + '/machineDetection', + callback_method: Bandwidth::CallbackMethodEnum::POST + ) + + call_body = Bandwidth::CreateCall.new( + application_id: BW_VOICE_APPLICATION_ID, + to: USER_NUMBER, + from: BW_NUMBER, + display_name: display_name, + answer_url: answer_url, + answer_method: answer_method, + disconnect_url: disconnect_url, + disconnect_method: disconnect_method, + machine_detection: amd_config, + call_timeout: call_timeout, + callback_timeout: callback_timeout + ) + + data, status_code, headers = @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body) + + expect(status_code).to eq(201) + expect(data).to be_instance_of(Bandwidth::CreateCallResponse) + expect(data.call_id.length).to eq(47) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data.to).to eq(USER_NUMBER) + expect(data.from).to eq(BW_NUMBER) + expect(data.call_timeout).to eq(call_timeout) + expect(data.callback_timeout).to eq(callback_timeout) + expect(data.enqueued_time).to be_instance_of(Time) + expect(data.answer_method).to eq(answer_method) + expect(data.answer_fallback_method).to eq(answer_fallback_method) + expect(data.disconnect_method).to eq(disconnect_method) + expect(data.answer_url).to eq(answer_url) + expect(data.disconnect_url).to eq(disconnect_url) + + $call_info_id = data.call_id + $active_calls.append($call_info_id) + end + end + + # Get Call State Information + describe 'get_call_state' do + it 'gets the call state' do + begin + sleep(SLEEP_TIME_S) + data, status_code, headers = @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, $call_info_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::CallState) + expect(data.call_id).to eq($call_info_id) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.application_id).to eq(BW_VOICE_APPLICATION_ID) + expect(data.start_time).to be_instance_of(Time).or be_nil + expect(data.last_update).to be_instance_of(Time) + expect(data.state).to be_instance_of(String) + expect(data.direction).to eq(direction) + rescue Bandwidth::ApiError => e + if e.code != 404 + raise e + end + end + end + end + + # Update Call + describe 'update_call' do + it 'creates and updates a call' do + update_call_body = Bandwidth::UpdateCall.new( + state: Bandwidth::CallStateEnum::ACTIVE, + redirect_url: MANTECA_BASE_URL + '/bxml/pause' + ) + + update_call_id = create_manteca_call(@calls_api_instance) + sleep(SLEEP_TIME_S) + + update_data, update_status_code, update_headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, update_call_id, update_call_body) + expect(update_status_code).to eq(200) + sleep(SLEEP_TIME_S) + + complete_data, complete_status_code, complete_headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, update_call_id, $complete_call_body) + expect(complete_status_code).to eq(200) + end + end + + # Update Call BXML + describe 'update_call_bxml' do + it 'updates a call using bxml' do + update_call_id = create_manteca_call(@calls_api_instance) + sleep(SLEEP_TIME_S) + + update_bxml = 'This is a test bxml response' + update_data, update_status_code, update_headers = @calls_api_instance.update_call_bxml_with_http_info(BW_ACCOUNT_ID, update_call_id, update_bxml) + expect(update_status_code).to eq(204) + sleep(SLEEP_TIME_S) + + complete_data, complete_status_code, complete_headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, update_call_id, $complete_call_body) + expect(complete_status_code).to eq(200) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 400 error' do + call_body_bad = Bandwidth::CreateCall.new( + application_id: BW_VOICE_APPLICATION_ID, + to: '+1invalid', + from: BW_NUMBER, + answer_url: answer_url, + answer_method: answer_method, + disconnect_url: disconnect_url, + disconnect_method: disconnect_method + ) + + expect { + @calls_api_instance.create_call_with_http_info(BW_ACCOUNT_ID, call_body_bad) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(400) + } + end + + it 'causes a 404 error' do + expect { + @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, 'does-not-exist') + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(404) + } + end + + it 'causes a 401 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + expect { + @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, $call_info_id) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(401) + } + end + + it 'causes a 403 error' do + Bandwidth.configure do |config| + config.username = FORBIDDEN_USERNAME + config.password = FORBIDDEN_PASSWORD + end + + expect { + @calls_api_instance.get_call_state_with_http_info(BW_ACCOUNT_ID, $call_info_id) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(403) + } + end + end +end diff --git a/spec/integration/conferences_api_integration_spec.rb b/spec/integration/conferences_api_integration_spec.rb new file mode 100644 index 00000000..8db69f47 --- /dev/null +++ b/spec/integration/conferences_api_integration_spec.rb @@ -0,0 +1,169 @@ +require_relative '../call_utils' + +# Integration Tests for Bandwidth::ConferencesApi +describe 'ConferencesApi Integration Tests' do + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + config.return_binary_data = true + end + @conferences_api_instance = Bandwidth::ConferencesApi.new + @calls_api_instance = Bandwidth::CallsApi.new + + # conference info + $manteca_test_id = setup_manteca('conference') + $manteca_call_id = create_manteca_call($manteca_test_id, '/bxml/joinConferencePause', @calls_api_instance) + $conference_id = '' + $recording_id = '' + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Get Conferences + describe 'list_conferences' do + it 'list all conferences' do + conference_opts = { + name: $manteca_test_id + } + + sleep(SLEEP_TIME_S) + data, status_code, headers = @conferences_api_instance.list_conferences_with_http_info(BW_ACCOUNT_ID, conference_opts) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::Conference) + expect(data[0].id).to be_instance_of(String) + $conference_id = data[0].id + end + end + + # Get Conference Information + describe 'get_conference' do + it 'get a conference by id' do + data, status_code, headers = @conferences_api_instance.get_conference_with_http_info(BW_ACCOUNT_ID, $conference_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::Conference) + expect(data.id).to eq($conference_id) + expect(data.name).to eq($manteca_test_id) + expect(data.tag).to eq($manteca_test_id) + end + end + + # Get Conference Member + describe 'get_conference_member' do + it 'gets a conference member by call id' do + data, status_code, headers = @conferences_api_instance.get_conference_member_with_http_info(BW_ACCOUNT_ID, $conference_id, $manteca_call_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::ConferenceMember) + expect(data.conference_id).to eq($conference_id) + expect(data.call_id).to eq($manteca_call_id) + end + end + + # Update Conference Member + describe 'update_conference_member' do + it 'updates a conference member by call id' do + update_conference_member = Bandwidth::UpdateConferenceMember.new( + mute: false + ) + + data, status_code, headers = @conferences_api_instance.update_conference_member_with_http_info(BW_ACCOUNT_ID, $conference_id, $manteca_call_id, update_conference_member) + expect(status_code).to eq(204) + end + end + + # Update Conference + describe 'update_conference' do + it 'updates a conference' do + update_conference_body = Bandwidth::UpdateConference.new( + status: Bandwidth::ConferenceStateEnum::ACTIVE, + redirect_url: MANTECA_BASE_URL + '/bxml/pause', + redirect_method: Bandwidth::RedirectMethodEnum::POST, + username: 'username', + password: 'password', + redirect_fallback_url: MANTECA_BASE_URL + '/bxml/pause', + redirect_fallback_method: Bandwidth::RedirectMethodEnum::POST, + fallback_username: 'username', + fallback_password: 'password' + ) + + data, status_code, headers = @conferences_api_instance.update_conference_with_http_info(BW_ACCOUNT_ID, $conference_id, update_conference_body) + expect(status_code).to eq(204) + end + end + + # Update Conference BXML + describe 'update_conference_bxml' do + it 'updates a conference using bxml' do + update_bxml = 'This should be a conference recording.' + + data, status_code, headers = @conferences_api_instance.update_conference_bxml_with_http_info(BW_ACCOUNT_ID, $conference_id, update_bxml) + expect(status_code).to eq(204) + + retries = 0 + recording_complete = false + begin + while !recording_complete && retries < MAX_RETRIES + recording_complete = get_manteca_test_status($manteca_test_id)['callRecorded'] + retries += 1 + sleep(SLEEP_TIME_S) + end + rescue => e + puts e.inspect + end + + expect(recording_complete).to be true + end + end + + # Get Conference Recordings + describe 'list_conference_recordings' do + it 'lists recordings for a conference' do + data, status_code, headers = @conferences_api_instance.list_conference_recordings_with_http_info(BW_ACCOUNT_ID, $conference_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::ConferenceRecordingMetadata) + expect(data[0].conference_id).to eq($conference_id) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data[0].name).to eq($manteca_test_id) + expect(data[0].status).to eq('complete').or eq('partial') + expect(data[0].recording_id).to be_instance_of(String) + expect(data[0].file_format).to eq(Bandwidth::FileFormatEnum::WAV) + + $recording_id = data[0].recording_id + end + end + + # Get Conference Recording Information + describe 'get_conference_recording' do + it 'gets a conference recording by id' do + data, status_code, headers = @conferences_api_instance.get_conference_recording_with_http_info(BW_ACCOUNT_ID, $conference_id, $recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::ConferenceRecordingMetadata) + expect(data.conference_id).to eq($conference_id) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.name).to eq($manteca_test_id) + expect(data.status).to eq('complete').or eq('partial') + expect(data.recording_id).to be_instance_of(String) + expect(data.file_format).to eq(Bandwidth::FileFormatEnum::WAV) + end + end + + # Download Conference Recording + describe 'download_conference_recording test' do + it 'should work' do + data, status_code, headers = @conferences_api_instance.download_conference_recording_with_http_info(BW_ACCOUNT_ID, $conference_id, $recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(String) + end + end +end diff --git a/spec/integration/media_api_integration_spec.rb b/spec/integration/media_api_integration_spec.rb new file mode 100644 index 00000000..77b04642 --- /dev/null +++ b/spec/integration/media_api_integration_spec.rb @@ -0,0 +1,92 @@ +# Integration Tests for Bandwidth::MediaApi +describe 'MediaApi Integration Tests' do + # media info + let(:binary_media_data) { '123456' } + let(:media_file_data) { File.open('spec/fixtures/ruby_cat.jpeg').read } + let(:media_file_md5) { Digest::MD5.hexdigest(media_file_data) } + + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + config.return_binary_data = true + end + @api_instance_media = Bandwidth::MediaApi.new + + # media names + @binary_media_name = 'ruby_binary_media' + SecureRandom.uuid + @media_file_name = 'ruby_media_file' + SecureRandom.uuid + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Upload Media + describe 'upload_media' do + it 'uploads binary media' do + data, status_code, headers = @api_instance_media.upload_media_with_http_info(BW_ACCOUNT_ID, @binary_media_name, binary_media_data) + expect(status_code).to eq(204) + end + + it 'uploads media file' do + data, status_code, headers = @api_instance_media.upload_media_with_http_info(BW_ACCOUNT_ID, @media_file_name, media_file_data) + expect(status_code).to eq(204) + end + end + + # List Media + describe 'list_media' do + it 'lists media' do + data, status_code, headers = @api_instance_media.list_media_with_http_info(BW_ACCOUNT_ID) + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::Media) + expect(data[0].content).to be_instance_of(String) + expect(data[0].content_length).to be > 0 + end + end + + # Get Media + describe 'get_media' do + it 'gets uploaded binary media' do + data, status_code, headers = @api_instance_media.get_media_with_http_info(BW_ACCOUNT_ID, @binary_media_name) + expect(status_code).to eq(200) + expect(data).to eq(binary_media_data) + end + + it 'gets uploaded media file' do + data, status_code, headers = @api_instance_media.get_media_with_http_info(BW_ACCOUNT_ID, @media_file_name) + response_md5 = Digest::MD5.hexdigest(data) + + expect(status_code).to eq(200) + expect(response_md5).to eq(media_file_md5) + end + end + + # Delete Media + describe 'delete_media' do + it 'deletes the binary media' do + data, status_code, headers = @api_instance_media.delete_media_with_http_info(BW_ACCOUNT_ID, @binary_media_name) + expect(status_code).to eq(204) + end + + it 'deletes the media file' do + data, status_code, headers = @api_instance_media.delete_media_with_http_info(BW_ACCOUNT_ID, @media_file_name) + expect(status_code).to eq(204) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 404 error' do + expect { + @api_instance_media.get_media_with_http_info(BW_ACCOUNT_ID, 'does_not_exist') + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(404) + } + end + end +end diff --git a/spec/integration/messages_api_integration_spec.rb b/spec/integration/messages_api_integration_spec.rb new file mode 100644 index 00000000..e5ed4a95 --- /dev/null +++ b/spec/integration/messages_api_integration_spec.rb @@ -0,0 +1,138 @@ +# Integration Tests for Bandwidth::MessagesApi +describe 'MessagesApi Integration Tests' do + # message info + let(:mms_text) { 'ruby sdk test MMS' } + let(:sms_text) { 'ruby sdk test SMS' } + let(:mms_tag) { 'ruby sdk test MMS tag' } + let(:sms_tag) { 'ruby sdk test SMS tag' } + let(:media_url) { 'https://cdn2.thecatapi.com/images/MTY3ODIyMQ.jpg' } + let(:priority) { Bandwidth::PriorityEnum::HIGH } + let(:list_message_direction) { Bandwidth::ListMessageDirectionEnum::OUTBOUND } + + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + @messaging_api_instance = Bandwidth::MessagesApi.new() + + # expiration time + @expiration_time = (Time.now + 60).round.to_datetime.rfc3339 + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Create Message + describe 'create_message' do + it 'creates an mms message' do + message_request = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: [USER_NUMBER], + from: BW_NUMBER, + text: mms_text, + media: [media_url], + tag: mms_tag + ) + + data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request) + + expect(status_code).to eq(202) + expect(data).to be_instance_of(Bandwidth::Message) + expect(data.id.length).to eq(29) + expect(data.owner).to eq(BW_NUMBER) + expect(data.to).to eq([USER_NUMBER]) + expect(data.from).to eq(BW_NUMBER) + expect(data.text).to eq(mms_text) + expect(data.media).to eq([media_url]) + expect(data.tag).to eq(mms_tag) + end + + it 'creates an sms message' do + message_request = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: [USER_NUMBER], + from: BW_NUMBER, + text: sms_text, + tag: sms_tag, + priority: priority, + expiration: @expiration_time + ) + + data, status_code, headers = @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, message_request) + + expect(status_code).to eq(202) + expect(data).to be_instance_of(Bandwidth::Message) + expect(data.id.length).to eq(29) + expect(data.owner).to eq(BW_NUMBER) + expect(data.to).to eq([USER_NUMBER]) + expect(data.from).to eq(BW_NUMBER) + expect(data.text).to eq(sms_text) + expect(data.tag).to eq(sms_tag) + expect(data.priority).to eq(priority) + expect(data.expiration).to eq(Time.parse(@expiration_time)) + end + end + + # List Messages + describe 'list_messages' do + it 'lists messages' do + get_opts = { + source_tn: BW_NUMBER, + message_direction: list_message_direction + } + data, status_code, headers = @messaging_api_instance.list_messages_with_http_info(BW_ACCOUNT_ID, get_opts) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::MessagesList) + expect(data.messages).to be_instance_of(Array) + expect(data.messages[0]).to be_instance_of(Bandwidth::ListMessageItem) + expect(data.messages[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data.messages[0].message_direction).to eq(list_message_direction) + expect(data.messages[0].source_tn).to eq(BW_NUMBER) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 400 error' do + body = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: ['+1invalid'], + from: BW_NUMBER, + text: 'ruby sdk 400 test' + ) + + expect { + @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, body) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(400) + } + end + + it 'causes a 401 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + body = Bandwidth::MessageRequest.new( + application_id: BW_MESSAGING_APPLICATION_ID, + to: [USER_NUMBER], + from: BW_NUMBER, + text: 'ruby sdk 401 test' + ) + + expect { + @messaging_api_instance.create_message_with_http_info(BW_ACCOUNT_ID, body) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(401) + } + end + end + +end diff --git a/spec/integration/mfa_api_integration_spec.rb b/spec/integration/mfa_api_integration_spec.rb new file mode 100644 index 00000000..945c3c32 --- /dev/null +++ b/spec/integration/mfa_api_integration_spec.rb @@ -0,0 +1,117 @@ +# Integration Tests for Bandwidth::MFAApi +describe 'MFAApi Integration Tests' do + # mfa info + let(:message) { 'Your temporary {NAME} {SCOPE} code is: {CODE}' } + let(:digits) { 6 } + + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + @mfa_api_instance = Bandwidth::MFAApi.new + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Messaging Authentication Code + describe 'generate_messaging_code' do + it 'generates messaging mfa code' do + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + message: message, + digits: digits + ) + + data, status_code, headers = @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::MessagingCodeResponse) + expect(data.message_id.length).to eq(29) + end + end + + # Voice Authentication Code + describe 'generate_voice_code' do + it 'generates voice mfa code' do + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: BW_VOICE_APPLICATION_ID, + message: message, + digits: digits + ) + + data, status_code, headers = @mfa_api_instance.generate_voice_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::VoiceCodeResponse) + expect(data.call_id.length).to eq(47) + end + end + + # Verify Authentication Code + describe 'verify_code' do + it 'verifies mfa code' do + req_schema = Bandwidth::VerifyCodeRequest.new( + to: '+1000' + rand(1...10000000).to_s, + scope: '2FA', + expiration_time_in_minutes: 3, + code: '12345' + ) + + data, status_code, headers = @mfa_api_instance.verify_code_with_http_info(BW_ACCOUNT_ID, req_schema) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::VerifyCodeResponse) + expect(data.valid).to be false + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 400 error' do + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: 'not_an_application_id', + message: message, + digits: digits + ) + + expect { + @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(400) + } + end + + it 'causes a 403 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + req_schema = Bandwidth::CodeRequest.new( + to: USER_NUMBER, + from: BW_NUMBER, + application_id: BW_MESSAGING_APPLICATION_ID, + message: message, + digits: digits + ) + + expect { + @mfa_api_instance.generate_messaging_code_with_http_info(BW_ACCOUNT_ID, req_schema) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(403) + } + end + end +end diff --git a/spec/integration/phone_number_lookup_api_integration_spec.rb b/spec/integration/phone_number_lookup_api_integration_spec.rb new file mode 100644 index 00000000..e19279f7 --- /dev/null +++ b/spec/integration/phone_number_lookup_api_integration_spec.rb @@ -0,0 +1,96 @@ +# Integration Tests for Bandwidth::PhoneNumberLookupApi +describe 'PhoneNumberLookupApi Integration Tests' do + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + @api_instance_tnlookup = Bandwidth::PhoneNumberLookupApi.new + + # lookup info + $lookup_request_id = '' + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Create Lookup + describe 'create_lookup' do + it 'creates a tn lookup request' do + tn_body = Bandwidth::LookupRequest.new( + tns: [BW_NUMBER] + ) + data, status_code, headers = @api_instance_tnlookup.create_lookup_with_http_info(BW_ACCOUNT_ID, tn_body) + + expect(status_code).to eq(202) + expect(data).to be_instance_of(Bandwidth::CreateLookupResponse) + expect(data.request_id.length).to eq(36) + expect(data.status).to be_instance_of(String) + + $lookup_request_id = data.request_id + sleep(1) + end + end + + # Get Lookup Status + describe 'get_lookup_status' do + it 'gets lookup status' do + data, status_code, headers = @api_instance_tnlookup.get_lookup_status_with_http_info(BW_ACCOUNT_ID, $lookup_request_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::LookupStatus) + expect(data.request_id).to eq($lookup_request_id) + expect(data.status).to be_instance_of(String) + expect(data.result).to be_instance_of(Array) + expect(data.result[0].response_code).to be_instance_of(Integer) + expect(data.result[0].e_164_format).to eq(BW_NUMBER) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 400 error' do + tn_body_bad = Bandwidth::LookupRequest.new( + tns: ['+1invalid'] + ) + + expect { + @api_instance_tnlookup.create_lookup_with_http_info(BW_ACCOUNT_ID, tn_body_bad) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(400) + } + end + + it 'causes a 404 error' do + req_id_dne = '12345678-abcd-cdef-9876-12345678abcd' + + expect { + @api_instance_tnlookup.get_lookup_status_with_http_info(BW_ACCOUNT_ID, req_id_dne) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(404) + } + end + + it 'causes a 401 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + tn_body = Bandwidth::LookupRequest.new( + tns: [BW_NUMBER] + ) + + expect { + @api_instance_tnlookup.create_lookup_with_http_info(BW_ACCOUNT_ID, tn_body) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(401) + } + end + end +end diff --git a/spec/integration/recordings_api_integration_spec.rb b/spec/integration/recordings_api_integration_spec.rb new file mode 100644 index 00000000..d4d85419 --- /dev/null +++ b/spec/integration/recordings_api_integration_spec.rb @@ -0,0 +1,226 @@ +require_relative '../call_utils' + +# Integration Tests for Bandwidth::RecordingsApi +describe 'RecordingsApi Integration Tests' do + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + config.return_binary_data = true + end + @recordings_api_instance = Bandwidth::RecordingsApi.new + @calls_api_instance = Bandwidth::CallsApi.new + + # recording info + $manteca_test_id = setup_manteca('CALL') + $manteca_call_id = create_manteca_call($manteca_test_id, '/bxml/startLongRecording', @calls_api_instance) + $recording_id = '' + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Update Recording + describe 'update_call_recording_state' do + it 'updates and ends the manteca call recording' do + pause_recording = Bandwidth::UpdateCallRecording.new( + state: Bandwidth::RecordingStateEnum::PAUSED + ) + + start_recording = Bandwidth::UpdateCallRecording.new( + state: Bandwidth::RecordingStateEnum::RECORDING + ) + + sleep(SLEEP_TIME_S * 2) + pause_data, pause_status_code, pause_headers = @recordings_api_instance.update_call_recording_state_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, pause_recording) + expect(pause_status_code).to eq(200) + + sleep(SLEEP_TIME_S) + record_data, record_status_code, record_headers = @recordings_api_instance.update_call_recording_state_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, start_recording) + expect(record_status_code).to eq(200) + + complete_data, complete_status_code, complete_headers = @calls_api_instance.update_call_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $complete_call_body) + expect(complete_status_code).to eq(200) + + retries = 0 + recording_complete = false + begin + while !recording_complete && retries < MAX_RETRIES + recording_complete = get_manteca_test_status($manteca_test_id)['callRecorded'] + retries += 1 + sleep(SLEEP_TIME_S) + end + rescue => e + puts e.inspect + end + + expect(recording_complete).to be true + end + end + + # Get Call Recordings + describe 'list_account_call_recordings' do + it 'lists account call recordings' do + data, status_code, headers = @recordings_api_instance.list_account_call_recordings_with_http_info(BW_ACCOUNT_ID) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata) + expect(data[0].application_id).to be_instance_of(String) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + end + end + + # List Call Recordings + describe 'list_call_recordings' do + it 'lists all recordings for a single call' do + data, status_code, headers = @recordings_api_instance.list_call_recordings_with_http_info(BW_ACCOUNT_ID, $manteca_call_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Array) + expect(data[0]).to be_instance_of(Bandwidth::CallRecordingMetadata) + expect(data[0].application_id).to eq(MANTECA_APPLICATION_ID) + expect(data[0].account_id).to eq(BW_ACCOUNT_ID) + expect(data[0].call_id).to eq($manteca_call_id) + expect(data[0].recording_id).to be_instance_of(String) + expect(data[0].status).to eq('complete').or eq('partial') + + $recording_id = data[0].recording_id + end + end + + # Get Call Recording + describe 'get_call_recording' do + it 'gets a call recording by id' do + data, status_code, headers = @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::CallRecordingMetadata) + expect(data.application_id).to eq(MANTECA_APPLICATION_ID) + expect(data.account_id).to eq(BW_ACCOUNT_ID) + expect(data.call_id).to eq($manteca_call_id) + expect(data.status).to eq('complete').or eq('partial') + expect(data.recording_id).to eq($recording_id) + end + end + + # Download Recording + describe 'download_call_recording' do + it 'downloads a call recording by id' do + data, status_code, headers = @recordings_api_instance.download_call_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(String) + end + end + + # Create Transcription Request + describe 'transcribe_call_recording' do + it 'creates a transcription request' do + transcribe_recording = Bandwidth::TranscribeRecording.new( + callback_url: MANTECA_BASE_URL + '/transcriptions', + tag: $manteca_test_id + ) + + data, status_code, headers = @recordings_api_instance.transcribe_call_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id, transcribe_recording) + expect(status_code).to eq(204) + + retries = 0 + transcription_complete = false + sleep(SLEEP_TIME_S * 10) + begin + while !transcription_complete && retries < MAX_RETRIES + transcription_complete = get_manteca_test_status($manteca_test_id)['callTranscribed'] + retries += 1 + sleep(SLEEP_TIME_S) + end + rescue => e + puts e.inspect + end + + expect(transcription_complete).to be true + end + end + + # Get Transcription + describe 'get_call_transcription' do + it 'gets the completed call recording transcription' do + data, status_code, headers = @recordings_api_instance.get_call_transcription_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::TranscriptionList) + expect(data.transcripts).to be_instance_of(Array) + expect(data.transcripts[0]).to be_instance_of(Bandwidth::Transcription) + expect(data.transcripts[0].text).to be_instance_of(String) + expect(data.transcripts[0].confidence).to be_instance_of(Float) + end + end + + # Delete Transcription + describe 'delete_call_transcription' do + it 'deletes the completed call recording transcription' do + data, status_code, headers = @recordings_api_instance.delete_call_transcription_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + expect(status_code).to eq(204) + end + end + + # Delete Recording Media + describe 'delete_recording_media' do + it 'deletes the completed call recording media' do + data, status_code, headers = @recordings_api_instance.delete_recording_media_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + expect(status_code).to eq(204) + end + end + + # Delete Recording + describe 'delete_recording' do + it 'deletes the completed call recording data' do + data, status_code, headers = @recordings_api_instance.delete_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + expect(status_code).to eq(204) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 404 error' do + dne_id = 'does-not-exist' + + expect { + @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, dne_id, dne_id) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(404) + } + end + + it 'causes a 401 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + expect { + @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(401) + } + end + + it 'causes a 403 error' do + Bandwidth.configure do |config| + config.username = FORBIDDEN_USERNAME + config.password = FORBIDDEN_PASSWORD + end + + expect { + @recordings_api_instance.get_call_recording_with_http_info(BW_ACCOUNT_ID, $manteca_call_id, $recording_id) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(403) + } + end + end +end diff --git a/spec/integration/statistics_api_integration_spec.rb b/spec/integration/statistics_api_integration_spec.rb new file mode 100644 index 00000000..73f7382d --- /dev/null +++ b/spec/integration/statistics_api_integration_spec.rb @@ -0,0 +1,58 @@ +# Integration Tests for Bandwidth::StatisticsApi +describe 'StatisticsApi Integration Tests' do + before(:all) do + WebMock.allow_net_connect! + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + @statistics_api_instance = Bandwidth::StatisticsApi.new + end + + after(:all) do + WebMock.disable_net_connect! + end + + # Get Account Statistics + describe 'get_statistics' do + it 'gets account statistics' do + data, status_code, headers = @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID) + + expect(status_code).to eq(200) + expect(data).to be_instance_of(Bandwidth::AccountStatistics) + expect(data.current_call_queue_size).to be_instance_of(Integer) + expect(data.max_call_queue_size).to eq(7500) + end + end + + # HTTP 4XX Errors + describe 'http error' do + it 'causes a 401 error' do + Bandwidth.configure do |config| + config.username = UNAUTHORIZED_USERNAME + config.password = UNAUTHORIZED_PASSWORD + end + + expect { + @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(401) + } + end + + it 'causes a 403 error' do + Bandwidth.configure do |config| + config.username = FORBIDDEN_USERNAME + config.password = FORBIDDEN_PASSWORD + end + + expect { + @statistics_api_instance.get_statistics_with_http_info(BW_ACCOUNT_ID) + }.to raise_error { |e| + expect(e).to be_instance_of(Bandwidth::ApiError) + expect(e.code).to eq(403) + } + end + end +end diff --git a/spec/models/bxml/bxml_spec.rb b/spec/models/bxml/bxml_spec.rb new file mode 100644 index 00000000..b68ce1f0 --- /dev/null +++ b/spec/models/bxml/bxml_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::Bxml +describe 'Bandwidth::Bxml::Bxml' do + let(:instance) { Bandwidth::Bxml::Bxml.new } + + describe 'test an instance of Bxml' do + it 'validates instance of Bxml' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Bxml) + expect(instance).to be_a(Bandwidth::Bxml::Root) + end + + it 'test the to_bxml method of the Bxml instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/nestable_verb_spec.rb b/spec/models/bxml/nestable_verb_spec.rb new file mode 100644 index 00000000..62e368dc --- /dev/null +++ b/spec/models/bxml/nestable_verb_spec.rb @@ -0,0 +1,11 @@ +# Unit tests for Bandwidth::Bxml::NestableVerb +describe 'Bandwidth::Bxml::NestableVerb' do + let(:instance) { Bandwidth::Bxml::NestableVerb.new('Test') } + + describe 'test an instance of NestableVerb' do + it 'validates instance of NestableVerb' do + expect(instance).to be_a(Bandwidth::Bxml::NestableVerb) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + end +end diff --git a/spec/models/bxml/response_spec.rb b/spec/models/bxml/response_spec.rb new file mode 100644 index 00000000..21c7c8fc --- /dev/null +++ b/spec/models/bxml/response_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::Response +describe 'Bandwidth::Bxml::Response' do + let(:instance) { Bandwidth::Bxml::Response.new } + + describe 'test an instance of Response' do + it 'validates instance of Response' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Response) + expect(instance).to be_a(Bandwidth::Bxml::Root) + end + + it 'test the to_bxml method of the Response instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verb_spec.rb b/spec/models/bxml/verb_spec.rb new file mode 100644 index 00000000..bd55289d --- /dev/null +++ b/spec/models/bxml/verb_spec.rb @@ -0,0 +1,15 @@ +# Unit tests for Bandwidth::Bxml::Verb +describe 'Bandwidth::Bxml::Verb' do + let(:instance) { Bandwidth::Bxml::Verb.new('Test') } + + describe 'test an instance of Verb' do + it 'validates instance of Verb' do + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Verb instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/bridge_spec.rb b/spec/models/bxml/verbs/bridge_spec.rb new file mode 100644 index 00000000..89d30481 --- /dev/null +++ b/spec/models/bxml/verbs/bridge_spec.rb @@ -0,0 +1,58 @@ +# Unit tests for Bandwidth::Bxml::Bridge +describe 'Bandwidth::Bxml::Bridge' do + let(:initial_attributes) { + { + bridge_complete_url: 'https://initial.com', + bridge_complete_method: 'POST', + bridge_complete_fallback_url: 'https://initial.com', + bridge_complete_fallback_method: 'POST', + bridge_target_complete_url: 'https://initial.com', + bridge_target_complete_method: 'POST', + bridge_target_complete_fallback_url: 'https://initial.com', + bridge_target_complete_fallback_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + bridge_complete_url: 'https://new.com', + bridge_complete_method: 'GET', + bridge_complete_fallback_url: 'https://new.com', + bridge_complete_fallback_method: 'GET', + bridge_target_complete_url: 'https://new.com', + bridge_target_complete_method: 'GET', + bridge_target_complete_fallback_url: 'https://new.com', + bridge_target_complete_fallback_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag' + } + } + + let(:instance) { Bandwidth::Bxml::Bridge.new('c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d', initial_attributes) } + + describe 'test an instance of Bridge' do + it 'validates instance of Bridge' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Bridge) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Bridge instance' do + expected = "\nc-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Bridge instance' do + instance.set_attributes(new_attributes) + expected = "\nc-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/conference_spec.rb b/spec/models/bxml/verbs/conference_spec.rb new file mode 100644 index 00000000..82def922 --- /dev/null +++ b/spec/models/bxml/verbs/conference_spec.rb @@ -0,0 +1,58 @@ +# Unit tests for Bandwidth::Bxml::Conference +describe 'Bandwidth::Bxml::Conference' do + let(:initial_attributes) { + { + mute: true, + hold: true, + call_ids_to_coach: 'initial', + conference_event_url: 'https://initial.com', + conference_event_method: 'POST', + conference_event_fallback_url: 'https://initial.com', + conference_event_fallback_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag', + callback_timeout: 5.0 + } + } + + let(:new_attributes) { + { + mute: false, + hold: false, + call_ids_to_coach: 'new', + conference_event_url: 'https://new.com', + conference_event_method: 'GET', + conference_event_fallback_url: 'https://new.com', + conference_event_fallback_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag', + callback_timeout: 10.0 + } + } + + let(:instance) { Bandwidth::Bxml::Conference.new('conference_name', initial_attributes) } + + describe 'test an instance of Conference' do + it 'validates instance of Conference' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Conference) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Conference instance' do + expected = "\nconference_name\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Conference instance' do + instance.set_attributes(new_attributes) + expected = "\nconference_name\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/custom_param_spec.rb b/spec/models/bxml/verbs/custom_param_spec.rb new file mode 100644 index 00000000..4efc5e52 --- /dev/null +++ b/spec/models/bxml/verbs/custom_param_spec.rb @@ -0,0 +1,36 @@ +# Unit tests for Bandwidth::Bxml::CustomParam +describe 'Bandwidth::Bxml::CustomParam' do + let(:initial_attributes) { + { + name: 'initial_name', + value: 'initial_value' + } + } + + let(:new_attributes) { + { + name: 'new_name', + value: 'new_value' + } + } + + let(:instance) { Bandwidth::Bxml::CustomParam.new(initial_attributes) } + + describe 'test an instance of CustomParam' do + it 'validates instance of CustomParam' do + expect(instance).to be_instance_of(Bandwidth::Bxml::CustomParam) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the CustomParam instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the CustomParam instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/forward_spec.rb b/spec/models/bxml/verbs/forward_spec.rb new file mode 100644 index 00000000..099ecef6 --- /dev/null +++ b/spec/models/bxml/verbs/forward_spec.rb @@ -0,0 +1,44 @@ +# Unit tests for Bandwidth::Bxml::Forward +describe 'Bandwidth::Bxml::Forward' do + let(:initial_attributes) { + { + to: '+19195551234', + from: '+19195554321', + call_timeout: 5, + diversion_treatment: 'propogate', + diversion_reason: 'user-busy', + uui: '93d6f3c0be5845960b744fa28015d8ede84bd1a4;encoding=base64,asdf;encoding=jwt' + } + } + + let(:new_attributes) { + { + to: '+19195554321', + from: '+19195551234', + call_timeout: 10, + diversion_treatment: 'stack', + diversion_reason: 'no-answer', + uui: '4fa28015d8ede84bd1a493d6f3c0be5845960b74;encoding=base64,fdsa;encoding=jwt' + } + } + + let(:instance) { Bandwidth::Bxml::Forward.new(initial_attributes) } + + describe 'test an instance of Forward' do + it 'validates instance of Forward' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Forward) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Forward instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Forward instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/gather_spec.rb b/spec/models/bxml/verbs/gather_spec.rb new file mode 100644 index 00000000..9144ccbf --- /dev/null +++ b/spec/models/bxml/verbs/gather_spec.rb @@ -0,0 +1,86 @@ +# Unit tests for Bandwidth::Bxml::Gather +describe 'Bandwidth::Bxml::Gather' do + let(:initial_attributes) { + { + gather_url: 'https://initial.com', + gather_method: 'POST', + gather_fallback_url: 'https://initial.com', + gather_fallback_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag', + terminating_digits: '5', + max_digits: 5, + inter_digit_timeout: 5, + first_digit_timeout: 5, + repeat_count: 5 + } + } + + let(:new_attributes) { + { + gather_url: 'https://new.com', + gather_method: 'POST', + gather_fallback_url: 'https://new.com', + gather_fallback_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag', + terminating_digits: '10', + max_digits: 10, + inter_digit_timeout: 10, + first_digit_timeout: 10, + repeat_count: 10 + } + } + + let (:play_audio) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav') } + let (:speak_sentence) { Bandwidth::Bxml::SpeakSentence.new('Holaruby speak sentence SSML test') } + + let(:instance) { Bandwidth::Bxml::Gather.new([], initial_attributes) } + let(:instance_nested) { Bandwidth::Bxml::Gather.new([play_audio], initial_attributes) } + + describe 'test an instance of Gather' do + it 'validates instance of Gather' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Gather) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Gather instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Gather instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end + + describe 'test an instance of Gather with nested verbs' do + it 'validates instance of Gather' do + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Gather) + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the nested Gather instance' do + expected = "\n\n https://audio.url/audio1.wav\n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + + it 'tests the add_verb method of the nested Gather instance' do + expected_single = "\n\n https://audio.url/audio1.wav\n Holaruby speak sentence SSML test\n\n" + instance_nested.add_audio_verb(speak_sentence) + expect(instance_nested.to_bxml).to eq(expected_single) + + expected_multiple = "\n\n https://audio.url/audio1.wav\n Holaruby speak sentence SSML test\n Holaruby speak sentence SSML test\n https://audio.url/audio1.wav\n\n" + instance_nested.add_audio_verb([speak_sentence, play_audio]) + expect(instance_nested.to_bxml).to eq(expected_multiple) + end + end +end diff --git a/spec/models/bxml/verbs/hangup_spec.rb b/spec/models/bxml/verbs/hangup_spec.rb new file mode 100644 index 00000000..dd0be2ee --- /dev/null +++ b/spec/models/bxml/verbs/hangup_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::Hangup +describe 'Bandwidth::Bxml::Hangup' do + let(:instance) { Bandwidth::Bxml::Hangup.new } + + describe 'test an instance of Hangup' do + it 'validates instance of Hangup' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Hangup) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Hangup instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/pause_recording_spec.rb b/spec/models/bxml/verbs/pause_recording_spec.rb new file mode 100644 index 00000000..100e7732 --- /dev/null +++ b/spec/models/bxml/verbs/pause_recording_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::PauseRecording +describe 'Bandwidth::Bxml::PauseRecording' do + let(:instance) { Bandwidth::Bxml::PauseRecording.new } + + describe 'test an instance of PauseRecording' do + it 'validates instance of PauseRecording' do + expect(instance).to be_instance_of(Bandwidth::Bxml::PauseRecording) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the PauseRecording instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/pause_spec.rb b/spec/models/bxml/verbs/pause_spec.rb new file mode 100644 index 00000000..34782c80 --- /dev/null +++ b/spec/models/bxml/verbs/pause_spec.rb @@ -0,0 +1,34 @@ +# Unit tests for Bandwidth::Bxml::Pause +describe 'Bandwidth::Bxml::Pause' do + let(:initial_attributes) { + { + duration: 5 + } + } + + let(:new_attributes) { + { + duration: 10 + } + } + + let(:instance) { Bandwidth::Bxml::Pause.new(initial_attributes) } + + describe 'test an instance of Pause' do + it 'validates instance of Pause' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Pause) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Pause instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Pause instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/phone_number_spec.rb b/spec/models/bxml/verbs/phone_number_spec.rb new file mode 100644 index 00000000..14b709b8 --- /dev/null +++ b/spec/models/bxml/verbs/phone_number_spec.rb @@ -0,0 +1,54 @@ +# Unit tests for Bandwidth::Bxml::PhoneNumber +describe 'Bandwidth::Bxml::PhoneNumber' do + let(:initial_attributes) { + { + transfer_answer_url: 'https://initial.com', + transfer_answer_method: 'POST', + transfer_answer_fallback_url: 'https://initial.com', + transfer_answer_fallback_method: 'POST', + transfer_disconnect_url: 'https://initial.com', + transfer_disconnect_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + transfer_answer_url: 'https://new.com', + transfer_answer_method: 'GET', + transfer_answer_fallback_url: 'https://new.com', + transfer_answer_fallback_method: 'GET', + transfer_disconnect_url: 'https://new.com', + transfer_disconnect_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag' + } + } + + let(:instance) { Bandwidth::Bxml::PhoneNumber.new('+19195551234', initial_attributes) } + + describe 'test an instance of PhoneNumber' do + it 'validates instance of PhoneNumber' do + expect(instance).to be_instance_of(Bandwidth::Bxml::PhoneNumber) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the PhoneNumber instance' do + expected = "\n+19195551234\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the PhoneNumber instance' do + instance.set_attributes(new_attributes) + expected = "\n+19195551234\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/play_audio_spec.rb b/spec/models/bxml/verbs/play_audio_spec.rb new file mode 100644 index 00000000..a9858ebf --- /dev/null +++ b/spec/models/bxml/verbs/play_audio_spec.rb @@ -0,0 +1,36 @@ +# Unit tests for Bandwidth::Bxml::PlayAudio +describe 'Bandwidth::Bxml::PlayAudio' do + let(:initial_attributes) { + { + username: 'initial_username', + password: 'initial_password' + } + } + + let(:new_attributes) { + { + username: 'new_username', + password: 'new_password' + } + } + + let(:instance) { Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav', initial_attributes) } + + describe 'test an instance of PlayAudio' do + it 'validates instance of PlayAudio' do + expect(instance).to be_instance_of(Bandwidth::Bxml::PlayAudio) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the PlayAudio instance' do + expected = "\nhttps://audio.url/audio1.wav\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the PlayAudio instance' do + instance.set_attributes(new_attributes) + expected = "\nhttps://audio.url/audio1.wav\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/record_spec.rb b/spec/models/bxml/verbs/record_spec.rb new file mode 100644 index 00000000..d125b2ea --- /dev/null +++ b/spec/models/bxml/verbs/record_spec.rb @@ -0,0 +1,68 @@ +# Unit tests for Bandwidth::Bxml::Record +describe 'Bandwidth::Bxml::Record' do + let(:initial_attributes) { + { + record_complete_url: 'https://initial.com', + record_complete_method: 'POST', + record_complete_fallback_url: 'https://initial.com', + record_complete_fallback_method: 'POST', + recording_available_url: 'https://initial.com', + recording_available_method: 'POST', + transcribe: true, + transcription_available_url: 'https://initial.com', + transcription_available_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag', + terminating_digits: '5', + max_duration: 5, + silence_timeout: 5, + file_format: 'wav' + } + } + + let(:new_attributes) { + { + record_complete_url: 'https://new.com', + record_complete_method: 'GET', + record_complete_fallback_url: 'https://new.com', + record_complete_fallback_method: 'GET', + recording_available_url: 'https://new.com', + recording_available_method: 'GET', + transcribe: true, + transcription_available_url: 'https://new.com', + transcription_available_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag', + terminating_digits: '0', + max_duration: 10, + silence_timeout: 10, + file_format: 'mp3' + } + } + + let(:instance) { Bandwidth::Bxml::Record.new(initial_attributes) } + + describe 'test an instance of Record' do + it 'validates instance of Record' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Record) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Record instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Record instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/redirect_spec.rb b/spec/models/bxml/verbs/redirect_spec.rb new file mode 100644 index 00000000..b45c5b39 --- /dev/null +++ b/spec/models/bxml/verbs/redirect_spec.rb @@ -0,0 +1,50 @@ +# Unit tests for Bandwidth::Bxml::Redirect +describe 'Bandwidth::Bxml::Redirect' do + let(:initial_attributes) { + { + redirect_url: 'https://initial.com', + redirect_method: 'POST', + redirect_fallback_url: 'https://initial.com', + redirect_fallback_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + redirect_url: 'https://new.com', + redirect_method: 'GET', + redirect_fallback_url: 'https://new.com', + redirect_fallback_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag' + } + } + + let(:instance) { Bandwidth::Bxml::Redirect.new(initial_attributes) } + + describe 'test an instance of Redirect' do + it 'validates instance of Redirect' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Redirect) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Redirect instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Redirect instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/resume_recording_spec.rb b/spec/models/bxml/verbs/resume_recording_spec.rb new file mode 100644 index 00000000..d2bd46d4 --- /dev/null +++ b/spec/models/bxml/verbs/resume_recording_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::ResumeRecording +describe 'Bandwidth::Bxml::ResumeRecording' do + let(:instance) { Bandwidth::Bxml::ResumeRecording.new } + + describe 'test an instance of ResumeRecording' do + it 'validates instance of ResumeRecording' do + expect(instance).to be_instance_of(Bandwidth::Bxml::ResumeRecording) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the ResumeRecording instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/ring_spec.rb b/spec/models/bxml/verbs/ring_spec.rb new file mode 100644 index 00000000..14b5f01b --- /dev/null +++ b/spec/models/bxml/verbs/ring_spec.rb @@ -0,0 +1,36 @@ +# Unit tests for Bandwidth::Bxml::Ring +describe 'Bandwidth::Bxml::Ring' do + let(:initial_attributes) { + { + duration: 5.0, + answer_call: true + } + } + + let(:new_attributes) { + { + duration: 10.0, + answer_call: false + } + } + + let(:instance) { Bandwidth::Bxml::Ring.new(initial_attributes) } + + describe 'test an instance of Ring' do + it 'validates instance of Ring' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Ring) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Ring instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Ring instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/send_dtmf_spec.rb b/spec/models/bxml/verbs/send_dtmf_spec.rb new file mode 100644 index 00000000..e7fd5216 --- /dev/null +++ b/spec/models/bxml/verbs/send_dtmf_spec.rb @@ -0,0 +1,36 @@ +# Unit tests for Bandwidth::Bxml::SendDtmf +describe 'Bandwidth::Bxml::SendDtmf' do + let(:initial_attributes) { + { + tone_duration: 5, + tone_interval: 5 + } + } + + let(:new_attributes) { + { + tone_duration: 10, + tone_interval: 10 + } + } + + let(:instance) { Bandwidth::Bxml::SendDtmf.new('1234', initial_attributes) } + + describe 'test an instance of SendDtmf' do + it 'validates instance of SendDtmf' do + expect(instance).to be_instance_of(Bandwidth::Bxml::SendDtmf) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the SendDtmf instance' do + expected = "\n1234\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the SendDtmf instance' do + instance.set_attributes(new_attributes) + expected = "\n1234\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/sip_uri_spec.rb b/spec/models/bxml/verbs/sip_uri_spec.rb new file mode 100644 index 00000000..be78eaf2 --- /dev/null +++ b/spec/models/bxml/verbs/sip_uri_spec.rb @@ -0,0 +1,56 @@ +# Unit tests for Bandwidth::Bxml::SipUri +describe 'Bandwidth::Bxml::SipUri' do + let(:initial_attributes) { + { + uui: 'abc123', + transfer_answer_url: 'https://initial.com', + transfer_answer_method: 'POST', + transfer_answer_fallback_url: 'https://initial.com', + transfer_answer_fallback_method: 'POST', + transfer_disconnect_url: 'https://initial.com', + transfer_disconnect_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + uui: '123abc', + transfer_answer_url: 'https://new.com', + transfer_answer_method: 'GET', + transfer_answer_fallback_url: 'https://new.com', + transfer_answer_fallback_method: 'GET', + transfer_disconnect_url: 'https://new.com', + transfer_disconnect_method: 'GET', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag' + } + } + + let(:instance) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net', initial_attributes) } + + describe 'test an instance of SipUri' do + it 'validates instance of SipUri' do + expect(instance).to be_instance_of(Bandwidth::Bxml::SipUri) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the SipUri instance' do + expected = "\nsip:1-999-123-4567@voip-provider.example.net\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the SipUri instance' do + instance.set_attributes(new_attributes) + expected = "\nsip:1-999-123-4567@voip-provider.example.net\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/speak_sentence_spec.rb b/spec/models/bxml/verbs/speak_sentence_spec.rb new file mode 100644 index 00000000..e91ec3b8 --- /dev/null +++ b/spec/models/bxml/verbs/speak_sentence_spec.rb @@ -0,0 +1,38 @@ +# Unit tests for Bandwidth::Bxml::SpeakSentence +describe 'Bandwidth::Bxml::SpeakSentence' do + let(:initial_attributes) { + { + voice: 'julie', + gender: 'female', + locale: 'en_US' + } + } + + let(:new_attributes) { + { + voice: 'simon', + gender: 'male', + locale: 'en_UK' + } + } + + let(:instance) { Bandwidth::Bxml::SpeakSentence.new('Holaruby speak sentence SSML test', initial_attributes) } + + describe 'test an instance of SpeakSentence' do + it 'validates instance of SpeakSentence' do + expect(instance).to be_instance_of(Bandwidth::Bxml::SpeakSentence) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the SpeakSentence instance' do + expected = "\nHolaruby speak sentence SSML test\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the SpeakSentence instance' do + instance.set_attributes(new_attributes) + expected = "\nHolaruby speak sentence SSML test\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/start_gather_spec.rb b/spec/models/bxml/verbs/start_gather_spec.rb new file mode 100644 index 00000000..007f61f3 --- /dev/null +++ b/spec/models/bxml/verbs/start_gather_spec.rb @@ -0,0 +1,42 @@ +# Unit tests for Bandwidth::Bxml::StartGather +describe 'Bandwidth::Bxml::StartGather' do + let(:initial_attributes) { + { + dtmf_url: 'https://initial.com', + dtmf_method: 'POST', + username: 'initial_username', + password: 'initial_password', + tag: 'initial_tag' + } + } + + let(:new_attributes) { + { + dtmf_url: 'https://new.com', + dtmf_method: 'GET', + username: 'new_username', + password: 'new_password', + tag: 'new_tag' + } + } + + let(:instance) { Bandwidth::Bxml::StartGather.new(initial_attributes) } + + describe 'test an instance of StartGather' do + it 'validates instance of StartGather' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StartGather) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StartGather instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StartGather instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/start_recording_spec.rb b/spec/models/bxml/verbs/start_recording_spec.rb new file mode 100644 index 00000000..d3bb5131 --- /dev/null +++ b/spec/models/bxml/verbs/start_recording_spec.rb @@ -0,0 +1,52 @@ +# Unit tests for Bandwidth::Bxml::StartRecording +describe 'Bandwidth::Bxml::StartRecording' do + let(:initial_attributes) { + { + recording_available_url: 'https://initial.com', + recording_available_method: 'POST', + transcribe: true, + transcription_available_url: 'https://initial.com', + transcription_available_method: 'POST', + username: 'initial_username', + password: 'initial_password', + tag: 'initial_tag', + file_format: 'wav', + multi_channel: true + } + } + + let(:new_attributes) { + { + recording_available_url: 'https://new.com', + recording_available_method: 'GET', + transcribe: false, + transcription_available_url: 'https://new.com', + transcription_available_method: 'GET', + username: 'new_username', + password: 'new_password', + tag: 'new_tag', + file_format: 'mp3', + multi_channel: false + } + } + + let(:instance) { Bandwidth::Bxml::StartRecording.new(initial_attributes) } + + describe 'test an instance of StartRecording' do + it 'validates instance of StartRecording' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StartRecording) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StartRecording instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StartRecording instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/start_stream_spec.rb b/spec/models/bxml/verbs/start_stream_spec.rb new file mode 100644 index 00000000..3f645da1 --- /dev/null +++ b/spec/models/bxml/verbs/start_stream_spec.rb @@ -0,0 +1,72 @@ +# Unit tests for Bandwidth::Bxml::StartStream +describe 'Bandwidth::Bxml::StartStream' do + let(:initial_attributes) { + { + name: 'initial_name', + tracks: 'inbound', + destination: 'https://initial.com', + stream_event_url: 'https://initial.com', + stream_event_method: 'POST', + username: 'initial_username', + password: 'initial_password' + } + } + + let(:new_attributes) { + { + name: 'new_name', + tracks: 'outbound', + destination: 'https://new.com', + stream_event_url: 'https://new.com', + stream_event_method: 'GET', + username: 'new_username', + password: 'new_password' + } + } + + let (:stream_param_1) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_1', value: 'stream_param_value_1' }) } + let (:stream_param_2) { Bandwidth::Bxml::StreamParam.new({ name: 'stream_param_name_2', value: 'stream_param_value_2' }) } + + let(:instance) { Bandwidth::Bxml::StartStream.new([], initial_attributes) } + let(:instance_nested) { Bandwidth::Bxml::StartStream.new([stream_param_1], initial_attributes) } + + describe 'test an instance of StartStream' do + it 'validates instance of StartStream' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StartStream) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StartStream instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StartStream instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end + + describe 'test an instance of StartStream with nested verbs' do + it 'validates instance of StartStream' do + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartStream) + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the nested StartStream instance' do + expected = "\n\n \n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + + it 'tests the add_stream_param method of the nested StartStream instance' do + expected_single = "\n\n \n \n\n" + instance_nested.add_stream_param(stream_param_2) + expect(instance_nested.to_bxml).to eq(expected_single) + + expected_multiple = "\n\n \n \n \n \n\n" + instance_nested.add_stream_param([stream_param_2, stream_param_2]) + expect(instance_nested.to_bxml).to eq(expected_multiple) + end + end +end diff --git a/spec/models/bxml/verbs/start_transcription_spec.rb b/spec/models/bxml/verbs/start_transcription_spec.rb new file mode 100644 index 00000000..56dcc0a0 --- /dev/null +++ b/spec/models/bxml/verbs/start_transcription_spec.rb @@ -0,0 +1,74 @@ +# Unit tests for Bandwidth::Bxml::StartTranscription +describe 'Bandwidth::Bxml::StartTranscription' do + let(:initial_attributes) { + { + name: 'initial_name', + tracks: 'inbound', + transcription_event_url: 'https://initial.com', + transcription_event_method: 'POST', + username: 'initial_username', + password: 'initial_password', + destination: 'https://initial.com', + stabilized: true + } + } + + let(:new_attributes) { + { + name: 'new_name', + tracks: 'outbound', + transcription_event_url: 'https://new.com', + transcription_event_method: 'GET', + username: 'new_username', + password: 'new_password', + destination: 'https://new.com', + stabilized: false + } + } + + let (:custom_param_1) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_1', value: 'custom_param_value_1' }) } + let (:custom_param_2) { Bandwidth::Bxml::CustomParam.new({ name: 'custom_param_name_2', value: 'custom_param_value_2' }) } + + let(:instance) { Bandwidth::Bxml::StartTranscription.new([], initial_attributes) } + let(:instance_nested) { Bandwidth::Bxml::StartTranscription.new([custom_param_1], initial_attributes) } + + describe 'test an instance of StartTranscription' do + it 'validates instance of StartTranscription' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StartTranscription) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StartTranscription instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StartTranscription instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end + + describe 'test an instance of StartTranscription with nested verbs' do + it 'validates instance of StartTranscription' do + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::StartTranscription) + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the nested StartTranscription instance' do + expected = "\n\n \n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + + it 'tests the add_custom_param method of the nested StartTranscription instance' do + expected_single = "\n\n \n \n\n" + instance_nested.add_custom_param(custom_param_2) + expect(instance_nested.to_bxml).to eq(expected_single) + + expected_multiple = "\n\n \n \n \n \n\n" + instance_nested.add_custom_param([custom_param_2, custom_param_2]) + expect(instance_nested.to_bxml).to eq(expected_multiple) + end + end +end diff --git a/spec/models/bxml/verbs/stop_gather_spec.rb b/spec/models/bxml/verbs/stop_gather_spec.rb new file mode 100644 index 00000000..db03d06d --- /dev/null +++ b/spec/models/bxml/verbs/stop_gather_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::StopGather +describe 'Bandwidth::Bxml::StopGather' do + let(:instance) { Bandwidth::Bxml::StopGather.new } + + describe 'test an instance of StopGather' do + it 'validates instance of StopGather' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StopGather) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StopGather instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/stop_recording_spec.rb b/spec/models/bxml/verbs/stop_recording_spec.rb new file mode 100644 index 00000000..a381d083 --- /dev/null +++ b/spec/models/bxml/verbs/stop_recording_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::StopRecording +describe 'Bandwidth::Bxml::StopRecording' do + let(:instance) { Bandwidth::Bxml::StopRecording.new } + + describe 'test an instance of StopRecording' do + it 'validates instance of StopRecording' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StopRecording) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StopRecording instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/stop_stream_spec.rb b/spec/models/bxml/verbs/stop_stream_spec.rb new file mode 100644 index 00000000..9d5f9a7c --- /dev/null +++ b/spec/models/bxml/verbs/stop_stream_spec.rb @@ -0,0 +1,34 @@ +# Unit tests for Bandwidth::Bxml::StopStream +describe 'Bandwidth::Bxml::StopStream' do + let(:initial_attributes) { + { + name: 'initial_name' + } + } + + let(:new_attributes) { + { + name: 'new_name' + } + } + + let(:instance) { Bandwidth::Bxml::StopStream.new(initial_attributes) } + + describe 'test an instance of StopStream' do + it 'validates instance of StopStream' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StopStream) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StopStream instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StopStream instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/stop_transcription_spec.rb b/spec/models/bxml/verbs/stop_transcription_spec.rb new file mode 100644 index 00000000..d3a11b67 --- /dev/null +++ b/spec/models/bxml/verbs/stop_transcription_spec.rb @@ -0,0 +1,34 @@ +# Unit tests for Bandwidth::Bxml::StopTranscription +describe 'Bandwidth::Bxml::StopTranscription' do + let(:initial_attributes) { + { + name: 'initial_name' + } + } + + let(:new_attributes) { + { + name: 'new_name' + } + } + + let(:instance) { Bandwidth::Bxml::StopTranscription.new(initial_attributes) } + + describe 'test an instance of StopTranscription' do + it 'validates instance of StopTranscription' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StopTranscription) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StopTranscription instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StopTranscription instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/stream_param_spec.rb b/spec/models/bxml/verbs/stream_param_spec.rb new file mode 100644 index 00000000..cdc804d6 --- /dev/null +++ b/spec/models/bxml/verbs/stream_param_spec.rb @@ -0,0 +1,36 @@ +# Unit tests for Bandwidth::Bxml::StreamParam +describe 'Bandwidth::Bxml::StreamParam' do + let(:initial_attributes) { + { + name: 'initial_name', + value: 'initial_value' + } + } + + let(:new_attributes) { + { + name: 'new_name', + value: 'new_value' + } + } + + let(:instance) { Bandwidth::Bxml::StreamParam.new(initial_attributes) } + + describe 'test an instance of StreamParam' do + it 'validates instance of StreamParam' do + expect(instance).to be_instance_of(Bandwidth::Bxml::StreamParam) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the StreamParam instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the StreamParam instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/tag_spec.rb b/spec/models/bxml/verbs/tag_spec.rb new file mode 100644 index 00000000..4c53b945 --- /dev/null +++ b/spec/models/bxml/verbs/tag_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::Bxml::Tag +describe 'Bandwidth::Bxml::Tag' do + let(:instance) { Bandwidth::Bxml::Tag.new('test_tag') } + + describe 'test an instance of Tag' do + it 'validates instance of Tag' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Tag) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Tag instance' do + expected = "\ntest_tag\n" + expect(instance.to_bxml).to eq(expected) + end + end +end diff --git a/spec/models/bxml/verbs/transfer_spec.rb b/spec/models/bxml/verbs/transfer_spec.rb new file mode 100644 index 00000000..5d48279c --- /dev/null +++ b/spec/models/bxml/verbs/transfer_spec.rb @@ -0,0 +1,84 @@ +# Unit tests for Bandwidth::Bxml::Transfer +describe 'Bandwidth::Bxml::Transfer' do + let(:initial_attributes) { + { + transfer_caller_id: '+19195551234', + call_timeout: 5, + transfer_complete_url: 'https://initial.com', + transfer_complete_method: 'POST', + transfer_complete_fallback_url: 'https://initial.com', + transfer_complete_fallback_method: 'POST', + username: 'initial_username', + password: 'initial_password', + fallback_username: 'initial_fallback_username', + fallback_password: 'initial_fallback_password', + tag: 'initial_tag', + diversion_treatment: 'propogate', + diversion_reason: 'user-busy' + } + } + + let(:new_attributes) { + { + transfer_caller_id: '+19195554321', + call_timeout: 10, + transfer_complete_url: 'https://new.com', + transfer_complete_method: 'POST', + transfer_complete_fallback_url: 'https://new.com', + transfer_complete_fallback_method: 'POST', + username: 'new_username', + password: 'new_password', + fallback_username: 'new_fallback_username', + fallback_password: 'new_fallback_password', + tag: 'new_tag', + diversion_treatment: 'stack', + diversion_reason: 'no-answer' + } + } + + let(:phone_number) { Bandwidth::Bxml::PhoneNumber.new('+19195551234') } + let(:sip_uri) { Bandwidth::Bxml::SipUri.new('sip:1-999-123-4567@voip-provider.example.net') } + + let(:instance) { Bandwidth::Bxml::Transfer.new([], initial_attributes) } + let(:instance_nested) { Bandwidth::Bxml::Transfer.new([phone_number], initial_attributes) } + + describe 'test an instance of Transfer' do + it 'validates instance of Transfer' do + expect(instance).to be_instance_of(Bandwidth::Bxml::Transfer) + expect(instance).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the Transfer instance' do + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + + it 'tests the set_attributes method of the Transfer instance' do + instance.set_attributes(new_attributes) + expected = "\n\n" + expect(instance.to_bxml).to eq(expected) + end + end + + describe 'test an instance of Transfer with nested verbs' do + it 'validates instance of Transfer' do + expect(instance_nested).to be_instance_of(Bandwidth::Bxml::Transfer) + expect(instance_nested).to be_a(Bandwidth::Bxml::Verb) + end + + it 'tests the to_bxml method of the nested Transfer instance' do + expected = "\n\n +19195551234\n\n" + expect(instance_nested.to_bxml).to eq(expected) + end + + it 'tests the add_verb method of the nested Transfer instance' do + expected_single = "\n\n +19195551234\n sip:1-999-123-4567@voip-provider.example.net\n\n" + instance_nested.add_transfer_recipient(sip_uri) + expect(instance_nested.to_bxml).to eq(expected_single) + + expected_multiple = "\n\n +19195551234\n sip:1-999-123-4567@voip-provider.example.net\n sip:1-999-123-4567@voip-provider.example.net\n +19195551234\n\n" + instance_nested.add_transfer_recipient([sip_uri, phone_number]) + expect(instance_nested.to_bxml).to eq(expected_multiple) + end + end +end diff --git a/spec/models/call_state_enum_spec.rb b/spec/models/call_state_enum_spec.rb new file mode 100644 index 00000000..4dad702d --- /dev/null +++ b/spec/models/call_state_enum_spec.rb @@ -0,0 +1,16 @@ +# Unit tests for Bandwidth::CallStateEnum +describe Bandwidth::CallStateEnum do + let(:instance) { Bandwidth::CallStateEnum.new } + + describe 'test an instance of CallStateEnum' do + it 'creates an instance of CallStateEnum' do + expect(instance).to be_instance_of(Bandwidth::CallStateEnum) + end + + it 'raises an error for an invalid enum value' do + expect { + Bandwidth::CallStateEnum.build_from_hash('invalid') + }.to raise_error(RuntimeError) + end + end +end diff --git a/spec/models/call_state_spec.rb b/spec/models/call_state_spec.rb new file mode 100644 index 00000000..41b549aa --- /dev/null +++ b/spec/models/call_state_spec.rb @@ -0,0 +1,168 @@ +# Unit tests for Bandwidth::CallState +describe Bandwidth::CallState do + let(:call_state_default) { Bandwidth::CallState.new } + let(:call_state_values) { Bandwidth::CallState.new({ + application_id: '04e88489-df02-4e34-a0ee-27a91849555f', + account_id: '9900000', + call_id: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + parent_call_id: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + to: '+19195551234', + from: '+19195554321', + direction: 'inbound', + state: 'disconnected', + stir_shaken: { + 'verstat': 'TN-Verification-Passed', + 'attestationIndicator': 'A', + 'originatingId': 'abc123' + }, + identity: 'eyJhbGciOiJFUzI1NiI', + enqueued_time: '2022-06-16T13:15:07.160Z', + start_time: '2022-06-16T13:15:07.160Z', + answer_time: '2022-06-16T13:15:18.126Z', + end_time: '2022-06-16T13:15:18.314Z', + disconnect_cause: 'hangup', + error_message: nil, + error_id: nil, + last_update: '2022-06-16T13:15:18.314Z' + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::CallState.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::CallState.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::CallState.acceptable_attributes).to eq(Bandwidth::CallState.attribute_map.values) + end + end + + describe 'EnumAttributeValidator' do + it 'validates string enum' do + validator = Bandwidth::CallState::EnumAttributeValidator.new(String, ['valid']) + expect(validator.valid?('valid')).to be true + expect(validator.valid?('invalid')).to be false + end + + it 'validates integer enum' do + validator = Bandwidth::CallState::EnumAttributeValidator.new(Integer, [1]) + expect(validator.valid?(1)).to be true + expect(validator.valid?('invalid')).to be false + end + + it 'validates float enum' do + validator = Bandwidth::CallState::EnumAttributeValidator.new(Float, [1.0]) + expect(validator.valid?(1.0)).to be true + expect(validator.valid?('invalid')).to be false + end + end + + describe '#build_from_hash' do + it 'validates instance of CallState created by the build_from_hash method' do + call_state_from_hash = Bandwidth::CallState.build_from_hash({ + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + accountId: '9900000', + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + to: '+19195551234', + from: '+19195554321', + direction: 'inbound', + state: 'disconnected', + stirShaken: { + 'verstat': 'TN-Verification-Passed', + 'attestationIndicator': 'A', + 'originatingId': 'abc123' + }, + identity: 'eyJhbGciOiJFUzI1NiI', + enqueuedTime: '2022-06-16T13:15:07.160Z', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + endTime: '2022-06-16T13:15:18.314Z', + disconnectCause: 'hangup', + errorMessage: nil, + errorId: nil, + lastUpdate: '2022-06-16T13:15:18.314Z' + }) + expect(call_state_from_hash).to be_instance_of(Bandwidth::CallState) + expect(call_state_from_hash.application_id).to eq('04e88489-df02-4e34-a0ee-27a91849555f') + expect(call_state_from_hash.account_id).to eq('9900000') + expect(call_state_from_hash.call_id).to eq('c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85') + expect(call_state_from_hash.parent_call_id).to eq('c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85') + expect(call_state_from_hash.to).to eq('+19195551234') + expect(call_state_from_hash.from).to eq('+19195554321') + expect(call_state_from_hash.direction).to eq('inbound') + expect(call_state_from_hash.state).to eq('disconnected') + expect(call_state_from_hash.stir_shaken).to eq({ + 'verstat' => 'TN-Verification-Passed', + 'attestationIndicator' => 'A', + 'originatingId' => 'abc123' + }) + expect(call_state_from_hash.identity).to eq('eyJhbGciOiJFUzI1NiI') + expect(call_state_from_hash.enqueued_time).to eq(Time.parse('2022-06-16T13:15:07.160Z')) + expect(call_state_from_hash.start_time).to eq(Time.parse('2022-06-16T13:15:07.160Z')) + expect(call_state_from_hash.answer_time).to eq(Time.parse('2022-06-16T13:15:18.126Z')) + expect(call_state_from_hash.end_time).to eq(Time.parse('2022-06-16T13:15:18.314Z')) + expect(call_state_from_hash.disconnect_cause).to eq('hangup') + expect(call_state_from_hash.error_message).to eq(nil) + expect(call_state_from_hash.error_id).to eq(nil) + expect(call_state_from_hash.last_update).to eq(Time.parse('2022-06-16T13:15:18.314Z')) + end + end + + describe '#hash' do + it 'returns a hash code according to attributes' do + expect(call_state_default.hash).to be_instance_of(Integer) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(call_state_default.to_s).to eq('{}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + expect(call_state_default.eql?(Bandwidth::CallState.new)).to be true + expect(call_state_default.eql?(call_state_values)).to be false + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the object' do + expect(call_state_values.to_body).to eq({ + applicationId: '04e88489-df02-4e34-a0ee-27a91849555f', + accountId: '9900000', + callId: 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + parentCallId: 'c-25ac29a2-1331029c-2cb0-4a07-b215-b22865662d85', + to: '+19195551234', + from: '+19195554321', + direction: 'inbound', + state: 'disconnected', + stirShaken: { + 'verstat': 'TN-Verification-Passed', + 'attestationIndicator': 'A', + 'originatingId': 'abc123' + }, + identity: 'eyJhbGciOiJFUzI1NiI', + enqueuedTime: '2022-06-16T13:15:07.160Z', + startTime: '2022-06-16T13:15:07.160Z', + answerTime: '2022-06-16T13:15:18.126Z', + endTime: '2022-06-16T13:15:18.314Z', + disconnectCause: 'hangup', + errorMessage: nil, + errorId: nil, + lastUpdate: '2022-06-16T13:15:18.314Z' + }) + end + end +end diff --git a/spec/models/deferred_result_spec.rb b/spec/models/deferred_result_spec.rb new file mode 100644 index 00000000..8a0c2e0b --- /dev/null +++ b/spec/models/deferred_result_spec.rb @@ -0,0 +1,74 @@ +# Unit tests for Bandwidth::DeferredResult +describe Bandwidth::DeferredResult do + let(:deferred_result_default) { Bandwidth::DeferredResult.new } + let(:deferred_result_values) { Bandwidth::DeferredResult.new({ + result: { key: 'value' }, + set_or_expired: true + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::DeferredResult.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::DeferredResult.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::DeferredResult.acceptable_attributes).to eq(Bandwidth::DeferredResult.attribute_map.values) + end + end + + describe '#openapi_nullable' do + it 'expects nullable attributes to be an empty set' do + expect(Bandwidth::DeferredResult.openapi_nullable).to eq(Set.new([])) + end + end + + describe '#build_from_hash' do + it 'validates instance of DeferredResult created by the build_from_hash method' do + deferred_result_from_hash = Bandwidth::DeferredResult.build_from_hash({ + result: { key: 'value' }, + setOrExpired: true + }) + expect(deferred_result_from_hash).to be_instance_of(Bandwidth::DeferredResult) + expect(deferred_result_from_hash.result).to eq({ key: 'value' }) + expect(deferred_result_from_hash.set_or_expired).to be true + end + end + + describe '#hash' do + it 'returns a hash code according to attributes' do + expect(deferred_result_default.hash).to be_instance_of(Integer) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(deferred_result_values.to_s).to eq('{:result=>{:key=>"value"}, :setOrExpired=>true}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + expect(deferred_result_default.eql?(Bandwidth::DeferredResult.new)).to be true + expect(deferred_result_default.eql?(deferred_result_values)).to be false + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the object' do + expect(deferred_result_values.to_body).to eq({ + result: { key: 'value' }, + setOrExpired: true + }) + end + end +end diff --git a/spec/models/message_spec.rb b/spec/models/message_spec.rb new file mode 100644 index 00000000..c2c745b6 --- /dev/null +++ b/spec/models/message_spec.rb @@ -0,0 +1,138 @@ +# Unit tests for Bandwidth::Message +describe Bandwidth::Message do + let(:message_default) { Bandwidth::Message.new } + let(:message_values) { Bandwidth::Message.new({ + id: '1589228074636lm4k2je7j7jklbn2', + owner: '+19195554321', + application_id: '93de2206-9669-4e07-948d-329f4b722ee2', + time: '2022-06-16T13:15:07.160Z', + segment_count: 2, + direction: Bandwidth::MessageDirectionEnum::IN, + to: ['+19195551234'], + from: '+19195554321', + media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'], + text: 'Hello world', + tag: 'custom tag', + priority: 'default', + expiration: '2022-06-16T13:45:07.160Z' + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::Message.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::Message.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::Message.acceptable_attributes).to eq(Bandwidth::Message.attribute_map.values) + end + end + + describe 'enum validation' do + it 'works' do + + end + end + + describe 'EnumAttributeValidator' do + it 'validates string enum' do + validator = Bandwidth::Message::EnumAttributeValidator.new(String, ['valid']) + expect(validator.valid?('valid')).to be true + expect(validator.valid?('invalid')).to be false + end + + it 'validates integer enum' do + validator = Bandwidth::Message::EnumAttributeValidator.new(Integer, [1]) + expect(validator.valid?(1)).to be true + expect(validator.valid?('invalid')).to be false + end + + it 'validates float enum' do + validator = Bandwidth::Message::EnumAttributeValidator.new(Float, [1.0]) + expect(validator.valid?(1.0)).to be true + expect(validator.valid?('invalid')).to be false + end + end + + describe '#build_from_hash' do + it 'validates instance of Message created by the build_from_hash method' do + message_from_hash = Bandwidth::Message.build_from_hash({ + id: '1589228074636lm4k2je7j7jklbn2', + owner: '+19195554321', + applicationId: '93de2206-9669-4e07-948d-329f4b722ee2', + time: '2022-06-16T13:15:07.160Z', + segmentCount: 2, + direction: Bandwidth::MessageDirectionEnum::IN, + to: ['+19195551234'], + from: '+19195554321', + media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'], + text: 'Hello world', + tag: 'custom tag', + priority: 'default', + expiration: '2022-06-16T13:45:07.160Z' + }) + expect(message_from_hash).to be_instance_of(Bandwidth::Message) + expect(message_from_hash.id).to eq('1589228074636lm4k2je7j7jklbn2') + expect(message_from_hash.owner).to eq('+19195554321') + expect(message_from_hash.application_id).to eq('93de2206-9669-4e07-948d-329f4b722ee2') + expect(message_from_hash.time).to eq(Time.parse('2022-06-16T13:15:07.160Z')) + expect(message_from_hash.segment_count).to eq(2) + expect(message_from_hash.direction).to eq(Bandwidth::MessageDirectionEnum::IN) + expect(message_from_hash.to).to eq(['+19195551234']) + expect(message_from_hash.from).to eq('+19195554321') + expect(message_from_hash.media).to eq(['https://dev.bandwidth.com/images/bandwidth-logo.png']) + expect(message_from_hash.text).to eq('Hello world') + expect(message_from_hash.tag).to eq('custom tag') + expect(message_from_hash.priority).to eq('default') + expect(message_from_hash.expiration).to eq(Time.parse('2022-06-16T13:45:07.160Z')) + end + end + + describe '#hash' do + it 'returns a hash code according to attributes' do + expect(message_default.hash).to be_instance_of(Integer) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(message_default.to_s).to eq('{}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + expect(message_default.eql?(Bandwidth::Message.new)).to be true + expect(message_default.eql?(message_values)).to be false + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the object' do + expect(message_values.to_body).to eq({ + id: '1589228074636lm4k2je7j7jklbn2', + owner: '+19195554321', + applicationId: '93de2206-9669-4e07-948d-329f4b722ee2', + time: '2022-06-16T13:15:07.160Z', + segmentCount: 2, + direction: Bandwidth::MessageDirectionEnum::IN, + to: ['+19195551234'], + from: '+19195554321', + media: ['https://dev.bandwidth.com/images/bandwidth-logo.png'], + text: 'Hello world', + tag: 'custom tag', + priority: 'default', + expiration: '2022-06-16T13:45:07.160Z' + }) + end + end +end diff --git a/spec/models/verify_code_request_spec.rb b/spec/models/verify_code_request_spec.rb new file mode 100644 index 00000000..48673ff5 --- /dev/null +++ b/spec/models/verify_code_request_spec.rb @@ -0,0 +1,126 @@ +# Unit tests for Bandwidth::VerifyCodeRequest +describe Bandwidth::VerifyCodeRequest do + let(:verify_code_request_values) { Bandwidth::VerifyCodeRequest.new({ + to: '+19195551234', + scope: '2FA', + expiration_time_in_minutes: 1.0, + code: '123456' + }) } + + describe '#initialize' do + it 'causes an ArgumentError by passing an Array to the initialize method' do + expect { + Bandwidth::VerifyCodeRequest.new([]) + }.to raise_error(ArgumentError) + end + + it 'causes an ArgumentError by passing an invalid attribute to the initialize method' do + expect { + Bandwidth::VerifyCodeRequest.new({ invalid: true }) + }.to raise_error(ArgumentError) + end + end + + describe '#acceptable_attributes' do + it 'expects acceptable JSON attributes to be those in the attribute map' do + expect(Bandwidth::VerifyCodeRequest.acceptable_attributes).to eq(Bandwidth::VerifyCodeRequest.attribute_map.values) + end + end + + describe '#openapi_nullable' do + it 'expects nullable attributes to be an empty set' do + expect(Bandwidth::VerifyCodeRequest.openapi_nullable).to eq(Set.new([])) + end + end + + describe '#build_from_hash' do + it 'validates instance of VerifyCodeRequest created by the build_from_hash method' do + verify_code_request_from_hash = Bandwidth::VerifyCodeRequest.build_from_hash({ + to: '+19195551234', + scope: '2FA', + expirationTimeInMinutes: 1.0, + code: '123456' + }) + expect(verify_code_request_from_hash).to be_instance_of(Bandwidth::VerifyCodeRequest) + expect(verify_code_request_from_hash.to).to eq('+19195551234') + expect(verify_code_request_from_hash.scope).to eq('2FA') + expect(verify_code_request_from_hash.expiration_time_in_minutes).to eq(1.0) + expect(verify_code_request_from_hash.code).to eq('123456') + end + end + + describe '#hash' do + it 'returns a hash code according to attributes' do + expect(verify_code_request_values.hash).to be_instance_of(Integer) + end + end + + describe '#to_s' do + it 'returns a string representation of the object' do + expect(verify_code_request_values.to_s).to eq('{:to=>"+19195551234", :scope=>"2FA", :expirationTimeInMinutes=>1.0, :code=>"123456"}') + end + end + + describe '#eq? #==' do + it 'returns true/false when comparing objects' do + verify_code_request_equal = Bandwidth::VerifyCodeRequest.new({ + to: '+19195551234', + scope: '2FA', + expiration_time_in_minutes: 1.0, + code: '123456' + }) + expect(verify_code_request_equal.eql?(verify_code_request_values)).to be true + end + end + + describe '#to_body #to_hash' do + it 'returns a hash representation of the object' do + expect(verify_code_request_values.to_body).to eq({ + to: '+19195551234', + scope: '2FA', + expirationTimeInMinutes: 1.0, + code: '123456' + }) + end + end + + describe 'custom attribute writers' do + it '#to=' do + expect { + Bandwidth::VerifyCodeRequest.new({ to: nil }) + }.to raise_error(ArgumentError, 'to cannot be nil') + + expect { + Bandwidth::VerifyCodeRequest.new({ to: 'invalid' }) + }.to raise_error(ArgumentError, 'invalid value for "to", must conform to the pattern (?-mix:^\+[1-9]\d{1,14}$).') + end + + it '#expiration_time_in_minutes=' do + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: nil }) + }.to raise_error(ArgumentError, 'expiration_time_in_minutes cannot be nil') + + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 16 }) + }.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be smaller than or equal to 15.') + + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 0 }) + }.to raise_error(ArgumentError, 'invalid value for "expiration_time_in_minutes", must be greater than or equal to 1.') + end + + it '#code=' do + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: nil }) + }.to raise_error(ArgumentError, 'code cannot be nil') + + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123456789' }) + }.to raise_error(ArgumentError, 'invalid value for "code", the character length must be smaller than or equal to 8.') + + expect { + Bandwidth::VerifyCodeRequest.new({ to: '+19195551234', expiration_time_in_minutes: 1, code: '123' }) + }.to raise_error(ArgumentError, 'invalid value for "code", the character length must be great than or equal to 4.') + end + end +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 00000000..29b3424b --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,171 @@ +# Test Coverage Configuration +require 'simplecov' +SimpleCov.start do + add_filter 'spec/integration' + add_filter 'spec/call_utils.rb' + add_filter do |source_file| + if !source_file.filename.include? 'bandwidth-sdk/models' then + false + else + !(['/models/call_state_enum.rb', + '/models/call_state.rb', + '/models/deferred_result.rb', + '/models/message.rb', + '/models/verify_code_request.rb' + ].any? { |name| source_file.filename.include?(name) }) + end + end + add_group 'Models', 'lib/bandwidth-sdk/models/' + add_group 'APIs', 'lib/bandwidth-sdk/api/' + add_group 'Client', ['api_client.rb', 'api_error.rb', 'configuration.rb', 'bandwidth-sdk.rb'] + add_group 'Tests', 'spec' +end + +# load the gem +require 'bandwidth-sdk' + +# load call utils every time. This prevents an error from occuring when running only unit tests +require_relative './call_utils' + +# use webmock to stub HTTP requests +require 'webmock/rspec' + +# The following was generated by the `rspec --init` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + config.before(:suite) { + begin + BW_USERNAME = ENV.fetch('BW_USERNAME') + BW_PASSWORD = ENV.fetch('BW_PASSWORD') + FORBIDDEN_USERNAME = ENV.fetch('BW_USERNAME_FORBIDDEN') + FORBIDDEN_PASSWORD = ENV.fetch('BW_PASSWORD_FORBIDDEN') + BW_ACCOUNT_ID = ENV.fetch('BW_ACCOUNT_ID') + BW_VOICE_APPLICATION_ID = ENV.fetch('BW_VOICE_APPLICATION_ID') + BW_MESSAGING_APPLICATION_ID = ENV.fetch('BW_MESSAGING_APPLICATION_ID') + BASE_CALLBACK_URL = ENV.fetch('BASE_CALLBACK_URL') + BW_NUMBER = ENV.fetch('BW_NUMBER') + USER_NUMBER = ENV.fetch('USER_NUMBER') + MANTECA_ACTIVE_NUMBER = ENV.fetch('MANTECA_ACTIVE_NUMBER') + MANTECA_IDLE_NUMBER = ENV.fetch('MANTECA_IDLE_NUMBER') + MANTECA_BASE_URL = ENV.fetch('MANTECA_BASE_URL') + MANTECA_APPLICATION_ID = ENV.fetch('MANTECA_APPLICATION_ID') + OPERATING_SYSTEM = ENV.fetch('OPERATING_SYSTEM') + RUBY_VERSION = ENV.fetch('RUBY_VERSION') + rescue + puts 'Environmental variables not found' + exit(-1) + end + + SLEEP_TIME_S = 3 # default sleep time in seconds + MAX_RETRIES = 40 + UNAUTHORIZED_USERNAME = 'bad_username' + UNAUTHORIZED_PASSWORD = 'bad_password' + $active_calls = [] + + $complete_call_body = Bandwidth::UpdateCall.new( + state: Bandwidth::CallStateEnum::COMPLETED + ) + } + + config.after(:suite) { + Bandwidth.configure do |config| + config.username = BW_USERNAME + config.password = BW_PASSWORD + end + calls_api = Bandwidth::CallsApi.new + # cleanup_calls($active_calls, calls_api) + } + + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # This setting enables warnings. It's recommended, but in some cases may + # be too noisy due to issues in dependencies. + config.warnings = true + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/test/controllers/controller_test_base.rb b/test/controllers/controller_test_base.rb deleted file mode 100644 index 2ea63c53..00000000 --- a/test/controllers/controller_test_base.rb +++ /dev/null @@ -1,21 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'json' -require 'minitest/autorun' -require 'minitest/hell' -require 'minitest/pride' -require 'minitest/proveit' -require 'bandwidth' -require_relative '../test_helper' -require_relative '../http_response_catcher' - -class ControllerTestBase < Minitest::Test - parallelize_me! - include Bandwidth - - # Create configuration and set any test parameters - CONFIG = Configuration.new -end diff --git a/test/http_response_catcher.rb b/test/http_response_catcher.rb deleted file mode 100644 index c76d12ff..00000000 --- a/test/http_response_catcher.rb +++ /dev/null @@ -1,19 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -class HttpResponseCatcher < Bandwidth::HttpCallBack - attr_accessor :response - - def on_before_request(request) - end - - # Catching the response - def on_after_response(response) - @response = response - end -end - - - diff --git a/test/integration/test_integration.rb b/test/integration/test_integration.rb deleted file mode 100644 index 5b586b10..00000000 --- a/test/integration/test_integration.rb +++ /dev/null @@ -1,851 +0,0 @@ -# test_integration.rb -# -# A simple integration test against Bandwidth's APIs - -require 'test/unit' -require 'securerandom' -require_relative '../../lib/bandwidth.rb' - -include Bandwidth -include Bandwidth::Voice -include Bandwidth::Messaging -include Bandwidth::MultiFactorAuth -include Bandwidth::WebRtc - -begin - BW_USERNAME = ENV.fetch("BW_USERNAME") - BW_PASSWORD = ENV.fetch("BW_PASSWORD") - BW_ACCOUNT_ID = ENV.fetch("BW_ACCOUNT_ID") - BW_VOICE_APPLICATION_ID = ENV.fetch("BW_VOICE_APPLICATION_ID") - BW_MESSAGING_APPLICATION_ID = ENV.fetch("BW_MESSAGING_APPLICATION_ID") - BASE_CALLBACK_URL = ENV.fetch("BASE_CALLBACK_URL") - BW_NUMBER = ENV.fetch("BW_NUMBER") - USER_NUMBER = ENV.fetch("USER_NUMBER") -rescue - puts "Environmental variables not found" - exit(-1) -end - -class IntegrationTest < Test::Unit::TestCase - def setup - @bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: BW_USERNAME, - voice_basic_auth_password: BW_PASSWORD, - messaging_basic_auth_user_name: BW_USERNAME, - messaging_basic_auth_password: BW_PASSWORD, - multi_factor_auth_basic_auth_user_name: BW_USERNAME, - multi_factor_auth_basic_auth_password: BW_PASSWORD, - phone_number_lookup_basic_auth_user_name: BW_USERNAME, - phone_number_lookup_basic_auth_password: BW_PASSWORD - ) - - @bandwidth_client_invalid_auth = Bandwidth::Client.new( - voice_basic_auth_user_name: "bad_username", - voice_basic_auth_password: "bad_password", - messaging_basic_auth_user_name: "bad_username", - messaging_basic_auth_password: "bad_password", - multi_factor_auth_basic_auth_user_name: "bad_username", - multi_factor_auth_basic_auth_password: "bad_password", - phone_number_lookup_basic_auth_user_name: "bad_username", - phone_number_lookup_basic_auth_password: "bad_password" - ) - end - - def test_create_message - body = MessageRequest.new - body.application_id = BW_MESSAGING_APPLICATION_ID - body.to = [USER_NUMBER] - body.from = BW_NUMBER - body.text = "Ruby Integration" - body.priority = "high" - body.expiration = "2091-02-01T11:29:18-05:00" - response = @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body) - assert(response.data.to == [USER_NUMBER]) - assert(response.data.from == BW_NUMBER) - assert(response.data.text == "Ruby Integration") - assert(response.data.priority == "high") - assert(response.data.expiration == "2091-02-01T11:29:18-05:00") - assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned - end - - def test_create_message_invalid_phone_number - body = MessageRequest.new - body.application_id = BW_MESSAGING_APPLICATION_ID - body.to = ["+1invalid"] - body.from = BW_NUMBER - body.text = "Ruby Integration" - begin - @bandwidth_client.messaging_client.client.create_message(BW_ACCOUNT_ID, body) - #workaround to make sure that if the above error is not raised, the build will fail - assert(false, "Expected exception not raised") - rescue MessagingException => e - assert(e.description.length > 0, "description value not set") - end - end - - def test_upload_download_media - #define constants for upload media and download media - media_id = "text-media-id-" + SecureRandom.uuid - media = "Hello world" - - #media upload - @bandwidth_client.messaging_client.client.upload_media(BW_ACCOUNT_ID, media_id, media, :content_type => "text/plain", :cache_control => "no-cache") - - #media download - downloaded_media = @bandwidth_client.messaging_client.client.get_media(BW_ACCOUNT_ID, media_id).data - - assert_equal(downloaded_media, media, "Downloaded media file not equal to upload") - end - - def test_get_message - # Send a successful request to the GET messages API - response = @bandwidth_client.messaging_client.client.get_messages(BW_ACCOUNT_ID, :message_id => "abc123") - assert_equal(response.status_code, 200, "API did not return a 200 OK") - end - - def test_get_message_invalid_auth - # Send an unsuccessful request to the GET messages API - assert_raise MessagingException do - response = @bandwidth_client_invalid_auth.messaging_client.client.get_messages(BW_ACCOUNT_ID) - end - end - - def test_create_call_and_get_call_state - body = CreateCallRequest.new - body.from = BW_NUMBER - body.to = USER_NUMBER - body.application_id = BW_VOICE_APPLICATION_ID - body.answer_url = BASE_CALLBACK_URL - response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body) - assert(response.data.call_id.length > 0, "call_id value not set") - assert_not_nil(response.data.enqueued_time, "enqueued time is nil") - assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object") - - #Get phone call information - sleep(2) - begin - response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id) - assert(response.data.state.length > 0, "state value not set") - assert_not_nil(response.data.enqueued_time, "enqueued time is nil") - assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object") - rescue ApiErrorException => e - if e.response_code != 404 - raise StandardError, "Unexpected HTTP Response: " + e.message - end - end - - end - - def test_create_call_with_amd_and_get_call_state - machine_detection = MachineDetectionConfiguration.new - machine_detection.mode = 'async' - machine_detection.detection_timeout = 5.0 - machine_detection.silence_timeout = 5.0 - machine_detection.speech_threshold = 5.0 - machine_detection.speech_end_threshold = 5.0 - machine_detection.delay_result = true - machine_detection.callback_url = BASE_CALLBACK_URL + '/machineDetection' - machine_detection.callback_method = 'POST' - machine_detection.machine_speech_end_threshold = 3.2 - - body = CreateCallRequest.new - body.from = BW_NUMBER - body.to = USER_NUMBER - body.application_id = BW_VOICE_APPLICATION_ID - body.answer_url = BASE_CALLBACK_URL - body.machine_detection = machine_detection - response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body) - assert(response.data.call_id.length > 0, "call_id value not set") - - #Get phone call information - sleep(2) - begin - response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id) - assert(response.data.state.length > 0, "state value not set") - rescue ApiErrorException => e - if e.response_code != 404 - raise StandardError, "Unexpected HTTP Response: " + e.message - end - end - end - - def test_create_call_with_priority - body = CreateCallRequest.new - body.from = BW_NUMBER - body.to = USER_NUMBER - body.application_id = BW_VOICE_APPLICATION_ID - body.answer_url = BASE_CALLBACK_URL - body.priority = 1 - - response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body) - assert(response.data.call_id.length > 0, "call_id value not set") - assert(response.data.priority == 1, "priority not set") - end - - def test_create_call_invalid_phone_number - body = CreateCallRequest.new - body.from = BW_NUMBER - body.to = "+1invalid" - body.application_id = BW_VOICE_APPLICATION_ID - body.answer_url = BASE_CALLBACK_URL - - begin - @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, :body => body) - #workaround to make sure that if the above error is not raised, the build will fail - assert(false, "Expected exception not raised") - rescue ApiErrorException => e - assert(e.description.length > 0, "description value not set") - end - end - - def test_forward - forward = Bandwidth::Voice::Forward.new({ - :to => "+15554443333", - :from => "+13334445555", - :call_timeout => 25, - :diversion_treatment => "none", - :diversion_reason => "away" - }) - - response = Bandwidth::Voice::Response.new() - response.push(forward) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_gather - gather = Bandwidth::Voice::Gather.new({ - :gather_url => "https://test.com", - :gather_method => "POST", - :username => "user", - :password => "pass", - :tag => "tag", - :terminating_digits => "#", - :max_digits => 3, - :inter_digit_timeout => 5, - :first_digit_timeout => "10", - :repeat_count => 1, - :gather_fallback_url => "https://test.com", - :gather_fallback_method => "GET", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - - response = Bandwidth::Voice::Response.new() - response.push(gather) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_gather_nested_speak_sentence - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "test" - }) - gather = Bandwidth::Voice::Gather.new({ - :speak_sentence => speak_sentence - }) - - response = Bandwidth::Voice::Response.new() - response.push(gather) - expected = 'test' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_gather_nested_play_audio - play_audio = Bandwidth::Voice::PlayAudio.new({ - :url => "https://test.com" - }) - gather = Bandwidth::Voice::Gather.new({ - :play_audio => play_audio - }) - - response = Bandwidth::Voice::Response.new() - response.push(gather) - expected = 'https://test.com' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_gather_multiple_nested_verbs - play_audio = Bandwidth::Voice::PlayAudio.new({ - :url => "https://test.com" - }) - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "test" - }) - gather = Bandwidth::Voice::Gather.new({ - :nested_verbs => [play_audio, speak_sentence] - }) - - response = Bandwidth::Voice::Response.new() - response.push(gather) - expected = 'https://test.comtest' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_empty_bxml_verb - bxml = Bandwidth::Voice::Bxml.new() - - expected = '' - actual = bxml.to_bxml() - assert_equal(expected, actual) - end - - def test_speak_sentence_pause - bxml = Bandwidth::Voice::Bxml.new() - - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "new modify call bxml is pog", - :voice => "Julie" - }) - - pause = Bandwidth::Voice::Pause.new({ - :duration => 6 - }) - - bxml.push(speak_sentence) - bxml.push(pause) - - expected = 'new modify call bxml is pog' - actual = bxml.to_bxml() - assert_equal(expected, actual) - end - - def test_hangup - hangup = Bandwidth::Voice::Hangup.new() - - response = Bandwidth::Voice::Response.new() - response.push(hangup) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_pause - pause = Bandwidth::Voice::Pause.new({ - :duration => 2 - }) - - response = Bandwidth::Voice::Response.new() - response.push(pause) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_pause_recording - pause_recording = Bandwidth::Voice::PauseRecording.new() - - response = Bandwidth::Voice::Response.new() - response.push(pause_recording) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_play_audio - play_audio = Bandwidth::Voice::PlayAudio.new({ - :url => "https://test.com", - :username => "user", - :password => "pass" - }) - - response = Bandwidth::Voice::Response.new() - response.push(play_audio) - expected = 'https://test.com' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_record - record = Bandwidth::Voice::Record.new({ - :record_complete_url => "https://complete.com", - :record_complete_method => "POST", - :recording_available_url => "https://available.com", - :recording_available_method => "GET", - :transcribe => false, - :detect_language=> true, - :transcription_available_url => "https://transcribe.com", - :transcription_available_method => "POST", - :username => "user", - :password => "pass", - :tag => "tag", - :terminating_digits => "#", - :max_duration => 3, - :silence_timeout => 5, - :file_format => "wav", - :record_complete_fallback_url => "https://test.com", - :record_complete_fallback_method => "GET", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - - response = Bandwidth::Voice::Response.new() - response.push(record) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_redirect - redirect = Bandwidth::Voice::Redirect.new({ - :redirect_url => "https://redirect.com", - :redirect_method => "GET", - :username => "user", - :password => "pass", - :tag => "tag", - :redirect_fallback_url => "https://test.com", - :redirect_fallback_method => "GET", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - - response = Bandwidth::Voice::Response.new() - response.push(redirect) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_resume_recording - resume_recording = Bandwidth::Voice::ResumeRecording.new() - - response = Bandwidth::Voice::Response.new() - response.push(resume_recording) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_send_dtmf - send_dtmf = Bandwidth::Voice::SendDtmf.new({ - :dtmf => "12w34", - :tone_duration => 75, - :tone_interval => 65 - }) - - response = Bandwidth::Voice::Response.new() - response.push(send_dtmf) - expected = '12w34' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_speak_sentence - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => "test", - :voice => "julie", - :gender => "female", - :locale => "en_US" - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - expected = 'test' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_speak_sentence_ssml - speak_sentence = Bandwidth::Voice::SpeakSentence.new({ - :sentence => 'Hello, you have reached the home of Antonio Mendoza.Please leave a message.', - }) - - response = Bandwidth::Voice::Response.new() - response.push(speak_sentence) - expected = 'Hello, you have reached the home of Antonio Mendoza.Please leave a message.' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_start_recording - start_recording = Bandwidth::Voice::StartRecording.new({ - :recording_available_url => "https://available.com", - :recording_available_method => "POST", - :transcribe => false, - :transcription_available_url => "https://transcribe.com", - :transcription_available_method => "GET", - :username => "user", - :password => "pass", - :tag => "tag", - :file_format => "mp3", - :multi_channel => true - }) - - response = Bandwidth::Voice::Response.new() - response.push(start_recording) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_stop_recording - stop_recording = Bandwidth::Voice::StopRecording.new() - - response = Bandwidth::Voice::Response.new() - response.push(stop_recording) - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_transfer - phone_number = Bandwidth::Voice::PhoneNumber.new({ - :number => "+15554443333", - :transfer_answer_url => "https://phoneanswer.com", - :transfer_answer_method => "GET", - :transfer_disconnect_url => "https://phonedisconnect.com", - :transfer_disconnect_method => "POST", - :username => "phoneuser", - :password => "phonepassword", - :tag => "phonetag", - :transfer_answer_fallback_url => "https://test.com", - :transfer_answer_fallback_method => "GET", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - transfer = Bandwidth::Voice::Transfer.new({ - :transfer_caller_id => "+13334445555", - :call_timeout => 3, - :transfer_complete_url => "https://transfercomplete.com", - :transfer_complete_method => "POST", - :username => "transferuser", - :password => "transferpass", - :tag => "transfertag", - :diversion_treatment => "none", - :diversion_reason => "away", - :phone_numbers => [phone_number], - :transfer_complete_fallback_url => "https://test.com", - :transfer_complete_fallback_method => "GET", - :fallback_username => "fusern", - :fallback_password => "fpassw" - }) - - response = Bandwidth::Voice::Response.new() - response.push(transfer) - expected = '+15554443333' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_conference - conference = Bandwidth::Voice::Conference.new({ - :conference_name => 'my-conference', - :mute => false, - :hold => true, - :call_ids_to_coach => "c-123,c-234", - :conference_event_url => "https://test.com", - :conference_event_method => "POST", - :username => "user", - :password => "pass", - :tag => "tag", - :conference_event_fallback_url => "https://test2.com", - :conference_event_fallback_method => "POST", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - response = Bandwidth::Voice::Response.new() - response.push(conference) - - expected = 'my-conference' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_conference_coach_ids_array - conference = Bandwidth::Voice::Conference.new({ - :conference_name => 'my-conference', - :call_ids_to_coach => ["c-123", "c-234"], - }) - response = Bandwidth::Voice::Response.new() - response.push(conference) - - expected = 'my-conference' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_conference_no_coach - conference = Bandwidth::Voice::Conference.new({ - :conference_name => 'my-conference' - }) - response = Bandwidth::Voice::Response.new() - response.push(conference) - - expected = 'my-conference' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_mfa_messaging - body = TwoFactorCodeRequestSchema.new - body.from = BW_NUMBER - body.to = USER_NUMBER - body.application_id = BW_MESSAGING_APPLICATION_ID - body.scope = "scope" - body.digits = 6 - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - - response = @bandwidth_client.multi_factor_auth_client.mfa.create_messaging_two_factor(BW_ACCOUNT_ID, body) - assert(response.data.message_id.length > 0, "message id value not set") - end - - def test_mfa_voice - body = TwoFactorCodeRequestSchema.new - body.from = BW_NUMBER - body.to = USER_NUMBER - body.application_id = BW_VOICE_APPLICATION_ID - body.scope = "scope" - body.digits = 6 - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" - - response = @bandwidth_client.multi_factor_auth_client.mfa.create_voice_two_factor(BW_ACCOUNT_ID, body) - assert(response.data.call_id.length > 0, "call id value not set") - end - - def test_mfa_verify - body = TwoFactorVerifyRequestSchema.new - body.to = "+1000" + rand(1111111..9999999).to_s - body.application_id = BW_VOICE_APPLICATION_ID - body.scope = "scope" - body.code = "123456" - body.expiration_time_in_minutes = 3 - response = @bandwidth_client.multi_factor_auth_client.mfa.create_verify_two_factor(BW_ACCOUNT_ID, body) - #Ruby has no check to see if variables are of type boolean - #An explicit true/false check is required - assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean") - end - - def test_bridge - bridge = Bandwidth::Voice::Bridge.new({ - :call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", - :bridge_complete_url => "https://test.com", - :bridge_complete_method => "POST", - :bridge_target_complete_url => "https://test2.com", - :bridge_target_complete_method => "GET", - :username => "user", - :password => "pass", - :tag => "custom tag", - :bridge_complete_fallback_url => "https://test3.com", - :bridge_complete_fallback_method => "GET", - :bridge_target_complete_fallback_url => "https://test4.com", - :bridge_target_complete_fallback_method => "POST", - :fallback_username => "fuser", - :fallback_password => "fpass" - }) - - response = Bandwidth::Voice::Response.new() - response.push(bridge) - - expected = 'c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_ring - ring = Bandwidth::Voice::Ring.new({ - :duration => 5, - :answer_call => false - }) - - response = Bandwidth::Voice::Response.new() - response.push(ring) - - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_start_gather - start_gather = Bandwidth::Voice::StartGather.new({ - :username => "user", - :password => "pass", - :tag => "custom tag", - :dtmf_url => "https://test.com", - :dtmf_method => "GET" - }) - - response = Bandwidth::Voice::Response.new() - response.push(start_gather) - - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_stop_gather - stop_gather = Bandwidth::Voice::StopGather.new() - - response = Bandwidth::Voice::Response.new() - response.push(stop_gather) - - expected = '' - actual = response.to_bxml() - assert_equal(expected, actual) - end - - def test_tn_lookup - body = OrderRequest.new - body.tns = [BW_NUMBER] - create_response = @bandwidth_client.phone_number_lookup_client.client.create_lookup_request(BW_ACCOUNT_ID, body) - assert(create_response.data.request_id.length > 0, "request_id value not set") - - request_id = create_response.data.request_id - get_response = @bandwidth_client.phone_number_lookup_client.client.get_lookup_request_status(BW_ACCOUNT_ID, request_id) - assert(get_response.data.status.length > 0, "status value not set") - end - - def test_webrtc_generate_bxml - expected = 'sip:sipx.webrtc.bandwidth.com:5060' - actual = Bandwidth::WebRtc.generate_bxml('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4') - assert_equal(expected, actual) - end - - def test_webrtc_generate_transfer_bxml_verb - expected = 'sip:sipx.webrtc.bandwidth.com:5060' - actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4') - assert_equal(expected, actual) - end - - def test_start_stream_bxml_verb - expected = '' - response = Bandwidth::Voice::Response.new() - - stream_param1 = Bandwidth::Voice::StreamParam.new({ - :name => "name1", - :value => "value1" - }) - - start_stream = Bandwidth::Voice::StartStream.new({ - :destination => "https://www.test.com/stream", - :name => "test_stream", - :tracks => "inbound", - :streamEventUrl => "https://www.test.com/event", - :streamEventMethod => "POST", - :username => "username", - :password => "password", - :stream_params => stream_param1 - }) - - response.push(start_stream) - actual = response.to_bxml() - - assert_equal(expected, actual) - end - - def test_start_stream_multiple_nested_stream_params - expected = '' - response = Bandwidth::Voice::Response.new() - - stream_param1 = Bandwidth::Voice::StreamParam.new({ - :name => "name1", - :value => "value1" - }) - - stream_param2 = Bandwidth::Voice::StreamParam.new({ - :name => "name2", - :value => "value2" - }) - - start_stream = Bandwidth::Voice::StartStream.new({ - :destination => "https://www.test.com/stream", - :name => "test_stream", - :tracks => "inbound", - :streamEventUrl => "https://www.test.com/event", - :streamEventMethod => "POST", - :username => "username", - :password => "password", - :nested_verbs => [stream_param1, stream_param2] - }) - - response.push(start_stream) - actual = response.to_bxml() - - assert_equal(expected, actual) - end - - def test_stop_stream_bxml_verb - expected = '' - response = Bandwidth::Voice::Response.new() - stop_stream = Bandwidth::Voice::StopStream.new({ - :name => "test_stream" - }) - response.push(stop_stream) - actual = response.to_bxml() - - assert_equal(expected, actual) - end - - def test_start_transcription_bxml_verb - expected = '' - response = Bandwidth::Voice::Response.new() - - custom_param1 = Bandwidth::Voice::CustomParam.new({ - :name => "name1", - :value => "value1" - }) - - start_transcription = Bandwidth::Voice::StartTranscription.new({ - :name => "test_transcription", - :tracks => "inbound", - :transcriptionEventUrl => "https://www.test.com/event", - :transcriptionEventMethod => "POST", - :username => "username", - :password => "password", - :destination => "https://www.test.com/transcription", - :custom_params => custom_param1 - }) - - response.push(start_transcription) - actual = response.to_bxml() - - assert_equal(expected, actual) - end - - def test_start_transcription_multiple_nested_custom_params - expected = '' - response = Bandwidth::Voice::Response.new() - - custom_param1 = Bandwidth::Voice::CustomParam.new({ - :name => "name1", - :value => "value1" - }) - - custom_param2 = Bandwidth::Voice::CustomParam.new({ - :name => "name2", - :value => "value2" - }) - - start_transcription = Bandwidth::Voice::StartTranscription.new({ - :destination => "https://www.test.com/transcription", - :name => "test_transcription", - :tracks => "inbound", - :transcriptionEventUrl => "https://www.test.com/event", - :transcriptionEventMethod => "POST", - :username => "username", - :password => "password", - :nested_verbs => [custom_param1, custom_param2] - }) - - response.push(start_transcription) - actual = response.to_bxml() - - assert_equal(expected, actual) - end - - def test_stop_transcription_bxml_verb - expected = '' - response = Bandwidth::Voice::Response.new() - stop_transcription = Bandwidth::Voice::StopTranscription.new({ - :name => "test_transcription" - }) - response.push(stop_transcription) - actual = response.to_bxml() - - assert_equal(expected, actual) - end -end diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index 39784787..00000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,94 +0,0 @@ -# bandwidth -# -# This file was automatically generated by APIMATIC v2.0 -# ( https://apimatic.io ). - -require 'tempfile' -require 'open-uri' - -class TestHelper - - @cache = Hash.new - - # Class method to compare the received headers with the expected headers. - # @param [Hash] A hash of expected headers (keys in lower case). - # @param [Hash] A hash of received headers. - # @param [Boolean, optional] A flag which determines if we allow extra headers. - def self.match_headers(expected_headers, - received_headers, - allow_extra: true) - return false if ((received_headers.length < expected_headers.length) || - ((allow_extra == false) && (received_headers.length > expected_headers.length))) - - received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}] - expected_headers.each do |e_key, e_value| - return false unless received_headers.key?(e_key) - return false if ((e_value != nil) && - (e_value != received_headers[e_key])) - end - - return true - end - - # Class method to compare the received body with the expected body. - # @param [Dynamic] The expected body. - # @param [Dynamic] The received body. - # @param [Boolean, optional] A flag which determines if we check values in dictionaries. - # @param [Boolean, optional] A flag which determines if we check the order of array elements. - # @param [Boolean, optional] A flag which determines if we check the count of array elements. - def self.match_body(expected_body, - received_body, - check_values: false, - check_order: false, - check_count: false) - if expected_body.instance_of? Hash - return false unless received_body.instance_of? Hash - for key in expected_body.keys - return false unless received_body.keys.include? key - if check_values or expected_body[key].instance_of? Hash - return false unless TestHelper.match_body(expected_body[key], - received_body[key], - check_values: check_values, - check_order: check_order, - check_count: check_count) - end - end - elsif expected_body.instance_of? Array - return False unless received_body.instance_of? Array - if check_count == true && (expected_body.length != received_body.length) - return false - else - previous_matches = Array.new - expected_body.each.with_index do |expected_element, i| - matches = (received_body.map.with_index do |received_element, j| - j if TestHelper.match_body(expected_element, - received_element, - check_values: check_values, - check_order: check_order, - check_count: check_count) - end).compact - return false if matches.length == 0 - if check_order == true - return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?) - previous_matches = matches - end - end - end - elsif expected_body != received_body - return false - end - return true - end - - # Class method which takes a URL, downloads the file (if not already downloaded - # for this test session) and returns the path of the file. - # @param [String] The URL of the required file. - def self.get_file(url) - unless @cache.keys.include? url - @cache[url] = Tempfile.new('APIMatic') - @cache[url].binmode - @cache[url].write(open(url).read) - end - return @cache[url].path - end -end