-
Notifications
You must be signed in to change notification settings - Fork 25
Custom Integration
mitochondrion edited this page Feb 1, 2017
·
16 revisions
###Branch
ak/yahoo_trade
###Integration The following code will launch the OAuth flow (use your deep link URL):
TradeItSDK.yahooLauncher.launchOAuth(
fromViewController: self,
withCallbackUrl: "tradeItExampleScheme://completeYahooOAuth")
When you receive the deep link, complete the OAuth flow like this:
TradeItSDK.linkedBrokerManager.completeOAuth(
withOAuthVerifier: oAuthVerifier,
onSuccess: { linkedBroker in
TradeItSDK.yahooLauncher.launchOAuthConfirmationScreen(
fromViewController: self,
withLinkedBroker: linkedBroker)
}, onFailure: { errorResult in
// Do something with the error. The SDK has code for generating UIAlertController instances from errors if you want to use our alerts. Lemme know and I can show you.
}
)
And once a broker has been linked, the trading flow can be launched like this:
let order = TradeItOrder()
// Since you will be launching from a QSP screen with buy/sell buttons you can prepopulate symbol/action
order.symbol = "YHOO"
order.action = .buy
TradeItSDK.yahooLauncher.launchTrading(fromViewController: self, withOrder: order)