public class WWClient extends Object implements Serializable, IWWClient
IWWClient.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
|
Space |
createSpace(String title)
Easy helper method to create a Space with a title
|
Space |
createSpace(String title,
List<String> members)
Easy helper method to create a Space with a title and list of Members
|
Space |
createSpaceWithQuery(SpaceCreateGraphQLMutation mutationObject)
Easy helper method to create a Space with a SpaceCreateGraphQLMutation object
|
boolean |
deleteSpace(String id)
Easy helper method to delete a Space
|
String |
getAppCredentials()
Converts appId and appSecret into required content for Authorization header
|
IWWClient.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
|
ArrayList<String> |
updateSpaceMembers(String id,
List<String> members,
SpaceUpdateGraphQLMutation.UpdateSpaceMemberOperation addOrRemove)
Easy helper method for updating a Space members returning List of member IDs updated
|
UpdateSpaceContainer |
updateSpaceMembersAndTitle(String id,
String title,
List<String> members,
SpaceUpdateGraphQLMutation.UpdateSpaceMemberOperation addOrRemove)
Easy helper method for updationg a Space members and title, returning UpdateSpaceContainer with array of member IDs updated and Space object with updated title
|
Space |
updateSpaceTitle(String id,
String newTitle)
Easy helper method for updating a Space Title returning Space object with updated Title
|
UpdateSpaceContainer |
updateSpaceWithMutation(SpaceUpdateGraphQLMutation mutationObject)
Easy helper method for updating a Space Title / members / both returning an UpdateSpaceContainer with updated Space details / updated members / both
|
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 IWWClient.ClientType getClientType()
IWWClient
getClientType
in interface IWWClient
IWWClient.ClientType.USER
or IWWClient.ClientType.APPLICATON
public String getAppCredentials() throws UnsupportedEncodingException
IWWClient
getAppCredentials
in interface IWWClient
UnsupportedEncodingException
- if the encoding option is not supportedpublic boolean isAuthenticated()
IWWClient
IWWClient.authenticate()
firstisAuthenticated
in interface IWWClient
public void authenticate() throws UnsupportedEncodingException, WWException
IWWClient
authenticate
in interface IWWClient
UnsupportedEncodingException
- Authorization header could not be constructedWWException
- Some other error occurred during authenticationpublic String getJWTToken()
IWWClient
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"getJWTToken
in interface IWWClient
public Object getExpiresIn()
IWWClient
AuthenticationResult
getExpiresIn
in interface IWWClient
public boolean isValid()
IWWClient
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 createSpace(String title, List<String> members) throws WWException
title
- String title for the Spacemembers
- List of member IDs to be granted access to the SpaceWWException
- containing an error message, if the request was unsuccessfulpublic Space createSpace(String title) throws WWException
title
- String title for the SpaceWWException
- containing an error message, if the request was unsuccessfulpublic Space createSpaceWithQuery(SpaceCreateGraphQLMutation mutationObject) throws WWException
mutationObject
- SpaceCreateGraphQLMutation containing the details to createWWException
- containing an error message, if the request was unsuccessfulpublic boolean deleteSpace(String id) throws WWException
id
- String id for the SpaceWWException
- containing an error message, if the request was unsuccessfulpublic Space updateSpaceTitle(String id, String newTitle) throws WWException
id
- String id of the Space to updatenewTitle
- String new title for the spaceWWException
- containing an error message, if the request was unsuccessfulpublic UpdateSpaceContainer updateSpaceWithMutation(SpaceUpdateGraphQLMutation mutationObject) throws WWException
mutationObject
- SpaceUpdateGraphQLMutation containing the details to updateWWException
- containing an error message, if the request was unsuccessfulpublic ArrayList<String> updateSpaceMembers(String id, List<String> members, SpaceUpdateGraphQLMutation.UpdateSpaceMemberOperation addOrRemove) throws WWException
id
- String id of the space to updatemembers
- List of member IDs to add / remove as membersaddOrRemove
- boolean whether members should be added to the Space or removedWWException
- containing an error message, if the request was unsuccessfulpublic UpdateSpaceContainer updateSpaceMembersAndTitle(String id, String title, List<String> members, SpaceUpdateGraphQLMutation.UpdateSpaceMemberOperation addOrRemove) throws WWException
id
- String id for the Space to updatetitle
- String title of the newly-created Spacemembers
- List of member IDs to add / remove as membersaddOrRemove
- UpdateSpaceMemberOperation enum whether members should be added to the Space or removedWWException
- 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.