Skip to content

Commit

Permalink
MBL-117: Add CompleteOnSessionCheckoutMutation to GraphAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-at-kickstarter committed Mar 18, 2024
1 parent c558498 commit b09f77f
Show file tree
Hide file tree
Showing 7 changed files with 330 additions and 51 deletions.
4 changes: 4 additions & 0 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1513,6 +1513,7 @@
E113BD912B7D615000D3A809 /* Prelude in Frameworks */ = {isa = PBXBuildFile; productRef = E113BD902B7D615000D3A809 /* Prelude */; };
E118351F2B75639F007B42E6 /* PaginationExampleViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = E118351E2B75639F007B42E6 /* PaginationExampleViewModel.swift */; };
E11CFE4B2B6C42CE00497375 /* OAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = E11CFE492B6C41B400497375 /* OAuth.swift */; };
E12420A22BA8921800037DB5 /* CompleteOnSessionCheckoutMutation.graphql in Resources */ = {isa = PBXBuildFile; fileRef = E12420A12BA8921800037DB5 /* CompleteOnSessionCheckoutMutation.graphql */; };
E16794282B7EAA5200064063 /* OAuthTokenExchange.swift in Sources */ = {isa = PBXBuildFile; fileRef = E16794272B7EAA5200064063 /* OAuthTokenExchange.swift */; };
E167942A2B85136900064063 /* OAuthTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E16794292B85136900064063 /* OAuthTests.swift */; };
E170B9112B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E170B9102B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift */; };
Expand Down Expand Up @@ -3132,6 +3133,7 @@
E118351E2B75639F007B42E6 /* PaginationExampleViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationExampleViewModel.swift; sourceTree = "<group>"; };
E11CFE492B6C41B400497375 /* OAuth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuth.swift; sourceTree = "<group>"; };
E11CFE4E2B7162A400497375 /* PaginationExampleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaginationExampleView.swift; sourceTree = "<group>"; };
E12420A12BA8921800037DB5 /* CompleteOnSessionCheckoutMutation.graphql */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CompleteOnSessionCheckoutMutation.graphql; sourceTree = "<group>"; };
E16794272B7EAA5200064063 /* OAuthTokenExchange.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthTokenExchange.swift; sourceTree = "<group>"; };
E16794292B85136900064063 /* OAuthTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OAuthTests.swift; sourceTree = "<group>"; };
E170B9102B20E83B001BEDD7 /* MockGraphQLClient+CombineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MockGraphQLClient+CombineTests.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5674,6 +5676,7 @@
6051C6742B67F2D600514202 /* CreatePaymentIntent.graphql */,
47C0BCD726C42135003658AC /* CreatePaymentSource.graphql */,
19047FBA2889A16300BDD1A8 /* CreateSetupIntent.graphql */,
E12420A12BA8921800037DB5 /* CompleteOnSessionCheckoutMutation.graphql */,
06261602273B0E1500389981 /* PostComment.graphql */,
062868E526B999EF00EC5052 /* DeletePaymentSource.graphql */,
47D7D09526C2EA5200D2BAB5 /* SignInWithApple.graphql */,
Expand Down Expand Up @@ -7467,6 +7470,7 @@
06DAAE5826AA3CCF00194E58 /* CountryFragment.graphql in Resources */,
06B3605C26E12288006CB9E4 /* FetchProjectByIdQuery.graphql in Resources */,
06566373270BA8E000CE7EDF /* FetchProjectRewardsByIdQuery.graphql in Resources */,
E12420A22BA8921800037DB5 /* CompleteOnSessionCheckoutMutation.graphql in Resources */,
8AC3E0892698CC1A00168BF8 /* FetchAddOnsQuery.graphql in Resources */,
0655C7282732FDA30087281F /* FetchRootCategories.graphql in Resources */,
19047FBB2889A16300BDD1A8 /* CreateSetupIntent.graphql in Resources */,
Expand Down
333 changes: 282 additions & 51 deletions KsApi/GraphAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,133 @@ public enum GraphAPI {
}
}

