-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create
VenmoCheckoutRequest
and VenmoCheckoutResult
structs, add …
…shell for client class and basic unit test setup
- Loading branch information
Showing
5 changed files
with
95 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
|
||
/// Used to configure options for approving a Venmo Checkout order | ||
public struct VenmoCheckoutRequest { | ||
|
||
/// The order ID associated with the request | ||
public let orderID: String | ||
|
||
/// Creates an instance of VenmoCheckoutRequest | ||
/// - Parameter orderID: The ID of an order to be approved | ||
public init(orderID: String) { | ||
self.orderID = orderID | ||
} | ||
} |
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,8 @@ | ||
import Foundation | ||
|
||
/// The result of the Venmo checkout payment flow. | ||
public struct VenmoCheckoutResult { | ||
|
||
/// The order ID associated with the transaction | ||
public let orderID: String | ||
} |
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 |
---|---|---|
@@ -1,6 +1,38 @@ | ||
import Foundation | ||
#if canImport(CorePayments) | ||
import CorePayments | ||
#endif | ||
|
||
public class VenmoClient { | ||
|
||
// TODO: to be implemented in a future PR | ||
// MARK: - Properties | ||
|
||
private let config: CoreConfig | ||
private let universalLink: URL | ||
private let networkingClient: NetworkingClient | ||
|
||
// MARK: - Initializers | ||
|
||
/// Initialize a VenmoClient to process a Venmo payment | ||
/// - Parameter config: The CoreConfig object | ||
init(config: CoreConfig, universalLink: URL) { | ||
self.config = config | ||
self.universalLink = universalLink | ||
self.networkingClient = NetworkingClient(coreConfig: config) | ||
} | ||
|
||
/// For internal use for testing/mocking purpose | ||
init(config: CoreConfig, universalLink: URL, networkingClient: NetworkingClient) { | ||
self.config = config | ||
self.universalLink = universalLink | ||
self.networkingClient = networkingClient | ||
} | ||
|
||
/// Launch the Venmo checkout flow | ||
/// - Parameters: | ||
/// - request: the `VenmoCheckoutRequest` for the transaction | ||
public func start(_ request: VenmoCheckoutRequest) async throws -> VenmoCheckoutResult { | ||
// TODO: - Add logic in a future PR | ||
.init(orderID: "test-order-id") | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,20 @@ | ||
import XCTest | ||
import AuthenticationServices | ||
@testable import VenmoPayments | ||
@testable import CorePayments | ||
@testable import TestShared | ||
|
||
public class VenmoClient_Tests: XCTestCase { | ||
|
||
// TODO: to be implemented in a future PR | ||
var config: CoreConfig! | ||
var venmoClient: VenmoClient! | ||
var mockNetworkingClient: MockNetworkingClient! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
config = CoreConfig(clientID: "test-client-id", environment: .sandbox) | ||
mockNetworkingClient = MockNetworkClient(http: MockHTTP(coreConfig: config)) | ||
} | ||
|
||
// TODO: Add other relevant unit tests in a future PR | ||
} |