@@ -43,10 +43,10 @@ class IterableAPITests: XCTestCase {
43
43
IterableAPI . initialize ( apiKey: IterableAPITests . apiKey, networkSession: networkSession)
44
44
IterableAPI . email = IterableAPITests . email
45
45
IterableAPI . track ( event: eventName, dataFields: nil , onSuccess: { ( json) in
46
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_TRACK , queryParams: [ ( name: " api_key " , IterableAPITests . apiKey) ] )
46
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_TRACK , queryParams: [ ( name: " api_key " , IterableAPITests . apiKey) ] )
47
47
let body = networkSession. getRequestBody ( )
48
- TestUtils . validateElementPresent ( withName: ITBL_KEY_EVENT_NAME, andValue: eventName, inDictionary: body)
49
- TestUtils . validateElementPresent ( withName: ITBL_KEY_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
48
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_EVENT_NAME, andValue: eventName, inDictionary: body)
49
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
50
50
expectation. fulfill ( )
51
51
} ) { ( reason, data) in
52
52
expectation. fulfill ( )
@@ -88,11 +88,11 @@ class IterableAPITests: XCTestCase {
88
88
IterableAPI . email = IterableAPITests . email
89
89
let dataFields : Dictionary < String , String > = [ " var1 " : " val1 " , " var2 " : " val2 " ]
90
90
IterableAPI . updateUser ( dataFields, mergeNestedObjects: true , onSuccess: { ( json) in
91
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_UPDATE_USER , queryParams: [ ( name: " api_key " , IterableAPITests . apiKey) ] )
91
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_UPDATE_USER , queryParams: [ ( name: " api_key " , IterableAPITests . apiKey) ] )
92
92
let body = networkSession. getRequestBody ( )
93
- TestUtils . validateElementPresent ( withName: ITBL_KEY_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
94
- TestUtils . validateElementPresent ( withName: ITBL_KEY_MERGE_NESTED, andValue: true , inDictionary: body)
95
- TestUtils . validateElementPresent ( withName: ITBL_KEY_DATA_FIELDS, andValue: dataFields, inDictionary: body)
93
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
94
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_MERGE_NESTED, andValue: true , inDictionary: body)
95
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_DATA_FIELDS, andValue: dataFields, inDictionary: body)
96
96
expectation. fulfill ( )
97
97
} ) { ( reason, _) in
98
98
if let reason = reason {
@@ -117,12 +117,12 @@ class IterableAPITests: XCTestCase {
117
117
onSuccess: { json in
118
118
TestUtils . validate ( request: networkSession. request!,
119
119
requestType: . post,
120
- apiEndPoint: ITBConsts . apiEndpoint ,
121
- path: ENDPOINT_UPDATE_EMAIL ,
120
+ apiEndPoint: . ITBL_ENDPOINT_API ,
121
+ path: . ITBL_PATH_UPDATE_EMAIL ,
122
122
queryParams: [ ( name: " api_key " , value: IterableAPITests . apiKey) ] )
123
123
let body = networkSession. getRequestBody ( )
124
- TestUtils . validateElementPresent ( withName: ITBL_KEY_NEW_EMAIL, andValue: newEmail, inDictionary: body)
125
- TestUtils . validateElementPresent ( withName: ITBL_KEY_CURRENT_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
124
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_NEW_EMAIL, andValue: newEmail, inDictionary: body)
125
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_CURRENT_EMAIL, andValue: IterableAPITests . email, inDictionary: body)
126
126
XCTAssertEqual ( IterableAPI . email, newEmail)
127
127
expectation. fulfill ( )
128
128
} ,
@@ -189,7 +189,7 @@ class IterableAPITests: XCTestCase {
189
189
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
190
190
TestUtils . validateElementPresent ( withName
: " email " , andValue
: " [email protected] " , inDictionary
: body
)
191
191
TestUtils . validateMatch ( keyPath: KeyPath ( " device.applicationName " ) , value: " my-push-integration " , inDictionary: body)
192
- TestUtils . validateMatch ( keyPath: KeyPath ( " device.platform " ) , value: ITBL_KEY_APNS_SANDBOX, inDictionary: body)
192
+ TestUtils . validateMatch ( keyPath: KeyPath ( " device.platform " ) , value: String . ITBL_KEY_APNS_SANDBOX, inDictionary: body)
193
193
TestUtils . validateMatch ( keyPath: KeyPath ( " device.token " ) , value: ( token as NSData ) . iteHexadecimalString ( ) , inDictionary: body)
194
194
195
195
// more device fields
@@ -249,9 +249,9 @@ class IterableAPITests: XCTestCase {
249
249
networkSession. callback = nil
250
250
IterableAPI . disableDeviceForCurrentUser ( withOnSuccess: { ( json) in
251
251
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
252
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_DISABLE_DEVICE , queryParams: [ ( name: ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
253
- TestUtils . validateElementPresent ( withName: ITBL_KEY_TOKEN, andValue: ( token as NSData ) . iteHexadecimalString ( ) , inDictionary: body)
254
- TestUtils . validateElementPresent ( withName
: ITBL_KEY_EMAIL
, andValue
: " [email protected] " , inDictionary
: body
)
252
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_DISABLE_DEVICE , queryParams: [ ( name: AnyHashable . ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
253
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_TOKEN, andValue: ( token as NSData ) . iteHexadecimalString ( ) , inDictionary: body)
254
+ TestUtils . validateElementPresent ( withName
: AnyHashable . ITBL_KEY_EMAIL
, andValue
: " [email protected] " , inDictionary
: body
)
255
255
expectation. fulfill ( )
256
256
} ) { ( errorMessage, data) in
257
257
expectation. fulfill ( )
@@ -275,10 +275,10 @@ class IterableAPITests: XCTestCase {
275
275
networkSession. callback = nil
276
276
IterableAPI . disableDeviceForAllUsers ( withOnSuccess: { ( json) in
277
277
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
278
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_DISABLE_DEVICE , queryParams: [ ( name: ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
279
- TestUtils . validateElementPresent ( withName: ITBL_KEY_TOKEN, andValue: ( token as NSData ) . iteHexadecimalString ( ) , inDictionary: body)
280
- TestUtils . validateElementNotPresent ( withName: ITBL_KEY_EMAIL, inDictionary: body)
281
- TestUtils . validateElementNotPresent ( withName: ITBL_KEY_USER_ID, inDictionary: body)
278
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_DISABLE_DEVICE , queryParams: [ ( name: AnyHashable . ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
279
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_TOKEN, andValue: ( token as NSData ) . iteHexadecimalString ( ) , inDictionary: body)
280
+ TestUtils . validateElementNotPresent ( withName: AnyHashable . ITBL_KEY_EMAIL, inDictionary: body)
281
+ TestUtils . validateElementNotPresent ( withName: AnyHashable . ITBL_KEY_USER_ID, inDictionary: body)
282
282
expectation. fulfill ( )
283
283
} ) { ( errorMessage, data) in
284
284
expectation. fulfill ( )
@@ -320,9 +320,9 @@ class IterableAPITests: XCTestCase {
320
320
321
321
IterableAPI . track ( purchase: 10.55 , items: [ ] , dataFields: nil , onSuccess: { ( json) in
322
322
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
323
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_COMMERCE_TRACK_PURCHASE , queryParams: [ ( name: ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
324
- TestUtils . validateMatch ( keyPath: KeyPath ( " \( ITBL_KEY_USER) . \( ITBL_KEY_USER_ID) " ) , value: " zeeUserId " , inDictionary: body)
325
- TestUtils . validateElementPresent ( withName: ITBL_KEY_TOTAL, andValue: 10.55 , inDictionary: body)
323
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_COMMERCE_TRACK_PURCHASE , queryParams: [ ( name: AnyHashable . ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
324
+ TestUtils . validateMatch ( keyPath: KeyPath ( " \( AnyHashable . ITBL_KEY_USER) . \( AnyHashable . ITBL_KEY_USER_ID) " ) , value: " zeeUserId " , inDictionary: body)
325
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_TOTAL, andValue: 10.55 , inDictionary: body)
326
326
327
327
expectation. fulfill ( )
328
328
} ) { ( reason, _) in
@@ -350,10 +350,10 @@ class IterableAPITests: XCTestCase {
350
350
351
351
IterableAPI . track ( purchase: total, items: items, dataFields: nil , onSuccess: { ( json) in
352
352
let body = networkSession. getRequestBody ( ) as! [ String : Any ]
353
- TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: ITBConsts . apiEndpoint , path: ENDPOINT_COMMERCE_TRACK_PURCHASE , queryParams: [ ( name: ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
354
- TestUtils . validateMatch ( keyPath
: KeyPath ( " \( ITBL_KEY_USER
) . \( ITBL_KEY_EMAIL
) " ) , value
: " [email protected] " , inDictionary
: body
)
355
- TestUtils . validateElementPresent ( withName: ITBL_KEY_TOTAL, andValue: total, inDictionary: body)
356
- let itemsElement = body [ ITBL_KEY_ITEMS] as! [ [ AnyHashable : Any ] ]
353
+ TestUtils . validate ( request: networkSession. request!, requestType: . post, apiEndPoint: . ITBL_ENDPOINT_API , path: . ITBL_PATH_COMMERCE_TRACK_PURCHASE , queryParams: [ ( name: AnyHashable . ITBL_KEY_API_KEY, value: IterableAPITests . apiKey) ] )
354
+ TestUtils . validateMatch ( keyPath
: KeyPath ( " \( AnyHashable . ITBL_KEY_USER
) . \( AnyHashable . ITBL_KEY_EMAIL
) " ) , value
: " [email protected] " , inDictionary
: body
)
355
+ TestUtils . validateElementPresent ( withName: AnyHashable . ITBL_KEY_TOTAL, andValue: total, inDictionary: body)
356
+ let itemsElement = body [ AnyHashable . ITBL_KEY_ITEMS] as! [ [ AnyHashable : Any ] ]
357
357
XCTAssertEqual ( itemsElement. count, 1 )
358
358
let firstElement = itemsElement [ 0 ]
359
359
TestUtils . validateElementPresent ( withName: " id " , andValue: " id1 " , inDictionary: firstElement)
0 commit comments