Package com.vortexsoftware.sdk
Class VortexClient
java.lang.Object
com.vortexsoftware.sdk.VortexClient
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 Summary
ConstructorsConstructorDescriptionVortexClient(String apiKey) Create a new Vortex client with the given API keyVortexClient(String apiKey, String baseUrl) Create a new Vortex client with custom base URL -
Method Summary
Modifier and TypeMethodDescriptionacceptInvitations(List<String> invitationIds, AcceptUser user) Accept multiple invitations using the new User format (preferred)acceptInvitations(List<String> invitationIds, InvitationTarget target) Deprecated.acceptInvitations(List<String> invitationIds, List<InvitationTarget> targets) Deprecated.UseacceptInvitations(List, AcceptUser)instead and call once per user.voidclose()Close the HTTP client when donecreateInvitation(CreateInvitationRequest request) Create an invitation from your backendvoiddeleteInvitationsByGroup(String groupType, String groupId) Delete all invitations for a specific groupgenerateJwt(Map<String, Object> params) Generate a JWT using the same algorithm as the Node.js SDKgetInvitation(String invitationId) Get a specific invitation by IDgetInvitationsByGroup(String groupType, String groupId) Get all invitations for a specific groupgetInvitationsByTarget(String targetType, String targetValue) Get invitations by target (email, username, phoneNumber)Reinvite a user (send invitation again)voidrevokeInvitation(String invitationId) Revoke (delete) an invitation
-
Constructor Details
-
VortexClient
Create a new Vortex client with the given API key -
VortexClient
Create a new Vortex client with custom base URL
-
-
Method Details
-
generateJwt
Generate a JWT using the same algorithm as the Node.js SDKThis 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
Get a specific invitation by ID- Throws:
VortexException
-
revokeInvitation
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 acceptuser- 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.UseacceptInvitations(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 accepttarget- 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.UseacceptInvitations(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 accepttargets- List of legacy target objects- Returns:
- Last accepted invitation result
- Throws:
VortexException- if the API request fails
-
deleteInvitationsByGroup
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
Reinvite a user (send invitation again)- Throws:
VortexException
-
createInvitation
public CreateInvitationResponse createInvitation(CreateInvitationRequest request) throws VortexException Create an invitation from your backendThis 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 invitationsms: 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
-
acceptInvitations(List, AcceptUser)instead.