Skip to content

Commit e670685

Browse files
authored
DX-1814 new readme (#19)
* Update README.md * Added links and version * Numbers are hard
1 parent 66a9ec9 commit e670685

File tree

1 file changed

+89
-12
lines changed

1 file changed

+89
-12
lines changed

README.md

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,42 @@
11
# Bandwidth Ruby SDK
2-
3-
Bandwidth's API docs can be found at https://dev.bandwidth.com
42

5-
Ruby specific docs can be found at https://dev.bandwidth.com/sdks/ruby.html
3+
## Getting Started
64

7-
## Download & Install
5+
### Installation
86

97
```
108
gem install bandwidth-sdk
119
```
1210

13-
## Initialize Bandwidth Client
11+
### Initialize
1412

1513
```ruby
1614
require 'bandwidth'
1715

1816
include Bandwidth
1917
include Bandwidth::Voice
2018
include Bandwidth::Messaging
19+
include Bandwidth::WebRtc
20+
include Bandwidth::TwoFactorAuth
2121

2222
bandwidth_client = Bandwidth::Client.new(
2323
voice_basic_auth_user_name: 'username',
2424
voice_basic_auth_password: 'password',
25-
messaging_basic_auth_user_name: 'token',
26-
messaging_basic_auth_password: 'secret',
25+
messaging_basic_auth_user_name: 'username',
26+
messaging_basic_auth_password: 'username',
27+
two_factor_auth_basic_auth_user_name: 'username',
28+
two_factor_auth_basic_auth_password: 'password',
29+
web_rtc_basic_auth_user_name: 'username',
30+
web_rtc_basic_auth_password: 'password'
2731
)
32+
account_id = "12345"
2833
```
2934

30-
## Create Phone Call
35+
### Create Phone Call
3136

3237
```ruby
3338
voice_client = bandwidth_client.voice_client.client
3439

35-
account_id = '1'
3640
body = ApiCreateCallRequest.new
3741
body.from = '+16666666666'
3842
body.to = '+17777777777'
@@ -49,7 +53,7 @@ rescue Bandwidth::ErrorResponseException => e
4953
end
5054
```
5155

52-
## Generate BXML
56+
### Generate BXML
5357

5458
```ruby
5559
response = Bandwidth::Voice::Response.new()
@@ -59,12 +63,11 @@ response.push(hangup)
5963
puts response.to_bxml()
6064
```
6165

62-
## Send Text Message
66+
### Send Text Message
6367

6468
```ruby
6569
messaging_client = bandwidth_client.messaging_client.client
6670

67-
account_id = '1'
6871
body = MessageRequest.new
6972
body.application_id = '1-2-3'
7073
body.to = ['+17777777777']
@@ -83,3 +86,77 @@ rescue Bandwidth::PathClientException => e
8386
puts e.response_code #400
8487
end
8588
```
89+
90+
### Create A MFA Request
91+
92+
```ruby
93+
auth_client = bandwidth_client.two_factor_auth_client.mfa
94+
95+
from_phone = "+18888888888"
96+
to_phone = "+17777777777"
97+
messaging_application_id = "1-d-b"
98+
scope = "scope"
99+
digits = 6
100+
101+
body = TwoFactorCodeRequestSchema.new
102+
body.from = from_phone
103+
body.to = to_phone
104+
body.application_id = messaging_application_id
105+
body.scope = scope
106+
body.digits = digits
107+
body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
108+
109+
auth_client.create_messaging_two_factor(account_id, body)
110+
111+
code = "123456" #This is the user input to validate
112+
113+
body = TwoFactorVerifyRequestSchema.new
114+
body.from = from_phone
115+
body.to = to_phone
116+
body.application_id = application_id
117+
body.scope = scope
118+
body.code = code
119+
body.digits = digits
120+
body.expiration_time_in_minutes = 3
121+
122+
response = auth_client.create_verify_two_factor(account_id, body)
123+
puts "Auth status: " + response.data.valid.to_s
124+
```
125+
126+
### WebRtc Participant & Session Management
127+
128+
```ruby
129+
web_rtc_client = bandwidth_client.web_rtc_client.client
130+
131+
create_session_body = Session.new
132+
create_session_body.tag = 'new-session'
133+
134+
create_session_response = web_rtc_client.create_session(account_id, :body => create_session_body)
135+
session_id = create_session_response.data.id
136+
puts session_id
137+
138+
create_participant_body = Participant.new
139+
create_participant_body.publish_permissions = [
140+
PublishPermissionEnum::AUDIO,
141+
PublishPermissionEnum::VIDEO
142+
]
143+
create_participant_body.callback_url = "https://sample.com"
144+
145+
create_participant_response = web_rtc_client.create_participant(account_id, :body => create_participant_body)
146+
participant_id = create_participant_response.data.participant.id
147+
puts participant_id
148+
149+
web_rtc_client.add_participant_to_session(account_id, session_id, participant_id)
150+
```
151+
152+
## Supported Ruby Versions
153+
154+
This package can be used with Ruby >= 2.0
155+
156+
## Documentation
157+
158+
Documentation for this package can be found at https://dev.bandwidth.com/sdks/ruby.html
159+
160+
## Credentials
161+
162+
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html

0 commit comments

Comments
 (0)