Interface Worcade

    • 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 a WorcadeBuilder instance 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
      • 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
      • logoutApplication

        Result<?> logoutApplication()
        Logout the current logged in user, invalidating the session token.
      • 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
      • invalidateCurrentApiKey

        Result<?> invalidateCurrentApiKey()
      • getAuthentication

        Result<? extends Authentication> getAuthentication()
        Get information about the currently authenticated application and/or user, and the company and groups they are members of
      • 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 calling close() 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 by copyWithSameAuth()
      • withRetry

        static <T> Result<T> withRetry​(Supplier<Result<T>> method)
        Automatically retries a call if it returns with Code.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.