public class WWClient extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
WWClient.ClientType |
Constructor and Description |
---|
WWClient() |
Modifier and Type | Method and Description |
---|---|
void |
authenticate()
Attempt authentication of the WWClient
|
static WWClient |
buildClientApplicationAccess(String appId,
String appSecret,
AuthenticationEndpoint authenticationEndpoint)
Creates an application-level WWClient, not associated with a specific user
|
static WWClient |
buildClientUserAccess(String userToken,
String appId,
String appSecret,
AuthenticationEndpoint authenticationEndpoint,
String redirectTo)
Creates and returns a WWClient for a specific user
|
String |
getAppCredentials()
Converts appId and appSecret into required content for Authorization header
|
WWClient.ClientType |
getClientType()
Getter for ClientType, dependent upon the initialiser user
|
Conversation |
getConversationById(String conversationId)
Easy helper method to get a Conversation and its details by a conversation id
|
Conversation |
getConversationWithQuery(ConversationGraphQLQuery query)
Easy helper method to get a Conversation and its details with a query
|
Object |
getExpiresIn()
Gets the length of time until the token expires from the
AuthenticationResult |
String |
getJWTToken()
Gets JWT token for the user / application from the
AuthenticationResult . |
Person |
getMe()
Easy helper method to get My Person object.
|
Message |
getMessageById(String messageId)
Easy helper method to get a Message and its details by id
|
Message |
getMessageWithQuery(MessageGraphQLQuery query)
Easy helper method to get a Message and its details with a query
|
List<Person> |
getPeople(List<String> ids)
Easy helper method to get Person objects with ids
|
List<Person> |
getPeopleByName(String name)
Easy helper method to get Person objects with part of a name
|
List<Person> |
getPeopleWithQuery(PeopleGraphQLQuery query)
Easy helper method to get Person objects with a query
|
Person |
getPersonByEmail(String personEmail)
Easy helper method to get a Person with a person email.
|
Person |
getPersonById(String personId)
Easy helper method to get a Person with a person id.
|
Person |
getPersonWithQuery(PersonGraphQLQuery query)
Easy helper method to get a Person with a query
|
Space |
getSpaceById(String spaceId)
Easy helper method to get a Space by a Space id
|
List<Person> |
getSpaceMembersById(String spaceId)
Easy helper method to get members for a space with the space id
|
List<Person> |
getSpaceMembersWithQuery(SpaceMembersGraphQLQuery query)
Easy helper method to get members of space with a query
|
List<? extends Space> |
getSpaces()
Easy helper method to get spaces from the WWClient
|
List<? extends Space> |
getSpacesWithQuery(SpacesGraphQLQuery query)
Easy helper method to get Spaces with a query
|
Space |
getSpaceWithQuery(SpaceGraphQLQuery query)
Easy helper method to get a Space by using a SpaceGraphQLQuery
|
boolean |
isAuthenticated()
Whether or not authentication has successfully occurred.
|
boolean |
isValid()
Tests whether the
AuthenticationResult is valid |
MessageResponse |
postMessageToSpace(AppMessage message,
String spaceId)
Easy helper method to post a Application Message to a Space
|
public static WWClient buildClientUserAccess(String userToken, String appId, String appSecret, AuthenticationEndpoint authenticationEndpoint, String redirectTo)
userToken
- String, the JWT user token to be passed, used to authenticate as the specific userappId
- String, the ID for the application the code is being run fromappSecret
- String, the secret for the application the code is being run fromauthenticationEndpoint
- AuthenticationEndpoint
or any sub-class thereof. Typically WWAuthenticationEndpoint
redirectTo
- String, URL to redirect to after authenticationpublic static WWClient buildClientApplicationAccess(String appId, String appSecret, AuthenticationEndpoint authenticationEndpoint)
appId
- String, the ID for the application the code is being run fromappSecret
- String, the secret for the application the code is being run fromauthenticationEndpoint
- AuthenticationEndpoint
or any sub-class thereof. Typically WWAuthenticationEndpoint
public WWClient.ClientType getClientType()
WWClient.ClientType.USER
or WWClient.ClientType.APPLICATON
public String getAppCredentials() throws UnsupportedEncodingException
UnsupportedEncodingException
- if the encoding option is not supportedpublic boolean isAuthenticated()
authenticate()
firstpublic void authenticate() throws UnsupportedEncodingException, WWException
UnsupportedEncodingException
- Authorization header could not be constructedWWException
- Some other error occurred during authenticationpublic String getJWTToken()
AuthenticationResult
. The JWT token is an expiring token associated with the appId and appSecret. From the documentation: "This JWT
token is what you have to use in your App to pass to Watson Work Services on API calls so that you can use its services securely"public Object getExpiresIn()
AuthenticationResult
public boolean isValid()
AuthenticationResult
is validpublic List<? extends Space> getSpaces() throws WWException
WWException
- containing an error message, if the request was unsuccessfulpublic List<? extends Space> getSpacesWithQuery(SpacesGraphQLQuery query) throws WWException
query
- SpacesGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic Space getSpaceById(String spaceId) throws WWException
spaceId
- id of the SpaceWWException
- containing an error message, if the request was unsuccessfulpublic Space getSpaceWithQuery(SpaceGraphQLQuery query) throws WWException
query
- SpaceGraphQLQuery for the callWWException
- containing an error message, if the request was unsuccessfulpublic Conversation getConversationById(String conversationId) throws WWException
conversationId
- String id of the conversationWWException
- containing an error message, if the request was unsuccessfulpublic Conversation getConversationWithQuery(ConversationGraphQLQuery query) throws WWException
query
- ConversationGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic Message getMessageById(String messageId) throws WWException
messageId
- String id of the MessageWWException
- containing an error message, if the request was unsuccessfulpublic Message getMessageWithQuery(MessageGraphQLQuery query) throws WWException
query
- MessageGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic Person getPersonById(String personId) throws WWException
personId
- String id of the personWWException
- containing an error message, if the request was unsuccessfulpublic Person getPersonByEmail(String personEmail) throws WWException
personEmail
- String email of the personWWException
- containing an error message, if the request was unsuccessfulpublic Person getPersonWithQuery(PersonGraphQLQuery query) throws WWException
query
- PersonGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic List<Person> getSpaceMembersById(String spaceId) throws WWException
spaceId
- String id of the spaceWWException
- containing an error message, if the request was unsuccessfulpublic List<Person> getSpaceMembersWithQuery(SpaceMembersGraphQLQuery query) throws WWException
query
- SpaceMembersGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic Person getMe() throws WWException
WWException
- containing an error message, if the request was unsuccessfulpublic List<Person> getPeople(List<String> ids) throws WWException
ids
- List of String person idsWWException
- containing an error message, if the request was unsuccessfulpublic List<Person> getPeopleByName(String name) throws WWException
name
- String part of a name. This needs to be a single wordWWException
- containing an error message, if the request was unsuccessfulpublic List<Person> getPeopleWithQuery(PeopleGraphQLQuery query) throws WWException
query
- PeopleGraphQLQuery containing query parametersWWException
- containing an error message, if the request was unsuccessfulpublic MessageResponse postMessageToSpace(AppMessage message, String spaceId) throws WWException
message
- Application Message (use AppMessageBuilder) to postspaceId
- ID of the Space, where the message should be postedWWException
- contains an error message, if the post was unsuccessfulCopyright © 2017 OpenNTF. All rights reserved.