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

Print all requests to console in debug mode #4365

Merged
merged 4 commits into from
Dec 18, 2024
Merged
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
4 changes: 4 additions & 0 deletions Stripe/StripeiOSTests/APIRequestTest.swift
Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@ class APIRequestTest: STPNetworkStubbingTestCase {

APIRequest<STPCard>.parseResponse(
httpURLResponse,
method: "GET",
body: body,
error: errorParameter
) { (object: STPCard?, response, error) in
@@ -173,6 +174,7 @@ class APIRequestTest: STPNetworkStubbingTestCase {

APIRequest<STPCard>.parseResponse(
httpURLResponse,
method: "GET",
body: body,
error: errorParameter
) { (object: STPCard?, response, error) in
@@ -200,6 +202,7 @@ class APIRequestTest: STPNetworkStubbingTestCase {

APIRequest<STPCard>.parseResponse(
httpURLResponse,
method: "GET",
body: body,
error: errorParameter
) { (object: STPCard?, response, error) in
@@ -230,6 +233,7 @@ class APIRequestTest: STPNetworkStubbingTestCase {

APIRequest<STPCard>.parseResponse(
httpURLResponse,
method: "GET",
body: body,
error: errorParameter
) { (object: STPCard?, response, error) in
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ let JSONKeyObject = "object"
apiClient.urlSession.stp_performDataTask(
with: request as URLRequest,
completionHandler: { body, response, error in
self.parseResponse(response, body: body, error: error, completion: completion)
self.parseResponse(response, method: "POST", body: body, error: error, completion: completion)
}
)
}
@@ -81,7 +81,7 @@ let JSONKeyObject = "object"
apiClient.urlSession.stp_performDataTask(
with: request as URLRequest,
completionHandler: { body, response, error in
self.parseResponse(response, body: body, error: error, completion: completion)
self.parseResponse(response, method: "GET", body: body, error: error, completion: completion)
}
)
}
@@ -123,13 +123,14 @@ let JSONKeyObject = "object"
apiClient.urlSession.stp_performDataTask(
with: request as URLRequest,
completionHandler: { body, response, error in
self.parseResponse(response, body: body, error: error, completion: completion)
self.parseResponse(response, method: "DELETE" ,body: body, error: error, completion: completion)
}
)
}

class func parseResponse(
_ response: URLResponse?,
method: String,
body: Data?,
error: Error?,
completion: @escaping (ResponseType?, HTTPURLResponse?, Error?) -> Void
@@ -186,6 +187,14 @@ let JSONKeyObject = "object"
}
// END OF STPEmptyStripeResponse HACK

#if DEBUG
if let httpResponse,
let requestId = httpResponse.value(forHTTPHeaderField: "request-id"),
let url = httpResponse.value(forKey: "URL") as? URL {
print("[Stripe SDK]: \(method) \"\(url.relativePath)\" \(httpResponse.statusCode) \(requestId)")
}
#endif

if let responseObject = ResponseType.decodedObject(fromAPIResponse: jsonDictionary) {
safeCompletion(responseObject, nil)
} else {