Skip to content

Commit

Permalink
Move data model to Connections Bindings
Browse files Browse the repository at this point in the history
This avoids the dummy `LinkConsumerIncentive` struct in `StripeFinancialConnections`.
  • Loading branch information
tillh-stripe committed Jan 10, 2025
1 parent 43d734a commit cabfd94
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 40 deletions.
8 changes: 8 additions & 0 deletions StripeCore/StripeCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@
CAF857D45689FBEF17627E80 /* BundleLocatorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 937066801E91C99C50192364 /* BundleLocatorProtocol.swift */; };
CB0E9DC82CB9C79E00E083D1 /* LinkBankPaymentMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB0E9DC72CB9C79E00E083D1 /* LinkBankPaymentMethod.swift */; };
CB1FB2383FAEE0194C39E4DE /* OHHTTPStubsSwift in Frameworks */ = {isa = PBXBuildFile; productRef = E86AC7DD5F4DE2780E0AC425 /* OHHTTPStubsSwift */; };
CB80352A2D31BA79008F0556 /* AvailableIncentives.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB8035292D31BA79008F0556 /* AvailableIncentives.swift */; };
CB80352C2D31BAC7008F0556 /* LinkConsumerIncentive.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB80352B2D31BAC7008F0556 /* LinkConsumerIncentive.swift */; };
CB8A47A5FD057112CB607DE9 /* MockData.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5334916D2A4F927645C2569 /* MockData.swift */; };
D144C3A657E5C16975CB2191 /* NSError+StripeCore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 23506F3E93ECA5A96DCE7E31 /* NSError+StripeCore.swift */; };
D22FAB2F1AE9AE43C1808747 /* StripeAPIConfiguration+Version.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F1BFF01B1EA57F6EA7BFBF1 /* StripeAPIConfiguration+Version.swift */; };
Expand Down Expand Up @@ -335,6 +337,8 @@
C666CC926642D7AA76E75B5B /* StripeCoreTestUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StripeCoreTestUtils.h; sourceTree = "<group>"; };
CB0E9DC72CB9C79E00E083D1 /* LinkBankPaymentMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkBankPaymentMethod.swift; sourceTree = "<group>"; };
CB2721EE8E075E700FF3E58A /* StripeiOS-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "StripeiOS-Release.xcconfig"; sourceTree = "<group>"; };
CB8035292D31BA79008F0556 /* AvailableIncentives.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableIncentives.swift; sourceTree = "<group>"; };
CB80352B2D31BAC7008F0556 /* LinkConsumerIncentive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkConsumerIncentive.swift; sourceTree = "<group>"; };
CC70CDF482E22A29B11466F7 /* STPAPIClient+EmptyResponseTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "STPAPIClient+EmptyResponseTest.swift"; sourceTree = "<group>"; };
CD9288E147B8C9D33CCB5045 /* pl-PL */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "pl-PL"; path = "pl-PL.lproj/Localizable.strings"; sourceTree = "<group>"; };
CF15BAFA3E58D68668EE6DCC /* STPSnapshotTestCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPSnapshotTestCase.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -492,6 +496,8 @@
492039922CA47A8600CE2072 /* ElementsSessionContext.swift */,
49F3828C2CC02D43001CE69A /* BillingAddress.swift */,
CB0E9DC72CB9C79E00E083D1 /* LinkBankPaymentMethod.swift */,
CB8035292D31BA79008F0556 /* AvailableIncentives.swift */,
CB80352B2D31BAC7008F0556 /* LinkConsumerIncentive.swift */,
);
path = "Connections Bindings";
sourceTree = "<group>";
Expand Down Expand Up @@ -1070,6 +1076,7 @@
F628BBE9FDA9D3A217ACA753 /* STPNumericStringValidator.swift in Sources */,
C9B6C451F9A46C9FB031CE95 /* STPURLCallbackHandler.swift in Sources */,
A62AEDF871AC89489FE19A13 /* ServerErrorMapper.swift in Sources */,
CB80352A2D31BA79008F0556 /* AvailableIncentives.swift in Sources */,
B6DBB2BF2BA8C4E400783D15 /* STPAnalyticsClient+Error.swift in Sources */,
6A05FB452BCF24100001D128 /* FinancialConnectionsSDKResult.swift in Sources */,
49F3828D2CC02D43001CE69A /* BillingAddress.swift in Sources */,
Expand All @@ -1078,6 +1085,7 @@
0709F5D265CC641E6DE1011D /* URLSession+Retry.swift in Sources */,
6A05FB492BCF244A0001D128 /* InstantDebitsLinkedBank.swift in Sources */,
2991461DD354A6124CCF78DA /* STPLocalizationUtils.swift in Sources */,
CB80352C2D31BAC7008F0556 /* LinkConsumerIncentive.swift in Sources */,
4506A7016EA7C45796D3A30D /* STPLocalizedString.swift in Sources */,
DFF3092E51B6C3ED81AB1448 /* String+Localized.swift in Sources */,
6B987BDD2C9111BC00DDFDB3 /* Notification+Stripe.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// AvailableIncentives.swift
// StripeCore
//
// Created by Till Hellmund on 1/10/25.
//

import Foundation

@_spi(STP) public struct AvailableIncentives: Decodable {
@_spi(STP) public let incentives: [LinkConsumerIncentive]

@_spi(STP) public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
incentives = try container.decode([LinkConsumerIncentive].self, forKey: .data)
}

enum CodingKeys: String, CodingKey {
case data
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
//
// LinkConsumerIncentive.swift
// StripePayments
// StripeCore
//
// Created by Till Hellmund on 10/8/24.
// Created by Till Hellmund on 1/10/25.
//

import Foundation

@_spi(STP) public final class LinkConsumerIncentive: NSObject, STPAPIResponseDecodable {
@_spi(STP) public struct LinkConsumerIncentive: Decodable {

@_spi(STP) public let incentiveParams: IncentiveParams
@_spi(STP) public let incentiveDisplayText: String?

@_spi(STP) public private(set) var allResponseFields: [AnyHashable: Any] = [:]

init(
incentiveParams: IncentiveParams,
incentiveDisplayText: String?
Expand Down Expand Up @@ -42,10 +40,10 @@ import Foundation
return LinkConsumerIncentive(
incentiveParams: incentiveParams,
incentiveDisplayText: incentiveDisplayText
) as? Self
)
}

@_spi(STP) public struct IncentiveParams {
@_spi(STP) public struct IncentiveParams: Decodable {
@_spi(STP) public let paymentMethod: String
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@
CB734C25A19D38A87876FB2B /* FinancialConnectionsAnalyticsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73AB8A480620B5C3567F453C /* FinancialConnectionsAnalyticsTest.swift */; };
CBEAB081DD7353928F485071 /* APIPollingHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 710183EE587F6FDA077FC150 /* APIPollingHelperTests.swift */; };
CBF7BE2271D309F2B1E794CC /* FinancialConnectionsDataAccessNotice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32ED8A7E94822F14AD94A698 /* FinancialConnectionsDataAccessNotice.swift */; };
CBF7BE602D11DA5E00A4C172 /* AvailableIncentives.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF7BE5F2D11DA5E00A4C172 /* AvailableIncentives.swift */; };
CF47070B2A4CA27FEE9AE5FA /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6A764CF4DB5B5F6F488132A8 /* [email protected] */; };
D0C1EF46A418A8F8774B7418 /* FinancialConnectionsSession_both_accounts_la.json in Resources */ = {isa = PBXBuildFile; fileRef = F6CF7F1005B57D566E139DE3 /* FinancialConnectionsSession_both_accounts_la.json */; };
D0C6D94867FA04B1BF80D56D /* StripeCoreTestUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F9AB787FE87EDD702B1BBF09 /* StripeCoreTestUtils.framework */; };
Expand Down Expand Up @@ -484,7 +483,6 @@
C93F7139E9BFB044902962D0 /* FinancialConnectionsImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsImage.swift; sourceTree = "<group>"; };
CA2DA47ECE153F888FA675CE /* StripeiOS Tests-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "StripeiOS Tests-Debug.xcconfig"; sourceTree = "<group>"; };
CB3C49A180D1697B03C79A59 /* UIViewController+KeyboardAvoiding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIViewController+KeyboardAvoiding.swift"; sourceTree = "<group>"; };
CBF7BE5F2D11DA5E00A4C172 /* AvailableIncentives.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AvailableIncentives.swift; sourceTree = "<group>"; };
CDD861E4EB8BA294545B7651 /* NetworkingLinkVerificationViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkingLinkVerificationViewController.swift; sourceTree = "<group>"; };
CE10909F3FC7D60E13B65226 /* et-EE */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "et-EE"; path = "et-EE.lproj/Localizable.strings"; sourceTree = "<group>"; };
CEC1BC95816DAD5AE9680662 /* FinancialConnectionsAccountFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FinancialConnectionsAccountFetcher.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -747,7 +745,6 @@
isa = PBXGroup;
children = (
32249762D11692D5B34BBF38 /* ConsumerSession */,
CBF7BE5F2D11DA5E00A4C172 /* AvailableIncentives.swift */,
D890BD770F4E33D23ABA37EA /* BankAccountToken.swift */,
359BF8ACFB35A16EBD96C4F0 /* FinancialConnectionsAccount.swift */,
5C837C27C2577391B91FF0E5 /* FinancialConnectionsAuthSession.swift */,
Expand Down Expand Up @@ -1340,7 +1337,6 @@
C59DBA5A86A3331113D6ED7E /* LoadingView.swift in Sources */,
9B2CAE99344C26D524EDCF26 /* ModalPresentationWrapperViewController.swift in Sources */,
6ABFE5522B72BE630037437C /* PrepaneViews.swift in Sources */,
CBF7BE602D11DA5E00A4C172 /* AvailableIncentives.swift in Sources */,
FE268512851E63E4E111DECD /* FinancialConnectionsSDKImplementation.swift in Sources */,
E85DCFCA61299EF27B3201CF /* FinancialConnectionsSheet.swift in Sources */,
F22DE4B785D51B318A1A3D08 /* FinancialConnectionsSheetError.swift in Sources */,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Foundation
@_spi(STP) import StripeCore
@_spi(STP) import StripePayments

