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.b2b.api.organizationsmembers
// !!!
// 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.b2b.api.organizationsmembersoauthproviders.OAuthProviders
import com.stytch.java.b2b.api.organizationsmembersoauthproviders.OAuthProvidersImpl
import com.stytch.java.b2b.models.organizationsmembers.CreateRequest
import com.stytch.java.b2b.models.organizationsmembers.CreateRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.CreateResponse
import com.stytch.java.b2b.models.organizationsmembers.DangerouslyGetRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteMFAPhoneNumberResponse
import com.stytch.java.b2b.models.organizationsmembers.DeletePasswordRequest
import com.stytch.java.b2b.models.organizationsmembers.DeletePasswordRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeletePasswordResponse
import com.stytch.java.b2b.models.organizationsmembers.DeleteRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteResponse
import com.stytch.java.b2b.models.organizationsmembers.DeleteTOTPRequest
import com.stytch.java.b2b.models.organizationsmembers.DeleteTOTPRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteTOTPResponse
import com.stytch.java.b2b.models.organizationsmembers.GetRequest
import com.stytch.java.b2b.models.organizationsmembers.GetResponse
import com.stytch.java.b2b.models.organizationsmembers.ReactivateRequest
import com.stytch.java.b2b.models.organizationsmembers.ReactivateRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.ReactivateResponse
import com.stytch.java.b2b.models.organizationsmembers.SearchRequest
import com.stytch.java.b2b.models.organizationsmembers.SearchRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.SearchResponse
import com.stytch.java.b2b.models.organizationsmembers.UpdateRequest
import com.stytch.java.b2b.models.organizationsmembers.UpdateRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.UpdateResponse
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
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 Members {
public val oauthProviders: OAuthProviders
/**
* Updates a Member specified by `organization_id` and `member_id`.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
* are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
* permission to perform the `update.info.name` action on the `stytch.organization` Resource.
*
* If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
* does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
* proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public suspend fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
): StytchResult
/**
* Updates a Member specified by `organization_id` and `member_id`.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
* are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
* permission to perform the `update.info.name` action on the `stytch.organization` Resource.
*
* If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
* does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
* proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Updates a Member specified by `organization_id` and `member_id`.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has the necessary permissions. The specific permissions needed depend on which of the optional fields
* are passed in the request. For example, if the `organization_name` argument is provided, the Member Session must have
* permission to perform the `update.info.name` action on the `stytch.organization` Resource.
*
* If the Member Session does not contain a Role that satisfies the requested permissions, or if the Member's Organization
* does not match the `organization_id` passed in the request, a 403 error will be thrown. Otherwise, the request will
* proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public fun updateCompletable(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
): CompletableFuture>
/**
* Deletes a Member specified by `organization_id` and `member_id`. /%}
*/
public suspend fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
): StytchResult
/**
* Deletes a Member specified by `organization_id` and `member_id`. /%}
*/
public fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Deletes a Member specified by `organization_id` and `member_id`. /%}
*/
public fun deleteCompletable(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
): CompletableFuture>
/**
* Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by
* `organization_id` and `member_id`. /%}
*/
public suspend fun reactivate(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions? = null,
): StytchResult
/**
* Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by
* `organization_id` and `member_id`. /%}
*/
public fun reactivate(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Reactivates a deleted Member's status and its associated email status (if applicable) to active, specified by
* `organization_id` and `member_id`. /%}
*/
public fun reactivateCompletable(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions? = null,
): CompletableFuture>
/**
* Delete a Member's MFA phone number.
*
* To change a Member's phone number, you must first call this endpoint to delete the existing phone number.
*
* Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is
* deleted, and MFA will not be enforced until the Member logs in again.
* If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter
* a new phone number
* and calling the [OTP SMS send](https://stytch.com/docs/b2b/api/otp-sms-send) endpoint, then calling the
* [OTP SMS Authenticate](https://stytch.com/docs/b2b/api/authenticate-otp-sms) endpoint.
* /%}
*/
public suspend fun deleteMFAPhoneNumber(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions? = null,
): StytchResult
/**
* Delete a Member's MFA phone number.
*
* To change a Member's phone number, you must first call this endpoint to delete the existing phone number.
*
* Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is
* deleted, and MFA will not be enforced until the Member logs in again.
* If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter
* a new phone number
* and calling the [OTP SMS send](https://stytch.com/docs/b2b/api/otp-sms-send) endpoint, then calling the
* [OTP SMS Authenticate](https://stytch.com/docs/b2b/api/authenticate-otp-sms) endpoint.
* /%}
*/
public fun deleteMFAPhoneNumber(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Delete a Member's MFA phone number.
*
* To change a Member's phone number, you must first call this endpoint to delete the existing phone number.
*
* Existing Member Sessions that include a phone number authentication factor will not be revoked if the phone number is
* deleted, and MFA will not be enforced until the Member logs in again.
* If you wish to enforce MFA immediately after a phone number is deleted, you can do so by prompting the Member to enter
* a new phone number
* and calling the [OTP SMS send](https://stytch.com/docs/b2b/api/otp-sms-send) endpoint, then calling the
* [OTP SMS Authenticate](https://stytch.com/docs/b2b/api/authenticate-otp-sms) endpoint.
* /%}
*/
public fun deleteMFAPhoneNumberCompletable(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions? = null,
): CompletableFuture>
public suspend fun deleteTOTP(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions? = null,
): StytchResult
public fun deleteTOTP(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
public fun deleteTOTPCompletable(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions? = null,
): CompletableFuture>
/**
* Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting
* an empty `query` returns all non-deleted Members within the specified Organizations.
*
* *All fuzzy search filters require a minimum of three characters.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has permission to perform the `search` action on the `stytch.member` Resource. In addition, enforcing
* RBAC on this endpoint means that you may only search for Members within the calling Member's Organization, so the
* `organization_ids` argument may only contain the `organization_id` of the Member Session passed in the header.
*
* If the Member Session does not contain a Role that satisfies the requested permission, or if the `organization_ids`
* argument contains an `organization_id` that the Member Session does not belong to, a 403 error will be thrown.
* Otherwise, the request will proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public suspend fun search(
data: SearchRequest,
methodOptions: SearchRequestOptions? = null,
): StytchResult
/**
* Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting
* an empty `query` returns all non-deleted Members within the specified Organizations.
*
* *All fuzzy search filters require a minimum of three characters.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has permission to perform the `search` action on the `stytch.member` Resource. In addition, enforcing
* RBAC on this endpoint means that you may only search for Members within the calling Member's Organization, so the
* `organization_ids` argument may only contain the `organization_id` of the Member Session passed in the header.
*
* If the Member Session does not contain a Role that satisfies the requested permission, or if the `organization_ids`
* argument contains an `organization_id` that the Member Session does not belong to, a 403 error will be thrown.
* Otherwise, the request will proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public fun search(
data: SearchRequest,
methodOptions: SearchRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Search for Members within specified Organizations. An array with at least one `organization_id` is required. Submitting
* an empty `query` returns all non-deleted Members within the specified Organizations.
*
* *All fuzzy search filters require a minimum of three characters.
*
* Our RBAC implementation offers out-of-the-box handling of authorization checks for this endpoint. If you pass in
* a header containing a `session_token` or a `session_jwt` for an unexpired Member Session, we will check that the
* Member Session has permission to perform the `search` action on the `stytch.member` Resource. In addition, enforcing
* RBAC on this endpoint means that you may only search for Members within the calling Member's Organization, so the
* `organization_ids` argument may only contain the `organization_id` of the Member Session passed in the header.
*
* If the Member Session does not contain a Role that satisfies the requested permission, or if the `organization_ids`
* argument contains an `organization_id` that the Member Session does not belong to, a 403 error will be thrown.
* Otherwise, the request will proceed as normal.
*
* To learn more about our RBAC implementation, see our [RBAC guide](https://stytch.com/docs/b2b/guides/rbac/overview).
*/
public fun searchCompletable(
data: SearchRequest,
methodOptions: SearchRequestOptions? = null,
): CompletableFuture>
/**
* Delete a Member's password. /%}
*/
public suspend fun deletePassword(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions? = null,
): StytchResult
/**
* Delete a Member's password. /%}
*/
public fun deletePassword(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Delete a Member's password. /%}
*/
public fun deletePasswordCompletable(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions? = null,
): CompletableFuture>
/**
* Get a Member by `member_id`. This endpoint does not require an `organization_id`, enabling you to get members across
* organizations. This is a dangerous operation. Incorrect use may open you up to indirect object reference (IDOR)
* attacks. We recommend using the [Get Member](https://stytch.com/docs/b2b/api/get-member) API instead.
*/
public suspend fun dangerouslyGet(data: DangerouslyGetRequest): StytchResult
/**
* Get a Member by `member_id`. This endpoint does not require an `organization_id`, enabling you to get members across
* organizations. This is a dangerous operation. Incorrect use may open you up to indirect object reference (IDOR)
* attacks. We recommend using the [Get Member](https://stytch.com/docs/b2b/api/get-member) API instead.
*/
public fun dangerouslyGet(
data: DangerouslyGetRequest,
callback: (StytchResult) -> Unit,
)
/**
* Get a Member by `member_id`. This endpoint does not require an `organization_id`, enabling you to get members across
* organizations. This is a dangerous operation. Incorrect use may open you up to indirect object reference (IDOR)
* attacks. We recommend using the [Get Member](https://stytch.com/docs/b2b/api/get-member) API instead.
*/
public fun dangerouslyGetCompletable(data: DangerouslyGetRequest): CompletableFuture>
/**
* Creates a Member. An `organization_id` and `email_address` are required. /%}
*/
public suspend fun create(
data: CreateRequest,
methodOptions: CreateRequestOptions? = null,
): StytchResult
/**
* Creates a Member. An `organization_id` and `email_address` are required. /%}
*/
public fun create(
data: CreateRequest,
methodOptions: CreateRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Creates a Member. An `organization_id` and `email_address` are required. /%}
*/
public fun createCompletable(
data: CreateRequest,
methodOptions: CreateRequestOptions? = null,
): CompletableFuture>
/**
* Get a Member by `member_id` or `email_address`.
*/
public suspend fun get(data: GetRequest): StytchResult
/**
* Get a Member by `member_id` or `email_address`.
*/
public fun get(
data: GetRequest,
callback: (StytchResult) -> Unit,
)
/**
* Get a Member by `member_id` or `email_address`.
*/
public fun getCompletable(data: GetRequest): CompletableFuture>
}
internal class MembersImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : Members {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override val oauthProviders: OAuthProviders = OAuthProvidersImpl(httpClient, coroutineScope)
override suspend fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
val asJson = moshi.adapter(UpdateRequest::class.java).toJson(data)
httpClient.put("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}", asJson, headers)
}
override fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(update(data, methodOptions))
}
}
override fun updateCompletable(
data: UpdateRequest,
methodOptions: UpdateRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
update(data, methodOptions)
}.asCompletableFuture()
override suspend fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
httpClient.delete("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}", headers)
}
override fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(delete(data, methodOptions))
}
}
override fun deleteCompletable(
data: DeleteRequest,
methodOptions: DeleteRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
delete(data, methodOptions)
}.asCompletableFuture()
override suspend fun reactivate(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
val asJson = moshi.adapter(ReactivateRequest::class.java).toJson(data)
httpClient.put("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}/reactivate", asJson, headers)
}
override fun reactivate(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(reactivate(data, methodOptions))
}
}
override fun reactivateCompletable(
data: ReactivateRequest,
methodOptions: ReactivateRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
reactivate(data, methodOptions)
}.asCompletableFuture()
override suspend fun deleteMFAPhoneNumber(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
httpClient.delete("/v1/b2b/organizations/${data.organizationId}/members/mfa_phone_numbers/${data.memberId}", headers)
}
override fun deleteMFAPhoneNumber(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(deleteMFAPhoneNumber(data, methodOptions))
}
}
override fun deleteMFAPhoneNumberCompletable(
data: DeleteMFAPhoneNumberRequest,
methodOptions: DeleteMFAPhoneNumberRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
deleteMFAPhoneNumber(data, methodOptions)
}.asCompletableFuture()
override suspend fun deleteTOTP(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
httpClient.delete("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}/totp", headers)
}
override fun deleteTOTP(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(deleteTOTP(data, methodOptions))
}
}
override fun deleteTOTPCompletable(
data: DeleteTOTPRequest,
methodOptions: DeleteTOTPRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
deleteTOTP(data, methodOptions)
}.asCompletableFuture()
override suspend fun search(
data: SearchRequest,
methodOptions: SearchRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
val asJson = moshi.adapter(SearchRequest::class.java).toJson(data)
httpClient.post("/v1/b2b/organizations/members/search", asJson, headers)
}
override fun search(
data: SearchRequest,
methodOptions: SearchRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(search(data, methodOptions))
}
}
override fun searchCompletable(
data: SearchRequest,
methodOptions: SearchRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
search(data, methodOptions)
}.asCompletableFuture()
override suspend fun deletePassword(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions?,
): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
methodOptions?.let {
headers = methodOptions.addHeaders(headers)
}
httpClient.delete("/v1/b2b/organizations/${data.organizationId}/members/passwords/${data.memberPasswordId}", headers)
}
override fun deletePassword(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions?,
callback: (StytchResult) -> Unit,
) {
coroutineScope.launch {
callback(deletePassword(data, methodOptions))
}
}
override fun deletePasswordCompletable(
data: DeletePasswordRequest,
methodOptions: DeletePasswordRequestOptions?,
): CompletableFuture> =
coroutineScope.async {
deletePassword(data, methodOptions)
}.asCompletableFuture()
override suspend fun dangerouslyGet(data: DangerouslyGetRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(DangerouslyGetRequest::class.java).toJson(data)
val type = Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)
val adapter: JsonAdapter