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.organizations
// !!!
// 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.organizationsmembers.Members
import com.stytch.java.b2b.api.organizationsmembers.MembersImpl
import com.stytch.java.b2b.models.organizations.CreateRequest
import com.stytch.java.b2b.models.organizations.CreateResponse
import com.stytch.java.b2b.models.organizations.DeleteRequest
import com.stytch.java.b2b.models.organizations.DeleteRequestOptions
import com.stytch.java.b2b.models.organizations.DeleteResponse
import com.stytch.java.b2b.models.organizations.GetRequest
import com.stytch.java.b2b.models.organizations.GetResponse
import com.stytch.java.b2b.models.organizations.MetricsRequest
import com.stytch.java.b2b.models.organizations.MetricsResponse
import com.stytch.java.b2b.models.organizations.SearchRequest
import com.stytch.java.b2b.models.organizations.SearchResponse
import com.stytch.java.b2b.models.organizations.UpdateRequest
import com.stytch.java.b2b.models.organizations.UpdateRequestOptions
import com.stytch.java.b2b.models.organizations.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 Organizations {
public val members: Members
/**
* Creates an. An `organization_name` and a unique `organization_slug` are required.
*
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public suspend fun create(data: CreateRequest): StytchResult
/**
* Creates an. An `organization_name` and a unique `organization_slug` are required.
*
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public fun create(
data: CreateRequest,
callback: (StytchResult) -> Unit,
)
/**
* Creates an. An `organization_name` and a unique `organization_slug` are required.
*
* By default, `email_invites` and `sso_jit_provisioning` will be set to `ALL_ALLOWED`, and `mfa_policy` will be set to
* `OPTIONAL` if no Organization authentication settings are explicitly defined in the request.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public fun createCompletable(data: CreateRequest): CompletableFuture>
/**
* Returns an specified by `organization_id`.
*/
public suspend fun get(data: GetRequest): StytchResult
/**
* Returns an specified by `organization_id`.
*/
public fun get(
data: GetRequest,
callback: (StytchResult) -> Unit,
)
/**
* Returns an specified by `organization_id`.
*/
public fun getCompletable(data: GetRequest): CompletableFuture>
/**
* Updates an specified by `organization_id`. An Organization must always have at least one auth setting set to either
* `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public suspend fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
): StytchResult
/**
* Updates an specified by `organization_id`. An Organization must always have at least one auth setting set to either
* `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public fun update(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Updates an specified by `organization_id`. An Organization must always have at least one auth setting set to either
* `RESTRICTED` or `ALL_ALLOWED` in order to provision new Members.
*
* *See the [Organization authentication settings](https://stytch.com/docs/b2b/api/org-auth-settings) resource to learn
* more about fields like `email_jit_provisioning`, `email_invites`, `sso_jit_provisioning`, etc., and their behaviors.
*/
public fun updateCompletable(
data: UpdateRequest,
methodOptions: UpdateRequestOptions? = null,
): CompletableFuture>
/**
* Deletes an specified by `organization_id`. All Members of the Organization will also be deleted.
*/
public suspend fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
): StytchResult
/**
* Deletes an specified by `organization_id`. All Members of the Organization will also be deleted.
*/
public fun delete(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
callback: (StytchResult) -> Unit,
)
/**
* Deletes an specified by `organization_id`. All Members of the Organization will also be deleted.
*/
public fun deleteCompletable(
data: DeleteRequest,
methodOptions: DeleteRequestOptions? = null,
): CompletableFuture>
/**
* Search for Organizations. If you send a request with no body params, no filtering will be applied and the endpoint will
* return all Organizations. All fuzzy search filters require a minimum of three characters.
*/
public suspend fun search(data: SearchRequest): StytchResult
/**
* Search for Organizations. If you send a request with no body params, no filtering will be applied and the endpoint will
* return all Organizations. All fuzzy search filters require a minimum of three characters.
*/
public fun search(
data: SearchRequest,
callback: (StytchResult) -> Unit,
)
/**
* Search for Organizations. If you send a request with no body params, no filtering will be applied and the endpoint will
* return all Organizations. All fuzzy search filters require a minimum of three characters.
*/
public fun searchCompletable(data: SearchRequest): CompletableFuture>
public suspend fun metrics(data: MetricsRequest): StytchResult
public fun metrics(
data: MetricsRequest,
callback: (StytchResult) -> Unit,
)
public fun metricsCompletable(data: MetricsRequest): CompletableFuture>
}
internal class OrganizationsImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : Organizations {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override val members: Members = MembersImpl(httpClient, coroutineScope)
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/b2b/organizations", 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