-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Connections soft linking interface (#828)
* Adds connections sdk soft linking * Fix version * iOS12 availablility * Add unit test * localized strings fixes
- Loading branch information
1 parent
ebcf442
commit a8d4384
Showing
9 changed files
with
143 additions
and
6 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,21 @@ | ||
// | ||
// ConnectionsSDKAvailability.swift | ||
// StripeiOS | ||
// | ||
// Created by Vardges Avetisyan on 2/24/22. | ||
// Copyright © 2022 Stripe, Inc. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
@_spi(STP) import StripeCore | ||
|
||
@available(iOS 12, *) | ||
struct ConnectionsSDKAvailability { | ||
static func connections() -> ConnectionsSDKInterface? { | ||
guard let klass = NSClassFromString("StripeConnections.ConnectionsSDKImplementation") as? ConnectionsSDKInterface.Type else { | ||
return nil | ||
} | ||
|
||
return klass.init() | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
StripeConnections/StripeConnections/Source/ConnectionsSDK/ConnectionsSDKImplementation.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,37 @@ | ||
// | ||
// ConnectionsSDKImplementation.swift | ||
// StripeConnections | ||
// | ||
// Created by Vardges Avetisyan on 2/24/22. | ||
// | ||
|
||
import UIKit | ||
@_spi(STP) import StripeCore | ||
|
||
/** | ||
NOTE: If you change the name of this class, make sure to also change it ConnectionsSDKAvailability file | ||
*/ | ||
@available(iOS 12, *) | ||
@_spi(STP) public class ConnectionsSDKImplementation: ConnectionsSDKInterface { | ||
|
||
required public init() {} | ||
|
||
public func presentConnectionsSheet(clientSecret: String, | ||
from presentingViewController: UIViewController, | ||
completion: @escaping (ConnectionsSDKResult) -> ()) { | ||
let connectionsSheet = ConnectionsSheet(linkAccountSessionClientSecret: clientSecret) | ||
connectionsSheet.present( | ||
from: presentingViewController, | ||
completion: { result in | ||
switch result { | ||
case .completed(session: _): | ||
completion(.completed) | ||
case .canceled: | ||
completion(.cancelled) | ||
case .failed(let error): | ||
completion(.failed(error: error)) | ||
} | ||
}) | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
StripeConnections/StripeConnectionsTests/SoftLinkTests.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,17 @@ | ||
// | ||
// SoftLinkTests.swift | ||
// StripeConnectionsTests | ||
// | ||
// Created by Vardges Avetisyan on 3/4/22. | ||
// | ||
|
||
import Foundation | ||
@_spi(STP) import StripeCore | ||
import XCTest | ||
|
||
class SoftLinkTest: XCTestCase { | ||
func testLoadingImplementationClass() { | ||
let klass = NSClassFromString("StripeConnections.ConnectionsSDKImplementation") as? ConnectionsSDKInterface.Type | ||
XCTAssertNotNil(klass) | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
StripeCore/StripeCore/Source/Connections Bindings/ConnectionsSDKInterface.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,21 @@ | ||
// | ||
// ConnectionsSDKInterface.swift | ||
// StripeCore | ||
// | ||
// Created by Vardges Avetisyan on 2/24/22. | ||
// | ||
|
||
import UIKit | ||
|
||
@_spi(STP) public enum ConnectionsSDKResult { | ||
case completed | ||
case cancelled | ||
case failed(error: Error) | ||
} | ||
|
||
@_spi(STP) public protocol ConnectionsSDKInterface { | ||
init() | ||
func presentConnectionsSheet(clientSecret: String, | ||
from presentingViewController: UIViewController, | ||
completion: @escaping (ConnectionsSDKResult) -> ()) | ||
} |
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