mirror of
https://github.com/ProtonMail/protoncore_android.git
synced 2026-05-15 09:50:41 +00:00
test: Updated TestSubscriptionData annotation to use latest payments seed subscription command.
This commit is contained in:
@@ -30,6 +30,7 @@ import okhttp3.Response
|
||||
|
||||
public const val SEED_PAYMENT_METHOD: String = "quark/raw::payments:seed-payment-method"
|
||||
public const val NEW_SEED_SUBSCRIBER: String = "quark/raw::new-payments:seed:subscribed-user"
|
||||
public const val NEW_SEED_SUBSCRIPTION: String = "quark/raw::new-payments:seed:subscription"
|
||||
|
||||
public fun QuarkCommand.seedSubscriber(
|
||||
user: User = User(plan = Plan.Free),
|
||||
@@ -55,6 +56,35 @@ public fun QuarkCommand.seedSubscriber(
|
||||
client.executeQuarkRequest(it)
|
||||
}
|
||||
|
||||
public fun QuarkCommand.seedSubscription(
|
||||
userId: String,
|
||||
plan: String = "free",
|
||||
cycleDurationMonths: Int = 1,
|
||||
currency: String = "USD",
|
||||
coupon: String = "",
|
||||
delinquent: Boolean = false, // Request adding this parameter support in quark command.
|
||||
isTrial: Boolean = false
|
||||
): Response =
|
||||
route(NEW_SEED_SUBSCRIPTION)
|
||||
.args(
|
||||
buildList {
|
||||
add("user-id" to userId)
|
||||
add("plan" to plan)
|
||||
add("cycle" to cycleDurationMonths.toString())
|
||||
add("currency" to currency)
|
||||
if (coupon.isNotEmpty()) {
|
||||
add("--coupon" to coupon)
|
||||
}
|
||||
if (isTrial) {
|
||||
add("--trial" to "")
|
||||
}
|
||||
}.toEncodedArgs()
|
||||
)
|
||||
.build()
|
||||
.let {
|
||||
client.executeQuarkRequest(it)
|
||||
}
|
||||
|
||||
public fun QuarkCommand.seedUserWithCreditCard(user: User = User()): Response =
|
||||
route(SEED_PAYMENT_METHOD)
|
||||
.args(
|
||||
|
||||
+3
@@ -31,7 +31,10 @@ public annotation class TestSubscriptionData(
|
||||
val plan: Plan = Plan.Free,
|
||||
val customPlan: String = "",
|
||||
val couponCode: String = EMPTY_STRING,
|
||||
val cycle: Int = 1,
|
||||
val currency: String = "USD",
|
||||
val delinquent: Boolean = false,
|
||||
val isTrial: Boolean = false
|
||||
)
|
||||
|
||||
public val TestSubscriptionData.annotationTestData: AnnotationTestData<TestSubscriptionData>
|
||||
|
||||
@@ -24,6 +24,7 @@ import me.proton.core.test.quark.response.CreateUserQuarkResponse
|
||||
import me.proton.core.test.quark.v2.QuarkCommand
|
||||
import me.proton.core.test.quark.v2.command.NEW_SEED_SUBSCRIBER
|
||||
import me.proton.core.test.quark.v2.command.USERS_CREATE
|
||||
import me.proton.core.test.quark.v2.command.seedSubscription
|
||||
import me.proton.core.test.quark.v2.command.setPaymentMethods
|
||||
import me.proton.core.test.quark.v2.toEncodedArgs
|
||||
import me.proton.core.test.rule.annotation.PrepareUser
|
||||
@@ -77,22 +78,15 @@ public fun QuarkCommand.seedTestUserData(userData: TestUserData): CreateUserQuar
|
||||
public fun QuarkCommand.subscriptionCreate(
|
||||
subscription: TestSubscriptionData,
|
||||
decryptedUserId: String
|
||||
): Response {
|
||||
return route("quark/raw::user:create:subscription")
|
||||
.args(
|
||||
listOf(
|
||||
"userID" to decryptedUserId,
|
||||
"--planID" to subscription.customPlan.ifEmpty { subscription.plan.planName },
|
||||
"--couponCode" to subscription.couponCode,
|
||||
"--delinquent" to subscription.delinquent.toString(),
|
||||
"--format" to "json"
|
||||
).toEncodedArgs()
|
||||
)
|
||||
.build()
|
||||
.let {
|
||||
client.executeQuarkRequest(it)
|
||||
}
|
||||
}
|
||||
): Response = seedSubscription(
|
||||
userId = decryptedUserId,
|
||||
plan = subscription.plan.planName.takeIf { subscription.customPlan.isEmpty() } ?: subscription.customPlan,
|
||||
cycleDurationMonths = subscription.cycle,
|
||||
currency = subscription.currency,
|
||||
coupon = subscription.couponCode,
|
||||
delinquent = subscription.delinquent,
|
||||
isTrial = subscription.isTrial
|
||||
)
|
||||
|
||||
public fun QuarkCommand.seedSubscriber(
|
||||
userData: PrepareUser,
|
||||
|
||||
Reference in New Issue
Block a user