From 59fddba010d0f05d4a8cf2728b764d712af42e6e Mon Sep 17 00:00:00 2001 From: richherrera Date: Wed, 3 Jul 2024 14:16:17 -0600 Subject: [PATCH 1/2] Clean up initializer --- Sources/BraintreeCore/BTAPIClient.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Sources/BraintreeCore/BTAPIClient.swift b/Sources/BraintreeCore/BTAPIClient.swift index f23e11101f..dd412a8255 100644 --- a/Sources/BraintreeCore/BTAPIClient.swift +++ b/Sources/BraintreeCore/BTAPIClient.swift @@ -37,11 +37,7 @@ import Foundation /// Initialize a new API client. /// - Parameter authorization: Your tokenization key or client token. Passing an invalid value may return `nil`. @objc(initWithAuthorization:) - public convenience init?(authorization: String) { - self.init(authorization: authorization, sendAnalyticsEvent: true) - } - - init?(authorization: String, sendAnalyticsEvent: Bool) { + public init?(authorization: String) { self.metadata = BTClientMetadata() guard let authorizationType = Self.authorizationType(for: authorization) else { return nil } From 6adee541888a025a45342f717849ee647c5c20b8 Mon Sep 17 00:00:00 2001 From: richherrera Date: Wed, 3 Jul 2024 14:16:23 -0600 Subject: [PATCH 2/2] Fix UTs --- .../BTConfiguration+ApplePay_Tests.swift | 2 +- .../Analytics/BTAnalyticsService_Tests.swift | 2 +- UnitTests/BraintreeTestShared/MockAPIClient.swift | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/UnitTests/BraintreeApplePayTests/BTConfiguration+ApplePay_Tests.swift b/UnitTests/BraintreeApplePayTests/BTConfiguration+ApplePay_Tests.swift index 2d4e776e69..fbc56e72b9 100644 --- a/UnitTests/BraintreeApplePayTests/BTConfiguration+ApplePay_Tests.swift +++ b/UnitTests/BraintreeApplePayTests/BTConfiguration+ApplePay_Tests.swift @@ -5,7 +5,7 @@ import PassKit @testable import BraintreeTestShared class BTConfiguration_ApplePay_Tests : XCTestCase { - var mockAPIClient = MockAPIClient.init(authorization: "development_tokenization_key", sendAnalyticsEvent: false)! + var mockAPIClient = MockAPIClient.init(authorization: "development_tokenization_key")! func testIsApplePayEnabled_whenApplePayStatusFromConfigurationJSONIsAString_returnsTrue() { for applePayStatus in ["mock", "production", "asdfasdf"] { diff --git a/UnitTests/BraintreeCoreTests/Analytics/BTAnalyticsService_Tests.swift b/UnitTests/BraintreeCoreTests/Analytics/BTAnalyticsService_Tests.swift index 001c947798..f10e5113f7 100644 --- a/UnitTests/BraintreeCoreTests/Analytics/BTAnalyticsService_Tests.swift +++ b/UnitTests/BraintreeCoreTests/Analytics/BTAnalyticsService_Tests.swift @@ -48,7 +48,7 @@ final class BTAnalyticsService_Tests: XCTestCase { // MARK: - Helper Functions func stubbedAPIClientWithAnalyticsURL(_ analyticsURL: String? = nil) -> MockAPIClient { - let stubAPIClient = MockAPIClient(authorization: "development_tokenization_key", sendAnalyticsEvent: false) + let stubAPIClient = MockAPIClient(authorization: "development_tokenization_key") if analyticsURL != nil { stubAPIClient?.cannedConfigurationResponseBody = BTJSON( diff --git a/UnitTests/BraintreeTestShared/MockAPIClient.swift b/UnitTests/BraintreeTestShared/MockAPIClient.swift index c7dee730cf..d0815408d5 100644 --- a/UnitTests/BraintreeTestShared/MockAPIClient.swift +++ b/UnitTests/BraintreeTestShared/MockAPIClient.swift @@ -27,10 +27,6 @@ public class MockAPIClient: BTAPIClient { var fetchedPaymentMethods = false var fetchPaymentMethodsSorting = false - override init?(authorization: String, sendAnalyticsEvent: Bool = false) { - super.init(authorization: authorization, sendAnalyticsEvent: sendAnalyticsEvent) - } - public override func get(_ path: String, parameters: Encodable?, httpType: BTAPIClientHTTPService, completion completionBlock: ((BTJSON?, HTTPURLResponse?, Error?) -> Void)? = nil) { lastGETPath = path lastGETParameters = try? parameters?.toDictionary()