Skip to content

Commit

Permalink
MBL-1251 get create attribution event graphqltransformer (#1969)
Browse files Browse the repository at this point in the history
MBL-1251 Add a new getCreateAttributionEvent GraphQLTransformer
  • Loading branch information
ycheng-kickstarter committed Mar 6, 2024
1 parent f6c5d30 commit 9f17a55
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.kickstarter.services.transformers

import CreateAttributionEventMutation
import TriggerThirdPartyEventMutation
import UserPrivacyQuery
import com.google.android.gms.common.util.Base64Utils
import com.google.gson.Gson
import com.kickstarter.libs.Permission
import com.kickstarter.libs.utils.extensions.negate
import com.kickstarter.mock.factories.RewardFactory
Expand All @@ -28,13 +31,15 @@ import com.kickstarter.models.UserPrivacy
import com.kickstarter.models.Video
import com.kickstarter.models.Web
import com.kickstarter.services.apiresponses.ShippingRulesEnvelope
import com.kickstarter.services.mutations.CreateAttributionEventData
import com.kickstarter.viewmodels.usecases.TPEventInputData
import fragment.FullProject
import fragment.ProjectCard
import org.jetbrains.annotations.Nullable
import org.joda.time.DateTime
import type.AppDataInput
import type.CollaboratorPermission
import type.CreateAttributionEventInput
import type.CreditCardPaymentType
import type.CurrencyCode
import type.RewardType
Expand Down Expand Up @@ -854,3 +859,24 @@ fun getTriggerThirdPartyEventMutation(eventInput: TPEventInputData): TriggerThir
return TriggerThirdPartyEventMutation.builder().triggerThirdPartyEventInput(graphInput)
.build()
}

/**
* From KS dataModel CreateAttributionEventData, transform it into
* GraphQL defined mutation CreateAttributionEventMutation
*/
fun getCreateAttributionEventMutation(eventInput: CreateAttributionEventData, gson: Gson): CreateAttributionEventMutation {

// Use gson to convert map -> JSON type to match mutation
val eventPropertiesJson = gson.toJson(eventInput.eventProperties)

val graphInput =
CreateAttributionEventInput.builder()
.eventName(eventInput.eventName)
.eventProperties(eventPropertiesJson)
.projectId(eventInput.projectId)
.clientMutationId(eventInput.clientMutationId)
.build()

return CreateAttributionEventMutation.builder().input(graphInput)
.build()
}

0 comments on commit 9f17a55

Please sign in to comment.