Skip to content

Commit

Permalink
MBL-1918 API | Expose 'incremental' field on the CreateBacking muta…
Browse files Browse the repository at this point in the history
…tion (#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
  • Loading branch information
jlplks authored Dec 7, 2024
1 parent 317b28b commit 0482474
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/src/main/graphql/checkout.graphql
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/graphql/fragments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ fragment backing on Backing {
pledgedOn
backerCompleted
isPostCampaign
incremental
project {
... project
}
Expand Down
71 changes: 66 additions & 5 deletions app/src/main/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -4496,11 +4501,6 @@ type Order implements Node {
"""
address: Address

"""
Whether the order requires shipping or tax
"""
autoExemptable: Boolean!

"""
The associated backer
"""
Expand All @@ -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
"""
Expand All @@ -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.
"""
Expand Down Expand Up @@ -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.
"""
Expand Down Expand Up @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Reward>? = 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<Reward>? = null, val refTag: RefTag?, val stripeCardId: String? = null, val incremental: Boolean? = null)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand Down

0 comments on commit 0482474

Please sign in to comment.