Skip to content

Commit 27b00dc

Browse files
author
guillaumedebavelaere
committed
WIP
1 parent 3c11bfc commit 27b00dc

23 files changed

+276
-87
lines changed

ExampleApp/AppDelegate.swift

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1111
TradeItSDK.configure(
1212
apiKey: AppDelegate.API_KEY,
1313
oAuthCallbackUrl: URL(string: "tradeItExampleScheme://completeOAuth")!,
14+
verify1FACallbackUrl: URL(string: "tradeItExampleScheme://complete1FA")!,
1415
environment: AppDelegate.ENVIRONMENT,
1516
userCountryCode: "US"
1617
)
@@ -45,16 +46,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4546
print("=====> Received OAuth callback URL: \(url.absoluteString)")
4647

4748
let MANUAL_HOST = "manualCompleteOAuth"
49+
let VERIFY_1FA = "complete1FA"
4850

4951
// Check for the intended url.scheme, url.host, and url.path before proceeding
5052
if let urlComponents = URLComponents(url: url, resolvingAgainstBaseURL: false),
5153
urlComponents.scheme == "tradeitexamplescheme",
5254
let host = urlComponents.host,
53-
let queryItems = urlComponents.queryItems,
54-
let oAuthVerifier = queryItems.filter({ $0.name == "oAuthVerifier" }).first?.value {
55+
let queryItems = urlComponents.queryItems {
5556

5657
if host == MANUAL_HOST {
57-
self.completeManualOAuth(oAuthVerifier: oAuthVerifier)
58+
if let oAuthVerifier = queryItems.filter({ $0.name == "oAuthVerifier" }).first?.value {
59+
self.completeManualOAuth(oAuthVerifier: oAuthVerifier)
60+
}
61+
} else if host == VERIFY_1FA {
62+
self.handleExampleVerify1FA(verify1FACallbackUrl: url, host: host)
5863
} else {
5964
self.handleExampleOAuth(oAuthCallbackUrl: url, host: host)
6065
}
@@ -211,6 +216,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
211216
}
212217
}
213218
}
219+
220+
private func handleExampleVerify1FA(verify1FACallbackUrl: URL, host: String) {
221+
let VERIFY_1FA = "complete1FA"
222+
if var topViewController = UIApplication.shared.keyWindow?.rootViewController {
223+
while let presentedViewController = topViewController.presentedViewController {
224+
topViewController = presentedViewController
225+
}
226+
227+
if let navController = topViewController as? UINavigationController,
228+
let navTopViewController = navController.topViewController {
229+
topViewController = navTopViewController
230+
}
231+
232+
switch host {
233+
case VERIFY_1FA:
234+
TradeItSDK.launcher.handleVerify1FACallback(
235+
onTopmostViewController: topViewController,
236+
verify1FACallbackUrl: verify1FACallbackUrl
237+
)
238+
default:
239+
print("=====> ERROR: Received unknown verify 1 FA callback URL host: \(host)")
240+
}
241+
}
242+
}
214243
}
215244

216245
// Only implement this protocol if you need to inject your own market data

ExampleApp/ExampleViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ class ExampleViewController: UIViewController, UITableViewDataSource, UITableVie
239239
action: {
240240
let order = TradeItOrder()
241241
// Any order fields that are set will pre-populate the ticket.
242-
order.symbol = "CMG"
243-
order.quantity = 10
244-
order.action = .sell
245-
order.type = .stopLimit
246-
order.limitPrice = 20
247-
order.stopPrice = 30
242+
order.symbol = "T39"
243+
order.quantity = 100
244+
order.action = .buy
245+
order.type = .limit
246+
order.limitPrice = 0.5
247+
// order.stopPrice = 30
248248
order.expiration = .goodUntilCanceled
249249
TradeItSDK.launcher.launchTrading(fromViewController: self, withOrder: order)
250250
}

Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DEPENDENCIES:
2525
- Quick (~> 0.10.0)
2626

2727
SPEC REPOS:
28-
https://github.com/CocoaPods/Specs.git:
28+
https://github.com/cocoapods/specs.git:
2929
- BEMCheckBox
3030
- JSONModel
3131
- MBProgressHUD
@@ -43,4 +43,4 @@ SPEC CHECKSUMS:
4343

4444
PODFILE CHECKSUM: 8de6c042a9db9777f64178e4995be9fd85814f2f
4545

46-
COCOAPODS: 1.5.0
46+
COCOAPODS: 1.5.2
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#import <TradeItIosTicketSDK2/TradeItIosTicketSDK2.h>
2+
3+
@interface TradeItComplete1FARequest : TradeItRequest
4+
5+
-(nonnull id) initWithToken:(NSString* _Nullable) token;
6+
7+
@property (copy) NSString * _Nullable token;
8+
9+
@end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#import "TradeItComplete1FARequest.h"
2+
3+
@implementation TradeItComplete1FARequest
4+
5+
-(id) initWithToken:(NSString*) token {
6+
self = [super init];
7+
if(self){
8+
self.token = token;
9+
}
10+
return self;
11+
}
12+
13+
@end

TradeItIosEmsApi/TradeItIosEmsApiLib.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@
6666
#import "TradeItFxOrderCapabilities.h"
6767
#import "TradeItFxOrderCapabilitiesResult.h"
6868
#import "TradeItFxQuoteRequest.h"
69+
#import "TradeItVerifyOAuthURLResult.h"
70+
#import "TradeItComplete1FARequest.h"
6971

7072
// Use the BalanceService to get account balance information
7173
#import "TradeItAccountOverviewRequest.h"

TradeItIosEmsApi/TradeItPlaceTradeRequest.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
@interface TradeItPlaceTradeRequest : TradeItRequest
1313

14-
- (id _Nonnull)initWithOrderId:(NSString * _Nonnull) orderId;
14+
- (id _Nonnull)initWithOrderId:(NSString * _Nonnull) orderId
15+
andInterAppAddressCallback:(NSString * _Nonnull) interAppAddressCallback;
1516

1617
// The orderId as returned from the TradeItPreviewTradeRequest
1718
@property (copy) NSString * _Nullable orderId;
@@ -21,4 +22,6 @@
2122
// Setting this will be overriden
2223
@property (copy) NSString * _Nullable token;
2324

25+
@property (copy) NSString * _Nullable interAppAddressCallback;
26+
2427
@end

TradeItIosEmsApi/TradeItPlaceTradeRequest.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010

1111
@implementation TradeItPlaceTradeRequest
1212

13-
- (id)initWithOrderId:(NSString *) orderId {
13+
- (id)initWithOrderId:(NSString *) orderId
14+
andInterAppAddressCallback:(NSString *) interAppAddressCallback {
1415
self = [super init];
1516
if (self) {
1617
self.orderId = orderId;
18+
self.interAppAddressCallback = interAppAddressCallback;
1719
}
1820
return self;
1921
}

TradeItIosEmsApi/TradeItResult.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343

4444
- (BOOL)isSecurityQuestion;
4545

46+
- (BOOL)isVerify1FA;
47+
4648
- (BOOL)isReviewOrder;
4749

4850
- (BOOL)isError;

TradeItIosEmsApi/TradeItResult.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ - (BOOL)isSecurityQuestion {
2525
return [@"INFORMATION_NEEDED" isEqualToString:self.status];
2626
}
2727

28+
- (BOOL)isVerify1FA {
29+
return [@"VERIFY_1FA" isEqualToString:self.status];
30+
}
31+
2832
- (BOOL)isReviewOrder {
2933
return [@"REVIEW_ORDER" isEqualToString:self.status];
3034
}

0 commit comments

Comments
 (0)