Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Organizations Management API Support [SDK-2437] #341

Merged
merged 3 commits into from
Apr 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions src/main/java/com/auth0/client/mgmt/JobsEntity.java
Original file line number Diff line number Diff line change
@@ -81,19 +81,39 @@ public Request<Job> sendVerificationEmail(String userId, String clientId) {
* @see JobsEntity#sendVerificationEmail(String, String)
*/
public Request<Job> sendVerificationEmail(String userId, String clientId, EmailVerificationIdentity emailVerificationIdentity) {
return sendVerificationEmail(userId, clientId, emailVerificationIdentity, null);
}

/**
* Sends an Email Verification. A token with scope update:users is needed.
* See https://auth0.com/docs/api/management/v2#!/Jobs/post_verification_email.
*
* @param userId The user_id of the user to whom the email will be sent.
* @param clientId The id of the client, if not provided the global one will be used.
* @param emailVerificationIdentity The identity of the user. Required to verify primary identities when using social, enterprise, or passwordless connections. It is also required to verify secondary identities.
* @param orgId The organization ID. If provided, the organization_id and organization_name will be included as query arguments in the link back to the application.
*
* @return a Request to execute.
*
* @see JobsEntity#sendVerificationEmail(String, String)
*/
public Request<Job> sendVerificationEmail(String userId, String clientId, EmailVerificationIdentity emailVerificationIdentity, String orgId) {
Asserts.assertNotNull(userId, "user id");

String url = baseUrl
.newBuilder()
.addPathSegments("api/v2/jobs/verification-email")
.build()
.toString();
.newBuilder()
.addPathSegments("api/v2/jobs/verification-email")
.build()
.toString();

Map<String, Object> requestBody = new HashMap<>();
requestBody.put("user_id", userId);
if (clientId != null && !clientId.isEmpty()) {
requestBody.put("client_id", clientId);
}
if (orgId != null && !orgId.isEmpty()) {
requestBody.put("organization_id", orgId);
}
if (emailVerificationIdentity != null) {
Asserts.assertNotNull(emailVerificationIdentity.getProvider(), "identity provider");
Asserts.assertNotNull(emailVerificationIdentity.getUserId(), "identity user id");
9 changes: 9 additions & 0 deletions src/main/java/com/auth0/client/mgmt/ManagementAPI.java
Original file line number Diff line number Diff line change
@@ -348,4 +348,13 @@ public JobsEntity jobs() {
public RolesEntity roles() {
return new RolesEntity(client, baseUrl, apiToken);
}

/**
* Getter for the Organizations entity.
*
* @return the Organizations entity.
*/
public OrganizationsEntity organizations() {
return new OrganizationsEntity(client, baseUrl, apiToken);
}
}
Loading