Skip to content

Commit 0e990f5

Browse files
authored
Merge pull request #549 from Iterable/MOB-4287-remove-api-key-from-url
[MOB-4287] Removes the extra api-key argument from the request creator.
2 parents 42d5ef5 + 92ca5e5 commit 0e990f5

File tree

7 files changed

+13
-20
lines changed

7 files changed

+13
-20
lines changed

swift-sdk/Internal/ApiClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class ApiClient {
8282
return .failure(IterableError.general(description: "authProvider is missing"))
8383
}
8484

85-
return .success(RequestCreator(apiKey: apiKey, auth: authProvider.auth, deviceMetadata: deviceMetadata))
85+
return .success(RequestCreator(auth: authProvider.auth, deviceMetadata: deviceMetadata))
8686
}
8787

8888
private let apiKey: String

swift-sdk/Internal/OfflineRequestProcessor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct OfflineRequestProcessor: RequestProcessorProtocol {
246246
private let taskRunner: IterableTaskRunner
247247

248248
private func createRequestCreator(authProvider: AuthProvider) -> RequestCreator {
249-
return RequestCreator(apiKey: apiKey, auth: authProvider.auth, deviceMetadata: deviceMetadata)
249+
return RequestCreator(auth: authProvider.auth, deviceMetadata: deviceMetadata)
250250
}
251251

252252
private func sendIterableRequest(requestGenerator: (RequestCreator) -> Result<IterableRequest, IterableError>,

swift-sdk/Internal/RequestCreator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import UIKit
99
/// This will create IterableRequest
1010
/// The API Endpoint and request endpoint is not defined yet
1111
struct RequestCreator {
12-
let apiKey: String
1312
let auth: Auth
1413
let deviceMetadata: DeviceMetadata
1514

@@ -449,7 +448,7 @@ struct RequestCreator {
449448

450449
private func createPostRequest(path: String, body: [AnyHashable: Any]? = nil) -> PostRequest {
451450
PostRequest(path: path,
452-
args: [JsonKey.Header.apiKey: apiKey],
451+
args: nil,
453452
body: body)
454453
}
455454

tests/offline-events-tests/TaskProcessorTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class TaskProcessorTests: XCTestCase {
1919
let networkSession = MockNetworkSession()
2020
let internalAPI = InternalIterableAPI.initializeForTesting(apiKey: apiKey, config: config, networkSession: networkSession)
2121

22-
let requestCreator = RequestCreator(apiKey: apiKey,
23-
auth: auth,
22+
let requestCreator = RequestCreator(auth: auth,
2423
deviceMetadata: internalAPI.deviceMetadata)
2524
guard case let Result.success(trackEventRequest) = requestCreator.createTrackEventRequest(eventName, dataFields: dataFields) else {
2625
XCTFail("Could not create trackEvent request")
@@ -223,8 +222,7 @@ class TaskProcessorTests: XCTestCase {
223222
let dataFields = ["var1": "val1", "var2": "val2"]
224223

225224
let auth = Auth(userId: nil, email: email, authToken: nil)
226-
let requestCreator = RequestCreator(apiKey: apiKey,
227-
auth: auth,
225+
let requestCreator = RequestCreator(auth: auth,
228226
deviceMetadata: deviceMetadata)
229227
guard case let Result.success(trackEventRequest) = requestCreator.createTrackEventRequest(eventName, dataFields: dataFields) else {
230228
XCTFail("Could not create trackEvent request")

tests/offline-events-tests/TaskRunnerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class TaskRunnerTests: XCTestCase {
328328
let eventName = "CustomEvent1"
329329
let dataFields = ["var1": "val1", "var2": "val2"]
330330

331-
let requestCreator = RequestCreator(apiKey: apiKey, auth: auth, deviceMetadata: deviceMetadata)
331+
let requestCreator = RequestCreator(auth: auth, deviceMetadata: deviceMetadata)
332332
guard case let Result.success(trackEventRequest) = requestCreator.createTrackEventRequest(eventName, dataFields: dataFields) else {
333333
throw IterableError.general(description: "Could not create trackEvent request")
334334
}

tests/offline-events-tests/TaskSchedulerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TaskSchedulerTests: XCTestCase {
3131
expectation1.fulfill()
3232
}
3333
XCTAssertNotNil(reference)
34-
let requestCreator = RequestCreator(apiKey: apiKey, auth: auth, deviceMetadata: deviceMetadata)
34+
let requestCreator = RequestCreator(auth: auth, deviceMetadata: deviceMetadata)
3535
guard case let Result.success(trackEventRequest) = requestCreator.createTrackEventRequest(eventName, dataFields: dataFields) else {
3636
throw IterableError.general(description: "Could not create trackEvent request")
3737
}

tests/unit-tests/RequestCreatorTests.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class RequestCreatorTests: XCTestCase {
149149

150150
func testGetInAppMessagesRequestFailure() {
151151
let auth = Auth(userId: nil, email: nil, authToken: nil)
152-
let requestCreator = RequestCreator(apiKey: apiKey, auth: auth, deviceMetadata: deviceMetadata)
152+
let requestCreator = RequestCreator(auth: auth, deviceMetadata: deviceMetadata)
153153

154154
let failingRequest = requestCreator.createGetInAppMessagesRequest(1)
155155

@@ -247,8 +247,7 @@ class RequestCreatorTests: XCTestCase {
247247
}
248248

249249
func testUserlessUpdateUserRequest() {
250-
let userlessRequestCreator = RequestCreator(apiKey: apiKey,
251-
auth: userlessAuth,
250+
let userlessRequestCreator = RequestCreator(auth: userlessAuth,
252251
deviceMetadata: deviceMetadata)
253252

254253
let result = userlessRequestCreator.createUpdateUserRequest(dataFields: [:], mergeNestedObjects: false)
@@ -262,8 +261,7 @@ class RequestCreatorTests: XCTestCase {
262261
}
263262

264263
func testUserlessUpdateSubscriptionsRequest() {
265-
let userlessRequestCreator = RequestCreator(apiKey: apiKey,
266-
auth: userlessAuth,
264+
let userlessRequestCreator = RequestCreator(auth: userlessAuth,
267265
deviceMetadata: deviceMetadata)
268266

269267
let result = userlessRequestCreator.createUpdateSubscriptionsRequest()
@@ -277,8 +275,7 @@ class RequestCreatorTests: XCTestCase {
277275
}
278276

279277
func testUserlessTrackInboxSessionRequest() {
280-
let userlessRequestCreator = RequestCreator(apiKey: apiKey,
281-
auth: userlessAuth,
278+
let userlessRequestCreator = RequestCreator(auth: userlessAuth,
282279
deviceMetadata: deviceMetadata)
283280

284281
let result = userlessRequestCreator.createTrackInboxSessionRequest(inboxSession: IterableInboxSession())
@@ -323,8 +320,7 @@ class RequestCreatorTests: XCTestCase {
323320
}
324321

325322
func testRegisterTokenRequestPrefersUserId() {
326-
let userIdRequestCreator = RequestCreator(apiKey: apiKey,
327-
auth: userIdAuth,
323+
let userIdRequestCreator = RequestCreator(auth: userIdAuth,
328324
deviceMetadata: deviceMetadata)
329325

330326
let registerTokenInfo = RegisterTokenInfo(hexToken: "hex-token",
@@ -412,7 +408,7 @@ class RequestCreatorTests: XCTestCase {
412408
}
413409

414410
private func createRequestCreator() -> RequestCreator {
415-
RequestCreator(apiKey: apiKey, auth: auth, deviceMetadata: deviceMetadata)
411+
RequestCreator(auth: auth, deviceMetadata: deviceMetadata)
416412
}
417413

418414
private func createApiClient(networkSession: NetworkSessionProtocol) -> ApiClient {

0 commit comments

Comments
 (0)