Skip to content

Added missing model fields #288

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
63 changes: 59 additions & 4 deletions src/main/kotlin/com/workos/organizations/OrganizationsApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class OrganizationsApi(private val workos: WorkOS) {
* @param allowProfilesOutsideOrganization Whether the Connections within this Organization should allow Profiles that do not have a domain that is present in the set of the Organization's User Email Domains.
* @param domainData A list of data for the domains of the organization.
* @param domains A list of domains for the organization.
* @param externalId The external ID of the organization.
* @param metadata Object containing metadata key/value pairs associated with the organization.
*/
@JsonInclude(Include.NON_NULL)
class CreateOrganizationOptions @JvmOverloads constructor(
Expand All @@ -36,7 +38,13 @@ class OrganizationsApi(private val workos: WorkOS) {
val domainData: List<OrganizationDomainDataOptions>? = null,

@Deprecated("Use domainData instead.")
val domains: List<String>? = null
val domains: List<String>? = null,

@JsonProperty("external_id")
val externalId: String? = null,

@JsonProperty("metadata")
val metadata: Map<String, String>? = null,
) {
/**
* Builder class for creating [CreateOrganizationOptions].
Expand All @@ -50,6 +58,10 @@ class OrganizationsApi(private val workos: WorkOS) {

private var domains: List<String>? = null

private var externalId: String? = null

private var metadata: Map<String, String>? = null

/**
* Sets the name of the organization.
*/
Expand All @@ -72,11 +84,21 @@ class OrganizationsApi(private val workos: WorkOS) {
@Deprecated("Use domainData instead.")
fun domains(value: List<String>) = apply { domains = value }

/**
* Sets the external ID for the organization.
*/
fun externalId(value: String) = apply { externalId = value }

/**
* Sets the metadata for the organization.
*/
fun metadata(value: Map<String, String>) = apply { metadata = value }

/**
* Creates an instance of [CreateOrganizationOptions] with the given params.
*/
fun build(): CreateOrganizationOptions {
return CreateOrganizationOptions(name, allowProfilesOutsideOrganization, domainData, domains)
return CreateOrganizationOptions(name, allowProfilesOutsideOrganization, domainData, domains, externalId, metadata)
}
}

Expand Down Expand Up @@ -220,6 +242,9 @@ class OrganizationsApi(private val workos: WorkOS) {
* @param allowProfilesOutsideOrganization Whether the Connections within this Organization should allow Profiles that do not have a domain that is present in the set of the Organization's User Email Domains.
* @param domainData A list of data for the domains of the organization.
* @param domains A list of domains for the organization.
* @param stripeCustomerId The Stripe customer ID associated with this organization.
* @param externalId The external ID of the organization.
* @param metadata Object containing metadata key/value pairs associated with the organization.
*/
@JsonInclude(Include.NON_NULL)
class UpdateOrganizationOptions @JvmOverloads constructor(
Expand All @@ -232,7 +257,16 @@ class OrganizationsApi(private val workos: WorkOS) {
val domainData: List<OrganizationDomainDataOptions>? = null,

@Deprecated("Use domainData instead.")
val domains: List<String>? = null
val domains: List<String>? = null,

@JsonProperty("stripe_customer_id")
val stripeCustomerId: String? = null,

@JsonProperty("external_id")
val externalId: String? = null,

@JsonProperty("metadata")
val metadata: Map<String, String>? = null,
) {
/**
* Builder class for [UpdateOrganizationOptions].
Expand All @@ -246,6 +280,12 @@ class OrganizationsApi(private val workos: WorkOS) {

private var domains: List<String>? = null

private var stripeCustomerId: String? = null

private var externalId: String? = null

private var metadata: Map<String, String>? = null

/**
* Sets the name of the organization.
*/
Expand All @@ -268,11 +308,26 @@ class OrganizationsApi(private val workos: WorkOS) {
@Deprecated("Use domainData instead.")
fun domains(value: List<String>) = apply { domains = value }

/**
* Sets the Stripe customer ID associated with this organization.
*/
fun stripeCustomerId(value: String) = apply { stripeCustomerId = value }

/**
* Sets the external ID for the organization.
*/
fun externalId(value: String) = apply { externalId = value }

/**
* Sets the metadata for the organization.
*/
fun metadata(value: Map<String, String>) = apply { metadata = value }

/**
* Creates an instance of [UpdateOrganizationOptions].
*/
fun build(): UpdateOrganizationOptions {
return UpdateOrganizationOptions(name, allowProfilesOutsideOrganization, domainData, domains)
return UpdateOrganizationOptions(name, allowProfilesOutsideOrganization, domainData, domains, stripeCustomerId, externalId, metadata)
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/kotlin/com/workos/organizations/models/Organization.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param domains List of [OrganizationDomain]s.
* @param createdAt The timestamp of when the Organization was created.
* @param updatedAt The timestamp of when the Organization was updated.
* @param stripeCustomerId The Stripe customer ID associated with this organization.
* @param externalId The external ID of the Organization.
* @param metadata Object containing metadata key/value pairs associated with the Organization.
*/
data class Organization
@JsonCreator constructor(
Expand All @@ -40,5 +43,14 @@ data class Organization

@JvmField
@JsonProperty("updated_at")
val updatedAt: String
val updatedAt: String,

@JsonProperty("stripe_customer_id")
val stripeCustomerId: String? = null,

@JsonProperty("external_id")
val externalId: String? = null,

@JsonProperty("metadata")
val metadata: Map<String, String>? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.workos.usermanagement.models.OrganizationMemberships
import com.workos.usermanagement.models.PasswordReset
import com.workos.usermanagement.models.RefreshAuthentication
import com.workos.usermanagement.models.User
import com.workos.usermanagement.models.UserResponse
import com.workos.usermanagement.models.Users
import com.workos.usermanagement.types.AuthenticationAdditionalOptions
import com.workos.usermanagement.types.CreateMagicAuthOptions
Expand Down Expand Up @@ -355,13 +356,15 @@ class UserManagementApi(private val workos: WorkOS) {

/** Sets a new password using the `token` query parameter from the link that the user received. */
fun resetPassword(token: String, newPassword: String): User {
return workos.post(
val userResponse = workos.post(
"/user_management/password_reset/confirm",
User::class.java,
UserResponse::class.java,
RequestConfig.builder()
.data(ResetPasswordOptionsBuilder.create(token, newPassword).build())
.build()
)

return userResponse.user
}

/** Get the details of an existing organization membership. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.workos.usermanagement.types.PasswordHashTypeEnumType
* @param firstName The first name of the user.
* @param lastName The last name of the user.
* @param emailVerified Whether the user’s email address was previously verified.
* @param externalId The external ID of the user.
* @param metadata Object containing metadata key/value pairs associated with the user.
*/
abstract class AbstractUserOptionsBuilder<OptionsObject> @JvmOverloads constructor(
open var password: String? = null,
Expand All @@ -20,6 +22,8 @@ abstract class AbstractUserOptionsBuilder<OptionsObject> @JvmOverloads construct
open var firstName: String? = null,
open var lastName: String? = null,
open var emailVerified: Boolean? = null,
open var externalId: String? = null,
open var metadata: Map<String, String>? = null,
) {
/**
* Password
Expand Down Expand Up @@ -55,6 +59,16 @@ abstract class AbstractUserOptionsBuilder<OptionsObject> @JvmOverloads construct
*/
fun emailVerified(value: Boolean) = apply { emailVerified = value }

/**
* External ID
*/
fun externalId(value: String) = apply { externalId = value }

/**
* Metadata
*/
fun metadata(value: Map<String, String>) = apply { metadata = value }

/**
* Generates the options object.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import com.workos.usermanagement.types.PasswordHashTypeEnumType
* @param firstName The first name of the user.
* @param lastName The last name of the user.
* @param emailVerified Whether the user’s email address was previously verified.
* @param externalId The external ID of the user.
* @param metadata Object containing metadata key/value pairs associated with the user.
*/
class CreateUserOptionsBuilder @JvmOverloads constructor(
val email: String,
Expand All @@ -22,13 +24,17 @@ class CreateUserOptionsBuilder @JvmOverloads constructor(
override var firstName: String? = null,
override var lastName: String? = null,
override var emailVerified: Boolean? = null,
override var externalId: String? = null,
override var metadata: Map<String, String>? = null,
) : AbstractUserOptionsBuilder<CreateUserOptions>(
password,
passwordHash,
passwordHashType,
firstName,
lastName,
emailVerified
emailVerified,
externalId,
metadata
) {
/**
* Generates the CreateUserOptions object.
Expand All @@ -42,6 +48,8 @@ class CreateUserOptionsBuilder @JvmOverloads constructor(
firstName = this.firstName,
lastName = this.lastName,
emailVerified = this.emailVerified,
externalId = this.externalId,
metadata = this.metadata
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import com.workos.usermanagement.types.UpdateUserOptions
* @param password The password to set for the user.
* @param passwordHash The hashed password to set for the user. Mutually exclusive with password.
* @param passwordHashType The algorithm originally used to hash the password, used when providing a password_hash.
* @param externalId The external ID of the user.
* @param metadata Object containing metadata key/value pairs associated with the user.
*/
class UpdateUserOptionsBuilder @JvmOverloads constructor(
val id: String,
Expand All @@ -24,13 +26,17 @@ class UpdateUserOptionsBuilder @JvmOverloads constructor(
override var password: String? = null,
override var passwordHash: String? = null,
override var passwordHashType: PasswordHashTypeEnumType? = null,
override var externalId: String? = null,
override var metadata: Map<String, String>? = null,
) : AbstractUserOptionsBuilder<UpdateUserOptions>(
password,
passwordHash,
passwordHashType,
firstName,
lastName,
emailVerified
emailVerified,
externalId,
metadata
) {
/**
* Generates the UpdateUserOptions object.
Expand All @@ -45,6 +51,8 @@ class UpdateUserOptionsBuilder @JvmOverloads constructor(
password = this.password,
passwordHash = this.passwordHash,
passwordHashType = this.passwordHashType,
externalId = this.externalId,
metadata = this.metadata
)
}

Expand Down
10 changes: 9 additions & 1 deletion src/main/kotlin/com/workos/usermanagement/models/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
* @param lastSignInAt The timestamp when the user last signed in.
* @param createdAt The timestamp when the user was created.
* @param updatedAt The timestamp when the user was last updated.
* @param externalId The external ID of the user.
* @param metadata Object containing metadata key/value pairs associated with the user.
*/
data class User @JsonCreator constructor(
@JsonProperty("id")
Expand Down Expand Up @@ -42,5 +44,11 @@ data class User @JsonCreator constructor(
val createdAt: String,

@JsonProperty("updated_at")
val updatedAt: String
val updatedAt: String,

@JsonProperty("external_id")
val externalId: String? = null,

@JsonProperty("metadata")
val metadata: Map<String, String>,
)
15 changes: 15 additions & 0 deletions src/main/kotlin/com/workos/usermanagement/models/UserResponse.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.workos.usermanagement.models

import com.fasterxml.jackson.annotation.JsonCreator
import com.fasterxml.jackson.annotation.JsonProperty

/**
* A response containing a WorkOS user.
*
* @param user The corresponding user object.
*/
data class UserResponse @JsonCreator constructor(

@JsonProperty("user")
val user: User,
)
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,19 @@ class CreateUserOptions @JvmOverloads constructor(
* You should normally use the email verification flow to verify a user’s email address. However, if the user’s email was previously verified, or is being migrated from an existing user store, this can be set to true to mark it as already verified.
*/
@JsonProperty("email_verified")
val emailVerified: Boolean? = null
val emailVerified: Boolean? = null,

/**
* The external ID of the user.
*/
@JsonProperty("external_id")
val externalId: String? = null,

/**
* Object containing metadata key/value pairs associated with the user.
*/
@JsonProperty("metadata")
val metadata: Map<String, String>? = null
) {
init {
require(email.isNotBlank()) { "Email is required" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@ class UpdateUserOptions @JvmOverloads constructor(
* The algorithm originally used to hash the password, used when providing a password_hash.
*/
@JsonProperty("password_hash_type")
val passwordHashType: PasswordHashTypeEnumType? = null
val passwordHashType: PasswordHashTypeEnumType? = null,

/**
* The external ID of the user.
*/
@JsonProperty("external_id")
val externalId: String? = null,

/**
* Object containing metadata key/value pairs associated with the user.
*/
@JsonProperty("metadata")
val metadata: Map<String, String>? = null
) {
init {
require(id.isNotBlank()) { "User id is required" }
Expand Down
Loading