Skip to content

Commit

Permalink
bumping podspec
Browse files Browse the repository at this point in the history
  • Loading branch information
henrik-dmg committed May 4, 2021
1 parent c7e9b93 commit 10d298b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions HPOpenWeather.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "HPOpenWeather"
s.version = "4.1.4"
s.version = "4.1.5"
s.summary = "Cross-platform framework to communicate with the OpenWeatherMap JSON API"

s.license = { :type => "MIT", :file => "LICENSE.md" }
Expand All @@ -25,7 +25,7 @@ Pod::Spec.new do |s|
s.tvos.framework = "UIKit"
s.osx.framework = "AppKit"

s.swift_version = "5.3"
s.swift_version = "5.1"
s.requires_arc = true
s.dependency "HPNetwork"

Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/henrik-dmg/HPNetwork",
"state": {
"branch": null,
"revision": "7a12d2782733873cdc2ae2a5c555204c95844aed",
"version": "1.2.0"
"revision": "7e888cdaabf7cb6e8c6640db57cb4325099f79b2",
"version": "2.0.2"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.3
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription
Expand All @@ -17,7 +17,7 @@ let package = Package(
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/henrik-dmg/HPNetwork", from: "1.0.0")
.package(url: "https://github.com/henrik-dmg/HPNetwork", from: "2.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
13 changes: 10 additions & 3 deletions Sources/HPOpenWeather/Requests/APINetworkRequest.swift
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
import Foundation
import HPNetwork

public struct APINetworkRequest<Output: Decodable>: NetworkRequest {
public struct APINetworkRequest<Output: Decodable>: DecodableRequest {

public let url: URL?
public let urlSession: URLSession
public let finishingQueue: DispatchQueue
public let requestMethod: NetworkRequestMethod = .get
public let headerFields = [NetworkRequestHeaderField.contentTypeJSON]

public func convertResponse(response: NetworkResponse) throws -> Output {
public let decoder: JSONDecoder = {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .secondsSince1970
return decoder
}()

return try decoder.decode(Output.self, from: response.data)
public func makeURL() throws -> URL {
guard let url = url else {
throw NSError(code: 6, description: "Could not create URL")
}
return url
}

}
2 changes: 1 addition & 1 deletion Sources/HPOpenWeather/Requests/WeatherRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public struct WeatherRequest {
}

func makeNetworkRequest(settings: OpenWeather.Settings) throws -> APINetworkRequest<Output> {
if let date = date, abs(date.timeIntervalSinceNow) <= 6 * .hour {
if let date = date, date < Date(), abs(date.timeIntervalSinceNow) <= 6 * .hour {
throw NSError.timeMachineDate
}
return APINetworkRequest(url: makeURL(settings: settings), urlSession: urlSession, finishingQueue: finishingQueue)
Expand Down

0 comments on commit 10d298b

Please sign in to comment.