Skip to content

Commit 7da86d7

Browse files
Revert "Convert remaining objective c code to swift"
This reverts commit 703f26f.
1 parent 9ae4f43 commit 7da86d7

File tree

112 files changed

+980
-639
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+980
-639
lines changed

ExampleApp/AppDelegate.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import TradeItIosTicketSDK2
44
@UIApplicationMain
55
class AppDelegate: UIResponder, UIApplicationDelegate {
66
static let API_KEY = "exampleapp-test-api-key" // "tradeit-test-api-key"
7-
static let ENVIRONMENT = TradeitEmsEnvironments.tradeItEmsTestEnv
7+
static let ENVIRONMENT = TradeItEmsTestEnv
88
var window: UIWindow?
99

1010
override init() {
@@ -43,7 +43,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
4343
_ application: UIApplication,
4444
open url: URL,
4545
sourceApplication: String?,
46-
annotation: Any
46+
annotation: Any?
4747
) -> Bool {
4848
print("=====> Received OAuth callback URL: \(url.absoluteString)")
4949

@@ -226,9 +226,9 @@ class DummyMarketDataService: MarketDataService {
226226
// Get market data and populate TradeItQuote
227227
let quote = TradeItQuote()
228228
quote.companyName = "LOL"
229-
quote.lastPrice = 1337.42
230-
quote.change = 42.1337
231-
quote.pctChange = -123.456
229+
quote.lastPrice = 1337.42 as NSNumber
230+
quote.change = 42.1337 as NSNumber
231+
quote.pctChange = -123.456 as NSNumber
232232
quote.dateTime = "12:34:56"
233233
onSuccess(quote)
234234

@@ -242,7 +242,7 @@ class DummyMarketDataService: MarketDataService {
242242
class DummyStreamingMarketDataService: StreamingMarketDataService {
243243
private var timer: Timer?
244244
private var onUpdate: ((TradeItQuote) -> Void)?
245-
private var price = 500.0 as Double
245+
private var price = 500
246246

247247
func startUpdatingQuote(forSymbol symbol: String, onUpdate: @escaping (TradeItQuote) -> Void, onFailure: @escaping () -> Void) {
248248
self.onUpdate = onUpdate
@@ -261,16 +261,16 @@ class DummyStreamingMarketDataService: StreamingMarketDataService {
261261
}
262262

263263
@objc private func timerDidFire() {
264-
let priceChange = Double(generateRandomValue(lowerBound: -25, upperBound: 25))
264+
let priceChange = generateRandomValue(lowerBound: -25, upperBound: 25)
265265
self.price = self.price + priceChange
266266

267267
let quote = TradeItQuote()
268268
quote.companyName = "LOL"
269-
quote.lastPrice = price
270-
quote.bidPrice = price - 1
271-
quote.askPrice = price + 1
272-
quote.change = priceChange
273-
quote.pctChange = -123.456
269+
quote.lastPrice = NSNumber(value: price)
270+
quote.bidPrice = NSNumber(value: price - 1)
271+
quote.askPrice = NSNumber(value: price + 1)
272+
quote.change = NSNumber(value: priceChange)
273+
quote.pctChange = NSNumber(value: -123.456)
274274
quote.dateTime = "12:34:56"
275275

276276
onUpdate?(quote)

ExampleApp/ExampleViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ class ExampleViewController: UIViewController, UITableViewDataSource, UITableVie
822822
brokersUnlinked += 1
823823
},
824824
onFailure: { errorResult in
825-
print("=====> Error unlinking broker(\(linkedBroker.userId)): \(errorResult.code ?? 0), \(errorResult.shortMessage ?? ""), \(errorResult.longMessages?.first ?? "")")
825+
print("=====> Error unlinking broker(\(linkedBroker.userId)): \(errorResult.code ?? 0 as NSNumber), \(errorResult.shortMessage ?? ""), \(errorResult.longMessages?.first ?? "")")
826826
}
827827
)
828828
}

TradeItIosEmsApi/TradeItAccountOverviewRequest.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
class TradeItAccountOverviewRequest: TradeItRequest, Codable {
1+
class TradeItAccountOverviewRequest: TradeItRequest {
22

3-
var accountNumber: String
3+
var accountnumber: String
44
var token: String?
55

66
init(accountNumber: String) {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class TradeItAccountOverviewResult: TradeItResult {
2-
var accountOverview: TradeItAccountOverview?
2+
var accountOverview: TradeItAcccountOverview?
33
var fxAccountOverview: TradeItFxAccountOverview?
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class TradeItAllOrderStatusRequest: TradeItRequest, Codable {
1+
class TradeItAllOrderStatusRequest: TradeItRequest {
22
var token: String?
33
var accountNumber: String?
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class TradeItAuthLinkResult: TradeItResult {
2-
var userId: String = ""
3-
var userToken: String = ""
2+
var userId: String
3+
var userToken: String
44
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
class TradeItAuthenticatedRequest: TradeItRequest, Codable {
2-
var token: String = ""
1+
class TradeItAuthenticatedRequest: TradeItRequest {
2+
var token: String
33
}

TradeItIosEmsApi/TradeItAuthenticationRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class TradeItAuthenticationRequest: TradeItRequest, Codable {
1+
class TradeItAuthenticationRequest: TradeItRequest {
22

33
var userToken: String
44
var userId: String

TradeItIosEmsApi/TradeItBrokerListRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class TradeItBrokerListRequest: TradeItRequest, Codable {
1+
class TradeItBrokerListRequest: TradeItRequest {
22
var apiKey: String
33
var countryCode: String?
44

TradeItIosEmsApi/TradeItCancelOrderRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class TradeItCancelOrderRequest: TradeItRequest, Codable {
1+
class TradeItCancelOrderRequest: TradeItRequest {
22
var token: String?
33
var accountNumber: String?
44
var orderNumber: String?

TradeItIosEmsApi/TradeItConnector.h

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
//
2+
// TradeItConnector.h
3+
// TradeItIosEmsApi
4+
//
5+
// Created by Antonio Reyes on 1/12/16.
6+
// Copyright © 2016 TradeIt. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
#import "TradeItTypeDefs.h"
12+
#import "TradeItResult.h"
13+
#import "TradeItAuthLinkResult.h"
14+
#import "TradeItUpdateLinkResult.h"
15+
16+
/**
17+
Main class to manage the connection settings to the Trade It Execution Management System (EMS). And the account linking and storing of the userToken used for establishing the session
18+
*/
19+
@interface TradeItConnector : NSObject
20+
21+
/**
22+
* The apiKey is generated by TradeIt and unique to your application and is required for all API requests
23+
*/
24+
@property NSString * _Nonnull apiKey;
25+
26+
/**
27+
* Environment to send the request to. Default value is TradeItEmsProductionEnv
28+
* Tokens and API Keys are specific to environment
29+
*/
30+
@property TradeitEmsEnvironments environment;
31+
32+
/**
33+
* API version to use. Defaults to the latest.
34+
*/
35+
@property TradeItEmsApiVersion version;
36+
37+
@property NSURLSession * _Nonnull session;
38+
39+
- (nonnull id)initWithApiKey:(nonnull NSString *)apiKey
40+
environment:(TradeitEmsEnvironments)environment
41+
version:(TradeItEmsApiVersion)version;
42+
43+
/**
44+
* Using a successful response from the linkBrokerWithAuthenticationInfo:andCompletionBlock: this method will save basic information to the user preferences, and a UUID pointed to the actual user token which will be stored in the keychain.
45+
*/
46+
- (TradeItLinkedLogin * _Nullable)saveToKeychainWithLink:(TradeItAuthLinkResult * _Nullable)link
47+
withBroker:(NSString * _Nullable)broker
48+
withBrokerLongName:(NSString * _Nullable)brokerLongName;
49+
50+
/**
51+
* Same as above, but with a custom label. Useful if allowing users to link to more than one login per broker. The default, in the above method, is just the broker name.
52+
*/
53+
- (TradeItLinkedLogin * _Nullable)saveToKeychainWithLink:(TradeItAuthLinkResult * _Nullable)link
54+
withBroker:(NSString * _Nullable)broker
55+
withBrokerLongName:(NSString * _Nullable)brokerLongName
56+
andLabel:(NSString * _Nullable)label;
57+
58+
- (TradeItLinkedLogin * _Nullable)saveToKeychainWithUserId:(NSString * _Nullable)userId
59+
andUserToken:(NSString * _Nullable)userToken
60+
andBroker:(NSString * _Nullable)broker
61+
andBrokerLongName:(NSString * _Nullable)brokerLongName
62+
andLabel:(NSString * _Nullable)label;
63+
64+
/**
65+
* Using a successful response from the updateUserToken:withAuthenticationInfo:andCompletionBlock: this method will update the keychain token for an already linked account.
66+
*/
67+
- (TradeItLinkedLogin * _Nullable)updateKeychainWithLink:(TradeItAuthLinkResult * _Nullable)link
68+
withBroker:(NSString * _Nullable)broker
69+
withBrokerLongName:(NSString * _Nullable)brokerLongName;
70+
71+
/**
72+
* Retrieve a list of stored linkedLogins
73+
* @return an Array of TradeItLinkedLogin
74+
*/
75+
- (NSArray * _Nullable)getLinkedLogins;
76+
77+
- (void)deleteLocalLinkedLogin:(TradeItLinkedLogin * _Nonnull)login;
78+
79+
@end

0 commit comments

Comments
 (0)