Skip to content

Commit

Permalink
Clean up BTAPIClient.init (#1356)
Browse files Browse the repository at this point in the history
* Clean up initializer

* Fix UTs
  • Loading branch information
richherrera authored Jul 8, 2024
1 parent d93bd06 commit cf696aa
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 11 deletions.
6 changes: 1 addition & 5 deletions Sources/BraintreeCore/BTAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 0 additions & 4 deletions UnitTests/BraintreeTestShared/MockAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit cf696aa

Please sign in to comment.