-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup TriggerThirdPartyEvent mutation
* update Service and ServiceType * create new adapter files * convert TriggerCapiEventInput to TriggerThirdPartyInput * create TriggerThirdPartyEvent.graphql in /mutations
- Loading branch information
1 parent
df76cd4
commit 5c7a051
Showing
8 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...s/graphql/adapters/GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInput.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
extension GraphAPI.TriggerThirdPartyEvent { | ||
static func from(_ input: TriggerThirdPartyEventInput) -> GraphAPI.TriggerThirdPartyEvent { | ||
return GraphAPI.TriggerThirdPartyEvent( | ||
deviceId: input.deviceId, | ||
eventName: input.eventName, | ||
projectId: input.projectId, | ||
pledgeAmount: input.pledgeAmount, | ||
shipping: input.shipping, | ||
transactionId: input.transactionId, | ||
userId: input.userId, | ||
appData: GraphAPI.AppDataInput?, | ||
clientMutation: input.clientMutation | ||
) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...phql/adapters/GraphAPI.TriggerThirdPartyEventInput+TriggerThirdPartyEventInputTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@testable import KsApi | ||
import XCTest | ||
|
||
class GraphAPI_TriggerThirdPartyEventInput_TriggerThirdPartyEventInputTests: XCTestCase { | ||
func testTriggerThirdEventPartyInputCreation_WithValidData_Success() { | ||
let input = | ||
TriggerThirdPartyEventInput( | ||
deviceId: "deviceId", | ||
eventName: "eventName", | ||
projectId: "projectId", | ||
pledgeAmount: 1.0, | ||
shipping: 2.0, | ||
transactionId: "transactionId", | ||
userId: "userId", | ||
appData: GraphAPI.AppDataInput( | ||
advertiserTrackingEnabled: true, | ||
applicationTrackingEnabled: true, | ||
extinfo: ["appData"] | ||
), | ||
clientMutation: "" | ||
) | ||
|
||
let graphInput = GraphAPI.TriggerThirdPartyEvent.from(input) | ||
|
||
XCTAssertEqual(graphInput.deviceId, input.deviceId) | ||
XCTAssertEqual(graphInput.eventName, input.eventName) | ||
XCTAssertEqual(graphInput.projectId, input.projectId) | ||
XCTAssertEqual(graphInput.pledgeAmount, input.pledgeAmount) | ||
XCTAssertEqual(graphInput.shipping, input.shipping) | ||
XCTAssertEqual(graphInput.transactionId, input.transactionId) | ||
XCTAssertEqual(graphInput.userId, input.userId) | ||
XCTAssertNotNil(graphInput.appData) | ||
XCTAssertEqual(graphInput.clientMutation, input.clientMutation) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mutation triggerThirdPartyEvent($input: TriggerThirdPartyEventInput!) { | ||
triggerThirdPartyEvent(input: $input) { | ||
success | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import Foundation | ||
|
||
public struct TriggerThirdPartyEventInput: GraphMutationInput { | ||
let deviceId: String | ||
let eventName: String | ||
let projectId: String | ||
let pledgeAmount: Float? | ||
let shipping: Float? | ||
let transactionId: String? | ||
let userId: String? | ||
let appData: GraphAPI.AppDataInput? | ||
let clientMutation: String | ||
|
||
public init( | ||
deviceId: String, | ||
eventName: String, | ||
projectId: String, | ||
pledgeAmount: Float?, | ||
shipping: Float?, | ||
transactionId: String?, | ||
userId: String?, | ||
appData: GraphAPI.AppDataInput?, | ||
clientMutation: String | ||
) { | ||
self.deviceId = deviceId | ||
self.eventName = eventName | ||
self.projectId = projectId | ||
self.pledgeAmount = pledgeAmount | ||
self.shipping = shipping | ||
self.transactionId = transactionId | ||
self.userId = userId | ||
self.appData = appData | ||
self.clientMutation = clientMutation | ||
} | ||
|
||
public func toInputDictionary() -> [String: Any] { | ||
return [ | ||
"deviceId": self.deviceId, | ||
"eventName": self.eventName, | ||
"projectId": self.projectId, | ||
"pledgeAmount": self.pledgeAmount, | ||
"shipping": self.shipping, | ||
"transactionId": self.transactionId, | ||
"userId": self.userId, | ||
"appData": self.appData, | ||
"clientMutation": self.clientMutation | ||
] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
KsApi/mutations/inputs/TriggerThirdPartyEventInputTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@testable import KsApi | ||
import XCTest | ||
|
||
final class TriggerThirdPartyEventInputTests: XCTestCase { | ||
func testTriggerThirdPartyEventInputTestsDictionary_WithValue_Success() { | ||
let triggerThirdPartyEventInput = | ||
TriggerThirdPartyEventInput( | ||
deviceId: "deviceId", | ||
eventName: "eventName", | ||
projectId: "projectId", | ||
pledgeAmount: 1.0, | ||
shipping: 2.0, | ||
transactionId: "transactionId", | ||
userId: "userId", | ||
appData: GraphAPI.AppDataInput( | ||
advertiserTrackingEnabled: true, | ||
applicationTrackingEnabled: true, | ||
extinfo: ["appData"] | ||
), | ||
clientMutation: "" | ||
) | ||
|
||
let input = triggerThirdPartyEventInput.toInputDictionary() | ||
|
||
XCTAssertEqual(input["deviceId"] as? String, "deviceId") | ||
XCTAssertEqual(input["eventName"] as? String, "eventName") | ||
XCTAssertEqual(input["projectId"] as? String, "projectId") | ||
XCTAssertEqual(input["pledgeAmount"] as? Float, 1.0) | ||
XCTAssertEqual(input["shipping"] as? Float, 2.0) | ||
XCTAssertEqual(input["transactionId"] as? String, "transactionId") | ||
XCTAssertEqual(input["userId"] as? String, "userId") | ||
XCTAssertNotNil(input["appData"]) | ||
XCTAssertEqual(input["clientMutation"] as? String, "") | ||
} | ||
} |