From 0482474b1b52a86db9d9bc511316684e3e489421 Mon Sep 17 00:00:00 2001 From: jlplks Date: Sat, 7 Dec 2024 01:26:32 -0700 Subject: [PATCH] MBL-1918 API | Expose 'incremental' field on the `CreateBacking` mutation (#2185) * added incremental prop to CreateBaking mutation to indicates BE that PLOT is selected * fix ktlint and added incremental to KSApolloClientV2 * delete unecesary fields * fix ktlint * change incremental from Boolean = false to Boolean? = null * update schema --- app/src/main/graphql/checkout.graphql | 4 +- app/src/main/graphql/fragments.graphql | 1 + app/src/main/graphql/schema.graphqls | 71 +++++++++++++++++-- .../kickstarter/services/KSApolloClientV2.kt | 3 +- .../services/mutations/CreateBackingData.kt | 2 +- .../transformers/GraphQLTransformers.kt | 3 +- 6 files changed, 74 insertions(+), 10 deletions(-) diff --git a/app/src/main/graphql/checkout.graphql b/app/src/main/graphql/checkout.graphql index 63177f90b5..a7680f9f04 100644 --- a/app/src/main/graphql/checkout.graphql +++ b/app/src/main/graphql/checkout.graphql @@ -1,5 +1,5 @@ -mutation CreateBacking($projectId: ID!, $amount: String!, $paymentType: String!, $paymentSourceId: String, $setupIntentClientSecret: String, $locationId: String, $rewardIds: [ID!], $refParam: String) { - createBacking(input: {projectId: $projectId, amount: $amount, paymentType: $paymentType, paymentSourceId: $paymentSourceId, setupIntentClientSecret: $setupIntentClientSecret, locationId: $locationId, rewardIds: $rewardIds, refParam: $refParam}) { +mutation CreateBacking($projectId: ID!, $amount: String!, $paymentType: String!, $paymentSourceId: String, $setupIntentClientSecret: String, $locationId: String, $rewardIds: [ID!], $refParam: String, $incremental: Boolean) { + createBacking(input: {projectId: $projectId, amount: $amount, paymentType: $paymentType, paymentSourceId: $paymentSourceId, setupIntentClientSecret: $setupIntentClientSecret, locationId: $locationId, rewardIds: $rewardIds, refParam: $refParam, incremental: $incremental}) { checkout { id backing { diff --git a/app/src/main/graphql/fragments.graphql b/app/src/main/graphql/fragments.graphql index 6c4e036d14..8ddc7ae342 100644 --- a/app/src/main/graphql/fragments.graphql +++ b/app/src/main/graphql/fragments.graphql @@ -152,6 +152,7 @@ fragment backing on Backing { pledgedOn backerCompleted isPostCampaign + incremental project { ... project } diff --git a/app/src/main/graphql/schema.graphqls b/app/src/main/graphql/schema.graphqls index 471e1a45c3..0adeb1db13 100644 --- a/app/src/main/graphql/schema.graphqls +++ b/app/src/main/graphql/schema.graphqls @@ -1649,6 +1649,11 @@ type Project implements Node & Commentable { """ onBehalfOf: String + """ + Build a payment plan given a project id and amount + """ + paymentPlan("Amount in project funding currency, dollars-and-cents equivalent format" amount: String!): PaymentPlan + """ Payment source on creator's account used to issue refunds. """ @@ -4496,11 +4501,6 @@ type Order implements Node { """ address: Address - """ - Whether the order requires shipping or tax - """ - autoExemptable: Boolean! - """ The associated backer """ @@ -4516,6 +4516,11 @@ type Order implements Node { """ cart: Cart + """ + Whether or not the order would be auto-exemptable if the order had no cross-sells. + """ + checkoutVoucherAutoCompletable: Boolean! + """ Add-ons selected for this order during Pledge Redemption """ @@ -4533,6 +4538,11 @@ type Order implements Node { id: ID! + """ + Whether the backer must acknowledge cross-sells to complete checkout + """ + mustAcknowledgeCrossSells: Boolean! + """ Payment source used on an order. """ @@ -8281,6 +8291,23 @@ type CreatorToolsPaths { projectPath: String! } +""" +A payment plan for a pledge over time project +""" +type PaymentPlan { + """ + Amount is enough to qualify for pledge over time, if project allows + """ + amountIsPledgeOverTimeEligible: Boolean! + + paymentIncrements: [PaymentIncrement!] + + """ + Whether the project permits pledge over time pledges + """ + projectIsPledgeOverTimeAllowed: Boolean! +} + """ The connection type for Backing. """ @@ -10762,6 +10789,11 @@ type Mutation { """ bulkEditQuestions(input: BulkEditQuestionsInput!): BulkEditQuestionsPayload + """ + Takes a stock location and bulk edits the location mapping + """ + bulkEditStockLocationMappings(input: BulkEditStockLocationMappingsInput!): BulkEditStockLocationMappingsPayload + """ Cancel a pledged backing """ @@ -16503,6 +16535,35 @@ input DeleteStockLocationInput { clientMutationId: String } +""" +Autogenerated return type of BulkEditStockLocationMappings +""" +type BulkEditStockLocationMappingsPayload { + """ + A unique identifier for the client performing the mutation. + """ + clientMutationId: String + + """ + The updated stock location + """ + stockLocation: StockLocation! +} + +""" +Autogenerated input type of BulkEditStockLocationMappings +""" +input BulkEditStockLocationMappingsInput { + stockLocationId: ID! + + locationIds: [ID!]! + + """ + A unique identifier for the client performing the mutation. + """ + clientMutationId: String +} + """ Autogenerated return type of CreateOption """ diff --git a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt index 186390fbda..fd17c06b46 100644 --- a/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt +++ b/app/src/main/java/com/kickstarter/services/KSApolloClientV2.kt @@ -829,6 +829,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient amount = createBackingData.amount, paymentType = PaymentTypes.CREDIT_CARD.rawValue, paymentSourceId = if (createBackingData.paymentSourceId.isNotNull()) Optional.present(createBackingData.paymentSourceId) else Optional.absent(), + incremental = if (createBackingData.incremental.isNotNull()) Optional.present(createBackingData.incremental) else Optional.absent(), setupIntentClientSecret = if (createBackingData.setupIntentClientSecret.isNotNull()) Optional.present(createBackingData.setupIntentClientSecret) else Optional.absent(), @@ -1710,7 +1711,7 @@ class KSApolloClientV2(val service: ApolloClient, val gson: Gson) : ApolloClient response.data?.completeOrder?.let { val payload = CompleteOrderPayload( - status = it.status.name, + status = it.status.toString(), clientSecret = it.clientSecret ?: "" ) ps.onNext(payload) diff --git a/app/src/main/java/com/kickstarter/services/mutations/CreateBackingData.kt b/app/src/main/java/com/kickstarter/services/mutations/CreateBackingData.kt index 98b5ee757f..d64a01f3a5 100644 --- a/app/src/main/java/com/kickstarter/services/mutations/CreateBackingData.kt +++ b/app/src/main/java/com/kickstarter/services/mutations/CreateBackingData.kt @@ -4,4 +4,4 @@ import com.kickstarter.libs.RefTag import com.kickstarter.models.Project import com.kickstarter.models.Reward -data class CreateBackingData(val project: Project, val amount: String, val paymentSourceId: String? = null, val setupIntentClientSecret: String? = null, val locationId: String?, val reward: Reward? = null, val rewardsIds: List? = null, val refTag: RefTag?, val stripeCardId: String? = null) +data class CreateBackingData(val project: Project, val amount: String, val paymentSourceId: String? = null, val setupIntentClientSecret: String? = null, val locationId: String?, val reward: Reward? = null, val rewardsIds: List? = null, val refTag: RefTag?, val stripeCardId: String? = null, val incremental: Boolean? = null) diff --git a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt index 328236619b..aa401d2a5e 100644 --- a/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt +++ b/app/src/main/java/com/kickstarter/services/transformers/GraphQLTransformers.kt @@ -765,7 +765,7 @@ fun backingTransformer(backingGr: com.kickstarter.fragment.Backing?): Backing { val status = backingGr?.status?.rawValue ?: "" val isPostCampaign = backingGr?.isPostCampaign ?: false - + val incremental = backingGr?.incremental ?: false return Backing.builder() .amount(backingGr?.amount?.amount?.amount?.toDouble() ?: 0.0) .bonusAmount(backingGr?.bonusAmount?.amount?.amount?.toDouble() ?: 0.0) @@ -775,6 +775,7 @@ fun backingTransformer(backingGr: com.kickstarter.fragment.Backing?): Backing { .backerName(nameBacker) .backer(backer) .id(id) + .incremental(incremental) .reward(reward) .addOns(addOns) .rewardId(reward?.id())