-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BTShopperInsights
public API shell
#1142
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
55db5dc
payment-insights-shell
scannillo 3c7221b
Delete Braintree.xcworkspace/xcshareddata/swiftpm/Package.resolved
scannillo fb09a79
Move email & phone details to BTPaymentInsightsRequest
scannillo bf2efbd
Rename to BTShopperInsights
scannillo e00be07
Fixup - fix docstring for getRecommendedPaymentMethods() to reference…
scannillo 5973db0
PR feedback to clarify phone number to not contain special chars; add…
scannillo f93b7c6
PR Feedback - add docstrings to init; prefer init only for Request ob…
scannillo 4121489
Remove Obj-C support from ShopperInsights classes
scannillo c42fe39
Update Sources/BraintreeCore/BTShopperInsightsResult.swift
scannillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,27 @@ | ||
import Foundation | ||
|
||
/// Use `BTShopperInsightsClient` to optimize your checkout experience by prioritizing the customer’s preferred payment methods in your UI. | ||
/// By customizing each customer’s checkout experience, you can improve conversion, increase sales/repeat buys and boost user retention/loyalty. | ||
/// - Note: This feature is in beta. It's public API may change or be removed in future releases. | ||
@objcMembers class BTShopperInsightsClient: NSObject { | ||
|
||
private let apiClient: BTAPIClient | ||
|
||
/// Creates a `BTShopperInsightsClient` | ||
/// - Parameter apiClient: A `BTAPIClient` instance. | ||
/// - Note: This features only works with a client token. | ||
public init(apiClient: BTAPIClient) { | ||
self.apiClient = apiClient | ||
} | ||
|
||
/// This method confirms if the customer is a user of PayPal services using their email and phone number. | ||
/// - Parameters: | ||
/// - request: A `BTShopperInsightsRequest` containing the buyer's user information | ||
/// - Returns: A `BTShopperInsightsResult` instance | ||
/// - Note: This feature is in beta. It's public API may change or be removed in future releases. | ||
public func getRecommendedPaymentMethods(request: BTShopperInsightsRequest) async throws -> BTShopperInsightsResult { | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// TODO: - Add isAppInstalled checks for PP & Venmo. DTBTSDK-3176 | ||
// TODO: - Make API call to PaymentReadyAPI. DTBTSDK-3176 | ||
return BTShopperInsightsResult() | ||
} | ||
} |
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,28 @@ | ||
import Foundation | ||
|
||
/// Buyer data required to use the Shopper Insights feature. | ||
/// - Note: This feature is in beta. It's public API may change or be removed in future releases. | ||
@objcMembers public class BTShopperInsightsRequest: NSObject { | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// The buyer's email address. | ||
public let email: String | ||
|
||
/// The buyer's country code prefix to the national telephone number. An identifier for a specific country. | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// Must not contain special characters. | ||
public let phoneCountryCode: String | ||
|
||
/// The buyer's national phone number. Must not contain special characters. | ||
public let phoneNationalNumber: String | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/// Initialize a `BTShopperInsightsRequest` | ||
/// - Parameters: | ||
/// - email: The buyer's email address. | ||
/// - phoneCountryCode: The buyer's country code prefix to the national telephone number. An identifier for a specific country. | ||
/// - phoneNationalNumber: The buyer's national phone number. | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// - Note: This feature is in beta. It's public API may change or be removed in future releases. | ||
init(email: String, phoneCountryCode: String, phoneNationalNumber: String) { | ||
self.email = email | ||
self.phoneCountryCode = phoneCountryCode | ||
self.phoneNationalNumber = phoneNationalNumber | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
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,12 @@ | ||
import Foundation | ||
|
||
/// A summary of the buyer's recommended payment methods. | ||
/// - Note: This feature is in beta. It's public API may change or be removed in future releases. | ||
@objcMembers public class BTShopperInsightsResult: NSObject { | ||
|
||
/// If true, display the PayPal button with high priority. | ||
public var isPayPalRecommended = false | ||
|
||
/// If true dislpay the Venmo button with high priority. | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public var isVenmoRecommended = false | ||
} |
27 changes: 27 additions & 0 deletions
27
UnitTests/BraintreeCoreTests/BTShopperInsightsClient_Tests.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,27 @@ | ||
import Foundation | ||
import XCTest | ||
@testable import BraintreeCore | ||
@testable import BraintreeTestShared | ||
|
||
class BTShopperInsightsClient_Tests: XCTestCase { | ||
|
||
var mockAPIClient = MockAPIClient(authorization: "development_client_key")! | ||
var sut: BTShopperInsightsClient! | ||
|
||
override func setUp() { | ||
super.setUp() | ||
sut = BTShopperInsightsClient(apiClient: mockAPIClient) | ||
} | ||
|
||
func testGetRecommendedPaymentMethods_returnsDefaultRecommendations() async { | ||
let request = BTShopperInsightsRequest( | ||
email: "fake-email", | ||
phoneCountryCode: "fake-country-code", | ||
phoneNationalNumber: "fake-national-phone" | ||
) | ||
let result = try? await sut.getRecommendedPaymentMethods(request: request) | ||
|
||
XCTAssertNotNil(result!.isPayPalRecommended) | ||
XCTAssertNotNil(result!.isPayPalRecommended) | ||
scannillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious about new modules supporting objective-c - is this required by project setup still or could we move to only swift classes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I see now that this feature lives in core - what is the reason for not having a separate module for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are great questions - I honestly am very down to not add Objective-C support to this feature. We could always add it later if we see demand for it. Also worth noting - this feature will go out as an "alpha" so we have the room to iterate on it, break the API, etc.
Done in 0884b78. Will loop @jaxdesmarais in on this one though to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make this a separate module. I was approaching this from a path of least resistance approach for now as we target "alpha". We might save us the headache from creating and documenting an entire new module, if the feature doesn't get adopted. And should be relatively simple to move the files into a module if we do want to go that route later on. Open to folks thoughts, though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am totally down for this! Should we take the same approach with the Messaging module (Swift only/init first/etc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also drop the BT prefix? Or do we want to leave that consistent until v7?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another great question - maybe let's leave the prefix until we're ready to do that overhaul holistically?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me! I agree it could be confusing to have some things prefixed and some not so the consistency would be great then we can say goodbye to it in v7. 🚀