diff --git a/site/migration-guides/ruby/intro.md b/site/migration-guides/ruby/intro.md index 8ac9b8412..3e44b5fa2 100644 --- a/site/migration-guides/ruby/intro.md +++ b/site/migration-guides/ruby/intro.md @@ -11,9 +11,9 @@ pagination_prev: null See our releases on [GitHub](https://github.com/Bandwidth/ruby-sdk/releases) for more detailed changelogs -## [v11-beta](/migration-guides/ruby/v10->v11-beta/) +## [v11](/migration-guides/ruby/v10->v11/) ### What's Changed * Generated an entirely new SDK using the open-source [OpenAPI Generator Library](https://openapi-generator.tech/) -* Rewrote the [BXML library](/migration-guides/ruby/v10->v11-beta#bxml/) +* Rewrote the [BXML library](/migration-guides/ruby/v10->v11#bxml/) diff --git a/site/migration-guides/ruby/v11.mdx b/site/migration-guides/ruby/v11.mdx index 81e6894b8..26b6d4afc 100644 --- a/site/migration-guides/ruby/v11.mdx +++ b/site/migration-guides/ruby/v11.mdx @@ -1,9 +1,9 @@ --- -id: v11-beta -title: v10 -> v11-beta -slug: /ruby/v10->v11-beta -description: Ruby v10 to v15 Migration Guide -sidebar_label: v10 -> v11-beta +id: v11 +title: v10 -> v11 +slug: /ruby/v10->v11 +description: Ruby v10 to v11 Migration Guide +sidebar_label: v10 -> v11 hide_title: false image: '@site/static/img/bw-icon.svg' pagination_next: null @@ -14,7 +14,7 @@ import TabItem from '@theme/TabItem'; ## Client Initialization - + ```ruby @@ -40,7 +40,7 @@ account_id = '9900000' ``` - + ```ruby require 'bandwidth-sdk' @@ -57,7 +57,7 @@ account_id = '9900000' ### Custom URLs - + ```ruby @@ -70,7 +70,7 @@ bandwidth_client = Bandwidth::Client.new( ``` - + ```ruby # Currently Unsupported @@ -83,7 +83,7 @@ bandwidth_client = Bandwidth::Client.new( ### Create Message - + ```ruby @@ -113,7 +113,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MessagesApi.new @@ -133,7 +133,7 @@ end ### List Messages - + ```ruby @@ -157,7 +157,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MessagesApi.new @@ -193,7 +193,7 @@ end ### List Media - + ```ruby @@ -219,7 +219,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MediaApi.new @@ -241,7 +241,7 @@ end ### Get Media - + ```ruby @@ -267,7 +267,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MediaApi.new @@ -287,7 +287,7 @@ end ### Upload Media - + ```ruby @@ -320,7 +320,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MediaApi.new @@ -344,7 +344,7 @@ end ### Delete Media - + ```ruby @@ -367,7 +367,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MediaApi.new @@ -388,7 +388,7 @@ end ### Imports - + ```ruby @@ -398,7 +398,7 @@ include Bandwidth::Voice ``` - + ```ruby require 'bandwidth-sdk' @@ -415,7 +415,7 @@ Hangup.new # Only works if the include statement above is present ### Response - + ```ruby @@ -428,7 +428,7 @@ puts response.to_bxml() ``` - + ```ruby hangup = Bandwidth::Bxml::Hangup.new @@ -442,7 +442,7 @@ puts response.to_bxml() ### Bridge - + ```ruby @@ -454,7 +454,7 @@ bridge = Bandwidth::Voice::Bridge.new({ ``` - + ```ruby bridge_attributes = { @@ -481,7 +481,7 @@ bridge = Bandwidth::Bxml::Bridge.new('bridge_call_id', bridge_attributes) ### Conference - + ```ruby @@ -491,7 +491,7 @@ conference = Bandwidth::Voice::Conference.new({ ``` - + ```ruby conference_attributes = { @@ -518,7 +518,7 @@ conference = Bandwidth::Bxml::Conference.new('conference_name', conference_attri ### Forward - + ```ruby @@ -529,7 +529,7 @@ forward = Bandwidth::Voice::Forward.new({ ``` - + ```ruby forward_attributes = { @@ -549,7 +549,7 @@ forward = Bandwidth::Bxml::Forward.new(forward_attributes) ### Gather - + ```ruby @@ -567,7 +567,7 @@ gather = Bandwidth::Voice::Gather.new({ ``` - + ```ruby gather_attributes = { @@ -598,7 +598,7 @@ gather = Bandwidth::Bxml::Gather.new([play_audio, speak_sentence], gather_attrib ### Hangup - + ```ruby @@ -606,7 +606,7 @@ hangup = Bandwidth::Voice::Hangup.new() ``` - + ```ruby hangup = Bandwidth::Bxml::Hangup.new @@ -617,7 +617,7 @@ hangup = Bandwidth::Bxml::Hangup.new ### Pause - + ```ruby @@ -627,7 +627,7 @@ pause = Bandwidth::Voice::Pause.new({ ``` - + ```ruby pause = Bandwidth::Bxml::Pause.new({duration: 5}) @@ -638,7 +638,7 @@ pause = Bandwidth::Bxml::Pause.new({duration: 5}) ### Pause Recording - + ```ruby @@ -646,7 +646,7 @@ pause_recording = Bandwidth::Voice::PauseRecording.new() ``` - + ```ruby pause_recording = Bandwidth::Bxml::PauseRecording.new @@ -657,7 +657,7 @@ pause_recording = Bandwidth::Bxml::PauseRecording.new ### Play Audio - + ```ruby @@ -667,7 +667,7 @@ play_audio_ = Bandwidth::Voice::PlayAudio.new({ ``` - + ```ruby play_audio_attributes = { @@ -683,7 +683,7 @@ play_audio = Bandwidth::Bxml::PlayAudio.new('https://audio.url/audio1.wav', play ### Record - + ```ruby @@ -695,7 +695,7 @@ record = Bandwidth::Voice::Record.new({ ``` - + ```ruby record_attributes = { @@ -727,7 +727,7 @@ record = Bandwidth::Bxml::Record.new(record_attributes) ### Redirect - + ```ruby @@ -737,7 +737,7 @@ redirect = Bandwidth::Voice::Redirect.new({ ``` - + ```ruby redirect_attributes = { @@ -760,7 +760,7 @@ redirect = Bandwidth::Bxml::Redirect.new(redirect_attributes) ### Resume Recording - + ```ruby @@ -768,7 +768,7 @@ resume_recording = Bandwidth::Voice::ResumeRecording.new() ``` - + ```ruby resume_recording = Bandwidth::Bxml::ResumeRecording.new @@ -779,7 +779,7 @@ resume_recording = Bandwidth::Bxml::ResumeRecording.new ### Ring - + ```ruby @@ -790,7 +790,7 @@ ring = Bandwidth::Voice::Ring.new({ ``` - + ```ruby ring_attributes = { @@ -806,7 +806,7 @@ ring = Bandwidth::Bxml::Ring.new(ring_attributes) ### Send DTMF - + ```ruby @@ -816,7 +816,7 @@ send_dtmf = Bandwidth::Voice::SendDtmf.new({ ``` - + ```ruby send_dtmf_attributes = { @@ -832,7 +832,7 @@ send_dtmf = Bandwidth::Bxml::SendDtmf.new('1234', send_dtmf_attributes) ### Speak Sentence - + ```ruby @@ -843,7 +843,7 @@ speak_sentence = Bandwidth::Voice::SpeakSentence.new({ ``` - + ```ruby speak_sentence_attributes = { @@ -860,7 +860,7 @@ speak_sentence = Bandwidth::Bxml::SpeakSentence.new('speak this sentence', speak ### Start Gather - + ```ruby @@ -870,7 +870,7 @@ start_gather = Bandwidth::Voice::StartGather.new({ ``` - + ```ruby start_gather_attributes = { @@ -889,7 +889,7 @@ start_gather = Bandwidth::Bxml::StartGather.new(start_gather_attributes) ### Start Recording - + ```ruby @@ -900,7 +900,7 @@ start_recording = Bandwidth::Voice::StartRecording.new({ ``` - + ```ruby start_recording_attributes = { @@ -924,7 +924,7 @@ start_recording = Bandwidth::Bxml::StartRecording.new(start_recording_attributes ### Start Stream - + ```ruby @@ -943,7 +943,7 @@ start_stream = Bandwidth::Voice::StartStream.new({ ``` - + ```ruby start_stream_attributes = { @@ -966,7 +966,7 @@ start_stream = Bandwidth::Bxml::StartStream.new([stream_param], start_stream_att ### Stop Gather - + ```ruby @@ -974,7 +974,7 @@ stop_gather = Bandwidth::Voice::StopGather.new() ``` - + ```ruby stop_gather = Bandwidth::Bxml::StopGather.new @@ -985,7 +985,7 @@ stop_gather = Bandwidth::Bxml::StopGather.new ### Stop Recording - + ```ruby @@ -993,7 +993,7 @@ stop_recording = Bandwidth::Voice::StopRecording.new() ``` - + ```ruby stop_recording = Bandwidth::Bxml::StopRecording.new @@ -1004,7 +1004,7 @@ stop_recording = Bandwidth::Bxml::StopRecording.new ### Stop Stream - + ```ruby @@ -1014,7 +1014,7 @@ stop_stream = Bandwidth::Voice::StopStream.new({ ``` - + ```ruby stop_stream = Bandwidth::Bxml::StopStream.new({name: 'stop_stream_name'}) @@ -1025,7 +1025,7 @@ stop_stream = Bandwidth::Bxml::StopStream.new({name: 'stop_stream_name'}) ### Tag - + ```ruby @@ -1035,7 +1035,7 @@ tag = Bandwidth::Voice::Tag.new({ ``` - + ```ruby tag = Bandwidth::Bxml::Tag.new('tag_value') @@ -1046,7 +1046,7 @@ tag = Bandwidth::Bxml::Tag.new('tag_value') ### Transfer - + ```ruby @@ -1061,7 +1061,7 @@ transfer = Bandwidth::Voice::Transfer.new({ ``` - + ```ruby transfer_attributes = { @@ -1093,7 +1093,7 @@ transfer = Bandwidth::Bxml::Transfer.new([phone_number, sip_uri], transfer_attri ### Create Call - + ```ruby @@ -1124,7 +1124,7 @@ end ``` - + ```ruby api_instance = Bandwidth::CallsApi.new @@ -1144,7 +1144,7 @@ end ### Get Call Information - + ```ruby @@ -1173,7 +1173,7 @@ end ``` - + ```ruby api_instance = Bandwidth::CallsApi.new @@ -1193,7 +1193,7 @@ end ### Update Call - + ```ruby @@ -1223,7 +1223,7 @@ end ``` - + ```ruby api_instance = Bandwidth::CallsApi.new @@ -1243,7 +1243,7 @@ end ### Replace Call BXML - + ```ruby @@ -1251,7 +1251,7 @@ end ``` - + ```ruby api_instance = Bandwidth::CallsApi.new @@ -1276,7 +1276,7 @@ end ### List Conferences - + ```ruby @@ -1303,7 +1303,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1329,7 +1329,7 @@ end ### Get Conference Information - + ```ruby @@ -1357,7 +1357,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1377,7 +1377,7 @@ end ### Update Conference - + ```ruby @@ -1406,7 +1406,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1426,7 +1426,7 @@ end ### Update Conference BXML - + ```ruby @@ -1434,7 +1434,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1457,7 +1457,7 @@ end ### Get Conference Member - + ```ruby @@ -1485,7 +1485,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1506,7 +1506,7 @@ end ### Update Conference Member - + ```ruby @@ -1536,7 +1536,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1557,7 +1557,7 @@ end ### List Conference Recordings - + ```ruby @@ -1586,7 +1586,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1606,7 +1606,7 @@ end ### Get Conference Recording Information - + ```ruby @@ -1634,7 +1634,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1655,7 +1655,7 @@ end ### Download Conference Recording - + ```ruby @@ -1687,7 +1687,7 @@ end ``` - + ```ruby api_instance = Bandwidth::ConferencesApi.new @@ -1710,7 +1710,7 @@ end ### List Account Call Recordings - + ```ruby @@ -1737,7 +1737,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -1762,7 +1762,7 @@ end ### Update Recording - + ```ruby @@ -1791,7 +1791,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -1811,7 +1811,7 @@ end ### List Call Recordings - + ```ruby @@ -1840,7 +1840,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -1860,7 +1860,7 @@ end ### Get Call Recording - + ```ruby @@ -1888,7 +1888,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -1909,7 +1909,7 @@ end ### Delete Recording - + ```ruby @@ -1936,7 +1936,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -1956,7 +1956,7 @@ end ### Download Recording - + ```ruby @@ -1988,7 +1988,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -2009,7 +2009,7 @@ end ### Delete Recording Media - + ```ruby @@ -2036,7 +2036,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -2056,7 +2056,7 @@ end ### Get Transcription - + ```ruby @@ -2084,7 +2084,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -2105,7 +2105,7 @@ end ### Create Transcription Request - + ```ruby @@ -2135,7 +2135,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -2156,7 +2156,7 @@ end ### Delete Transcription - + ```ruby @@ -2183,7 +2183,7 @@ end ``` - + ```ruby api_instance = Bandwidth::RecordingsApi.new @@ -2205,7 +2205,7 @@ end ### Get Account Statistics - + ```ruby @@ -2213,7 +2213,7 @@ end ``` - + ```ruby api_instance = Bandwidth::StatisticsApi.new @@ -2234,7 +2234,7 @@ end ### Create Lookup - + ```ruby @@ -2266,7 +2266,7 @@ end ``` - + ```ruby api_instance = Bandwidth::PhoneNumberLookupApi.new @@ -2286,7 +2286,7 @@ end ### Get Lookup Request Status - + ```ruby @@ -2317,7 +2317,7 @@ end ``` - + ```ruby api_instance = Bandwidth::PhoneNumberLookupApi.new @@ -2339,7 +2339,7 @@ end ### Voice MFA Code - + ```ruby @@ -2370,7 +2370,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MFAApi.new @@ -2390,7 +2390,7 @@ end ### Messaging MFA Code - + ```ruby @@ -2421,7 +2421,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MFAApi.new @@ -2441,7 +2441,7 @@ end ### Verify MFA Code - + ```ruby @@ -2472,7 +2472,7 @@ end ``` - + ```ruby api_instance = Bandwidth::MFAApi.new diff --git a/site/sidebarsMigrationGuides.js b/site/sidebarsMigrationGuides.js index ab3171f18..5fec2d3b9 100644 --- a/site/sidebarsMigrationGuides.js +++ b/site/sidebarsMigrationGuides.js @@ -26,7 +26,7 @@ module.exports = { label: "Ruby", items: [ "ruby/ruby-migration-guides", - "ruby/v11-beta" + "ruby/v11" ] } ], diff --git a/site/specs/messaging.yml b/site/specs/messaging.yml index de4129a53..6f00b55dd 100644 --- a/site/specs/messaging.yml +++ b/site/specs/messaging.yml @@ -186,24 +186,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Messaging + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" - ) - messaging_client = bandwidth_client.messaging_client.client + api_instance = Bandwidth::MediaApi.new + account_id = '12345' begin - media = messaging_client.list_media("12345") - media.data.each { |item| - puts item.media_name - } - rescue APIException => e - puts e.response_code + result = api_instance.list_media(account_id) + result.each do |item| + p item.media_name + end + rescue Bandwidth::ApiError => e + p "Error when calling MediaApi->list_media: #{e}" end /users/{accountId}/media/{mediaId}: get: @@ -387,24 +386,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - include Bandwidth - include Bandwidth::Messaging - - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" - ) - messaging_client = bandwidth_client.messaging_client.client + api_instance = Bandwidth::MediaApi.new + account_id = '12345' + media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' begin - downloaded_media = messaging_client.get_media("12345", ENV['MEDIA_ID']) - f = File.open("file_to_write", "wb") - f.puts(downloaded_media.data) - f.close() - rescue APIException => e - puts e.response_code + result = api_instance.get_media(account_id, media_id) + f = File.open('file_to_write', 'wb') + f.p(result) + f.close + rescue Bandwidth::ApiError => e + p "Error when calling MediaApi->get_media: #{e}" end put: summary: Upload Media @@ -646,31 +644,26 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Messaging + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" - ) - messaging_client = bandwidth_client.messaging_client.client + api_instance = Bandwidth::MediaApi.new + account_id = '12345' + media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' + body = '12345' + opts = { + content_type: 'application/octet-stream', + cache_control: 'no-cache' + } begin - #f = File.open("some_file", "rb") - #file_content = f.read - file_content = "12345" - messaging_client.upload_media( - "12345", - ENV['MEDIA_ID'], - file_content, - :content_type => "application/octet-stream", - :cache_control => "no-cache" - ) - f.close() - rescue APIException => e - puts e.response_code + api_instance.upload_media(account_id, media_id, body, opts) + rescue Bandwidth::ApiError => e + p "Error when calling MediaApi->upload_media: #{e}" end delete: summary: Delete Media @@ -856,21 +849,21 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Messaging + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" - ) - messaging_client = bandwidth_client.messaging_client.client + api_instance = Bandwidth::MediaApi.new + account_id = '12345' + media_id = '14762070468292kw2fuqty55yp2b2/0/bw.png' begin - messaging_client.delete_media("12345", ENV['MEDIA_ID']) - rescue APIException => e - puts e.response_code + api_instance.delete_media(account_id, media_id) + rescue Bandwidth::ApiError => e + p "Error when calling MediaApi->delete_media: #{e}" end /users/{accountId}/messages: get: @@ -1059,22 +1052,21 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Messaging + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" - ) - messaging_client = bandwidth_client.messaging_client.client + api_instance = Bandwidth::MessagesApi.new + account_id = '12345' begin - result = messaging_client.get_messages("12345", :source_tn => "+15554443333") - puts result.data.total_count - rescue APIException => e - puts e.response_code + result = api_instance.list_messages(account_id) + p result.total_count + rescue Bandwidth::ApiError => e + p "Error when calling MessagesApi->list_messages: #{e}" end post: summary: Create Message @@ -1336,28 +1328,29 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Messaging + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - messaging_basic_auth_user_name: "api-username", - messaging_basic_auth_password: "api-password" + api_instance = Bandwidth::MessagesApi.new + account_id = '12345' + message_request = Bandwidth::MessageRequest.new( + { + application_id: '1234-asdf', + to: ['+15553334444'], + from: '+15554443333', + text: 'Hello world!' + } ) - messaging_client = bandwidth_client.messaging_client.client - body = MessageRequest.new - body.application_id = "1234-asdf" - body.to = ["+15553334444"] - body.from = "+15554443333" - body.text = 'Hey, check this out!' - body.tag = '{"test": "message"}' begin - result = messaging_client.create_message("12345", body) - puts 'messageId: ' + result.data.id - rescue APIException => e - puts e.response_code + result = api_instance.create_message(account_id, message_request) + p "messageId: #{result.id}" + rescue Bandwidth::ApiError => e + p "Error when calling MessagesApi->create_message: #{e}" end components: parameters: diff --git a/site/specs/multi-factor-auth.yml b/site/specs/multi-factor-auth.yml index 27cace8f2..41bde6562 100644 --- a/site/specs/multi-factor-auth.yml +++ b/site/specs/multi-factor-auth.yml @@ -291,29 +291,30 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::MultiFactorAuth + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" + api_instance = Bandwidth::MFAApi.new + account_id = '12345' + code_request = Bandwidth::CodeRequest.new( + { + to: '+15553334444', + from: '+15554443333', + application_id: '1234-qwer', + message: 'Your temporary {NAME} {SCOPE} code is {CODE}', + digits: 6 + } ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - body = TwoFactorCodeRequestSchema.new - body.application_id = "1234-qwer" - body.to = "+15553334444" - body.from = "+15554443333" - body.digits = 6 - body.scope = "scope" - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" begin - result = auth_client.create_voice_two_factor("12345", body) - puts 'callId: ' + result.data.call_id - rescue APIException => e - puts e.response_code + result = api_instance.generate_voice_code(account_id, code_request) + p "callId: #{result.call_id}" + rescue Bandwidth::ApiError => e + p "Error when calling MFAApi->generate_voice_code: #{e}" end /accounts/{accountId}/code/messaging: post: @@ -591,29 +592,30 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::MultiFactorAuth + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" + api_instance = Bandwidth::MFAApi.new + account_id = '12345' + code_request = Bandwidth::CodeRequest.new( + { + to: '+15553334444', + from: '+15554443333', + application_id: '1234-asdf', + message: 'Your temporary {NAME} {SCOPE} code is {CODE}', + digits: 6 + } ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - body = TwoFactorCodeRequestSchema.new - body.application_id = "1234-asdf" - body.to = "+15553334444" - body.from = "+15554443333" - body.digits = 6 - body.scope = "scope" - body.message = "Your temporary {NAME} {SCOPE} code is {CODE}" begin - result = auth_client.create_messaging_two_factor("12345", body) - puts 'messageId: ' + result.data.message_id - rescue APIException => e - puts e.response_code + result = api_instance.generate_messaging_code(account_id, code_request) + p "messageId: #{result.message_id}" + rescue Bandwidth::ApiError => e + p "Error when calling MFAApi->generate_messaging_code: #{e}" end /accounts/{accountId}/code/verify: post: @@ -906,28 +908,28 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::MultiFactorAuth + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - multi_factor_auth_basic_auth_user_name: "api-username", - multi_factor_auth_basic_auth_password: "api-password" + api_instance = Bandwidth::MFAApi.new + account_id = '12345' + verify_code_request = Bandwidth::VerifyCodeRequest.new( + { + to: '+15553334444', + expiration_time_in_minutes: 3, + code: '123456' + } ) - auth_client = bandwidth_client.multi_factor_auth_client.mfa - body = TwoFactorVerifyRequestSchema.new - body.application_id = "1234-qwer" - body.to = "+15553334444" - body.scope = "scope" - body.code = "123456" - body.expiration_time_in_minutes = 3 begin - result = auth_client.create_verify_two_factor("12345", body) - puts 'valid?: ' + result.data.valid - rescue APIException => e - puts e.response_code + result = api_instance.verify_code(account_id, verify_code_request) + p "valid?: #{result.valid}" + rescue Bandwidth::ApiError => e + p "Error when calling MFAApi->verify_code: #{e}" end components: schemas: diff --git a/site/specs/phone-number-lookup.yml b/site/specs/phone-number-lookup.yml index 8f1ee46f9..e55f420de 100644 --- a/site/specs/phone-number-lookup.yml +++ b/site/specs/phone-number-lookup.yml @@ -213,40 +213,28 @@ paths: print(e.response_code) - lang: Ruby source: > - require 'bandwidth' - - include Bandwidth + require 'bandwidth-sdk' - include Bandwidth::Voice - - - BW_USERNAME = "api-username" - - BW_PASSWORD = "api-password" - - BW_ACCOUNT_ID = "12345" - - - bandwidth_client = Bandwidth::Client.new( - phone_number_lookup_basic_auth_user_name: BW_USERNAME, - phone_number_lookup_basic_auth_password: BW_PASSWORD - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - phone_number_lookup_client = - bandwidth_client.phone_number_lookup_client.client + api_instance = Bandwidth::PhoneNumberLookupApi.new - body = OrderRequest.new + account_id = '12345' - body.tns = ["+15554443333"] + lookup_request = Bandwidth::LookupRequest.new({ tns: + ['+15554443333'] }) begin - result = phone_number_lookup_client.create_lookup_request(BW_ACCOUNT_ID, body) - puts result.data.request_id - rescue APIException => e - puts e.response_code + result = api_instance.create_lookup(account_id, lookup_request) + p result.request_id + rescue Bandwidth::ApiError => e + p "Error when calling PhoneNumberLookupApi->create_lookup: #{e}" end /accounts/{accountId}/tnlookup/{requestId}: get: @@ -415,39 +403,23 @@ paths: except APIException as e: print(e.response_code) - lang: Ruby - source: > - require 'bandwidth' - - include Bandwidth - - include Bandwidth::Voice - - - BW_USERNAME = "api-username" - - BW_PASSWORD = "api-password" - - BW_ACCOUNT_ID = "12345" - - - bandwidth_client = Bandwidth::Client.new( - phone_number_lookup_basic_auth_user_name: BW_USERNAME, - phone_number_lookup_basic_auth_password: BW_PASSWORD - ) - - - phone_number_lookup_client = - bandwidth_client.phone_number_lookup_client.client - + source: | + require 'bandwidth-sdk' - request_id = "1234-abcd" + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end + api_instance = Bandwidth::PhoneNumberLookupApi.new + account_id = '12345' + request_id = '004223a0-8b17-41b1-bf81-20732adf5590' begin - result = phone_number_lookup_client.get_lookup_request_status(BW_ACCOUNT_ID, request_id) - puts result.data.status - rescue APIException => e - puts e.response_code + result = api_instance.get_lookup_status(account_id, request_id) + p result.status + rescue Bandwidth::ApiError => e + p "Error when calling PhoneNumberLookupApi->get_lookup_status: #{e}" end components: schemas: diff --git a/site/specs/voice.yml b/site/specs/voice.yml index 7292ea8ff..ca697ef5e 100644 --- a/site/specs/voice.yml +++ b/site/specs/voice.yml @@ -310,29 +310,29 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Voice + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" + api_instance = Bandwidth::CallsApi.new + account_id = '12345' + create_call = Bandwidth::CreateCall.new( + { + to: '+15553334444', + from: '+15554443333', + application_id: '1234-qwer', + answer_url: 'https://sample.com' + } ) - voice_client = bandwidth_client.voice_client.client - - body = CreateCallRequest.new - body.from = "+15554443333" - body.to = "+15553334444" - body.answer_url = "http://www.myapp.com/hello" - body.application_id = "7fc9698a-b04a-468b-9e8f-91238c0d0086" - begin - result = voice_client.create_call("12345", body) - puts result.data.call_id - rescue APIException => e - puts e.response_code + result = api_instance.create_call(account_id, create_call) + p result.call_id + rescue Bandwidth::ApiError => e + p "Error when calling CallsApi->create_call: #{e}" end /accounts/{accountId}/calls/{callId}: get: @@ -525,26 +525,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" + api_instance = Bandwidth::CallsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - #result = voice_client.get_call("12345", call_id) - #puts result.data.state - puts "Method broke" - rescue APIException => e - puts e.response_code + result = api_instance.get_call_state(account_id, call_id) + p result.state + rescue Bandwidth::ApiError => e + p "Error when calling CallsApi->get_call_state: #{e}" end post: tags: @@ -780,28 +776,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client - - body = ModifyCallRequest.new - body.redirect_url = "http://www.myapp.com/new" - body.state = "active" + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" + api_instance = Bandwidth::CallsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + update_call = Bandwidth::UpdateCall.new begin - voice_client.modify_call("12345", call_id, body) - rescue APIException => e - puts e.response_code + api_instance.update_call(account_id, call_id, update_call) + rescue Bandwidth::ApiError => e + p "Error when calling CallsApi->update_call: #{e}" end /accounts/{accountId}/calls/{callId}/bxml: put: @@ -836,6 +826,29 @@ paths: $ref: '#/components/responses/voiceTooManyRequestsError' '500': $ref: '#/components/responses/voiceInternalServerError' + x-codeSamples: + - lang: Ruby + source: | + require 'bandwidth-sdk' + + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end + + api_instance = Bandwidth::CallsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + body = ' + + This is a test sentence. + ' + + begin + api_instance.update_call_bxml(account_id, call_id, body) + rescue Bandwidth::ApiError => e + p "Error when calling CallsApi->update_call_bxml: #{e}" + end /accounts/{accountId}/conferences: get: tags: @@ -1022,25 +1035,25 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + opts = { + min_created_time: '2022-06-21T19:13:21Z', + page_size: 500 + } begin - response = voice_client.get_conferences("12345") - if response.data.length > 0 - puts response.data[0].id - end - rescue APIException => e - puts e.response_code + result = api_instance.list_conferences(account_id, opts) + p result[0].id if result.length.positive? + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->list_conferences: #{e}" end /accounts/{accountId}/conferences/{conferenceId}: get: @@ -1234,25 +1247,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client - - conference_id = "conf-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' begin - response = voice_client.get_conference("12345", conference_id) - print(response.data.name) - rescue APIException => e - puts e.response_code + result = api_instance.get_conference(account_id, conference_id) + p result.name + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->get_conference: #{e}" end post: tags: @@ -1489,27 +1499,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client - - body = ModifyConferenceRequest.new - body.status = StatusEnum::ACTIVE + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - conference_id = "conf-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + update_conference = Bandwidth::UpdateConference.new begin - voice_client.modify_conference("12345", conference_id, body) - rescue APIException => e - puts e.response_code + api_instance.update_conference(account_id, conference_id, update_conference) + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->update_conference: #{e}" end /accounts/{accountId}/conferences/{conferenceId}/bxml: put: @@ -1542,6 +1547,29 @@ paths: $ref: '#/components/responses/voiceTooManyRequestsError' '500': $ref: '#/components/responses/voiceInternalServerError' + x-codeSamples: + - lang: Ruby + source: | + require 'bandwidth-sdk' + + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end + + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + body = ' + + + ' + + begin + api_instance.update_conference_bxml(account_id, conference_id, body) + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->update_conference_bxml: #{e}" + end /accounts/{accountId}/conferences/{conferenceId}/members/{memberId}: get: tags: @@ -1740,26 +1768,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client - - conference_id = "conf-1234" - member_id = "m-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + member_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - response = voice_client.get_conference_member("12345", conference_id, member_id) - puts response.data.member_url - rescue APIException => e - puts e.response_code + result = api_instance.get_conference_member(account_id, conference_id, member_id) + p result.member_url + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->get_conference_member: #{e}" end put: tags: @@ -2002,28 +2027,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + require 'bandwidth-sdk' - voice_client = bandwidth_client.voice_client.client - - body = ConferenceMemberState.new - body.mute = true + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - conference_id = "conf-1234" - call_id = "c-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + member_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + update_conference_member = Bandwidth::UpdateConferenceMember.new begin - voice_client.modify_conference_member("12345", conference_id, call_id, body) - rescue APIException => e - puts e.response_code + api_instance.update_conference_member(account_id, conference_id, member_id, update_conference_member) + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->update_conference_member: #{e}" end /accounts/{accountId}/conferences/{conferenceId}/recordings: get: @@ -2222,27 +2242,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - conference_id = "conf-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' begin - response = voice_client.get_conference_recordings("12345", conference_id) - if response.data.length > 0 - puts response.body[0].name - end - rescue APIException => e - puts e.response_code + result = api_instance.list_conference_recordings(account_id, conference_id) + p result[0].name if result.length.positive? + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->list_conference_recordings: #{e}" end /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}: get: @@ -2442,26 +2457,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - conference_id = "conf-1234" - recording_id = "r-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - response = voice_client.get_conference_recording("12345", conference_id, recording_id) - puts response.body.application_id - rescue APIException => e - puts e.response_code + result = api_instance.get_conference_recording(account_id, conference_id, recording_id) + p result.application_id + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->get_conference_recording: #{e}" end /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media: get: @@ -2659,30 +2671,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: BW_USERNAME, - voice_basic_auth_password: BW_PASSWORD - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client - - conference_id = "conf-1234" - recording_id = "r-1234" + api_instance = Bandwidth::ConferencesApi.new + account_id = '12345' + conference_id = 'conf-fe23a767-a75a5b77-20c5-4cca-b581-cbbf0776eca9' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - result = voice_client.get_download_conference_recording(BW_ACCOUNT_ID, conference_id, recording_id) - downloaded_recording = result.data - rescue APIException => e - puts e.response_code + result = api_instance.download_conference_recording(account_id, conference_id, recording_id) + p result + rescue Bandwidth::ApiError => e + p "Error when calling ConferencesApi->download_conference_recording: #{e}" end /accounts/{accountId}/recordings: get: @@ -2870,25 +2875,25 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + opts = { + to: '%2b19195551234', + from: '%2b19195554321' + } begin - result = voice_client.get_query_call_recordings("12345") - if result.data.length > 0 - puts result.data[0].recording_id - end - rescue APIException => e - puts e.response_code + result = api_instance.list_account_call_recordings(account_id, opts) + p result[0].recording_id if result.length.positive? + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->list_account_call_recordings: #{e}" end /accounts/{accountId}/calls/{callId}/recording: put: @@ -3106,28 +3111,30 @@ paths: except APIException as e: print(e.response_code) - lang: Ruby - source: | - require 'bandwidth' + source: > + require 'bandwidth-sdk' - include Bandwidth - include Bandwidth::Voice - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client - body = ModifyCallRecordingRequest.new - body.state = "paused" + api_instance = Bandwidth::RecordingsApi.new + + account_id = '12345' + + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + + update_call_recording = Bandwidth::UpdateCallRecording.new({ state: + Bandwidth::RecordingStateEnum::PAUSED }) - call_id = "c-1234" begin - voice_client.modify_call_recording_state("12345", call_id, body) - rescue APIException => e - puts e.response_code + api_instance.update_call_recording_state(account_id, call_id, update_call_recording) + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->update_call_recording_state: #{e}" end /accounts/{accountId}/calls/{callId}/recordings: get: @@ -3319,27 +3326,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - voice_client = bandwidth_client.voice_client.client - - call_id = "c-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - response = voice_client.get_call_recordings("12345", call_id) - if response.data.length > 0 - puts response.data[0].media_url - end - rescue APIException => e - puts e.response_code + result = api_instance.list_call_recordings(account_id, call_id) + p result[0].media_url if result.length.positive? + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->list_call_recordings: #{e}" end /accounts/{accountId}/calls/{callId}/recordings/{recordingId}: get: @@ -3532,26 +3534,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - response = voice_client.get_call_recording("12345", call_id, recording_id) - puts response.data.application_id - rescue APIException => e - puts e.response_code + result = api_instance.get_call_recording(account_id, call_id, recording_id) + p result.application_id + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->get_call_recording: #{e}" end delete: tags: @@ -3749,25 +3748,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + require 'bandwidth-sdk' - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - voice_client.delete_recording("12345", call_id, recording_id) - rescue APIException => e - puts e.response_code + api_instance.delete_recording(account_id, call_id, recording_id) + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->delete_recording: #{e}" end /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media: get: @@ -3956,30 +3952,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: BW_USERNAME, - voice_basic_auth_password: BW_PASSWORD - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - result = voice_client.get_download_call_recording(BW_ACCOUNT_ID, call_id, recording_id) - downloaded_recording = result.data - rescue APIException => e - puts e.response_code + result = api_instance.download_call_recording(account_id, call_id, recording_id) + p result + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->download_call_recording: #{e}" end delete: tags: @@ -4169,25 +4158,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - voice_client.delete_recording_media("12345", call_id, recording_id) - rescue APIException => e - print(e.response_code) + api_instance.delete_recording_media(account_id, call_id, recording_id) + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->delete_recording_media: #{e}" end /accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription: get: @@ -4394,26 +4380,23 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice + require 'bandwidth-sdk' - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - response = voice_client.get_call_transcription("12345", call_id, recording_id) - puts response.data.transcripts - rescue APIException => e - puts e.response_code + result = api_instance.get_call_transcription(account_id, call_id, recording_id) + p result.transcripts + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->get_call_transcription: #{e}" end post: tags: @@ -4651,31 +4634,25 @@ paths: except APIException as e: print(e.response_code) - lang: Ruby - source: |+ - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) - - voice_client = bandwidth_client.voice_client.client + source: | + require 'bandwidth-sdk' - call_id = "c-1234" - recording_id = "r-1234" + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - body = TranscribeRecordingRequest.new - body.callback_url = "https://callback-url.com" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + transcribe_recording = Bandwidth::TranscribeRecording.new begin - voice_client.create_transcribe_call_recording("12345", call_id, recording_id, body) - rescue APIException => e - puts e.response_code + api_instance.transcribe_call_recording(account_id, call_id, recording_id, transcribe_recording) + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->transcribe_call_recording: #{e}" end - delete: tags: - Recordings @@ -4870,25 +4847,22 @@ paths: print(e.response_code) - lang: Ruby source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::Voice - - bandwidth_client = Bandwidth::Client.new( - voice_basic_auth_user_name: "api-username", - voice_basic_auth_password: "api-password" - ) + require 'bandwidth-sdk' - voice_client = bandwidth_client.voice_client.client + Bandwidth.configure do |config| + config.username = 'api-username' + config.password = 'api-password' + end - call_id = "c-1234" - recording_id = "r-1234" + api_instance = Bandwidth::RecordingsApi.new + account_id = '12345' + call_id = 'c-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' + recording_id = 'r-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85' begin - voice_client.delete_call_transcription("12345", call_id, recording_id) - rescue APIException => e - puts e.response_code + api_instance.delete_call_transcription(account_id, call_id, recording_id) + rescue Bandwidth::ApiError => e + p "Error when calling RecordingsApi->delete_call_transcription: #{e}" end /accounts/{accountId}/statistics: get: diff --git a/site/specs/webrtc.yml b/site/specs/webrtc.yml index 9be38445f..a18eb766c 100644 --- a/site/specs/webrtc.yml +++ b/site/specs/webrtc.yml @@ -39,175 +39,6 @@ paths: $ref: '#/components/responses/webrtcForbiddenError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants' \ - -X POST \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "callbackUrl": "https://example.com/callback", - "publishPermissions": [ - "VIDEO", - "AUDIO" - ], - "tag": "participant1", - "deviceApiVersion": "V3" - }' - - lang: C# - source: "\uFEFFusing System;\nusing System.Collections.Generic;\nusing System.Threading.Tasks;\nusing Bandwidth.Standard;\nusing Bandwidth.Standard.Exceptions;\nusing Bandwidth.Standard.WebRtc.Models;\n\nclass Program\n{\n static async Task Main(string[] args)\n {\n var username = \"api-username\";\n var password = \"api-pasword\";\n var accountId = \"12345\";\n\n var client = new BandwidthClient.Builder()\n .WebRtcBasicAuthCredentials(username, password)\n .Build();\n\n var participant = new Participant()\n {\n PublishPermissions = new List() { PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO }\n };\n\n try\n {\n var response = await client.WebRtc.APIController.CreateParticipantAsync(accountId, participant);\n Console.WriteLine(response.Data);\n }\n catch (ApiException e)\n {\n Console.WriteLine(e.Message);\n }\n }\n}\n" - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.AccountsParticipantsResponse; - import com.bandwidth.webrtc.models.Participant; - import com.bandwidth.webrtc.models.PublishPermissionEnum; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - import java.util.Arrays; - import java.util.List; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - Participant participant = new Participant(); - List publishPermissions = Arrays.asList(PublishPermissionEnum.AUDIO, PublishPermissionEnum.VIDEO); - participant.setPublishPermissions(publishPermissions); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().createParticipantAsync(ACCOUNT_ID, participant); - } catch (Exception ex) { - System.out.println(ex.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - - const createParticipant = async function() { - try { - const response = await controller.createParticipant(accountId, { - callbackUrl: "http://www.myapp.com/new", - publishPermissions: ["AUDIO"] - }) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - createParticipant(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $body = new BandwidthLib\WebRtc\Models\Participant(); - $body->publishPermissions = array("AUDIO", "VIDEO"); - $body->deviceApiVersion = "V3"; - - try { - $response = $webRtcClient->createParticipant($BW_ACCOUNT_ID, $body); - print_r($response->getResult()->participant->id); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - from bandwidth.webrtc.models.participant import Participant - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Participant() - body.publish_permissions = ["AUDIO", "VIDEO"] - body.device_api_version = "V3" - - try: - response = web_rtc_client.create_participant(BW_ACCOUNT_ID, body) - print(response.body.participant.id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Participant.new - body.publish_permissions = ["AUDIO", "VIDEO"] - body.device_api_version = "V3" - - begin - response = web_rtc_client.create_participant(BW_ACCOUNT_ID, :body => body) - puts response.data.participant.id - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/participants/{participantId}: get: tags: @@ -231,182 +62,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants/320e2af6-13ec-498d-8b51-daba52c37853' - \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: |- - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var participantId = "320e2af6-13ec-498d-8b51-daba52c37853"; - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - var response = await client.WebRtc.APIController.GetParticipantAsync(accountId, participantId); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Participant; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getParticipantAsync(ACCOUNT_ID, participantId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - - const getParticipant = async function() { - try { - const response = await controller.getParticipant(accountId, participantId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - getParticipant(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $participantId = "1234-qwer"; - - try { - $response = $webRtcClient->getParticipant($BW_ACCOUNT_ID, $participantId); - print_r($response->getResult()->id); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - - try: - response = web_rtc_client.get_participant(BW_ACCOUNT_ID, participant_id) - print(response.body.id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - - begin - response = web_rtc_client.get_participant(BW_ACCOUNT_ID, participant_id) - puts response.data.id - rescue APIException => e - puts e.response_code - end delete: tags: - Participants @@ -429,177 +84,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/participants/320e2af6-13ec-498d-8b51-daba52c37853' - \ - -X DELETE \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var participantId = "320e2af6-13ec-498d-8b51-daba52c37853"; - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - await client.WebRtc.APIController.DeleteParticipantAsync(accountId, participantId); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().deleteParticipantAsync(ACCOUNT_ID, participantId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - - const deleteParticipant = async function() { - try { - const response = await controller.deleteParticipant(accountId, participantId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - deleteParticipant(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $participantId = "1234-abcd"; - - try { - $webRtcClient->deleteParticipant($BW_ACCOUNT_ID, $participantId); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - - try: - web_rtc_client.delete_participant(BW_ACCOUNT_ID, participant_id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - - begin - web_rtc_client.delete_participant(BW_ACCOUNT_ID, participant_id) - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/sessions: post: tags: @@ -624,193 +108,6 @@ paths: $ref: '#/components/responses/webrtcForbiddenError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: | - curl 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions' \ - -X POST \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "tag": "session1" - }' - - lang: C# - source: |- - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - var session = new Session() - { - Tag = "new-session" - }; - - try - { - var response = await client.WebRtc.APIController.CreateSessionAsync(accountId, session); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - import com.bandwidth.*; - import com.bandwidth.webrtc.models.*; - import com.bandwidth.http.response.ApiResponse; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - Session session = new Session(); - session.setTag("new-session"); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().createSessionAsync(ACCOUNT_ID, session); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - - const createSession = async function() { - try { - const response = await controller.createSession(accountId, { - tag: '{"SessionName": "my_session"}' - }) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - createSession(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $body = new BandwidthLib\WebRtc\Models\Session(); - $body->tag = "tag"; - - try { - $response = $webRtcClient->createSession($BW_ACCOUNT_ID, $body); - print_r($response->getResult()->id); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - from bandwidth.webrtc.models.session import Session - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Session() - body.tag = "tag" - - try: - response = web_rtc_client.create_session(BW_ACCOUNT_ID, body) - print(response.body.id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Session.new - body.tag = "tag" - - begin - response = web_rtc_client.create_session(BW_ACCOUNT_ID, :body => body) - puts response.data.id - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/sessions/{sessionId}: get: tags: @@ -834,182 +131,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5' - \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - var response = await client.WebRtc.APIController.GetSessionAsync(accountId, sessionId); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Session; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getSessionAsync(ACCOUNT_ID, sessionId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - - const getSession = async function() { - try { - const response = await controller.getSession(accountId, sessionId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - getSession(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $sessionId = "1234-qwer"; - - try { - $response = $webRtcClient->getSession($BW_ACCOUNT_ID, $sessionId); - print_r($response->getResult()->id); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - try: - response = web_rtc_client.get_session(BW_ACCOUNT_ID, session_id) - print(response.body.id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - begin - response = web_rtc_client.get_session(BW_ACCOUNT_ID, session_id) - print(response.data.id) - rescue APIException => e - print(e.response_code) - end delete: tags: - Sessions @@ -1032,178 +153,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5' - \ - -X DELETE \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - await client.WebRtc.APIController.DeleteSessionAsync(accountId, sessionId); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().deleteSessionAsync(ACCOUNT_ID, sessionId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - - const deleteSession = async function() { - try { - const response = await controller.deleteSession(accountId, sessionId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - deleteSession(); - - lang: PHP - source: |+ - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $sessionId = "1234-qwer"; - - try { - $webRtcClient->deleteSession($BW_ACCOUNT_ID, $sessionId); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - try: - web_rtc_client.delete_session(BW_ACCOUNT_ID, session_id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - begin - web_rtc_client.delete_session(BW_ACCOUNT_ID, session_id) - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/sessions/{sessionId}/participants: get: tags: @@ -1229,183 +178,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants' - \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - var response = await client.WebRtc.APIController.ListSessionParticipantsAsync(accountId, sessionId); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Participant; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - import java.util.List; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - try { - CompletableFuture>> completableFuture = client.getWebRtcClient().getAPIController().listSessionParticipantsAsync(ACCOUNT_ID, sessionId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - - const listSessionParticipants = async function() { - try { - const response = await controller.listSessionParticipants(accountId, sessionId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - listSessionParticipants(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $sessionId = "1234-qwer"; - - try { - $response = $webRtcClient->listSessionParticipants($BW_ACCOUNT_ID, $sessionId); - print_r($response->getResult()); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - try: - response = web_rtc_client.list_session_participants(BW_ACCOUNT_ID, session_id) - print(response.body) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - - begin - response = web_rtc_client.list_session_participants(BW_ACCOUNT_ID, session_id) - puts response.end - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/sessions/{sessionId}/participants/{participantId}: put: tags: @@ -1437,219 +209,6 @@ paths: $ref: '#/components/responses/webrtcConflictError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521' - \ - -X PUT \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "sessionId": "d8886aad-b956-4e1b-b2f4-d7c9f8162772", - "participants": [ - { - "participantId": "568749d5-04d5-483d-adf5-deac7dd3d521" - }, - { - "participantId": "0275e47f-dd21-4cf0-a1e1-dfdc719e73a7" - } - ] - }' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using System.Collections.Generic; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - var participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; // Returned via WebRTC's create participant request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - var subscriptions = new Subscriptions() - { - SessionId = sessionId - }; - - try - { - await client.WebRtc.APIController.AddParticipantToSessionAsync(accountId, sessionId, participantId, subscriptions); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Subscriptions; - import com.bandwidth.webrtc.models.ParticipantSubscription; - - import java.util.ArrayList; - import java.util.List; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; // Returned via WebRTC's create participant request. - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - Subscriptions subscriptions = new Subscriptions(); - subscriptions.setSessionId(sessionId); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().addParticipantToSessionAsync(ACCOUNT_ID, sessionId, participantId, subscriptions); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - const subscriptions = { - sessionId: sessionId - }; - - const addParticipantToSession = async function() { - try { - const response = await controller.addParticipantToSession(accountId, sessionId, participantId, subscriptions) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - addParticipantToSession(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $sessionId = "1234-abcd"; - $participantId = "4321-dcba"; - - $body = new BandwidthLib\WebRtc\Models\Subscriptions(); - $body->sessionId = $sessionId; - - try { - $webRtcClient->addParticipantToSession($BW_ACCOUNT_ID, $sessionId, $participantId, $body); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - participant_id = "4321-dcba" - subscriptions = {'sessionId': session_id} - - try: - web_rtc_client.add_participant_to_session(BW_ACCOUNT_ID, session_id, participant_id, subscriptions) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - participant_id = "4321-dcba" - - body = Subscriptions.new - body.session_id = session_id - - begin - web_rtc_client.add_participant_to_session(BW_ACCOUNT_ID, session_id, participant_id, body: body) - rescue APIException => e - puts e.response_code - end delete: tags: - Sessions @@ -1675,184 +234,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521' - \ - -X DELETE \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: |- - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - var participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; // Returned via WebRTC's create participant request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - await client.WebRtc.APIController.RemoveParticipantFromSessionAsync(accountId, sessionId, participantId); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().removeParticipantFromSessionAsync(ACCOUNT_ID, sessionId, participantId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - - const removeParticipantFromSession = async function() { - try { - const response = await controller.removeParticipantFromSession(accountId, sessionId, participantId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - removeParticipantFromSession(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $sessionId = "1234-abcd"; - $participantId = "4321-dcba"; - - try { - $webRtcClient->removeParticipantFromSession($BW_ACCOUNT_ID, $sessionId, $participantId); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - participant_id = "4312-dbca" - - try: - web_rtc_client.remove_participant_from_session(BW_ACCOUNT_ID, session_id, participant_id) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - session_id = "1234-abcd" - participant_id = "4312-dbca" - - begin - web_rtc_client.remove_participant_from_session(BW_ACCOUNT_ID, session_id, participant_id) - rescue APIException => e - puts e.response_code - end /accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions: get: tags: @@ -1879,188 +260,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521/subscriptions' - \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - var participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; // Returned via WebRTC's create participant request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - try - { - var response = await client.WebRtc.APIController.GetParticipantSubscriptionsAsync(accountId, sessionId, participantId); - Console.WriteLine(response.Data); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Subscriptions; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().getParticipantSubscriptionsAsync(ACCOUNT_ID, sessionId, participantId); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - - const getParticipantSubscriptions = async function() { - try { - const response = await controller.getParticipantSubscriptions(accountId, sessionId, participantId) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - getParticipantSubscriptions(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $participantId = "1234-abcd"; - $sessionId = "4321-dcba"; - - try { - $response = $webRtcClient->getParticipantSubscriptions($BW_ACCOUNT_ID, $sessionId, $participantId); - print_r($response->getResult()); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - session_id = "4321-dcba" - - try: - response = web_rtc_client.get_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id) - print(response.body) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: | - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - participant_id = "1234-abcd" - session_id = "4321-dcba" - - begin - response = web_rtc_client.get_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id) - puts response.data - rescue APIException => e - puts e.response_code - end put: tags: - Sessions @@ -2096,224 +295,6 @@ paths: $ref: '#/components/responses/webrtcNotFoundError' '500': $ref: '#/components/responses/webrtcInternalServerError' - x-codeSamples: - - lang: cURL - source: > - curl - 'https://api.webrtc.bandwidth.com/v1/accounts/12345/sessions/75c21163-e110-41bc-bd76-1bb428ec85d5/participants/568749d5-04d5-483d-adf5-deac7dd3d521/subscriptions' - \ - -X PUT \ - -H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \ - -H 'Content-Type: application/json' \ - -d '{ - "sessionId": "d8886aad-b956-4e1b-b2f4-d7c9f8162772", - "participants": [ - { - "participantId": "568749d5-04d5-483d-adf5-deac7dd3d521" - }, - { - "participantId": "0275e47f-dd21-4cf0-a1e1-dfdc719e73a7" - } - ] - }' - - lang: C# - source: | - using System; - using System.Threading.Tasks; - using Bandwidth.Standard; - using Bandwidth.Standard.Exceptions; - using Bandwidth.Standard.WebRtc.Models; - - class Program - { - static async Task Main(string[] args) - { - var username = "api-username"; - var password = "api-pasword"; - var accountId = "12345"; - - var sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; // Returned via WebRTC's create session request. - var participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; // Returned via WebRTC's create participant request. - - var client = new BandwidthClient.Builder() - .WebRtcBasicAuthCredentials(username, password) - .Build(); - - var subscriptions = new Subscriptions() - { - SessionId = sessionId - }; - - try - { - await client.WebRtc.APIController.UpdateParticipantSubscriptionsAsync(accountId, sessionId, participantId, subscriptions); - } - catch (ApiException e) - { - Console.WriteLine(e.Message); - } - } - } - - lang: Java - source: | - import com.bandwidth.BandwidthClient; - import com.bandwidth.http.response.ApiResponse; - import com.bandwidth.webrtc.models.Subscriptions; - - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.ExecutionException; - - public class Sample { - public static final String USERNAME = "api-username"; - public static final String PASSWORD = "api-password"; - public static final String ACCOUNT_ID = "12345"; - - public static void main(String[] args) { - String sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5"; - String participantId = "568749d5-04d5-483d-adf5-deac7dd3d521"; - - BandwidthClient client = new BandwidthClient.Builder() - .webRtcBasicAuthCredentials(USERNAME, PASSWORD) - .build(); - - Subscriptions subscriptions = new Subscriptions(); - subscriptions.setSessionId(sessionId); - - try { - CompletableFuture> completableFuture = client.getWebRtcClient().getAPIController().updateParticipantSubscriptionsAsync(ACCOUNT_ID, sessionId, participantId, subscriptions); - System.out.println(completableFuture.get().getResult()); - } catch (InterruptedException | ExecutionException e) { - System.out.println(e.getMessage()); - } - } - } - - lang: Node.js - source: | - import { Client, ApiController } from '@bandwidth/webrtc'; - - const BW_USERNAME = "api-username"; - const BW_PASSWORD = "api-password"; - const BW_ACCOUNT_ID = "12345"; - - const client = new Client({ - basicAuthUserName: BW_USERNAME, - basicAuthPassword: BW_PASSWORD - }); - - const controller = new ApiController(client); - - const accountId = BW_ACCOUNT_ID; - const sessionId = "75c21163-e110-41bc-bd76-1bb428ec85d5" - const participantId = "320e2af6-13ec-498d-8b51-daba52c37853" - const body = { "sessionId": "75c21163-e110-41bc-bd76-1bb428ec85d5", - "participants": [{ - "participantId": "568749d5-04d5-483d-adf5-deac7dd3d521" - }, { - "participantId": "0275e47f-dd21-4cf0-a1e1-dfdc719e73a7" - }] - } - - const updateParticipantSubscriptions = async function() { - try { - const response = await controller.updateParticipantSubscriptions(accountId, sessionId, participantId, body) - console.log(response.body); - } catch(error) { - console.error(error); - } - } - - updateParticipantSubscriptions(); - - lang: PHP - source: | - $BW_USERNAME, - 'webRtcBasicAuthPassword' => $BW_PASSWORD, - ) - ); - $client = new BandwidthLib\BandwidthClient($config); - - $webRtcClient = $client->getWebRtc()->getClient(); - - $body = new BandwidthLib\WebRtc\Models\Subscriptions(); - $body->sessionId = "1234-abcd"; - - $sessionId = "1234-abcd"; - $participantId = "4321-dcba"; - - try { - $webRtcClient->updateParticipantSubscriptions($BW_ACCOUNT_ID, $sessionId, $participantId, $body); - } catch (BandwidthLib\APIException $e) { - print_r($e->getResponseCode()); - } - - lang: Python - source: | - from bandwidth.bandwidth_client import BandwidthClient - from bandwidth.exceptions.api_exception import APIException - from bandwidth.webrtc.models.subscriptions import Subscriptions - - import os - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = BandwidthClient( - web_rtc_basic_auth_user_name=BW_USERNAME, - web_rtc_basic_auth_password=BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Subscriptions() - body.session_id = "1234-abcd" - - session_id = "1234-abcd" - participant_id = "4321-dcba" - - try: - web_rtc_client.update_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id, body) - except APIException as e: - print(e.response_code) - - lang: Ruby - source: |+ - require 'bandwidth' - - include Bandwidth - include Bandwidth::WebRtc - - BW_USERNAME = "api-username" - BW_PASSWORD = "api-password" - BW_ACCOUNT_ID = "12345" - - bandwidth_client = Bandwidth::Client.new( - web_rtc_basic_auth_user_name: BW_USERNAME, - web_rtc_basic_auth_password: BW_PASSWORD - ) - - web_rtc_client = bandwidth_client.web_rtc_client.client - - body = Subscriptions.new - body.session_id = "1234-abcd" - - session_id = "1234-abcd" - participant_id = "4321-dcba" - - begin - web_rtc_client.update_participant_subscriptions(BW_ACCOUNT_ID, session_id, participant_id, :body => body) - #NOTE: This is currently improperly defined - rescue APIException => e - puts e.response_code - end - components: schemas: publishPermissionsEnum: