Skip to content

Commit

Permalink
Improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
3lvis committed Jul 17, 2024
1 parent d4b6632 commit b36c3a0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Networking/Networking+New.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ extension Networking {
switch statusCode.statusCodeType {
case .informational, .successful:
logger.info("Received successful response with status code \(statusCode) from \(path, privacy: .public)")
if T.self == NetworkingJSON.self {
if T.self == NetworkingResponse.self {
let headers = Dictionary(uniqueKeysWithValues: httpResponse.allHeaderFields.compactMap { key, value in
(key as? String).map { ($0, AnyCodable(value)) }
})
let body = try JSONDecoder().decode([String: AnyCodable].self, from: responseData)
let networkingJSON = NetworkingJSON(headers: headers, body: body)
let networkingJSON = NetworkingResponse(headers: headers, body: body)
return .success(networkingJSON as! T)
} else {
let decoder = JSONDecoder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Foundation

public struct NetworkingJSON: Decodable {
public struct NetworkingResponse: Decodable {
public let headers: [String: AnyCodable]
public let body: [String: AnyCodable]
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/NetworkingTests/GETTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class GETTests: XCTestCase {
func testNetworkingJSON() async throws {
let networking = Networking(baseURL: baseURL)

let result: Result<NetworkingJSON, NetworkingError> = await networking.newGet("/auth")
let result: Result<NetworkingResponse, NetworkingError> = await networking.newGet("/auth")
switch result {
case .success(let success):
let header = success.headers.string(for: "access-token")
Expand Down

0 comments on commit b36c3a0

Please sign in to comment.