Skip to content

Commit 31a0c5a

Browse files
AISDK-190: Update sdks to support notification_config and source_config (#46)
1 parent 3dd0183 commit 31a0c5a

File tree

8 files changed

+123
-19
lines changed

8 files changed

+123
-19
lines changed

src/main/java/ai/rev/helpers/ClientHelper.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package ai.rev.helpers;
22

3-
import ai.rev.helpers.ApiInterceptor;
4-
import ai.rev.helpers.ErrorInterceptor;
53
import okhttp3.OkHttpClient;
64
import retrofit2.Retrofit;
75
import retrofit2.converter.gson.GsonConverterFactory;

src/main/java/ai/rev/sentimentanalysis/SentimentAnalysisClient.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package ai.rev.sentimentanalysis;
22

33
import ai.rev.helpers.ClientHelper;
4-
import ai.rev.speechtotext.ApiClient;
5-
import ai.rev.speechtotext.models.asynchronous.RevAiJob;
6-
import ai.rev.speechtotext.models.asynchronous.RevAiJobOptions;
74
import ai.rev.sentimentanalysis.models.Sentiment;
85
import ai.rev.sentimentanalysis.models.SentimentAnalysisJob;
96
import ai.rev.sentimentanalysis.models.SentimentAnalysisJobOptions;

src/main/java/ai/rev/sentimentanalysis/models/SentimentAnalysisJobOptions.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package ai.rev.sentimentanalysis.models;
22

3+
import ai.rev.speechtotext.models.CustomerUrlData;
34
import ai.rev.speechtotext.models.asynchronous.RevAiTranscript;
4-
55
import com.google.gson.annotations.SerializedName;
66

7+
import java.util.Map;
8+
79
/**
810
* A SentimentAnalysisJobOptions object represents parameters that are submitted along a new job.
911
*
@@ -24,11 +26,17 @@ public class SentimentAnalysisJobOptions {
2426
private RevAiTranscript json;
2527

2628
/**
27-
* The callback url that Rev AI will send a POST to when the job has finished.
29+
* The callback url that Rev AI will send a POST to when the job has finished.
30+
* @deprecated Use notification_config instead
2831
*/
2932
@SerializedName("callback_url")
33+
@Deprecated
3034
private String callbackUrl;
31-
35+
36+
/** Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */
37+
@SerializedName("notification_config")
38+
private CustomerUrlData notificationConfig;
39+
3240
/**
3341
* Optional information that can be provided.
3442
*/
@@ -81,7 +89,9 @@ public void setJson(RevAiTranscript json) {
8189
* Returns the callback url.
8290
*
8391
* @return the callback url.
92+
* @deprecated Use notificationConfig and getNotificationConfig instead
8493
*/
94+
@Deprecated
8595
public String getCallbackUrl() {
8696
return callbackUrl;
8797
}
@@ -91,11 +101,41 @@ public String getCallbackUrl() {
91101
* property is optional.
92102
*
93103
* @param callbackUrl The url to POST to when job processing is complete.
104+
* @deprecated Use setNotificationConfig instead
94105
*/
106+
@Deprecated
95107
public void setCallbackUrl(String callbackUrl) {
96108
this.callbackUrl = callbackUrl;
97109
}
98-
110+
111+
/**
112+
* Returns the notification config object.
113+
*
114+
* @return the notification config.
115+
*/
116+
public CustomerUrlData getNotificationConfig() {
117+
return notificationConfig;
118+
}
119+
120+
/**
121+
* Optional property to specify the callback url that Rev AI will POST to when job processing is complete
122+
*
123+
* @param callbackUrl The url to POST to when job processing is complete.
124+
* @param authHeaders Optional parameter to authenticate access to the callback url
125+
*/
126+
public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) {
127+
this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders);
128+
}
129+
130+
/**
131+
* Optional property to specify the callback url that Rev AI will POST to when job processing is complete
132+
*
133+
* @param callbackUrl The url to POST to when job processing is complete.
134+
*/
135+
public void setNotificationConfig(String callbackUrl) {
136+
setNotificationConfig(callbackUrl, null);
137+
}
138+
99139
/**
100140
* Returns the metadata.
101141
*

src/main/java/ai/rev/speechtotext/models/asynchronous/RevAiJobOptions.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public class RevAiJobOptions {
131131
* @return The media url.
132132
* @deprecated Set sourceConfig and use getSourceConfig instead
133133
*/
134+
@Deprecated
134135
public String getMediaUrl() {
135136
return mediaUrl;
136137
}
@@ -141,6 +142,7 @@ public String getMediaUrl() {
141142
* @param mediaUrl The direct download url to the file.
142143
* @deprecated Use setSourceConfig instead
143144
*/
145+
@Deprecated
144146
public void setMediaUrl(String mediaUrl) {
145147
this.mediaUrl = mediaUrl;
146148
}
@@ -180,8 +182,9 @@ public void setSourceConfig(String sourceMediaUrl) {
180182
* Returns the callback url.
181183
*
182184
* @return the callback url.
183-
* @deprecated Set the notificationConfig option with setNotificationConfig, then use getNotificationConfig instead
185+
* @deprecated Use notificationConfig and getNotificationConfig instead
184186
*/
187+
@Deprecated
185188
public String getCallbackUrl() {
186189
return callbackUrl;
187190
}
@@ -193,6 +196,7 @@ public String getCallbackUrl() {
193196
* @param callbackUrl The url to POST to when job processing is complete.
194197
* @deprecated Use setNotificationConfig instead
195198
*/
199+
@Deprecated
196200
public void setCallbackUrl(String callbackUrl) {
197201
this.callbackUrl = callbackUrl;
198202
}

src/main/java/ai/rev/topicextraction/TopicExtractionClient.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package ai.rev.topicextraction;
22

33
import ai.rev.helpers.ClientHelper;
4-
import ai.rev.speechtotext.ApiClient;
5-
import ai.rev.speechtotext.models.asynchronous.RevAiJob;
6-
import ai.rev.speechtotext.models.asynchronous.RevAiJobOptions;
74
import ai.rev.topicextraction.models.TopicExtractionJob;
85
import ai.rev.topicextraction.models.TopicExtractionJobOptions;
96
import ai.rev.topicextraction.models.TopicExtractionResult;

src/main/java/ai/rev/topicextraction/models/TopicExtractionJobOptions.java

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package ai.rev.topicextraction.models;
22

3+
import ai.rev.speechtotext.models.CustomerUrlData;
34
import ai.rev.speechtotext.models.asynchronous.RevAiTranscript;
4-
55
import com.google.gson.annotations.SerializedName;
66

7+
import java.util.Map;
8+
79
/**
810
* A TopicExtractionJobOptions object represents parameters that are submitted along a new job.
911
*
@@ -22,12 +24,18 @@ public class TopicExtractionJobOptions {
2224
*/
2325
@SerializedName("json")
2426
private RevAiTranscript json;
25-
26-
/**
27-
* The callback url that Rev AI will send a POST to when the job has finished.
27+
28+
/**
29+
* The callback url that Rev AI will send a POST to when the job has finished.
30+
* @deprecated Use notification_config instead
2831
*/
2932
@SerializedName("callback_url")
33+
@Deprecated
3034
private String callbackUrl;
35+
36+
/** Object containing information on the callback url that Rev AI will send a POST to when the job has finished. */
37+
@SerializedName("notification_config")
38+
private CustomerUrlData notificationConfig;
3139

3240
/**
3341
* Optional information that can be provided.
@@ -76,12 +84,14 @@ public RevAiTranscript getJson() {
7684
public void setJson(RevAiTranscript json) {
7785
this.json = json;
7886
}
79-
87+
8088
/**
8189
* Returns the callback url.
8290
*
8391
* @return the callback url.
92+
* @deprecated Use notificationConfig and getNotificationConfig instead
8493
*/
94+
@Deprecated
8595
public String getCallbackUrl() {
8696
return callbackUrl;
8797
}
@@ -91,10 +101,40 @@ public String getCallbackUrl() {
91101
* property is optional.
92102
*
93103
* @param callbackUrl The url to POST to when job processing is complete.
104+
* @deprecated Use setNotificationConfig instead
94105
*/
106+
@Deprecated
95107
public void setCallbackUrl(String callbackUrl) {
96108
this.callbackUrl = callbackUrl;
97109
}
110+
111+
/**
112+
* Returns the notification config object.
113+
*
114+
* @return the notification config.
115+
*/
116+
public CustomerUrlData getNotificationConfig() {
117+
return notificationConfig;
118+
}
119+
120+
/**
121+
* Optional property to specify the callback url that Rev AI will POST to when job processing is complete
122+
*
123+
* @param callbackUrl The url to POST to when job processing is complete.
124+
* @param authHeaders Optional parameter to authenticate access to the callback url
125+
*/
126+
public void setNotificationConfig(String callbackUrl, Map<String, String> authHeaders) {
127+
this.notificationConfig = new CustomerUrlData(callbackUrl, authHeaders);
128+
}
129+
130+
/**
131+
* Optional property to specify the callback url that Rev AI will POST to when job processing is complete
132+
*
133+
* @param callbackUrl The url to POST to when job processing is complete.
134+
*/
135+
public void setNotificationConfig(String callbackUrl) {
136+
setNotificationConfig(callbackUrl, null);
137+
}
98138

99139
/**
100140
* Returns the metadata.

src/test/java/ai/rev/sentimentanalysis/integration/SubmitJobTest.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class SubmitJobTest {
2727
(new Gson()).fromJson(
2828
getFileContents(Paths.get("./src/test/java/ai/rev/sentimentanalysis/resources/sample.json")),
2929
RevAiTranscript.class);
30+
private final String CALLBACK_URL = "https://example.com";
3031
private static SentimentAnalysisClient apiClient;
3132

3233
@Rule public TestName testName = new TestName();
@@ -46,6 +47,19 @@ public void SubmitJobText_TextAndOptionsSpecified_ReturnsJobInProgress()
4647
assertSentimentAnalysisJob(job);
4748
}
4849

50+
@Test
51+
public void SubmitJobText_TextAndOptionsWithNotificationConfig_ReturnsJobInProgress()
52+
throws IOException {
53+
SentimentAnalysisJobOptions jobOptions = getJobOptions();
54+
jobOptions.setCallbackUrl(null);
55+
jobOptions.setNotificationConfig(CALLBACK_URL);
56+
57+
SentimentAnalysisJob job = apiClient.submitJobText(TEXT_SOURCE, jobOptions);
58+
59+
assertSentimentAnalysisJob(job);
60+
assert job.getCallbackUrl() == null;
61+
}
62+
4963
@Test
5064
public void SubmitJobText_OnlyTextIsSpecified_ReturnsJobInProgress()
5165
throws IOException {
@@ -81,7 +95,7 @@ public void assertSentimentAnalysisJob(SentimentAnalysisJob job) {
8195
private SentimentAnalysisJobOptions getJobOptions() {
8296
SentimentAnalysisJobOptions revAiJobOptions = new SentimentAnalysisJobOptions();
8397
revAiJobOptions.setMetadata(testName.getMethodName());
84-
revAiJobOptions.setCallbackUrl("https://example.com");
98+
revAiJobOptions.setCallbackUrl(CALLBACK_URL);
8599
revAiJobOptions.setDeleteAfterSeconds(0);
86100
return revAiJobOptions;
87101
}

src/test/java/ai/rev/topicextraction/integration/SubmitJobTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class SubmitJobTest {
2727
(new Gson()).fromJson(
2828
getFileContents(Paths.get("./src/test/java/ai/rev/topicextraction/resources/sample.json")),
2929
RevAiTranscript.class);
30+
private final String CALLBACK_URL ="https://example.com";
3031
private static TopicExtractionClient apiClient;
3132

3233
@Rule public TestName testName = new TestName();
@@ -46,6 +47,19 @@ public void SubmitJobText_TextAndOptionsSpecified_ReturnsJobInProgress()
4647
assertTopicExtractionJob(job);
4748
}
4849

50+
@Test
51+
public void SubmitJobText_TextAndOptionsWithNotificationConfig_ReturnsJobInProgress()
52+
throws IOException {
53+
TopicExtractionJobOptions jobOptions = getJobOptions();
54+
jobOptions.setCallbackUrl(null);
55+
jobOptions.setNotificationConfig(CALLBACK_URL);
56+
57+
TopicExtractionJob job = apiClient.submitJobText(TEXT_SOURCE, jobOptions);
58+
59+
assertTopicExtractionJob(job);
60+
assert job.getCallbackUrl() == null;
61+
}
62+
4963
@Test
5064
public void SubmitJobText_OnlyTextIsSpecified_ReturnsJobInProgress()
5165
throws IOException {

0 commit comments

Comments
 (0)