Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package com.stytch.java.consumer.api.users
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
import com.stytch.java.consumer.models.users.CreateRequest
import com.stytch.java.consumer.models.users.CreateResponse
import com.stytch.java.consumer.models.users.DeleteBiometricRegistrationRequest
import com.stytch.java.consumer.models.users.DeleteBiometricRegistrationResponse
import com.stytch.java.consumer.models.users.DeleteCryptoWalletRequest
import com.stytch.java.consumer.models.users.DeleteCryptoWalletResponse
import com.stytch.java.consumer.models.users.DeleteEmailRequest
import com.stytch.java.consumer.models.users.DeleteEmailResponse
import com.stytch.java.consumer.models.users.DeleteOAuthRegistrationRequest
import com.stytch.java.consumer.models.users.DeleteOAuthRegistrationResponse
import com.stytch.java.consumer.models.users.DeletePasswordRequest
import com.stytch.java.consumer.models.users.DeletePasswordResponse
import com.stytch.java.consumer.models.users.DeletePhoneNumberRequest
import com.stytch.java.consumer.models.users.DeletePhoneNumberResponse
import com.stytch.java.consumer.models.users.DeleteRequest
import com.stytch.java.consumer.models.users.DeleteResponse
import com.stytch.java.consumer.models.users.DeleteTOTPRequest
import com.stytch.java.consumer.models.users.DeleteTOTPResponse
import com.stytch.java.consumer.models.users.DeleteWebAuthnRegistrationRequest
import com.stytch.java.consumer.models.users.DeleteWebAuthnRegistrationResponse
import com.stytch.java.consumer.models.users.ExchangePrimaryFactorRequest
import com.stytch.java.consumer.models.users.ExchangePrimaryFactorResponse
import com.stytch.java.consumer.models.users.GetRequest
import com.stytch.java.consumer.models.users.GetResponse
import com.stytch.java.consumer.models.users.SearchRequest
import com.stytch.java.consumer.models.users.SearchResponse
import com.stytch.java.consumer.models.users.UpdateRequest
import com.stytch.java.consumer.models.users.UpdateResponse
import com.stytch.java.http.HttpClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture
public interface Users {
/**
* Add a User to Stytch. A `user_id` is returned in the response that can then be used to perform other operations within
* Stytch. An `email` or a `phone_number` is required.
*/
public suspend fun create(data: CreateRequest): StytchResult
/**
* Add a User to Stytch. A `user_id` is returned in the response that can then be used to perform other operations within
* Stytch. An `email` or a `phone_number` is required.
*/
public fun create(
data: CreateRequest,
callback: (StytchResult) -> Unit,
)
/**
* Add a User to Stytch. A `user_id` is returned in the response that can then be used to perform other operations within
* Stytch. An `email` or a `phone_number` is required.
*/
public fun createCompletable(data: CreateRequest): CompletableFuture>
/**
* Get information about a specific User.
*/
public suspend fun get(data: GetRequest): StytchResult
/**
* Get information about a specific User.
*/
public fun get(
data: GetRequest,
callback: (StytchResult) -> Unit,
)
/**
* Get information about a specific User.
*/
public fun getCompletable(data: GetRequest): CompletableFuture>
/**
* Search for Users within your Stytch Project. Submit an empty `query` in the request to return all Users.
*/
public suspend fun search(data: SearchRequest): StytchResult
/**
* Search for Users within your Stytch Project. Submit an empty `query` in the request to return all Users.
*/
public fun search(
data: SearchRequest,
callback: (StytchResult) -> Unit,
)
/**
* Search for Users within your Stytch Project. Submit an empty `query` in the request to return all Users.
*/
public fun searchCompletable(data: SearchRequest): CompletableFuture>
/**
* Update a User's attributes.
*
* **Note:** In order to add a new email address or phone number to an existing User object, pass the new email address or
* phone number into the respective `/send` endpoint for the authentication method of your choice. If you specify the
* existing User's `user_id` while calling the `/send` endpoint, the new, unverified email address or phone number will be
* added to the existing User object. If the user successfully authenticates within 5 minutes of the `/send` request, the
* new email address or phone number will be marked as verified and remain permanently on the existing Stytch User.
* Otherwise, it will be removed from the User object, and any subsequent login requests using that phone number will
* create a new User. We require this process to guard against an account takeover vulnerability.
*/
public suspend fun update(data: UpdateRequest): StytchResult
/**
* Update a User's attributes.
*
* **Note:** In order to add a new email address or phone number to an existing User object, pass the new email address or
* phone number into the respective `/send` endpoint for the authentication method of your choice. If you specify the
* existing User's `user_id` while calling the `/send` endpoint, the new, unverified email address or phone number will be
* added to the existing User object. If the user successfully authenticates within 5 minutes of the `/send` request, the
* new email address or phone number will be marked as verified and remain permanently on the existing Stytch User.
* Otherwise, it will be removed from the User object, and any subsequent login requests using that phone number will
* create a new User. We require this process to guard against an account takeover vulnerability.
*/
public fun update(
data: UpdateRequest,
callback: (StytchResult) -> Unit,
)
/**
* Update a User's attributes.
*
* **Note:** In order to add a new email address or phone number to an existing User object, pass the new email address or
* phone number into the respective `/send` endpoint for the authentication method of your choice. If you specify the
* existing User's `user_id` while calling the `/send` endpoint, the new, unverified email address or phone number will be
* added to the existing User object. If the user successfully authenticates within 5 minutes of the `/send` request, the
* new email address or phone number will be marked as verified and remain permanently on the existing Stytch User.
* Otherwise, it will be removed from the User object, and any subsequent login requests using that phone number will
* create a new User. We require this process to guard against an account takeover vulnerability.
*/
public fun updateCompletable(data: UpdateRequest): CompletableFuture>
/**
* Exchange a user's email address or phone number for another.
*
* Must pass either an `email_address` or a `phone_number`.
*
* This endpoint only works if the user has exactly one factor. You are able to exchange the type of factor for another as
* well, i.e. exchange an `email_address` for a `phone_number`.
*
* Use this endpoint with caution as it performs an admin level action.
*/
public suspend fun exchangePrimaryFactor(data: ExchangePrimaryFactorRequest): StytchResult
/**
* Exchange a user's email address or phone number for another.
*
* Must pass either an `email_address` or a `phone_number`.
*
* This endpoint only works if the user has exactly one factor. You are able to exchange the type of factor for another as
* well, i.e. exchange an `email_address` for a `phone_number`.
*
* Use this endpoint with caution as it performs an admin level action.
*/
public fun exchangePrimaryFactor(
data: ExchangePrimaryFactorRequest,
callback: (StytchResult) -> Unit,
)
/**
* Exchange a user's email address or phone number for another.
*
* Must pass either an `email_address` or a `phone_number`.
*
* This endpoint only works if the user has exactly one factor. You are able to exchange the type of factor for another as
* well, i.e. exchange an `email_address` for a `phone_number`.
*
* Use this endpoint with caution as it performs an admin level action.
*/
public fun exchangePrimaryFactorCompletable(
data: ExchangePrimaryFactorRequest,
): CompletableFuture>
/**
* Delete a User from Stytch.
*/
public suspend fun delete(data: DeleteRequest): StytchResult
/**
* Delete a User from Stytch.
*/
public fun delete(
data: DeleteRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a User from Stytch.
*/
public fun deleteCompletable(data: DeleteRequest): CompletableFuture>
/**
* Delete an email from a User.
*/
public suspend fun deleteEmail(data: DeleteEmailRequest): StytchResult
/**
* Delete an email from a User.
*/
public fun deleteEmail(
data: DeleteEmailRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete an email from a User.
*/
public fun deleteEmailCompletable(data: DeleteEmailRequest): CompletableFuture>
/**
* Delete a phone number from a User.
*/
public suspend fun deletePhoneNumber(data: DeletePhoneNumberRequest): StytchResult
/**
* Delete a phone number from a User.
*/
public fun deletePhoneNumber(
data: DeletePhoneNumberRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a phone number from a User.
*/
public fun deletePhoneNumberCompletable(data: DeletePhoneNumberRequest): CompletableFuture>
/**
* Delete a WebAuthn registration from a User.
*/
public suspend fun deleteWebAuthnRegistration(
data: DeleteWebAuthnRegistrationRequest,
): StytchResult
/**
* Delete a WebAuthn registration from a User.
*/
public fun deleteWebAuthnRegistration(
data: DeleteWebAuthnRegistrationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a WebAuthn registration from a User.
*/
public fun deleteWebAuthnRegistrationCompletable(
data: DeleteWebAuthnRegistrationRequest,
): CompletableFuture>
/**
* Delete a biometric registration from a User.
*/
public suspend fun deleteBiometricRegistration(
data: DeleteBiometricRegistrationRequest,
): StytchResult
/**
* Delete a biometric registration from a User.
*/
public fun deleteBiometricRegistration(
data: DeleteBiometricRegistrationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a biometric registration from a User.
*/
public fun deleteBiometricRegistrationCompletable(
data: DeleteBiometricRegistrationRequest,
): CompletableFuture>
/**
* Delete a TOTP from a User.
*/
public suspend fun deleteTOTP(data: DeleteTOTPRequest): StytchResult
/**
* Delete a TOTP from a User.
*/
public fun deleteTOTP(
data: DeleteTOTPRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a TOTP from a User.
*/
public fun deleteTOTPCompletable(data: DeleteTOTPRequest): CompletableFuture>
/**
* Delete a crypto wallet from a User.
*/
public suspend fun deleteCryptoWallet(data: DeleteCryptoWalletRequest): StytchResult
/**
* Delete a crypto wallet from a User.
*/
public fun deleteCryptoWallet(
data: DeleteCryptoWalletRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a crypto wallet from a User.
*/
public fun deleteCryptoWalletCompletable(data: DeleteCryptoWalletRequest): CompletableFuture>
/**
* Delete a password from a User.
*/
public suspend fun deletePassword(data: DeletePasswordRequest): StytchResult
/**
* Delete a password from a User.
*/
public fun deletePassword(
data: DeletePasswordRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete a password from a User.
*/
public fun deletePasswordCompletable(data: DeletePasswordRequest): CompletableFuture>
/**
* Delete an OAuth registration from a User.
*/
public suspend fun deleteOAuthRegistration(data: DeleteOAuthRegistrationRequest): StytchResult
/**
* Delete an OAuth registration from a User.
*/
public fun deleteOAuthRegistration(
data: DeleteOAuthRegistrationRequest,
callback: (StytchResult) -> Unit,
)
/**
* Delete an OAuth registration from a User.
*/
public fun deleteOAuthRegistrationCompletable(
data: DeleteOAuthRegistrationRequest,
): CompletableFuture>
}
internal class UsersImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : Users {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override suspend fun create(data: CreateRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(CreateRequest::class.java).toJson(data)
httpClient.post("/v1/users", asJson, headers)
}
override fun create(
data: CreateRequest,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(create(data))
}
}
override fun createCompletable(data: CreateRequest): CompletableFuture> =
coroutineScope.async {
create(data)
}.asCompletableFuture()
override suspend fun get(data: GetRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(GetRequest::class.java).toJson(data)
val type = Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)
val adapter: JsonAdapter