Skip to content

Commit d27448a

Browse files
committed
Reorder signature
1 parent 0092f1d commit d27448a

File tree

3 files changed

+37
-16
lines changed

3 files changed

+37
-16
lines changed

Tests/swift-sdk-swift-tests/IterableAPITests.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,11 @@ class IterableAPITests: XCTestCase {
616616

617617
func testUpdateSubscriptions() {
618618
let expectation1 = expectation(description: "update subscriptions")
619-
let campaignId = NSNumber(value: 23)
620-
let templateId = NSNumber(value: 10)
621619
let emailListIds = [NSNumber(value: 382)]
622620
let unsubscriptedChannelIds = [NSNumber(value: 7845), NSNumber(value: 1048)]
623621
let unsubscribedMessageTypeIds = [NSNumber(value: 5671), NSNumber(value: 9087)]
622+
let campaignId = NSNumber(value: 23)
623+
let templateId = NSNumber(value: 10)
624624

625625
let networkSession = MockNetworkSession(statusCode: 200)
626626
networkSession.callback = {(_,_,_) in
@@ -631,17 +631,22 @@ class IterableAPITests: XCTestCase {
631631
queryParams: [])
632632

633633
let body = networkSession.getRequestBody() as! [String : Any]
634-
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_CAMPAIGN_ID), value: campaignId, inDictionary: body)
635-
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_TEMPLATE_ID), value: templateId, inDictionary: body)
636634
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_EMAIL_LIST_IDS), value: emailListIds, inDictionary: body)
637635
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_UNSUB_CHANNEL), value: unsubscriptedChannelIds, inDictionary: body)
638636
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_UNSUB_MESSAGE), value: unsubscribedMessageTypeIds, inDictionary: body)
637+
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_CAMPAIGN_ID), value: campaignId, inDictionary: body)
638+
TestUtils.validateMatch(keyPath: KeyPath(AnyHashable.ITBL_KEY_TEMPLATE_ID), value: templateId, inDictionary: body)
639639
expectation1.fulfill()
640640
}
641641
let config = IterableConfig()
642642
TestUtils.getTestUserDefaults().set("[email protected]", forKey: .ITBL_USER_DEFAULTS_EMAIL_KEY)
643643
IterableAPI.initializeForTesting(apiKey: IterableAPITests.apiKey, config:config, networkSession: networkSession)
644-
IterableAPI.updateSubscriptions(campaignId: campaignId, templateId: templateId, emailListIds: emailListIds, unsubscribedChannelIds: unsubscriptedChannelIds, unsubscribedMessageTypeIds: unsubscribedMessageTypeIds, subscribedMessageTypeIds: nil)
644+
IterableAPI.updateSubscriptions(emailListIds,
645+
unsubscribedChannelIds: unsubscriptedChannelIds,
646+
unsubscribedMessageTypeIds: unsubscribedMessageTypeIds,
647+
subscribedMessageTypeIds: nil,
648+
campaignId: campaignId,
649+
templateId: templateId)
645650
wait(for: [expectation1], timeout: testExpectationTimeout)
646651
}
647652

swift-sdk/Internal/IterableAPIInternal.swift

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,15 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol {
383383
}
384384
}
385385

386-
func updateSubscriptions(campaignId: NSNumber?, templateId: NSNumber?, emailListIds: [NSNumber]?, unsubscribedChannelIds: [NSNumber]?, unsubscribedMessageTypeIds: [NSNumber]?, subscribedMessageTypeIds: [NSNumber]?) {
386+
func updateSubscriptions(_ emailListIds: [NSNumber]? = nil,
387+
unsubscribedChannelIds: [NSNumber]? = nil,
388+
unsubscribedMessageTypeIds: [NSNumber]? = nil,
389+
subscribedMessageTypeIds: [NSNumber]? = nil,
390+
campaignId: NSNumber? = nil,
391+
templateId: NSNumber? = nil) {
387392
var dictionary = [AnyHashable : Any]()
388393
addEmailOrUserId(args: &dictionary)
389394

390-
if let campaignId = campaignId?.intValue {
391-
dictionary[.ITBL_KEY_CAMPAIGN_ID] = campaignId
392-
}
393-
394-
if let templateId = templateId?.intValue {
395-
dictionary[.ITBL_KEY_TEMPLATE_ID] = templateId
396-
}
397-
398395
if let emailListIds = emailListIds {
399396
dictionary[.ITBL_KEY_EMAIL_LIST_IDS] = emailListIds
400397
}
@@ -411,6 +408,14 @@ final class IterableAPIInternal : NSObject, PushTrackerProtocol {
411408
dictionary[.ITBL_KEY_SUB_MESSAGE] = subscribedMessageTypeIds
412409
}
413410

411+
if let campaignId = campaignId?.intValue {
412+
dictionary[.ITBL_KEY_CAMPAIGN_ID] = campaignId
413+
}
414+
415+
if let templateId = templateId?.intValue {
416+
dictionary[.ITBL_KEY_TEMPLATE_ID] = templateId
417+
}
418+
414419
if let request = createPostRequest(forPath: .ITBL_PATH_UPDATE_SUBSCRIPTIONS, withBody: dictionary) {
415420
sendRequest(request, onSuccess: IterableAPIInternal.defaultOnSucess(identifier: "updateSubscriptions"), onFailure: IterableAPIInternal.defaultOnFailure(identifier: "updateSubscriptions"))
416421
}

swift-sdk/IterableAPI.swift

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,19 @@ public final class IterableAPI : NSObject {
353353

354354
- remark: passing in an empty array will clear subscription list, passing in nil will not modify the list
355355
*/
356-
@objc(updateSubscriptions:templateId:emailListIds:unsubscribedChannelIds:unsubscribedMessageTypeIds:subscribedMessageTypeIds:) public static func updateSubscriptions(campaignId: NSNumber?, templateId: NSNumber?, emailListIds: [NSNumber]?, unsubscribedChannelIds: [NSNumber]?, unsubscribedMessageTypeIds: [NSNumber]?, subscribedMessageTypeIds: [NSNumber]?) {
357-
internalImplementation?.updateSubscriptions(campaignId: campaignId, templateId: templateId, emailListIds: emailListIds, unsubscribedChannelIds: unsubscribedChannelIds, unsubscribedMessageTypeIds: unsubscribedMessageTypeIds, subscribedMessageTypeIds: subscribedMessageTypeIds)
356+
@objc(updateSubscriptions:unsubscribedChannelIds:unsubscribedMessageTypeIds:subscribedMessageTypeIds:campaignIds:templateId:)
357+
public static func updateSubscriptions(_ emailListIds: [NSNumber]?,
358+
unsubscribedChannelIds: [NSNumber]?,
359+
unsubscribedMessageTypeIds: [NSNumber]?,
360+
subscribedMessageTypeIds: [NSNumber]?,
361+
campaignId: NSNumber?,
362+
templateId: NSNumber?) {
363+
internalImplementation?.updateSubscriptions(emailListIds,
364+
unsubscribedChannelIds: unsubscribedChannelIds,
365+
unsubscribedMessageTypeIds: unsubscribedMessageTypeIds,
366+
subscribedMessageTypeIds: subscribedMessageTypeIds,
367+
campaignId: campaignId,
368+
templateId: templateId)
358369
}
359370

360371
//MARK: In-App Notifications

0 commit comments

Comments
 (0)