From 1d038437ac13a26043fc2f1cfcd0ab0960508bad Mon Sep 17 00:00:00 2001 From: kean Date: Mon, 10 Jan 2022 16:31:23 -0500 Subject: [PATCH] Update copyright --- CHANGELOG.md | 6 +++++ Sources/Get/APIClient.swift | 2 +- Sources/Get/Helpers.swift | 2 +- Sources/Get/Request.swift | 25 +++++++++++++++---- Tests/GetTests/ClientAuthorizationTests.swift | 2 +- Tests/GetTests/ClientIIntegrationTests.swift | 2 +- .../GetTests/ClientSessionDelegateTests.swift | 2 +- Tests/GetTests/ClientTests.swift | 2 +- Tests/GetTests/GitHubAPI.swift | 2 +- Tests/GetTests/Helpers.swift | 2 +- 10 files changed, 34 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f79fc2c..1ea2c6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Get 0.x +## Get 0.4.0 + +*Jan 10, 2022* + +- Add public `Request` intializer + ## Get 0.3.1 *Dec 29, 2021* diff --git a/Sources/Get/APIClient.swift b/Sources/Get/APIClient.swift index 5add496..1fc8473 100644 --- a/Sources/Get/APIClient.swift +++ b/Sources/Get/APIClient.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import Foundation diff --git a/Sources/Get/Helpers.swift b/Sources/Get/Helpers.swift index 595371d..aabd19d 100644 --- a/Sources/Get/Helpers.swift +++ b/Sources/Get/Helpers.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import Foundation diff --git a/Sources/Get/Request.swift b/Sources/Get/Request.swift index cb24d89..3dd739d 100644 --- a/Sources/Get/Request.swift +++ b/Sources/Get/Request.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import Foundation @@ -11,6 +11,21 @@ public struct Request { var body: AnyEncodable? public var headers: [String: String]? public var id: String? + + public init(method: String, path: String, query: [(String, String?)]? = nil, headers: [String : String]? = nil) { + self.method = method + self.path = path + self.query = query + self.headers = headers + } + + public init(method: String, path: String, query: [(String, String?)]? = nil, body: U?, headers: [String : String]? = nil) { + self.method = method + self.path = path + self.query = query + self.body = body.map(AnyEncodable.init) + self.headers = headers + } public static func get(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request { Request(method: "GET", path: path, query: query, headers: headers) @@ -21,7 +36,7 @@ public struct Request { } public static func post(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request { - Request(method: "POST", path: path, query: query, body: body.map(AnyEncodable.init), headers: headers) + Request(method: "POST", path: path, query: query, body: body, headers: headers) } public static func put(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request { @@ -29,7 +44,7 @@ public struct Request { } public static func put(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request { - Request(method: "PUT", path: path, query: query, body: body.map(AnyEncodable.init), headers: headers) + Request(method: "PUT", path: path, query: query, body: body, headers: headers) } public static func patch(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request { @@ -37,7 +52,7 @@ public struct Request { } public static func patch(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request { - Request(method: "PATCH", path: path, query: query, body: body.map(AnyEncodable.init), headers: headers) + Request(method: "PATCH", path: path, query: query, body: body, headers: headers) } public static func delete(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request { @@ -45,7 +60,7 @@ public struct Request { } public static func delete(_ path: String, query: [(String, String?)]? = nil, body: U?, headers: [String: String]? = nil) -> Request { - Request(method: "DELETE", path: path, query: query, body: body.map(AnyEncodable.init), headers: headers) + Request(method: "DELETE", path: path, query: query, body: body, headers: headers) } public static func options(_ path: String, query: [(String, String?)]? = nil, headers: [String: String]? = nil) -> Request { diff --git a/Tests/GetTests/ClientAuthorizationTests.swift b/Tests/GetTests/ClientAuthorizationTests.swift index d7a130f..b2ab94e 100644 --- a/Tests/GetTests/ClientAuthorizationTests.swift +++ b/Tests/GetTests/ClientAuthorizationTests.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import XCTest import Mocker diff --git a/Tests/GetTests/ClientIIntegrationTests.swift b/Tests/GetTests/ClientIIntegrationTests.swift index 232aa00..5a8d9ae 100644 --- a/Tests/GetTests/ClientIIntegrationTests.swift +++ b/Tests/GetTests/ClientIIntegrationTests.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import XCTest import Mocker diff --git a/Tests/GetTests/ClientSessionDelegateTests.swift b/Tests/GetTests/ClientSessionDelegateTests.swift index a1fd3c8..460994c 100644 --- a/Tests/GetTests/ClientSessionDelegateTests.swift +++ b/Tests/GetTests/ClientSessionDelegateTests.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import XCTest import Mocker diff --git a/Tests/GetTests/ClientTests.swift b/Tests/GetTests/ClientTests.swift index 46da8a5..46debd4 100644 --- a/Tests/GetTests/ClientTests.swift +++ b/Tests/GetTests/ClientTests.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import XCTest import Mocker diff --git a/Tests/GetTests/GitHubAPI.swift b/Tests/GetTests/GitHubAPI.swift index 0a35123..b4678a1 100644 --- a/Tests/GetTests/GitHubAPI.swift +++ b/Tests/GetTests/GitHubAPI.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import Foundation import Get diff --git a/Tests/GetTests/Helpers.swift b/Tests/GetTests/Helpers.swift index d3e1bb4..2d5bf72 100644 --- a/Tests/GetTests/Helpers.swift +++ b/Tests/GetTests/Helpers.swift @@ -1,6 +1,6 @@ // The MIT License (MIT) // -// Copyright (c) 2021 Alexander Grebenyuk (github.com/kean). +// Copyright (c) 2021-2022 Alexander Grebenyuk (github.com/kean). import XCTest import Mocker