From 1c5dd703c93fd5bff89b4ab51e28b47ea24e23cf Mon Sep 17 00:00:00 2001 From: Naufal Aros Date: Tue, 28 Mar 2023 11:55:50 +0200 Subject: [PATCH] Make headers property in Request protocol settable --- AdyenNetworking/APIClient/Request.swift | 2 +- Networking Demo App/API/Requests/CreateUsersRequest.swift | 2 +- Networking Demo App/API/Requests/GetUsersRequest.swift | 2 +- .../API/Requests/InvalidCreateUsersRequest.swift | 2 +- Networking Demo AppTests/APIClientTests.swift | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AdyenNetworking/APIClient/Request.swift b/AdyenNetworking/APIClient/Request.swift index 4696194..2d62444 100644 --- a/AdyenNetworking/APIClient/Request.swift +++ b/AdyenNetworking/APIClient/Request.swift @@ -45,7 +45,7 @@ public protocol Request: Encodable { /// :nodoc: /// The HTTP headers. - var headers: [String: String] { get } + var headers: [String: String] { get set } /// :nodoc: /// The query parameters. diff --git a/Networking Demo App/API/Requests/CreateUsersRequest.swift b/Networking Demo App/API/Requests/CreateUsersRequest.swift index 2f65a3c..e3db3b1 100644 --- a/Networking Demo App/API/Requests/CreateUsersRequest.swift +++ b/Networking Demo App/API/Requests/CreateUsersRequest.swift @@ -32,7 +32,7 @@ internal struct CreateUsersRequest: Request { var counter: UInt = 0 - let headers: [String : String] = [:] + var headers: [String : String] = [:] func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() diff --git a/Networking Demo App/API/Requests/GetUsersRequest.swift b/Networking Demo App/API/Requests/GetUsersRequest.swift index d9c7d29..1dd19dc 100644 --- a/Networking Demo App/API/Requests/GetUsersRequest.swift +++ b/Networking Demo App/API/Requests/GetUsersRequest.swift @@ -31,7 +31,7 @@ internal struct GetUsersRequest: Request { var counter: UInt = 0 - let headers: [String : String] = [:] + var headers: [String : String] = [:] private enum CodingKeys: CodingKey {} } diff --git a/Networking Demo App/API/Requests/InvalidCreateUsersRequest.swift b/Networking Demo App/API/Requests/InvalidCreateUsersRequest.swift index 29373ec..2ffba99 100644 --- a/Networking Demo App/API/Requests/InvalidCreateUsersRequest.swift +++ b/Networking Demo App/API/Requests/InvalidCreateUsersRequest.swift @@ -21,7 +21,7 @@ internal struct InvalidCreateUsersRequest: Request { var counter: UInt = 0 - let headers: [String : String] = [:] + var headers: [String : String] = [:] private enum CodingKeys: CodingKey {} } diff --git a/Networking Demo AppTests/APIClientTests.swift b/Networking Demo AppTests/APIClientTests.swift index 896550b..d44bc1b 100644 --- a/Networking Demo AppTests/APIClientTests.swift +++ b/Networking Demo AppTests/APIClientTests.swift @@ -313,10 +313,10 @@ enum ValidationError: Error { } public class MockResponseValidator: AnyResponseValidator { - + var onValidated: (() throws -> Void)? - public func validate(_ responseData: Data, for request: R, with responseHeaders: [AnyHashable : Any]) throws { + public func validate(_ responseData: Data, for request: R, with responseHeaders: [String : String]) throws { try onValidated?() } }