Package ai.rev.sentimentanalysis
Class SentimentAnalysisClient
- java.lang.Object
-
- ai.rev.sentimentanalysis.SentimentAnalysisClient
-
public class SentimentAnalysisClient extends Object
The SentimentAnalysisClient object provides methods to send and retrieve information from all the Rev AI Sentiment Analysis API endpoints using the Retrofit HTTP client.
-
-
Field Summary
Fields Modifier and Type Field Description SentimentAnalysisInterfaceapiInterfaceInterface that SentimentAnalysisClient methods use to make requests
-
Constructor Summary
Constructors Constructor Description SentimentAnalysisClient(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.SentimentAnalysisJobgetJobDetails(String id)This method sends a GET request to the /jobs/{id} endpoint and returns aSentimentAnalysisJobobject.List<SentimentAnalysisJob>getListOfJobs()Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.List<SentimentAnalysisJob>getListOfJobs(Integer limit)Overload ofgetListOfJobs(Integer, String)without the optional startingAfter parameter.List<SentimentAnalysisJob>getListOfJobs(Integer limit, String startingAfter)This method sends a GET request to the /jobs endpoint and returns a list ofSentimentAnalysisJobobjects.List<SentimentAnalysisJob>getListOfJobs(String startingAfter)Overload ofgetListOfJobs(Integer, String)without the optional limit parameter.SentimentAnalysisResultgetResultObject(String id)The method sends a GET request to the /jobs/{id}/result endpoint and returns aSentimentAnalysisResultobject.SentimentAnalysisResultgetResultObject(String id, Sentiment filterFor)The method sends a GET request to the /jobs/{id}/result endpoint and returns aSentimentAnalysisResultobject.SentimentAnalysisJobsubmitJobJson(RevAiTranscript json)An overload ofsubmitJobText(String, SentimentAnalysisJobOptions)without the additional sentiment analysis options.SentimentAnalysisJobsubmitJobJson(RevAiTranscript json, SentimentAnalysisJobOptions options)The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the provided RevAiTranscript and returns aSentimentAnalysisJobobject.SentimentAnalysisJobsubmitJobText(String text)An overload ofsubmitJobText(String, SentimentAnalysisJobOptions)without the additional sentiment analysis options.SentimentAnalysisJobsubmitJobText(String text, SentimentAnalysisJobOptions options)The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the provided text and returns aSentimentAnalysisJobobject.
-
-
-
Field Detail
-
apiInterface
public SentimentAnalysisInterface apiInterface
Interface that SentimentAnalysisClient methods use to make requests
-
-
Constructor Detail
-
SentimentAnalysisClient
public SentimentAnalysisClient(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<SentimentAnalysisJob> getListOfJobs(Integer limit, String startingAfter) throws IOException
This method sends a GET request to the /jobs endpoint and returns a list ofSentimentAnalysisJobobjects.- 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
SentimentAnalysisJobobjects. - Throws:
IOException- If the response has a status code > 399.- See Also:
SentimentAnalysisJob, https://docs.rev.ai/api/sentiment-analysis/reference/#operation/GetListOfSentimentAnalysisJobs
-
getListOfJobs
public List<SentimentAnalysisJob> 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
SentimentAnalysisJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<SentimentAnalysisJob> 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
SentimentAnalysisJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getListOfJobs
public List<SentimentAnalysisJob> getListOfJobs() throws IOException
Overload ofgetListOfJobs(Integer, String)without the optional limit and startingAfter parameter.- Returns:
- A list of
SentimentAnalysisJobobjects. - Throws:
IOException- If the response has a status code > 399.
-
getJobDetails
public SentimentAnalysisJob getJobDetails(String id) throws IOException
This method sends a GET request to the /jobs/{id} endpoint and returns aSentimentAnalysisJobobject.- Parameters:
id- The ID of the job to return an object for.- Returns:
- A
SentimentAnalysisJobobject. - 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/sentiment-analysis/reference/#operation/DeleteSentimentAnalysisJobById
-
getResultObject
public SentimentAnalysisResult getResultObject(String id, Sentiment filterFor) throws IOException
The method sends a GET request to the /jobs/{id}/result endpoint and returns aSentimentAnalysisResultobject.- Parameters:
id- The ID of the job to return a result for.- Returns:
- SentimentAnalysisResult The result object.
- Throws:
IOException- If the response has a status code > 399.- See Also:
SentimentAnalysisResult
-
getResultObject
public SentimentAnalysisResult getResultObject(String id) throws IOException
The method sends a GET request to the /jobs/{id}/result endpoint and returns aSentimentAnalysisResultobject.- Parameters:
id- The ID of the job to return a result for.- Returns:
- SentimentAnalysisResult The result object.
- Throws:
IOException- If the response has a status code > 399.- See Also:
SentimentAnalysisResult
-
submitJobText
public SentimentAnalysisJob submitJobText(String text, SentimentAnalysisJobOptions options) throws IOException
The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the provided text and returns aSentimentAnalysisJobobject.- Parameters:
text- Text to have sentiments detected on it.options- The sentiment analysis options associated with this job.- Returns:
- SentimentAnalysisJob A representation of the sentiment analysis job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the text is null.- See Also:
SentimentAnalysisJob, https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob
-
submitJobText
public SentimentAnalysisJob submitJobText(String text) throws IOException
An overload ofsubmitJobText(String, SentimentAnalysisJobOptions)without the additional sentiment analysis options.- Parameters:
text- Text to have sentiments detected on it.- Returns:
- SentimentAnalysisJob A representation of the sentiment analysis job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the text is null.- See Also:
SentimentAnalysisJob,submitJobText(String, SentimentAnalysisJobOptions)
-
submitJobJson
public SentimentAnalysisJob submitJobJson(RevAiTranscript json, SentimentAnalysisJobOptions options) throws IOException
The method sends a POST request to the /jobs endpoint, starts a sentiment analysis job for the provided RevAiTranscript and returns aSentimentAnalysisJobobject.- Parameters:
json- RevAiTranscript to submit for sentiment analysisoptions- The sentiment analysis options associated with this job.- Returns:
- SentimentAnalysisJob A representation of the sentiment analysis job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the json is null.- See Also:
SentimentAnalysisJob, https://docs.rev.ai/api/sentiment-analysis/reference/#operation/SubmitSentimentAnalysisJob
-
submitJobJson
public SentimentAnalysisJob submitJobJson(RevAiTranscript json) throws IOException
An overload ofsubmitJobText(String, SentimentAnalysisJobOptions)without the additional sentiment analysis options.- Parameters:
json- RevAiTranscript to submit for sentiment analysis- Returns:
- SentimentAnalysisJob A representation of the sentiment analysis job.
- Throws:
IOException- If the response has a status code > 399.IllegalArgumentException- if the json is null.- See Also:
SentimentAnalysisJob,submitJobJson(RevAiTranscript, SentimentAnalysisJobOptions)
-
-