-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b605f3a
commit 81f5569
Showing
14 changed files
with
435 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
stytch/src/main/kotlin/com/stytch/java/b2b/api/passwordsdiscovery/PasswordsDiscovery.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.stytch.java.b2b.api.passwordsdiscovery | ||
|
||
// !!! | ||
// WARNING: This file is autogenerated | ||
// Only modify code within MANUAL() sections | ||
// or your changes may be overwritten later! | ||
// !!! | ||
|
||
import com.squareup.moshi.Moshi | ||
import com.stytch.java.b2b.api.passwordsdiscoveryemail.Email | ||
import com.stytch.java.b2b.api.passwordsdiscoveryemail.EmailImpl | ||
import com.stytch.java.b2b.models.passwordsdiscovery.AuthenticateRequest | ||
import com.stytch.java.b2b.models.passwordsdiscovery.AuthenticateResponse | ||
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 Discovery { | ||
public val email: Email | ||
|
||
public suspend fun authenticate(data: AuthenticateRequest): StytchResult<AuthenticateResponse> | ||
|
||
public fun authenticate( | ||
data: AuthenticateRequest, | ||
callback: (StytchResult<AuthenticateResponse>) -> Unit, | ||
) | ||
|
||
public fun authenticateCompletable(data: AuthenticateRequest): CompletableFuture<StytchResult<AuthenticateResponse>> | ||
} | ||
|
||
internal class DiscoveryImpl( | ||
private val httpClient: HttpClient, | ||
private val coroutineScope: CoroutineScope, | ||
) : Discovery { | ||
private val moshi = Moshi.Builder().add(InstantAdapter()).build() | ||
|
||
override val email: Email = EmailImpl(httpClient, coroutineScope) | ||
|
||
override suspend fun authenticate(data: AuthenticateRequest): StytchResult<AuthenticateResponse> = | ||
withContext(Dispatchers.IO) { | ||
var headers = emptyMap<String, String>() | ||
|
||
val asJson = moshi.adapter(AuthenticateRequest::class.java).toJson(data) | ||
httpClient.post("/v1/b2b/passwords/discovery/authenticate", asJson, headers) | ||
} | ||
|
||
override fun authenticate( | ||
data: AuthenticateRequest, | ||
callback: (StytchResult<AuthenticateResponse>) -> Unit, | ||
) { | ||
coroutineScope.launch { | ||
callback(authenticate(data)) | ||
} | ||
} | ||
|
||
override fun authenticateCompletable(data: AuthenticateRequest): CompletableFuture<StytchResult<AuthenticateResponse>> = | ||
coroutineScope.async { | ||
authenticate(data) | ||
}.asCompletableFuture() | ||
} |
94 changes: 94 additions & 0 deletions
94
...rc/main/kotlin/com/stytch/java/b2b/api/passwordsdiscoveryemail/PasswordsDiscoveryEmail.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.stytch.java.b2b.api.passwordsdiscoveryemail | ||
|
||
// !!! | ||
// WARNING: This file is autogenerated | ||
// Only modify code within MANUAL() sections | ||
// or your changes may be overwritten later! | ||
// !!! | ||
|
||
import com.squareup.moshi.Moshi | ||
import com.stytch.java.b2b.models.passwordsdiscoveryemail.ResetRequest | ||
import com.stytch.java.b2b.models.passwordsdiscoveryemail.ResetResponse | ||
import com.stytch.java.b2b.models.passwordsdiscoveryemail.ResetStartRequest | ||
import com.stytch.java.b2b.models.passwordsdiscoveryemail.ResetStartResponse | ||
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 Email { | ||
public suspend fun resetStart(data: ResetStartRequest): StytchResult<ResetStartResponse> | ||
|
||
public fun resetStart( | ||
data: ResetStartRequest, | ||
callback: (StytchResult<ResetStartResponse>) -> Unit, | ||
) | ||
|
||
public fun resetStartCompletable(data: ResetStartRequest): CompletableFuture<StytchResult<ResetStartResponse>> | ||
|
||
public suspend fun reset(data: ResetRequest): StytchResult<ResetResponse> | ||
|
||
public fun reset( | ||
data: ResetRequest, | ||
callback: (StytchResult<ResetResponse>) -> Unit, | ||
) | ||
|
||
public fun resetCompletable(data: ResetRequest): CompletableFuture<StytchResult<ResetResponse>> | ||
} | ||
|
||
internal class EmailImpl( | ||
private val httpClient: HttpClient, | ||
private val coroutineScope: CoroutineScope, | ||
) : Email { | ||
private val moshi = Moshi.Builder().add(InstantAdapter()).build() | ||
|
||
override suspend fun resetStart(data: ResetStartRequest): StytchResult<ResetStartResponse> = | ||
withContext(Dispatchers.IO) { | ||
var headers = emptyMap<String, String>() | ||
|
||
val asJson = moshi.adapter(ResetStartRequest::class.java).toJson(data) | ||
httpClient.post("/v1/b2b/passwords/discovery/email/reset/start", asJson, headers) | ||
} | ||
|
||
override fun resetStart( | ||
data: ResetStartRequest, | ||
callback: (StytchResult<ResetStartResponse>) -> Unit, | ||
) { | ||
coroutineScope.launch { | ||
callback(resetStart(data)) | ||
} | ||
} | ||
|
||
override fun resetStartCompletable(data: ResetStartRequest): CompletableFuture<StytchResult<ResetStartResponse>> = | ||
coroutineScope.async { | ||
resetStart(data) | ||
}.asCompletableFuture() | ||
|
||
override suspend fun reset(data: ResetRequest): StytchResult<ResetResponse> = | ||
withContext(Dispatchers.IO) { | ||
var headers = emptyMap<String, String>() | ||
|
||
val asJson = moshi.adapter(ResetRequest::class.java).toJson(data) | ||
httpClient.post("/v1/b2b/passwords/discovery/email/reset", asJson, headers) | ||
} | ||
|
||
override fun reset( | ||
data: ResetRequest, | ||
callback: (StytchResult<ResetResponse>) -> Unit, | ||
) { | ||
coroutineScope.launch { | ||
callback(reset(data)) | ||
} | ||
} | ||
|
||
override fun resetCompletable(data: ResetRequest): CompletableFuture<StytchResult<ResetResponse>> = | ||
coroutineScope.async { | ||
reset(data) | ||
}.asCompletableFuture() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.