Class VortexClient

java.lang.Object
com.vortexsoftware.sdk.VortexClient

public class VortexClient extends Object
Main Vortex SDK client for Java applications Provides JWT generation and Vortex API integration with the same functionality as the Node.js SDK, ensuring compatibility with React providers.
  • Constructor Details

    • VortexClient

      public VortexClient(String apiKey)
      Create a new Vortex client with the given API key
    • VortexClient

      public VortexClient(String apiKey, String baseUrl)
      Create a new Vortex client with custom base URL
  • Method Details

    • generateJwt

      public String generateJwt(Map<String,Object> params) throws VortexException
      Generate a JWT using the same algorithm as the Node.js SDK

      This replicates the exact JWT generation process from vortex.ts to ensure complete compatibility with React providers.

      Simple usage:

      
       Map<String, Object> params = new HashMap<>();
       User user = new User("user-123", "user@example.com");
       user.setName("Jane Doe");                                      // Optional: user's display name
       user.setAvatarUrl("https://example.com/avatars/jane.jpg");    // Optional: user's avatar URL
       user.setAdminScopes(Arrays.asList("autojoin"));               // Optional: grants admin privileges
       params.put("user", user);
       String jwt = client.generateJwt(params);
       

      With additional properties:

      
       Map<String, Object> params = new HashMap<>();
       User user = new User("user-123", "user@example.com");
       params.put("user", user);
       params.put("role", "admin");
       params.put("department", "Engineering");
       String jwt = client.generateJwt(params);
       
      Parameters:
      params - Map containing "user" key with User object and optional additional properties
      Returns:
      JWT token
      Throws:
      VortexException - if JWT generation fails
    • getInvitationsByTarget

      public List<InvitationResult> getInvitationsByTarget(String targetType, String targetValue) throws VortexException
      Get invitations by target (email, username, phoneNumber)
      Throws:
      VortexException
    • getInvitation

      public InvitationResult getInvitation(String invitationId) throws VortexException
      Get a specific invitation by ID
      Throws:
      VortexException
    • revokeInvitation

      public void revokeInvitation(String invitationId) throws VortexException
      Revoke (delete) an invitation
      Throws:
      VortexException
    • acceptInvitations

      public InvitationResult acceptInvitations(List<String> invitationIds, AcceptUser user) throws VortexException
      Accept multiple invitations using the new User format (preferred)

      Example:

      
       AcceptUser user = new AcceptUser();
       user.setEmail("user@example.com");
       user.setName("John Doe");
       List<InvitationResult> results = client.acceptInvitations(invitationIds, user);
       
      Parameters:
      invitationIds - List of invitation IDs to accept
      user - User object with email or phone (and optional name)
      Returns:
      List of accepted invitation results
      Throws:
      VortexException - if the API request fails
    • acceptInvitations

      @Deprecated public InvitationResult acceptInvitations(List<String> invitationIds, InvitationTarget target) throws VortexException
      Deprecated.
      Use acceptInvitations(List, AcceptUser) instead. This method is maintained for backward compatibility but will be removed in a future version. Use the new User format which supports email, phone, and name.

      Example migration:

      
       // Old way (deprecated):
       InvitationTarget target = new InvitationTarget("email", "user@example.com");
       List<InvitationResult> results = client.acceptInvitations(invitationIds, target);
      
       // New way (preferred):
       AcceptUser user = new AcceptUser("user@example.com");
       InvitationResult result = client.acceptInvitations(invitationIds, user);
       
      Accept multiple invitations using legacy target format (deprecated)
      Parameters:
      invitationIds - List of invitation IDs to accept
      target - Legacy target object with type and value
      Returns:
      Accepted invitation result
      Throws:
      VortexException - if the API request fails
    • acceptInvitations

      @Deprecated public InvitationResult acceptInvitations(List<String> invitationIds, List<InvitationTarget> targets) throws VortexException
      Deprecated.
      Use acceptInvitations(List, AcceptUser) instead and call once per user. This method calls the API once per target and is maintained only for backward compatibility.

      Example migration:

      
       // Old way (deprecated):
       List<InvitationTarget> targets = Arrays.asList(
           new InvitationTarget("email", "user1@example.com"),
           new InvitationTarget("email", "user2@example.com")
       );
       InvitationResult result = client.acceptInvitations(invitationIds, targets);
      
       // New way (preferred) - call once per user:
       for (InvitationTarget target : targets) {
           AcceptUser user = new AcceptUser(target.getValue());
           InvitationResult result = client.acceptInvitations(invitationIds, user);
       }
       
      Accept multiple invitations for multiple targets (deprecated)
      Parameters:
      invitationIds - List of invitation IDs to accept
      targets - List of legacy target objects
      Returns:
      Last accepted invitation result
      Throws:
      VortexException - if the API request fails
    • deleteInvitationsByGroup

      public void deleteInvitationsByGroup(String groupType, String groupId) throws VortexException
      Delete all invitations for a specific group
      Throws:
      VortexException
    • getInvitationsByGroup

      public List<InvitationResult> getInvitationsByGroup(String groupType, String groupId) throws VortexException
      Get all invitations for a specific group
      Throws:
      VortexException
    • reinvite

      public InvitationResult reinvite(String invitationId) throws VortexException
      Reinvite a user (send invitation again)
      Throws:
      VortexException
    • createInvitation

      public CreateInvitationResponse createInvitation(CreateInvitationRequest request) throws VortexException
      Create an invitation from your backend

      This method allows you to create invitations programmatically using your API key, without requiring a user JWT token. Useful for server-side invitation creation, such as "People You May Know" flows or admin-initiated invitations.

      Target types:

      • email: Send an email invitation
      • sms: Create an SMS invitation (short link returned for you to send)
      • internal: Create an internal invitation for PYMK flows (no email sent)

      Example - Email invitation:

      
       CreateInvitationRequest request = new CreateInvitationRequest(
           "widget-config-123",
           CreateInvitationTarget.email("invitee@example.com"),
           new Inviter("user-456", "inviter@example.com", "John Doe", null)
       );
       request.setGroups(Arrays.asList(
           new CreateInvitationGroup("team", "team-789", "Engineering")
       ));
       CreateInvitationResponse response = client.createInvitation(request);
       System.out.println("Invitation created: " + response.getId());
       System.out.println("Short link: " + response.getShortLink());
       

      Example - Internal invitation (PYMK flow):

      
       CreateInvitationRequest request = new CreateInvitationRequest(
           "widget-config-123",
           CreateInvitationTarget.internal("internal-user-abc"),
           new Inviter("user-456")
       );
       request.setSource("pymk");
       CreateInvitationResponse response = client.createInvitation(request);
       
      Parameters:
      request - The create invitation request
      Returns:
      CreateInvitationResponse with id, shortLink, status, and createdAt
      Throws:
      VortexException - if the API request fails
    • close

      public void close()
      Close the HTTP client when done