Package net.worcade.client
Interface Worcade
-
- All Known Implementing Classes:
WorcadeClient
@CheckReturnValue public interface Worcade
Entry point to the Worcade API client library. Create a Worcade client using thebuilder()method
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static WorcadeBuilderbuilder()Creates aWorcadeBuilderinstance from a registered service provider.voidclose()Closes all resources used by this client.WorcadecopyWithSameAuth()Creates a copy of this client which uses the same internal client instance.ExternalNumbercreateExternalNumber(String number, String description)RemoteIdcreateRemoteId(String remoteIdType, String remoteId)Create a remote id object for use withRemoteIdsApimethodsWebhook.HeadercreateWebhookHeader(String name, String value)WorkOrder.RowcreateWorkOrderRow(String name, Duration duration, Double cost, Currency currency)ApplicationApigetApplicationApi()AssetApigetAssetApi()AttachmentApigetAttachmentApi()Result<? extends Authentication>getAuthentication()Get information about the currently authenticated application and/or user, and the company and groups they are members ofChecklistApigetChecklistApi()CompanyApigetCompanyApi()ContactsApigetContactsApi()ConversationApigetConversationApi()GroupApigetGroupApi()LabelApigetLabelApi()Result<? extends Collection<? extends Notification>>getNotifications()ReclaimApigetReclaimApi()RoomApigetRoomApi()SearchApigetSearchApi()SiteApigetSiteApi()UserApigetUserApi()WebhookApigetWebhookApi()WorkOrderApigetWorkOrderApi()Result<ReferenceWithName>loginApplication(String applicationId, PrivateKey applicationPrivateKey, PublicKey worcadePublicKey)Login an application.Result<ReferenceWithName>loginUserByEmail(String email, String password)Login a user by email address.Result<ReferenceWithName>loginUserById(String userId, String password)Login a user by id.Result<?>logoutApplication()Logout the current logged in user, invalidating the session token.Result<?>logoutUser()Logout the current logged in user, invalidating the session token.Result<Boolean>probeUserTrust(String userId, String applicationId)Checks if the given user trusts the given application.Result<ReferenceWithName>setApplicationApiKey(String apiKey)Result<ReferenceWithName>setApplicationSourceAuth(String id)Result<? extends Authentication>setTrustedUser(Reference user)Set a trusted user for the logged in applicationResult<ReferenceWithName>setUserApiKey(String apiKey)static <T> Result<T>withRetry(Supplier<Result<T>> method)Automatically retries a call if it returns withCode.CONFLICT_ALLOW_RETRY.
-
-
-
Field Detail
-
VERSION
static final Version VERSION
The minimal Worcade API version for this version of the client library. The library is compatible with all later minor and patch versions, but not with later major versions.
-
-
Method Detail
-
builder
static WorcadeBuilder builder()
Creates aWorcadeBuilderinstance from a registered service provider. The api-client-jersey library provides such an instance, or you can implement your own if you don't want to depend on Jersey.
-
loginUserByEmail
Result<ReferenceWithName> loginUserByEmail(String email, String password)
Login a user by email address. This call replaces all existing authentications.- Returns:
- A reference to the logged in user
-
loginUserById
Result<ReferenceWithName> loginUserById(String userId, String password)
Login a user by id. This call replaces all existing authentications.- Returns:
- A reference to the logged in user
-
setUserApiKey
Result<ReferenceWithName> setUserApiKey(String apiKey)
-
logoutUser
Result<?> logoutUser()
Logout the current logged in user, invalidating the session token.
-
loginApplication
Result<ReferenceWithName> loginApplication(String applicationId, PrivateKey applicationPrivateKey, PublicKey worcadePublicKey)
Login an application. This call replaces all existing authentications.- Returns:
- A reference to the logged in application
-
setApplicationApiKey
Result<ReferenceWithName> setApplicationApiKey(String apiKey)
-
logoutApplication
Result<?> logoutApplication()
Logout the current logged in user, invalidating the session token.
-
setApplicationSourceAuth
Result<ReferenceWithName> setApplicationSourceAuth(String id)
-
setTrustedUser
Result<? extends Authentication> setTrustedUser(Reference user)
Set a trusted user for the logged in application- Returns:
- a failed result if the application does not trust the user, and a successful one otherwise
- Throws:
IllegalStateException- if there is no logged in application
-
probeUserTrust
Result<Boolean> probeUserTrust(String userId, String applicationId)
Checks if the given user trusts the given application. The application must be authenticated to use this endpoint.- Returns:
- a result of `true` if the user trusts the application
-
getAuthentication
Result<? extends Authentication> getAuthentication()
Get information about the currently authenticated application and/or user, and the company and groups they are members of
-
getNotifications
Result<? extends Collection<? extends Notification>> getNotifications()
-
createRemoteId
RemoteId createRemoteId(String remoteIdType, String remoteId)
Create a remote id object for use withRemoteIdsApimethods
-
createExternalNumber
ExternalNumber createExternalNumber(String number, String description)
-
createWebhookHeader
Webhook.Header createWebhookHeader(String name, String value)
-
createWorkOrderRow
WorkOrder.Row createWorkOrderRow(String name, Duration duration, Double cost, Currency currency)
-
getApplicationApi
ApplicationApi getApplicationApi()
-
getAssetApi
AssetApi getAssetApi()
-
getAttachmentApi
AttachmentApi getAttachmentApi()
-
getChecklistApi
ChecklistApi getChecklistApi()
-
getCompanyApi
CompanyApi getCompanyApi()
-
getContactsApi
ContactsApi getContactsApi()
-
getConversationApi
ConversationApi getConversationApi()
-
getGroupApi
GroupApi getGroupApi()
-
getLabelApi
LabelApi getLabelApi()
-
getReclaimApi
ReclaimApi getReclaimApi()
-
getRoomApi
RoomApi getRoomApi()
-
getSearchApi
SearchApi getSearchApi()
-
getSiteApi
SiteApi getSiteApi()
-
getUserApi
UserApi getUserApi()
-
getWebhookApi
WebhookApi getWebhookApi()
-
getWorkOrderApi
WorkOrderApi getWorkOrderApi()
-
copyWithSameAuth
Worcade copyWithSameAuth()
Creates a copy of this client which uses the same internal client instance. This is useful if you need a client that's not logged in, a client logged in with an application only, and a client logged in with an application and user simultaneously. Note that callingclose()on any copied instance closes the internal client, and hence closes all copies.
-
close
void close()
Closes all resources used by this client. Effectively also closes all copies created bycopyWithSameAuth()
-
withRetry
static <T> Result<T> withRetry(Supplier<Result<T>> method)
Automatically retries a call if it returns withCode.CONFLICT_ALLOW_RETRY. This method should only be used if you cannot otherwise make sure the calls won't conflict, for example by making them in series instead of parallel.
-
-