| OS | Ruby |
|---|---|
| Windows 2016 | 2.6, 2.7, 3.0 |
| Windows 2019 | 2.6, 2.7, 3.0 |
| Ubuntu 18.04 | 2.6, 2.7, 3.0 |
| Ubuntu 20.04 | 2.6, 2.7, 3.0 |
gem install bandwidth-sdk
require'bandwidth'includeBandwidthincludeBandwidth::VoiceincludeBandwidth::MessagingincludeBandwidth::WebRtcincludeBandwidth::TwoFactorAuthbandwidth_client=Bandwidth::Client.new(voice_basic_auth_user_name: 'username',voice_basic_auth_password: 'password',messaging_basic_auth_user_name: 'username',messaging_basic_auth_password: 'username',two_factor_auth_basic_auth_user_name: 'username',two_factor_auth_basic_auth_password: 'password',web_rtc_basic_auth_user_name: 'username',web_rtc_basic_auth_password: 'password')account_id="12345"voice_client=bandwidth_client.voice_client.clientbody=ApiCreateCallRequest.newbody.from='+16666666666'body.to='+17777777777'body.answer_url='https://test.com'body.application_id='3-d-4-b-5'beginresponse=voice_client.create_call(account_id,:body=>body)putsresponse.data.call_id#c-d45a41e5-bcb12581-b18e-4bdc-9874-6r3235dfweaoputsresponse.status_code#201rescueBandwidth::ErrorResponseException=>eputse.description#Invalid to: must be an E164 telephone numberputse.response_code#400endresponse=Bandwidth::Voice::Response.new()hangup=Bandwidth::Voice::Hangup.new()response.push(hangup)putsresponse.to_bxml()messaging_client=bandwidth_client.messaging_client.clientbody=MessageRequest.newbody.application_id='1-2-3'body.to=['+17777777777']body.from='+18888888888'body.text='Hello from Bandwidth'beginresponse=messaging_client.create_message(account_id,body)putsresponse.data.id#1570740275373xbn7mbhsfewasdrputsresponse.status_code#202rescueBandwidth::GenericClientException=>eputse.description#Access is deniedputse.response_code#403rescueBandwidth::PathClientException=>eputse.message#Your request could not be accepted.putse.response_code#400endauth_client=bandwidth_client.two_factor_auth_client.mfafrom_phone="+18888888888"to_phone="+17777777777"messaging_application_id="1-d-b"scope="scope"digits=6body=TwoFactorCodeRequestSchema.newbody.from=from_phonebody.to=to_phonebody.application_id=messaging_application_idbody.scope=scopebody.digits=digitsbody.message="Your temporary {NAME} {SCOPE} code is {CODE}"auth_client.create_messaging_two_factor(account_id,body)code="123456"#This is the user input to validatebody=TwoFactorVerifyRequestSchema.newbody.from=from_phonebody.to=to_phonebody.application_id=application_idbody.scope=scopebody.code=codebody.digits=digitsbody.expiration_time_in_minutes=3response=auth_client.create_verify_two_factor(account_id,body)puts"Auth status: " + response.data.valid.to_sweb_rtc_client=bandwidth_client.web_rtc_client.clientcreate_session_body=Session.newcreate_session_body.tag='new-session'create_session_response=web_rtc_client.create_session(account_id,:body=>create_session_body)session_id=create_session_response.data.idputssession_idcreate_participant_body=Participant.newcreate_participant_body.publish_permissions=[PublishPermissionEnum::AUDIO,PublishPermissionEnum::VIDEO]create_participant_body.callback_url="https://sample.com"create_participant_response=web_rtc_client.create_participant(account_id,:body=>create_participant_body)participant_id=create_participant_response.data.participant.idputsparticipant_idweb_rtc_client.add_participant_to_session(account_id,session_id,participant_id)This package can be used with Ruby >= 2.0
Documentation for this package can be found at https://dev.bandwidth.com/sdks/ruby.html
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html