struct PaymentMethodIncentive {
Expand Down
4 changes: 0 additions & 4 deletions StripePayments/StripePayments.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
CAC3A0302C2E127B007BC888 /* STPPaymentMethodSunbit.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAC3A02F2C2E127B007BC888 /* STPPaymentMethodSunbit.swift */; };
CAC80EC32C333646001E3D0D /* STPPaymentMethodSatispay.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAC80EC22C333646001E3D0D /* STPPaymentMethodSatispay.swift */; };
CAC80EC52C33368E001E3D0D /* STPPaymentMethodSatispayParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAC80EC42C33368E001E3D0D /* STPPaymentMethodSatispayParams.swift */; };
CB3BCBC12CB56AEC00CC35B6 /* LinkConsumerIncentive.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB3BCBC02CB56AEC00CC35B6 /* LinkConsumerIncentive.swift */; };
CB99BCA5D74904829DDF5A25 /* StripeCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 719D0377278FA11F93E19637 /* StripeCore.framework */; };
CBFB5A1330C916D5DC95F6FF /* STPLocalizedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086AC53333729531A067E435 /* STPLocalizedString.swift */; };
CCB5BAB2A22D94DE02938573 /* STPPaymentMethodMobilePayParams.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92A9741EA9B8FD4301DEB5FD /* STPPaymentMethodMobilePayParams.swift */; };
Expand Down Expand Up @@ -642,7 +641,6 @@
CAC3A02F2C2E127B007BC888 /* STPPaymentMethodSunbit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodSunbit.swift; sourceTree = "<group>"; };
CAC80EC22C333646001E3D0D /* STPPaymentMethodSatispay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodSatispay.swift; sourceTree = "<group>"; };
CAC80EC42C33368E001E3D0D /* STPPaymentMethodSatispayParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodSatispayParams.swift; sourceTree = "<group>"; };
CB3BCBC02CB56AEC00CC35B6 /* LinkConsumerIncentive.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkConsumerIncentive.swift; sourceTree = "<group>"; };
CEFD8715EEA4EECD411465FB /* STPPaymentMethodCardWallet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodCardWallet.swift; sourceTree = "<group>"; };
D07382674619AEF657397B21 /* STPThreeDSUICustomization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPThreeDSUICustomization.swift; sourceTree = "<group>"; };
D093EFAC2C8F0B310EBD10C4 /* STPPaymentMethodSofortParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = STPPaymentMethodSofortParams.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -926,7 +924,6 @@
504E0A8BF21E74D852CE507F /* Shared */ = {
isa = PBXGroup;
children = (
CB3BCBC02CB56AEC00CC35B6 /* LinkConsumerIncentive.swift */,
788D986E935F05CF28CD16D2 /* LinkSettings.swift */,
C07667F9D802EB8DD391A3C5 /* STPIntentAction.swift */,
DEECA909F82BFB3F8960F1EA /* STPIntentActionAlipayHandleRedirect.swift */,
Expand Down Expand Up @@ -1833,7 +1830,6 @@
61E1CA1D2BD6B3F100A421AE /* STPPaymentMethodMultibancoParams.swift in Sources */,
CF8A1ADADD2186407EBBBDCC /* STPSourceKlarnaDetails.swift in Sources */,
3B90B29A1B6BCE36C93E5C94 /* STPSourceSEPADebitDetails.swift in Sources */,
CB3BCBC12CB56AEC00CC35B6 /* LinkConsumerIncentive.swift in Sources */,
645789BA64D7822137F2B7BD /* STPSourceWeChatPayDetails.swift in Sources */,
B756C47DB92853FE963FEA2D /* STPAPIClient+ApplePay.swift in Sources */,
A0857C1CADDFF07B2A72431B /* STPAPIClient+LinkAccountSession.swift in Sources */,
Expand Down

0 comments on commit cabfd94

Please sign in to comment.