/// Autogenerated input type of CompleteOnSessionCheckout
public struct CompleteOnSessionCheckoutInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - checkoutId: The graphql relay id of the checkout
/// - paymentIntentClientSecret: The stripe payment intent client secret
/// - paymentSourceId: The rosie payment source id when using a saved source (optional)
/// - paymentSourceReusable: If the payment source can be reused for future payments (optional)
/// - applePay: Apple pay attributes for creating a payment source (optional)
/// - clientMutationId: A unique identifier for the client performing the mutation.
public init(checkoutId: GraphQLID, paymentIntentClientSecret: String, paymentSourceId: Swift.Optional<String?> = nil, paymentSourceReusable: Swift.Optional<Bool?> = nil, applePay: Swift.Optional<ApplePayInput?> = nil, clientMutationId: Swift.Optional<String?> = nil) {
graphQLMap = ["checkoutId": checkoutId, "paymentIntentClientSecret": paymentIntentClientSecret, "paymentSourceId": paymentSourceId, "paymentSourceReusable": paymentSourceReusable, "applePay": applePay, "clientMutationId": clientMutationId]
}

/// The graphql relay id of the checkout
public var checkoutId: GraphQLID {
get {
return graphQLMap["checkoutId"] as! GraphQLID
}
set {
graphQLMap.updateValue(newValue, forKey: "checkoutId")
}
}

/// The stripe payment intent client secret
public var paymentIntentClientSecret: String {
get {
return graphQLMap["paymentIntentClientSecret"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentIntentClientSecret")
}
}

/// The rosie payment source id when using a saved source (optional)
public var paymentSourceId: Swift.Optional<String?> {
get {
return graphQLMap["paymentSourceId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentSourceId")
}
}

/// If the payment source can be reused for future payments (optional)
public var paymentSourceReusable: Swift.Optional<Bool?> {
get {
return graphQLMap["paymentSourceReusable"] as? Swift.Optional<Bool?> ?? Swift.Optional<Bool?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentSourceReusable")
}
}

/// Apple pay attributes for creating a payment source (optional)
public var applePay: Swift.Optional<ApplePayInput?> {
get {
return graphQLMap["applePay"] as? Swift.Optional<ApplePayInput?> ?? Swift.Optional<ApplePayInput?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "applePay")
}
}

/// A unique identifier for the client performing the mutation.
public var clientMutationId: Swift.Optional<String?> {
get {
return graphQLMap["clientMutationId"] as? Swift.Optional<String?> ?? Swift.Optional<String?>.none
}
set {
graphQLMap.updateValue(newValue, forKey: "clientMutationId")
}
}
}

/// Necessary fields for Apple Pay
public struct ApplePayInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - token: Stripe token
/// - paymentInstrumentName
/// - paymentNetwork
/// - transactionIdentifier
public init(token: String, paymentInstrumentName: String, paymentNetwork: String, transactionIdentifier: String) {
graphQLMap = ["token": token, "paymentInstrumentName": paymentInstrumentName, "paymentNetwork": paymentNetwork, "transactionIdentifier": transactionIdentifier]
}

/// Stripe token
public var token: String {
get {
return graphQLMap["token"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "token")
}
}

public var paymentInstrumentName: String {
get {
return graphQLMap["paymentInstrumentName"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentInstrumentName")
}
}

public var paymentNetwork: String {
get {
return graphQLMap["paymentNetwork"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentNetwork")
}
}

public var transactionIdentifier: String {
get {
return graphQLMap["transactionIdentifier"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "transactionIdentifier")
}
}
}

/// Autogenerated input type of CreateAttributionEvent
public struct CreateAttributionEventInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap
Expand Down Expand Up @@ -276,57 +403,6 @@ public enum GraphAPI {
}
}

/// Necessary fields for Apple Pay
public struct ApplePayInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap

/// - Parameters:
/// - token: Stripe token
/// - paymentInstrumentName
/// - paymentNetwork
/// - transactionIdentifier
public init(token: String, paymentInstrumentName: String, paymentNetwork: String, transactionIdentifier: String) {
graphQLMap = ["token": token, "paymentInstrumentName": paymentInstrumentName, "paymentNetwork": paymentNetwork, "transactionIdentifier": transactionIdentifier]
}

/// Stripe token
public var token: String {
get {
return graphQLMap["token"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "token")
}
}

public var paymentInstrumentName: String {
get {
return graphQLMap["paymentInstrumentName"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentInstrumentName")
}
}

public var paymentNetwork: String {
get {
return graphQLMap["paymentNetwork"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "paymentNetwork")
}
}

public var transactionIdentifier: String {
get {
return graphQLMap["transactionIdentifier"] as! String
}
set {
graphQLMap.updateValue(newValue, forKey: "transactionIdentifier")
}
}
}

