Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up BTAPIClient.init #1356

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Sources/BraintreeCore/BTAPIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
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
Loading