-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7e9b93
commit 10d298b
Showing
5 changed files
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters