Package ai.rev.topicextraction
Class TopicExtractionClient
- java.lang.Object
-
- ai.rev.topicextraction.TopicExtractionClient
-
public class TopicExtractionClient extends Object
The TopicExtractionClient object provides methods to send and retrieve information from all the Rev AI Topic Extraction API endpoints using the Retrofit HTTP client.
-
-
Field Summary
Fields Modifier and Type Field Description TopicExtractionInterfaceapiInterfaceInterface that TopicExtractionClient methods use to make requests
-
Constructor Summary
Constructors Constructor Description TopicExtractionClient(String accessToken)Constructs the API client used to send HTTP requests to Rev AI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseConnection()Manually closes the connection when the code is running in a JVMvoiddeleteJob(String id)This method sends a DELETE request to the /jobs/{id} endpoint.TopicExtractionJobgetJobDetails(String id)This method sends a GET request to the /jobs/{id} endpoint and returns aTopicExtractionJobobject.List<TopicExtractionJob>getListOfJobs()Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.List<TopicExtractionJob>getListOfJobs(Integer limit)Overload ofgetListOfJobs(Integer, String)without the optional startingAfter parameter.List<TopicExtractionJob>getListOfJobs(Integer limit, String startingAfter)This method sends a GET request to the /jobs endpoint and returns a list ofTopicExtractionJobobjects.List<TopicExtractionJob>getListOfJobs(String startingAfter)Overload ofgetListOfJobs(Integer, String)without the optional limit parameter.TopicExtractionResultgetResultObject(String id)The method sends a GET request to the /jobs/{id}/result endpoint and returns aTopicExtractionResultobject.TopicExtractionResultgetResultObject(String id, Double threshold)The method sends a GET request to the /jobs/{id}/result endpoint and returns aTopicExtractionResultobject.TopicExtractionJobsubmitJobJson(RevAiTranscript json)An overload ofsubmitJobText(String, TopicExtractionJobOptions)without the additional topic extraction options.TopicExtractionJobsubmitJobJson(RevAiTranscript json, TopicExtractionJobOptions options)The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the provided RevAiTranscript and returns aTopicExtractionJobobject.TopicExtractionJobsubmitJobText(String text)An overload ofsubmitJobText(String, TopicExtractionJobOptions)without the additional topic extraction options.TopicExtractionJobsubmitJobText(String text, TopicExtractionJobOptions options)The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the provided text and returns aTopicExtractionJobobject.
-
-
-
Field Detail
-
apiInterface
public TopicExtractionInterface apiInterface
Interface that TopicExtractionClient methods use to make requests
-
-
Constructor Detail
-
TopicExtractionClient
public TopicExtractionClient(String accessToken)
Constructs the API client used to send HTTP requests to Rev AI. The user access token can be generated on the website at https://www.rev.ai/access_token.- Parameters:
accessToken- Rev AI authorization token associate with the account.- Throws:
IllegalArgumentException- If the access token is null or empty.
-
-
Method Detail
-
closeConnection
public void closeConnection()
Manually closes the connection when the code is running in a JVM
-
getListOfJobs
public List<TopicExtractionJob> getListOfJobs(Integer limit, String startingAfter) throws IOException
This method sends a GET request to the /jobs endpoint and returns a list ofTopicExtractionJobobjects.- Parameters:
limit- The maximum number of jobs to return. The default is 100, max is 1000.startingAfter- The job ID at which the list begins.- Returns:
- A list of
TopicExtractionJobobjects. - Throws:
IOException- If the response has a status code > 399.- See Also:
TopicExtractionJob, https://docs.rev.ai/api/topic-extraction/reference/#operation/GetListOfTopicExtractionJobs
-
getListOfJobs
public List<TopicExtractionJob> getListOfJobs(Integer limit) throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional startingAfter parameter.- Parameters:
limit- The maximum number of jobs to return. The default is 100, max is 1000.- Returns:
- A list of
TopicExtractionJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<TopicExtractionJob> getListOfJobs(String startingAfter) throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional limit parameter.- Parameters:
startingAfter- The job ID at which the list begins.- Returns:
- A list of
TopicExtractionJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<TopicExtractionJob> getListOfJobs() throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.- Returns:
- A list of
TopicExtractionJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getJobDetails
public TopicExtractionJob getJobDetails(String id) throws IOException
This method sends a GET request to the /jobs/{id} endpoint and returns aTopicExtractionJobobject.- Parameters:
id- The ID of the job to return an object for.- Returns:
- A
TopicExtractionJobobject. - Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the job ID is null.
-
deleteJob
public void deleteJob(String id) throws IOException
This method sends a DELETE request to the /jobs/{id} endpoint.- Parameters:
id- The Id of the job to be deleted.- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- If the job ID is null.- See Also:
- https://docs.rev.ai/api/topic-extraction/reference/#operation/DeleteTopicExtractionJobById
-
getResultObject
public TopicExtractionResult getResultObject(String id, Double threshold) throws IOException
The method sends a GET request to the /jobs/{id}/result endpoint and returns aTopicExtractionResultobject.- Parameters:
id- The ID of the job to return a result for.- Returns:
- TopicExtractionResult The result object.
- Throws:
IOException- If the response has a status code > 399.- See Also:
TopicExtractionResult
-
getResultObject
public TopicExtractionResult getResultObject(String id) throws IOException
The method sends a GET request to the /jobs/{id}/result endpoint and returns aTopicExtractionResultobject.- Parameters:
id- The ID of the job to return a result for.- Returns:
- TopicExtractionResult The result object.
- Throws:
IOException- If the response has a status code > 399.- See Also:
TopicExtractionResult
-
submitJobText
public TopicExtractionJob submitJobText(String text, TopicExtractionJobOptions options) throws IOException
The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the provided text and returns aTopicExtractionJobobject.- Parameters:
text- Text to have topics extracted from it.options- The topic extraction options associated with this job.- Returns:
- TopicExtractionJob A representation of the topic extraction job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the text is null.- See Also:
TopicExtractionJob, https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob
-
submitJobText
public TopicExtractionJob submitJobText(String text) throws IOException
An overload ofsubmitJobText(String, TopicExtractionJobOptions)without the additional topic extraction options.- Parameters:
text- Text to have topics extracted from it.- Returns:
- TopicExtractionJob A representation of the topic extraction job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the text is null.- See Also:
TopicExtractionJob,submitJobText(String, TopicExtractionJobOptions)
-
submitJobJson
public TopicExtractionJob submitJobJson(RevAiTranscript json, TopicExtractionJobOptions options) throws IOException
The method sends a POST request to the /jobs endpoint, starts a topic extraction job for the provided RevAiTranscript and returns aTopicExtractionJobobject.- Parameters:
json- RevAiTranscript to submit for topic extractionoptions- The topic extraction options associated with this job.- Returns:
- TopicExtractionJob A representation of the topic extraction job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the json is null.- See Also:
TopicExtractionJob, https://docs.rev.ai/api/topic-extraction/reference/#operation/SubmitTopicExtractionJob
-
submitJobJson
public TopicExtractionJob submitJobJson(RevAiTranscript json) throws IOException
An overload ofsubmitJobText(String, TopicExtractionJobOptions)without the additional topic extraction options.- Parameters:
json- RevAiTranscript to submit for topic extraction- Returns:
- TopicExtractionJob A representation of the topic extraction job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the json is null.- See Also:
TopicExtractionJob,submitJobJson(RevAiTranscript, TopicExtractionJobOptions)
-
-