From 53014f0fdf34aeaa2fa8afa4a84c78be66864c77 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 12 May 2020 12:40:50 +0200 Subject: [PATCH 01/23] Allow perform(decoding:) to output a non-optional type if successful --- Sources/Requests/Request.swift | 5 ++--- Tests/RequestsTests/RequestTests.swift | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index 49486b1..b686b62 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -155,7 +155,7 @@ open class Request: AbstractRequest { /// - error: The task error. open func perform(decoding object: T.Type, _ completionHandler: @escaping ( - _ result: Result<(T?, URLResponse?), Error>) throws -> Void) { + _ result: Result<(T, URLResponse?), Error>) throws -> Void) { perform { result in switch result { @@ -167,8 +167,7 @@ open class Request: AbstractRequest { return } - let object = try JSONDecoder().decode(T.self, from: data) - try completionHandler(.success((object, response.urlResponse))) + try completionHandler(.success((try JSONDecoder().decode(T.self, from: data), response.urlResponse))) case .failure(let error): try completionHandler(.failure(error)) } diff --git a/Tests/RequestsTests/RequestTests.swift b/Tests/RequestsTests/RequestTests.swift index 0e7edbb..6ef19b0 100644 --- a/Tests/RequestsTests/RequestTests.swift +++ b/Tests/RequestsTests/RequestTests.swift @@ -100,7 +100,7 @@ final class RequestTests: XCTestCase { .perform(decoding: User.self) { result in if let response = try? result.get(), - response.0?.username == "test" { + response.0.username == "test" { decodingExpectation.fulfill() } From 2d7868e6500bc5c86d5a23bc44b614ded7255b1f Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 12 May 2020 14:39:56 +0200 Subject: [PATCH 02/23] Update codecov GitHub action simulator iOS version --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 8f232d8..2934b0d 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Generate coverage report - run: xcodebuild -scheme Requests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=13.3' -enableCodeCoverage YES build test + run: xcodebuild -scheme Requests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=13.4.1' -enableCodeCoverage YES build test - name: Codecov uses: codecov/codecov-action@v1.0.5 with: From 9a2cf1fddae0dbe44c82a4d1d58dd62a811dac03 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 12 May 2020 16:43:25 +0200 Subject: [PATCH 03/23] Refactor perform(decoding:) --- Sources/Requests/Request.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index b686b62..a13769d 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -167,7 +167,8 @@ open class Request: AbstractRequest { return } - try completionHandler(.success((try JSONDecoder().decode(T.self, from: data), response.urlResponse))) + let object = try JSONDecoder().decode(T.self, from: data) + try completionHandler(.success((object, response.urlResponse))) case .failure(let error): try completionHandler(.failure(error)) } From b2e891aa6a7d398fc3f47efe6a1e2d9510c28cba Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 13 May 2020 15:30:22 +0200 Subject: [PATCH 04/23] Add error handling in perform(decoding:) --- Sources/Requests/Request.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index a13769d..f61f6d2 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -167,7 +167,12 @@ open class Request: AbstractRequest { return } - let object = try JSONDecoder().decode(T.self, from: data) + do { + let object = try JSONDecoder().decode(T.self, from: data) + } catch let error { + try completionHandler(.failure(error)) + } + try completionHandler(.success((object, response.urlResponse))) case .failure(let error): try completionHandler(.failure(error)) From 026ede3199f3afbb12ea664a756a1ea64d35f3c0 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 13 May 2020 15:32:36 +0200 Subject: [PATCH 05/23] Fix typo --- Sources/Requests/Request.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index f61f6d2..41692d8 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -169,11 +169,11 @@ open class Request: AbstractRequest { do { let object = try JSONDecoder().decode(T.self, from: data) + try completionHandler(.success((object, response.urlResponse))) } catch let error { try completionHandler(.failure(error)) } - try completionHandler(.success((object, response.urlResponse))) case .failure(let error): try completionHandler(.failure(error)) } From accabd0c29dea32c90acd905e7f52d3d7459a5a9 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 26 May 2020 16:50:50 +0200 Subject: [PATCH 06/23] Fix header configuration --- Sources/Requests/Request.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index b686b62..0fdc31a 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -191,7 +191,7 @@ open class Request: AbstractRequest { if let headers = headers { headers.forEach { header in - request.addValue(header.key, forHTTPHeaderField: header.value) + request.addValue(header.value, forHTTPHeaderField: header.key) } } From a78bc76cc0fd5ab43bf5025dc975df823120a0c1 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 26 May 2020 19:20:51 +0200 Subject: [PATCH 07/23] Fix headers set --- Sources/Requests/Request.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Requests/Request.swift b/Sources/Requests/Request.swift index 0fdc31a..540b5fd 100644 --- a/Sources/Requests/Request.swift +++ b/Sources/Requests/Request.swift @@ -191,7 +191,7 @@ open class Request: AbstractRequest { if let headers = headers { headers.forEach { header in - request.addValue(header.value, forHTTPHeaderField: header.key) + request.setValue(header.value, forHTTPHeaderField: header.key) } } From 99e618a151d5ee121b82ac3c500a0f2f6ebd2bf1 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 26 May 2020 19:28:22 +0200 Subject: [PATCH 08/23] Add perform(decoding:) data type error test --- Tests/RequestsTests/RequestTests.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Tests/RequestsTests/RequestTests.swift b/Tests/RequestsTests/RequestTests.swift index 6ef19b0..e74118d 100644 --- a/Tests/RequestsTests/RequestTests.swift +++ b/Tests/RequestsTests/RequestTests.swift @@ -110,6 +110,23 @@ final class RequestTests: XCTestCase { } func testPerformDecodingError() { + let throwingExpectation = expectation(description: "Perform should throw an error") + let sessionMock = URLSessionCodableMock() + sessionMock.data = Data(base64Encoded: "VEhJU0lTV1JPTkc=") + + try? Request(.get, + atPath: "/user", + onSession: sessionMock) + .perform(decoding: User.self) { result in + + XCTAssertThrowsError(try result.get()) + throwingExpectation.fulfill() + } + + wait(for: [throwingExpectation], timeout: 500) + } + + func testPerformDecodingNoDataError() { let throwingExpectation = expectation(description: "Perform should throw an error") let sessionMock = URLSessionCodableMock() sessionMock.data = nil From 01d00b66998bacd0c178c897f9a02999b0e51727 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 26 May 2020 21:47:13 +0200 Subject: [PATCH 09/23] Add podspec --- Requests.podspec | 143 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Requests.podspec diff --git a/Requests.podspec b/Requests.podspec new file mode 100644 index 0000000..745bcef --- /dev/null +++ b/Requests.podspec @@ -0,0 +1,143 @@ +# +# Be sure to run `pod spec lint requests.podspec' to ensure this is a +# valid spec and to remove all comments including this before submitting the spec. +# +# To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html +# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ +# + +Pod::Spec.new do |spec| + + # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # These will help people to find your library, and whilst it + # can feel like a chore to fill in it's definitely to your advantage. The + # summary should be tweet-length, and the description more in depth. + # + + spec.name = "Requests" + spec.version = "0.1.2" + spec.summary = "An object-oriented, URLSession-based network library." + + # This description is used to generate tags and improve search results. + # * Think: What does it do? Why did you write it? What is the focus? + # * Try to keep it short, snappy and to the point. + # * Write the description between the DESC delimiters below. + # * Finally, don't worry about the indent, CocoaPods strips it! + spec.description = <<-DESC + "An object-oriented, URLSession-based network library, made with simplicity in mind." + DESC + + spec.homepage = "https://github.com/Ast3r10n/requests" + # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" + + + # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Licensing your code is important. See https://choosealicense.com for more info. + # CocoaPods will detect a license file if there is a named LICENSE* + # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'. + # + + spec.license = { :type => "GNU", :file => "LICENSE" } + + + # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the authors of the library, with email addresses. Email addresses + # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also + # accepts just a name if you'd rather not provide an email address. + # + # Specify a social_media_url where others can refer to, for example a twitter + # profile URL. + # + + spec.author = { "Andrea Sacerdoti" => "andrea.sacerdoti@icloud.com" } + # Or just: spec.author = "Andrea Sacerdoti" + # spec.authors = { "Andrea Sacerdoti" => "email@address.com" } + spec.social_media_url = "https://twitter.com/AndreaSacerdoti" + + # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If this Pod runs only on iOS or OS X, then specify the platform and + # the deployment target. You can optionally include the target after the platform. + # + + # spec.platform = :ios + spec.platform = :ios, "8.0" + + # When using multiple platforms + # spec.ios.deployment_target = "8.0" + # spec.osx.deployment_target = "10.9" + # spec.watchos.deployment_target = "2.0" + # spec.tvos.deployment_target = "9.0" + + spec.swift_versions = "5.0" + + # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Specify the location from where the source should be retrieved. + # Supports git, hg, bzr, svn and HTTP. + # + + spec.source = { :git => "https://github.com/Ast3r10n/requests.git", :tag => "#{spec.version}" } + + + # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # CocoaPods is smart about how it includes source code. For source files + # giving a folder will include any swift, h, m, mm, c & cpp files. + # For header files it will include any header in the folder. + # Not including the public_header_files will make all headers public. + # + + spec.source_files = "Sources", "Sources/**/*.{swift}" + spec.exclude_files = "Sources/Exclude" + + spec.test_spec 'Tests' do |test_spec| + test_spec.source_files = 'Tests/**/*.swift' + test_spec.exclude_files = '*/LinuxMain.swift' + end + + # spec.public_header_files = "Classes/**/*.h" + + + # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # A list of resources included with the Pod. These are copied into the + # target bundle with a build phase script. Anything else will be cleaned. + # You can preserve files from being cleaned, please don't preserve + # non-essential files like tests, examples and documentation. + # + + # spec.resource = "icon.png" + # spec.resources = "Resources/*.png" + + # spec.preserve_paths = "FilesToSave", "MoreFilesToSave" + + + # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # Link your library with frameworks, or libraries. Libraries do not include + # the lib prefix of their name. + # + + # spec.framework = "SomeFramework" + # spec.frameworks = "SomeFramework", "AnotherFramework" + + # spec.library = "iconv" + # spec.libraries = "iconv", "xml2" + + + # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + # + # If your library depends on compiler flags you can set them in the xcconfig hash + # where they will only apply to your library. If you depend on other Podspecs + # you can include multiple dependencies to ensure it works. + + # spec.requires_arc = true + + # spec.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" } + # spec.dependency "JSONKit", "~> 1.4" + +end From d4eb03b9b5b4104989e1436fbcc2d44eba0db645 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Tue, 26 May 2020 22:12:43 +0200 Subject: [PATCH 10/23] Update podspec description, README --- Requests.podspec => AstRequests.podspec | 4 ++-- README.md | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) rename Requests.podspec => AstRequests.podspec (98%) diff --git a/Requests.podspec b/AstRequests.podspec similarity index 98% rename from Requests.podspec rename to AstRequests.podspec index 745bcef..c4d64f5 100644 --- a/Requests.podspec +++ b/AstRequests.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |spec| # summary should be tweet-length, and the description more in depth. # - spec.name = "Requests" + spec.name = "AstRequests" spec.version = "0.1.2" spec.summary = "An object-oriented, URLSession-based network library." @@ -25,7 +25,7 @@ Pod::Spec.new do |spec| # * Write the description between the DESC delimiters below. # * Finally, don't worry about the indent, CocoaPods strips it! spec.description = <<-DESC - "An object-oriented, URLSession-based network library, made with simplicity in mind." + "An object-oriented, URLSession-based network library, made with simplicity in mind. It's a direct wrapper for URLSession, with no other dependencies." DESC spec.homepage = "https://github.com/Ast3r10n/requests" diff --git a/README.md b/README.md index 5ab4d8d..dc13daa 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,17 @@ An object-oriented, URLSession-based network library. ## Installation +### Swift Package Manager + Add a Swift Package Dependency to your project with URL: ``` https://github.com/Ast3r10n/requests ``` +### Cocoapods + + + ## Usage A `Request` is a basic, standalone object, with a single associated task, configured through its initialiser. From 6014200f4fc61d1db88dfc7f2b96f584284ae989 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 27 May 2020 09:51:24 +0200 Subject: [PATCH 11/23] Rename project to SwiftQuests --- .github/workflows/swift.yml | 2 +- Package.swift | 12 ++++++------ README.md | 8 +++++--- .../DefaultRequestConfiguration.swift | 0 Sources/{Requests => SwiftQuests}/Request.swift | 0 .../RequestConfigurationHolder.swift | 0 AstRequests.podspec => SwiftQuests.podspec | 8 ++++---- Tests/LinuxMain.swift | 4 ++-- .../Mocks/URLSessionCodableMock.swift | 0 .../Mocks/URLSessionDataTaskMock.swift | 0 .../Mocks/URLSessionMock.swift | 0 .../Mocks/UserModel.swift | 0 .../RequestConfigurationTests.swift | 2 +- .../RequestTests.swift | 2 +- .../XCTestManifests.swift | 0 15 files changed, 20 insertions(+), 18 deletions(-) rename Sources/{Requests => SwiftQuests}/DefaultRequestConfiguration.swift (100%) rename Sources/{Requests => SwiftQuests}/Request.swift (100%) rename Sources/{Requests => SwiftQuests}/RequestConfigurationHolder.swift (100%) rename AstRequests.podspec => SwiftQuests.podspec (95%) rename Tests/{RequestsTests => SwiftQuestsTests}/Mocks/URLSessionCodableMock.swift (100%) rename Tests/{RequestsTests => SwiftQuestsTests}/Mocks/URLSessionDataTaskMock.swift (100%) rename Tests/{RequestsTests => SwiftQuestsTests}/Mocks/URLSessionMock.swift (100%) rename Tests/{RequestsTests => SwiftQuestsTests}/Mocks/UserModel.swift (100%) rename Tests/{RequestsTests => SwiftQuestsTests}/RequestConfigurationTests.swift (94%) rename Tests/{RequestsTests => SwiftQuestsTests}/RequestTests.swift (99%) rename Tests/{RequestsTests => SwiftQuestsTests}/XCTestManifests.swift (100%) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 2934b0d..0550b1a 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Generate coverage report - run: xcodebuild -scheme Requests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=13.4.1' -enableCodeCoverage YES build test + run: xcodebuild -scheme SwiftQuests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=13.4.1' -enableCodeCoverage YES build test - name: Codecov uses: codecov/codecov-action@v1.0.5 with: diff --git a/Package.swift b/Package.swift index 9d10932..462532c 100644 --- a/Package.swift +++ b/Package.swift @@ -3,18 +3,18 @@ import PackageDescription let package = Package( - name: "Requests", + name: "SwiftQuests", products: [ .library( - name: "Requests", - targets: ["Requests"]), + name: "SwiftQuests", + targets: ["SwiftQuests"]), ], targets: [ .target( - name: "Requests", + name: "SwiftQuests", dependencies: []), .testTarget( - name: "RequestsTests", - dependencies: ["Requests"]), + name: "SwiftQuestsTests", + dependencies: ["SwiftQuests"]), ] ) diff --git a/README.md b/README.md index dc13daa..6e99020 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Requests +# SwiftQuests An object-oriented, URLSession-based network library. @@ -10,12 +10,14 @@ An object-oriented, URLSession-based network library. Add a Swift Package Dependency to your project with URL: ``` -https://github.com/Ast3r10n/requests +https://github.com/Ast3r10n/swiftquests ``` ### Cocoapods - +``` +pod 'SwiftQuests' +``` ## Usage diff --git a/Sources/Requests/DefaultRequestConfiguration.swift b/Sources/SwiftQuests/DefaultRequestConfiguration.swift similarity index 100% rename from Sources/Requests/DefaultRequestConfiguration.swift rename to Sources/SwiftQuests/DefaultRequestConfiguration.swift diff --git a/Sources/Requests/Request.swift b/Sources/SwiftQuests/Request.swift similarity index 100% rename from Sources/Requests/Request.swift rename to Sources/SwiftQuests/Request.swift diff --git a/Sources/Requests/RequestConfigurationHolder.swift b/Sources/SwiftQuests/RequestConfigurationHolder.swift similarity index 100% rename from Sources/Requests/RequestConfigurationHolder.swift rename to Sources/SwiftQuests/RequestConfigurationHolder.swift diff --git a/AstRequests.podspec b/SwiftQuests.podspec similarity index 95% rename from AstRequests.podspec rename to SwiftQuests.podspec index c4d64f5..41a844a 100644 --- a/AstRequests.podspec +++ b/SwiftQuests.podspec @@ -1,5 +1,5 @@ # -# Be sure to run `pod spec lint requests.podspec' to ensure this is a +# Be sure to run `pod spec lint SwiftQuests.podspec' to ensure this is a # valid spec and to remove all comments including this before submitting the spec. # # To learn more about Podspec attributes see https://guides.cocoapods.org/syntax/podspec.html @@ -15,7 +15,7 @@ Pod::Spec.new do |spec| # summary should be tweet-length, and the description more in depth. # - spec.name = "AstRequests" + spec.name = "SwiftQuests" spec.version = "0.1.2" spec.summary = "An object-oriented, URLSession-based network library." @@ -28,7 +28,7 @@ Pod::Spec.new do |spec| "An object-oriented, URLSession-based network library, made with simplicity in mind. It's a direct wrapper for URLSession, with no other dependencies." DESC - spec.homepage = "https://github.com/Ast3r10n/requests" + spec.homepage = "https://github.com/Ast3r10n/swiftquests" # spec.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif" @@ -80,7 +80,7 @@ Pod::Spec.new do |spec| # Supports git, hg, bzr, svn and HTTP. # - spec.source = { :git => "https://github.com/Ast3r10n/requests.git", :tag => "#{spec.version}" } + spec.source = { :git => "https://github.com/Ast3r10n/swiftquests.git", :tag => "#{spec.version}" } # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 040bb69..f0d68d1 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1,7 +1,7 @@ import XCTest -import RequestsTests +import SwiftQuestsTests var tests = [XCTestCaseEntry]() -tests += RequestsTests.allTests() +tests += SwiftQuestsTests.allTests() XCTMain(tests) diff --git a/Tests/RequestsTests/Mocks/URLSessionCodableMock.swift b/Tests/SwiftQuestsTests/Mocks/URLSessionCodableMock.swift similarity index 100% rename from Tests/RequestsTests/Mocks/URLSessionCodableMock.swift rename to Tests/SwiftQuestsTests/Mocks/URLSessionCodableMock.swift diff --git a/Tests/RequestsTests/Mocks/URLSessionDataTaskMock.swift b/Tests/SwiftQuestsTests/Mocks/URLSessionDataTaskMock.swift similarity index 100% rename from Tests/RequestsTests/Mocks/URLSessionDataTaskMock.swift rename to Tests/SwiftQuestsTests/Mocks/URLSessionDataTaskMock.swift diff --git a/Tests/RequestsTests/Mocks/URLSessionMock.swift b/Tests/SwiftQuestsTests/Mocks/URLSessionMock.swift similarity index 100% rename from Tests/RequestsTests/Mocks/URLSessionMock.swift rename to Tests/SwiftQuestsTests/Mocks/URLSessionMock.swift diff --git a/Tests/RequestsTests/Mocks/UserModel.swift b/Tests/SwiftQuestsTests/Mocks/UserModel.swift similarity index 100% rename from Tests/RequestsTests/Mocks/UserModel.swift rename to Tests/SwiftQuestsTests/Mocks/UserModel.swift diff --git a/Tests/RequestsTests/RequestConfigurationTests.swift b/Tests/SwiftQuestsTests/RequestConfigurationTests.swift similarity index 94% rename from Tests/RequestsTests/RequestConfigurationTests.swift rename to Tests/SwiftQuestsTests/RequestConfigurationTests.swift index 3bdfaea..d1f48a3 100644 --- a/Tests/RequestsTests/RequestConfigurationTests.swift +++ b/Tests/SwiftQuestsTests/RequestConfigurationTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import Requests +@testable import SwiftQuests final class RequestConfigurationTests: XCTestCase { var configuration = DefaultRequestConfiguration() diff --git a/Tests/RequestsTests/RequestTests.swift b/Tests/SwiftQuestsTests/RequestTests.swift similarity index 99% rename from Tests/RequestsTests/RequestTests.swift rename to Tests/SwiftQuestsTests/RequestTests.swift index e74118d..d664591 100644 --- a/Tests/RequestsTests/RequestTests.swift +++ b/Tests/SwiftQuestsTests/RequestTests.swift @@ -6,7 +6,7 @@ // import XCTest -@testable import Requests +@testable import SwiftQuests final class RequestTests: XCTestCase { var request: Request? diff --git a/Tests/RequestsTests/XCTestManifests.swift b/Tests/SwiftQuestsTests/XCTestManifests.swift similarity index 100% rename from Tests/RequestsTests/XCTestManifests.swift rename to Tests/SwiftQuestsTests/XCTestManifests.swift From c5d20991d1553bd81b9c52704f89716c8185437c Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 27 May 2020 10:18:57 +0200 Subject: [PATCH 12/23] Update podspec version --- SwiftQuests.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SwiftQuests.podspec b/SwiftQuests.podspec index 41a844a..6165f1c 100644 --- a/SwiftQuests.podspec +++ b/SwiftQuests.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "SwiftQuests" - spec.version = "0.1.2" + spec.version = "0.1.3" spec.summary = "An object-oriented, URLSession-based network library." # This description is used to generate tags and improve search results. From 225cd99e73f92f80625339fc9d22b65bc4e063e1 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 27 May 2020 10:20:38 +0200 Subject: [PATCH 13/23] Update README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e99020..84b9f1e 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ An object-oriented, URLSession-based network library. -![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/Requests?token=43bbf53852d24e549074f62b39f01e39) +![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/swiftquests?token=43bbf53852d24e549074f62b39f01e39) ## Installation @@ -15,6 +15,7 @@ https://github.com/Ast3r10n/swiftquests ### Cocoapods +Add `SwiftQuests` to your Podfile: ``` pod 'SwiftQuests' ``` From 5d44f4aa07fc6bd95038002d66decb8eb45fcd08 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 27 May 2020 14:48:50 +0200 Subject: [PATCH 14/23] Update README with Result completions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84b9f1e..ace62aa 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ You then call the `perform` method to launch its associated task. ``` do { - try request.perform { data, response, error in + try request.perform { result in // Response implementation } } catch { @@ -59,7 +59,7 @@ Here's an example `Request` to get a `Decodable` `User` object from the `/user` do { try Request(.get, atPath: "/user") - .perform(decoding: User.self) { user, response, error in + .perform(decoding: User.self) { result in // Your completion handler here } From 7de99f4e068d7d062dd1c201605c9c609846292c Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Wed, 27 May 2020 15:42:24 +0200 Subject: [PATCH 15/23] Add README shields --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ace62aa..15dcb97 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ An object-oriented, URLSession-based network library. -![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/swiftquests?token=43bbf53852d24e549074f62b39f01e39) +![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/swiftquests?token=43bbf53852d24e549074f62b39f01e39) ![License](https://img.shields.io/github/license/Ast3r10n/swiftquests) ![Cocoapods](https://img.shields.io/cocoapods/p/SwiftQuests) ![LastCommit](https://img.shields.io/github/last-commit/Ast3r10n/swiftquests) ## Installation From c9a26cd4f307ccc6b2b20e37b74ff10087efd5e8 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Mon, 15 Jun 2020 14:48:37 +0200 Subject: [PATCH 16/23] Add syntax highlighting in README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 15dcb97..9d53ff3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ https://github.com/Ast3r10n/swiftquests ### Cocoapods Add `SwiftQuests` to your Podfile: -``` +```ruby pod 'SwiftQuests' ``` @@ -29,7 +29,7 @@ Once initialised, a `Request` is (for the most part) immutable. Its task will on To perform a basic `Request`, initialise one: -``` +```swift do { let request = try Request(.get, atPath: "/user") @@ -39,7 +39,7 @@ do { ``` You then call the `perform` method to launch its associated task. -``` +```swift do { try request.perform { result in // Response implementation @@ -55,7 +55,7 @@ do { Here's an example `Request` to get a `Decodable` `User` object from the `/user` endpoint. -``` +```swift do { try Request(.get, atPath: "/user") From 6055035cc4d67aacdcdd24c2b1627beecba429eb Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Thu, 27 Aug 2020 17:43:44 +0200 Subject: [PATCH 17/23] Make RequestConfigurationHolder.configuration public --- Sources/SwiftQuests/RequestConfigurationHolder.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/SwiftQuests/RequestConfigurationHolder.swift b/Sources/SwiftQuests/RequestConfigurationHolder.swift index f4efc2d..30acf28 100644 --- a/Sources/SwiftQuests/RequestConfigurationHolder.swift +++ b/Sources/SwiftQuests/RequestConfigurationHolder.swift @@ -14,9 +14,8 @@ public class RequestConfigurationHolder { /// The holder singleton instance. public static var shared = RequestConfigurationHolder() - // MARK: - Internal Properties /// The configuration assigned to the holder. - var configuration: RequestConfiguration + public var configuration: RequestConfiguration // MARK: - Internal Methods /// Creates a holder object, assigning the specified configuration. From d79c48e481daa641568d239775bfe920a101adc3 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Mon, 31 Aug 2020 12:12:14 +0200 Subject: [PATCH 18/23] Set RequestConfigurationHolder.configuration set internal --- Sources/SwiftQuests/RequestConfigurationHolder.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftQuests/RequestConfigurationHolder.swift b/Sources/SwiftQuests/RequestConfigurationHolder.swift index 30acf28..207bc8d 100644 --- a/Sources/SwiftQuests/RequestConfigurationHolder.swift +++ b/Sources/SwiftQuests/RequestConfigurationHolder.swift @@ -15,7 +15,7 @@ public class RequestConfigurationHolder { public static var shared = RequestConfigurationHolder() /// The configuration assigned to the holder. - public var configuration: RequestConfiguration + public internal(set) var configuration: RequestConfiguration // MARK: - Internal Methods /// Creates a holder object, assigning the specified configuration. From 9ce12a67109fd7609bfd916c2a6255278a6f0ea1 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Fri, 11 Sep 2020 11:02:16 +0200 Subject: [PATCH 19/23] Update RequestConfiguration protocol to allow computed properties --- .../SwiftQuests/DefaultRequestConfiguration.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/SwiftQuests/DefaultRequestConfiguration.swift b/Sources/SwiftQuests/DefaultRequestConfiguration.swift index 00e57ed..0c4047e 100644 --- a/Sources/SwiftQuests/DefaultRequestConfiguration.swift +++ b/Sources/SwiftQuests/DefaultRequestConfiguration.swift @@ -13,22 +13,22 @@ public protocol RequestConfiguration { /// The default Request headers. /// /// Any headers passed to specific `Requests` would be appended to these. - var defaultHeaders: [String: String] { get set } + var defaultHeaders: [String: String] { get } /// The Request protocol. - var requestProtocol: String { get set } + var requestProtocol: String { get } /// The default base URL (not including protocol). - var baseURL: String { get set } + var baseURL: String { get } /// The default port. - var port: Int { get set } + var port: Int { get } /// The server's authentication realm. - var authenticationRealm: String { get set } + var authenticationRealm: String { get } /// The default authentication method to use with Requests. - var authenticationMethod: String { get set } + var authenticationMethod: String { get } } public extension RequestConfiguration { From c66128074a251f475430dd6b43a80d8450e33fc8 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Fri, 11 Sep 2020 11:36:44 +0200 Subject: [PATCH 20/23] Remove iOS version specification in codecov action --- .github/workflows/swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 0550b1a..b127bd8 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Generate coverage report - run: xcodebuild -scheme SwiftQuests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro,OS=13.4.1' -enableCodeCoverage YES build test + run: xcodebuild -scheme SwiftQuests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11 Pro' -enableCodeCoverage YES build test - name: Codecov uses: codecov/codecov-action@v1.0.5 with: From 773ee52779c7d26d7a5d5f9f49c12d96fd637a9d Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Fri, 8 Jan 2021 17:23:06 +0100 Subject: [PATCH 21/23] Switch to using ephemeral URLSessionConfigurations by default --- Sources/SwiftQuests/Request.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sources/SwiftQuests/Request.swift b/Sources/SwiftQuests/Request.swift index c5dcb9a..2ea65ec 100644 --- a/Sources/SwiftQuests/Request.swift +++ b/Sources/SwiftQuests/Request.swift @@ -69,7 +69,7 @@ open class Request: AbstractRequest { /// The request `URLSession`. /// /// Defaults to a session with a `default` `URLSessionConfiguration` unless otherwise specified. - public var session = URLSession(configuration: .default) + public var session = URLSession(configuration: .ephemeral) /// The wrapped `URLRequest` object. public var urlRequest: URLRequest! @@ -138,9 +138,10 @@ open class Request: AbstractRequest { } if let credential = credential { - URLCredentialStorage.shared.set(credential, - for: configuration.protectionSpace, - task: task) + URLCredentialStorage.shared.set( + credential, + for: configuration.protectionSpace, + task: task) } task.resume() From f1fd9b7222022e992ddf93c82b28e304b74bdfa8 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti Date: Fri, 8 Jan 2021 17:23:16 +0100 Subject: [PATCH 22/23] Update gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 667fa55..d4b63cc 100644 --- a/.gitignore +++ b/.gitignore @@ -73,4 +73,5 @@ fastlane/test_output # After new code Injection tools there's a generated folder /iOSInjectionProject # https://github.com/johnno1962/injectionforxcode -iOSInjectionProject/ \ No newline at end of file +iOSInjectionProject/ +build/ From a9c9c32dba9d9781c07549e6cf087cbb3079e835 Mon Sep 17 00:00:00 2001 From: Andrea Sacerdoti <36516804+Ast3r10n@users.noreply.github.com> Date: Tue, 1 Jun 2021 10:26:01 +0200 Subject: [PATCH 23/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d53ff3..ba0a3ad 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ An object-oriented, URLSession-based network library. -![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/swiftquests?token=43bbf53852d24e549074f62b39f01e39) ![License](https://img.shields.io/github/license/Ast3r10n/swiftquests) ![Cocoapods](https://img.shields.io/cocoapods/p/SwiftQuests) ![LastCommit](https://img.shields.io/github/last-commit/Ast3r10n/swiftquests) +![Swift](https://github.com/Ast3r10n/requests/workflows/Swift/badge.svg) ![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/Ast3r10n/requests) ![Codecov](https://img.shields.io/codecov/c/gh/Ast3r10n/swiftquests?token=9980b291f6634fe6a969036234755d8c) ![License](https://img.shields.io/github/license/Ast3r10n/swiftquests) ![Cocoapods](https://img.shields.io/cocoapods/p/SwiftQuests) ![LastCommit](https://img.shields.io/github/last-commit/Ast3r10n/swiftquests) ## Installation