Skip to content

Commit

Permalink
Add create attribution event to service
Browse files Browse the repository at this point in the history
  • Loading branch information
ifosli committed Feb 26, 2024
1 parent 391bd00 commit 36626aa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions KsApi/MockService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

fileprivate let changePasswordResult: Result<EmptyResponseEnvelope, ErrorEnvelope>?

fileprivate let createAttributionEventResult: Result<EmptyResponseEnvelope, ErrorEnvelope>?

fileprivate let createBackingResult: Result<CreateBackingEnvelope, ErrorEnvelope>?

fileprivate let createCheckoutResult: Result<CreateCheckoutEnvelope, ErrorEnvelope>?
Expand Down Expand Up @@ -227,6 +229,7 @@
cancelBackingResult: Result<EmptyResponseEnvelope, ErrorEnvelope>? = nil,
changeEmailResult: Result<EmptyResponseEnvelope, ErrorEnvelope>? = nil,
changePasswordResult: Result<EmptyResponseEnvelope, ErrorEnvelope>? = nil,
createAttributionEventResult: Result<EmptyResponseEnvelope, ErrorEnvelope>? = nil,
createBackingResult: Result<CreateBackingEnvelope, ErrorEnvelope>? = nil,
createCheckoutResult: Result<CreateCheckoutEnvelope, ErrorEnvelope>? = nil,
createFlaggingResult: Result<EmptyResponseEnvelope, ErrorEnvelope>? = nil,
Expand Down Expand Up @@ -350,6 +353,8 @@

self.clearUserUnseenActivityResult = clearUserUnseenActivityResult

self.createAttributionEventResult = createAttributionEventResult

self.createBackingResult = createBackingResult

self.createCheckoutResult = createCheckoutResult
Expand Down Expand Up @@ -618,6 +623,17 @@
return client.performWithResult(mutation: mutation, result: self.changePasswordResult)
}

public func createAttributionEvent(input: GraphAPI.CreateAttributionEventInput) ->
SignalProducer<EmptyResponseEnvelope, ErrorEnvelope> {
guard let client = self.apolloClient else {
return .empty
}

let mutation = GraphAPI.CreateAttributionEventMutation(input: input)

return client.performWithResult(mutation: mutation, result: self.createAttributionEventResult)
}

internal func createBacking(input: CreateBackingInput)
-> SignalProducer<CreateBackingEnvelope, ErrorEnvelope> {
guard let client = self.apolloClient else {
Expand Down
10 changes: 10 additions & 0 deletions KsApi/Service.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ public struct Service: ServiceType {
}
}

public func createAttributionEvent(input: GraphAPI.CreateAttributionEventInput) ->
SignalProducer<EmptyResponseEnvelope, ErrorEnvelope> {
return GraphQL.shared.client
.perform(mutation: GraphAPI
.CreateAttributionEventMutation(input: input))
.flatMap { _ in
SignalProducer(value: EmptyResponseEnvelope())
}
}

public func createBacking(input: CreateBackingInput) ->
SignalProducer<CreateBackingEnvelope, ErrorEnvelope> {
return GraphQL.shared.client
Expand Down
4 changes: 4 additions & 0 deletions KsApi/ServiceType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public protocol ServiceType {
func clearUserUnseenActivity(input: EmptyInput)
-> SignalProducer<ClearUserUnseenActivityEnvelope, ErrorEnvelope>

/// Let the server know to create/track an attribution event.
func createAttributionEvent(input: GraphAPI.CreateAttributionEventInput) ->
SignalProducer<EmptyResponseEnvelope, ErrorEnvelope>

func createBacking(input: CreateBackingInput) ->
SignalProducer<CreateBackingEnvelope, ErrorEnvelope>

Expand Down

0 comments on commit 36626aa

Please sign in to comment.