/// Autogenerated input type of CreateCheckout
public struct CreateCheckoutInput: GraphQLMapConvertible {
public var graphQLMap: GraphQLMap
Expand Down Expand Up @@ -3984,6 +4060,161 @@ public enum GraphAPI {
}
}

public final class CompleteOnSessionCheckoutMutation: GraphQLMutation {
/// The raw GraphQL definition of this operation.
public let operationDefinition: String =
"""
mutation CompleteOnSessionCheckout($input: CompleteOnSessionCheckoutInput!) {
completeOnSessionCheckout(input: $input) {
__typename
checkout {
__typename
...CheckoutFragment
}
}
}
"""

public let operationName: String = "CompleteOnSessionCheckout"

public var queryDocument: String {
var document: String = operationDefinition
document.append("\n" + CheckoutFragment.fragmentDefinition)
return document
}

public var input: CompleteOnSessionCheckoutInput

public init(input: CompleteOnSessionCheckoutInput) {
self.input = input
}

public var variables: GraphQLMap? {
return ["input": input]
}

public struct Data: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["Mutation"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("completeOnSessionCheckout", arguments: ["input": GraphQLVariable("input")], type: .object(CompleteOnSessionCheckout.selections)),
]
}

public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public init(completeOnSessionCheckout: CompleteOnSessionCheckout? = nil) {
self.init(unsafeResultMap: ["__typename": "Mutation", "completeOnSessionCheckout": completeOnSessionCheckout.flatMap { (value: CompleteOnSessionCheckout) -> ResultMap in value.resultMap }])
}

/// Complete a checkout originating from an session payment
public var completeOnSessionCheckout: CompleteOnSessionCheckout? {
get {
return (resultMap["completeOnSessionCheckout"] as? ResultMap).flatMap { CompleteOnSessionCheckout(unsafeResultMap: $0) }
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "completeOnSessionCheckout")
}
}

public struct CompleteOnSessionCheckout: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["CompleteOnSessionCheckoutPayload"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLField("checkout", type: .object(Checkout.selections)),
]
}

public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public init(checkout: Checkout? = nil) {
self.init(unsafeResultMap: ["__typename": "CompleteOnSessionCheckoutPayload", "checkout": checkout.flatMap { (value: Checkout) -> ResultMap in value.resultMap }])
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
}
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
}

public var checkout: Checkout? {
get {
return (resultMap["checkout"] as? ResultMap).flatMap { Checkout(unsafeResultMap: $0) }
}
set {
resultMap.updateValue(newValue?.resultMap, forKey: "checkout")
}
}

public struct Checkout: GraphQLSelectionSet {
public static let possibleTypes: [String] = ["Checkout"]

public static var selections: [GraphQLSelection] {
return [
GraphQLField("__typename", type: .nonNull(.scalar(String.self))),
GraphQLFragmentSpread(CheckoutFragment.self),
]
}

public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public var __typename: String {
get {
return resultMap["__typename"]! as! String
}
set {
resultMap.updateValue(newValue, forKey: "__typename")
}
}

public var fragments: Fragments {
get {
return Fragments(unsafeResultMap: resultMap)
}
set {
resultMap += newValue.resultMap
}
}

public struct Fragments {
public private(set) var resultMap: ResultMap

public init(unsafeResultMap: ResultMap) {
self.resultMap = unsafeResultMap
}

public var checkoutFragment: CheckoutFragment {
get {
return CheckoutFragment(unsafeResultMap: resultMap)
}
set {
resultMap += newValue.resultMap
}
}
}
}
}
}
}

public final class CreateAttributionEventMutation: GraphQLMutation {
/// The raw GraphQL definition of this operation.
public let operationDefinition: String =
Expand Down
1 change: 1 addition & 0 deletions KsApi/GraphQLFiles.xcfilelist
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ $(PROJECT_DIR)/KsApi/fragments/CheckoutFragment.graphql
$(PROJECT_DIR)/KsApi/fragments/CommentWithRepliesFragment.graphql
$(PROJECT_DIR)/KsApi/mutations/UpdateBacking.graphql
$(PROJECT_DIR)/KsApi/mutations/PostComment.graphql
$(PROJECT_DIR)/KsApi/mutations/CompleteOnSessionCheckoutMutation.graphql
$(PROJECT_DIR)/KsApi/mutations/CreateCheckout.graphql
$(PROJECT_DIR)/KsApi/mutations/CreatePaymentIntent.graphql
$(PROJECT_DIR)/KsApi/mutations/UpdateUserAccount.graphql
Expand Down
Loading

0 comments on commit b09f77f

Please sign in to comment.