Skip to content

Commit 20a947d

Browse files
authored
DX-2778 Ubuntu Version (#77)
* DX-2778 Ubuntu Version * readme
1 parent 3a361d5 commit 20a947d

File tree

2 files changed

+180
-180
lines changed

2 files changed

+180
-180
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [windows-2022, windows-2019, ubuntu-18.04, ubuntu-20.04]
18+
os: [windows-2022, windows-2019, ubuntu-20.04, ubuntu-22.04]
1919
java-version: ['8', '11']
2020
distribution: ['zulu', 'temurin']
2121
steps:
2222
- name: Checkout
23-
uses: actions/checkout@v2
23+
uses: actions/checkout@v3
2424

2525
- name: Set up JDK
26-
uses: actions/setup-java@v2
26+
uses: actions/setup-java@v3
2727
with:
2828
distribution: ${{ matrix.distribution }}
2929
java-version: ${{ matrix.java-version }}

README.md

Lines changed: 177 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -1,177 +1,177 @@
1-
# Bandwidth Java SDK
2-
3-
[![Test](https://github.com/Bandwidth/java-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Bandwidth/java-sdk/actions/workflows/test.yml)
4-
5-
| **OS** | **Java** | **Distribution** |
6-
|:---:|:---:|:---:|
7-
| Windows 2016 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
8-
| Windows 2019 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
9-
| Ubuntu 18.04 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
10-
| Ubuntu 20.04 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
11-
## Getting Started
12-
13-
### Installation
14-
15-
Add the following dependency to your `pom.xml` file
16-
17-
```xml
18-
19-
<!-- https://mvnrepository.com/artifact/com.bandwidth.sdk/bandwidth-sdk -->
20-
<dependency>
21-
<groupId>com.bandwidth.sdk</groupId>
22-
<artifactId>bandwidth-sdk</artifactId>
23-
<version>{version}</version>
24-
</dependency>
25-
26-
```
27-
28-
### Initialize
29-
30-
```java
31-
32-
BandwidthClient client = new BandwidthClient.Builder()
33-
.messagingBasicAuthCredentials("username", "password")
34-
.voiceBasicAuthCredentials("username", "password")
35-
.twoFactorAuthBasicAuthCredentials("username", "password")
36-
.webRtcBasicAuthCredentials("username", "password")
37-
.build();
38-
String accountId = "12345";
39-
40-
```
41-
42-
### Create A Phone Call
43-
44-
```java
45-
46-
com.bandwidth.voice.controllers.APIController voiceController = client.getVoiceClient().getAPIController();
47-
48-
String to = "+15554443333";
49-
String from = "+15553334444";
50-
String applicationId = "3-a-b-c";
51-
String answerUrl = "https://sample.com";
52-
53-
ApiCreateCallRequest body = new ApiCreateCallRequest();
54-
body.setTo(to);
55-
body.setFrom(from);
56-
body.setApplicationId(applicationId);
57-
body.setAnswerUrl(answerUrl);
58-
59-
ApiResponse<ApiCallResponse> createCallResponse = voiceController.createCall(accountId, body);
60-
System.out.println(createCallResponse.getResult().getCallId());
61-
62-
```
63-
64-
### Send A Text Message
65-
66-
```java
67-
68-
String to = "+15554443333";
69-
ArrayList<String> toNumbers = new ArrayList<String>();
70-
toNumbers.add(to);
71-
String from = "+15553334444";
72-
String applicationId = "3-a-b-d";
73-
String text = "Hello from Java";
74-
75-
MessageRequest body = new MessageRequest();
76-
body.setTo(toNumbers);
77-
body.setFrom(from);
78-
body.setText(text);
79-
body.setApplicationId(applicationId);
80-
81-
ApiResponse<BandwidthMessage> createMessageResponse = messagingController.createMessage(accountId, body);
82-
System.out.println(createMessageResponse.getResult().getMessageId());
83-
84-
```
85-
86-
### Create BXML
87-
88-
```java
89-
90-
SpeakSentence speakSentence = SpeakSentence.builder()
91-
.text("Hello world")
92-
.voice("susan")
93-
.gender("female")
94-
.locale("en_US")
95-
.build();
96-
97-
String response = new Response()
98-
.add(speakSentence)
99-
.toBXML();
100-
System.out.println(response);
101-
102-
```
103-
104-
### Create A MFA Request
105-
106-
```java
107-
108-
String to = "+15554443333";
109-
String from = "+15553334444";
110-
String applicationId = "3-a-c-b");
111-
String scope = "scope";
112-
int digits = 6;
113-
String message = "Your temporary {NAME} {SCOPE} code is {CODE}";
114-
115-
TwoFactorCodeRequestSchema body = new TwoFactorCodeRequestSchema();
116-
body.setTo(to);
117-
body.setFrom(from);
118-
body.setApplicationId(applicationId);
119-
body.setScope(scope);
120-
body.setDigits(digits);
121-
body.setMessage(message);
122-
123-
mfaController.createVoiceTwoFactor(accountId, body);
124-
125-
String code = "123456"; //this is the user code to verify
126-
int expirationTimeInMinutes = 3;
127-
128-
TwoFactorVerifyRequestSchema body = new TwoFactorVerifyRequestSchema();
129-
body.setTo(to);
130-
body.setApplicationId(applicationId);
131-
body.setScope(scope);
132-
body.setCode(code);
133-
body.setExpirationTimeInMinutes(expirationTimeInMinutes);
134-
135-
ApiResponse<TwoFactorVerifyCodeResponse> response = mfaController.createVerifyTwoFactor(accountId, body);
136-
System.out.println(response.getResult().getValid());
137-
138-
```
139-
140-
### WebRtc Participant & Session Management
141-
142-
```java
143-
144-
Session createSessionBody = new Session();
145-
createSessionBody.setTag("new-session");
146-
147-
ApiResponse<Session> createSessionResponse = webrtcController.createSession(accountId, createSessionBody);
148-
String sessionId = createSessionResponse.getResult().getId();
149-
150-
Participant createParticipantBody = new Participant();
151-
createParticipantBody.setCallbackUrl("https://sample.com");
152-
ArrayList<PublishPermissionEnum> publishPermissions = new ArrayList<PublishPermissionEnum>();
153-
publishPermissions.add(PublishPermissionEnum.AUDIO);
154-
publishPermissions.add(PublishPermissionEnum.VIDEO);
155-
156-
ApiResponse<AccountsParticipantsResponse> createParticipantResponse = webrtcController.createParticipant(accountId, createParticipantBody);
157-
String participantId = createParticipantResponse.getResult().getParticipant().getId();
158-
159-
List<ParticipantSubscription> participantSubscriptions = new ArrayList<>();
160-
participantSubscriptions.add(new ParticipantSubscription(participantId));
161-
162-
webrtcController.addParticipantToSession(accountId, sessionId, participantId, new Subscriptions(sessionId, participantSubscriptions));
163-
164-
```
165-
166-
## Supported Java Versions
167-
168-
This package can be used with Java >= 1.8
169-
170-
## Documentation
171-
172-
Documentation for this package can be found at https://dev.bandwidth.com/sdks/java
173-
174-
## Credentials
175-
176-
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html
177-
1+
# Bandwidth Java SDK
2+
3+
[![Test](https://github.com/Bandwidth/java-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Bandwidth/java-sdk/actions/workflows/test.yml)
4+
5+
| **OS** | **Java** | **Distribution** |
6+
|:---:|:---:|:---:|
7+
| Windows 2016 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
8+
| Windows 2019 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
9+
| Ubuntu 20.04 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
10+
| Ubuntu 22.04 | 8, 11 | Zulu OpenJDK, Eclipse Temurin |
11+
## Getting Started
12+
13+
### Installation
14+
15+
Add the following dependency to your `pom.xml` file
16+
17+
```xml
18+
19+
<!-- https://mvnrepository.com/artifact/com.bandwidth.sdk/bandwidth-sdk -->
20+
<dependency>
21+
<groupId>com.bandwidth.sdk</groupId>
22+
<artifactId>bandwidth-sdk</artifactId>
23+
<version>{version}</version>
24+
</dependency>
25+
26+
```
27+
28+
### Initialize
29+
30+
```java
31+
32+
BandwidthClient client = new BandwidthClient.Builder()
33+
.messagingBasicAuthCredentials("username", "password")
34+
.voiceBasicAuthCredentials("username", "password")
35+
.twoFactorAuthBasicAuthCredentials("username", "password")
36+
.webRtcBasicAuthCredentials("username", "password")
37+
.build();
38+
String accountId = "12345";
39+
40+
```
41+
42+
### Create A Phone Call
43+
44+
```java
45+
46+
com.bandwidth.voice.controllers.APIController voiceController = client.getVoiceClient().getAPIController();
47+
48+
String to = "+15554443333";
49+
String from = "+15553334444";
50+
String applicationId = "3-a-b-c";
51+
String answerUrl = "https://sample.com";
52+
53+
ApiCreateCallRequest body = new ApiCreateCallRequest();
54+
body.setTo(to);
55+
body.setFrom(from);
56+
body.setApplicationId(applicationId);
57+
body.setAnswerUrl(answerUrl);
58+
59+
ApiResponse<ApiCallResponse> createCallResponse = voiceController.createCall(accountId, body);
60+
System.out.println(createCallResponse.getResult().getCallId());
61+
62+
```
63+
64+
### Send A Text Message
65+
66+
```java
67+
68+
String to = "+15554443333";
69+
ArrayList<String> toNumbers = new ArrayList<String>();
70+
toNumbers.add(to);
71+
String from = "+15553334444";
72+
String applicationId = "3-a-b-d";
73+
String text = "Hello from Java";
74+
75+
MessageRequest body = new MessageRequest();
76+
body.setTo(toNumbers);
77+
body.setFrom(from);
78+
body.setText(text);
79+
body.setApplicationId(applicationId);
80+
81+
ApiResponse<BandwidthMessage> createMessageResponse = messagingController.createMessage(accountId, body);
82+
System.out.println(createMessageResponse.getResult().getMessageId());
83+
84+
```
85+
86+
### Create BXML
87+
88+
```java
89+
90+
SpeakSentence speakSentence = SpeakSentence.builder()
91+
.text("Hello world")
92+
.voice("susan")
93+
.gender("female")
94+
.locale("en_US")
95+
.build();
96+
97+
String response = new Response()
98+
.add(speakSentence)
99+
.toBXML();
100+
System.out.println(response);
101+
102+
```
103+
104+
### Create A MFA Request
105+
106+
```java
107+
108+
String to = "+15554443333";
109+
String from = "+15553334444";
110+
String applicationId = "3-a-c-b");
111+
String scope = "scope";
112+
int digits = 6;
113+
String message = "Your temporary {NAME} {SCOPE} code is {CODE}";
114+
115+
TwoFactorCodeRequestSchema body = new TwoFactorCodeRequestSchema();
116+
body.setTo(to);
117+
body.setFrom(from);
118+
body.setApplicationId(applicationId);
119+
body.setScope(scope);
120+
body.setDigits(digits);
121+
body.setMessage(message);
122+
123+
mfaController.createVoiceTwoFactor(accountId, body);
124+
125+
String code = "123456"; //this is the user code to verify
126+
int expirationTimeInMinutes = 3;
127+
128+
TwoFactorVerifyRequestSchema body = new TwoFactorVerifyRequestSchema();
129+
body.setTo(to);
130+
body.setApplicationId(applicationId);
131+
body.setScope(scope);
132+
body.setCode(code);
133+
body.setExpirationTimeInMinutes(expirationTimeInMinutes);
134+
135+
ApiResponse<TwoFactorVerifyCodeResponse> response = mfaController.createVerifyTwoFactor(accountId, body);
136+
System.out.println(response.getResult().getValid());
137+
138+
```
139+
140+
### WebRtc Participant & Session Management
141+
142+
```java
143+
144+
Session createSessionBody = new Session();
145+
createSessionBody.setTag("new-session");
146+
147+
ApiResponse<Session> createSessionResponse = webrtcController.createSession(accountId, createSessionBody);
148+
String sessionId = createSessionResponse.getResult().getId();
149+
150+
Participant createParticipantBody = new Participant();
151+
createParticipantBody.setCallbackUrl("https://sample.com");
152+
ArrayList<PublishPermissionEnum> publishPermissions = new ArrayList<PublishPermissionEnum>();
153+
publishPermissions.add(PublishPermissionEnum.AUDIO);
154+
publishPermissions.add(PublishPermissionEnum.VIDEO);
155+
156+
ApiResponse<AccountsParticipantsResponse> createParticipantResponse = webrtcController.createParticipant(accountId, createParticipantBody);
157+
String participantId = createParticipantResponse.getResult().getParticipant().getId();
158+
159+
List<ParticipantSubscription> participantSubscriptions = new ArrayList<>();
160+
participantSubscriptions.add(new ParticipantSubscription(participantId));
161+
162+
webrtcController.addParticipantToSession(accountId, sessionId, participantId, new Subscriptions(sessionId, participantSubscriptions));
163+
164+
```
165+
166+
## Supported Java Versions
167+
168+
This package can be used with Java >= 1.8
169+
170+
## Documentation
171+
172+
Documentation for this package can be found at https://dev.bandwidth.com/sdks/java
173+
174+
## Credentials
175+
176+
Information for credentials for this package can be found at https://dev.bandwidth.com/guides/accountCredentials.html
177+

0 commit comments

Comments
 (0)