yalantis / apiclient Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Simple auth plugin is required. In case client won't use exchange tokens flow, the implementation of RestorationTokenPlugin is required only to provide auth token and looks like the following:
extension UserSessionController: AccessCredentialsProvider {
public var accessToken: String? {
get { return userSession.userMetadata.accessToken }
set { /* no-op; we're not using session restoration flow */ }
}
public var exchangeToken: String? {
get { return nil }
set { }
}
public func commitCredentialsUpdate(_ update: (AccessCredentialsProvider) -> Void) {
// no-op; we're not using session restoration flow
}
public func invalidate() {
// no-op; we're not using session restoration flow
}
}
in case there's an empty response APIClient couldn't parse it and sends errors:
Error Domain=NSCocoaErrorDomain Code=3840 "No value." UserInfo={NSDebugDescription=No value.}
need to handle the case in JSONDeserializer
:
func deserialize(_ response: HTTPURLResponse, data: Data) throws -> AnyObject {
do {
...
} catch {
if (error as NSError).code == 3840 { // empty response
return .success(NSArray())
}
...
}
}
Because of RestorationTokenPlugins
prepare` method multipart request check fails:
https://monosnap.com/file/u7FVqgPpBj2b4Sm58obGhJcma31t1l
currently, NetworkError being parsed only in case there's no body in response:
request.responseJSON(completionHandler: { response in
guard let httpResponse = response.response, let data = response.data else {
AlamofireRequestExecutor.defineError(response.error, completion: completion)
return
}
completion(.success((httpResponse, data)))
})
in that case flow goes to APIClient and it invalidates response due to header (validateResult
method)
According to comparisons, Marshal looks like the best solution. Consider adding support for it
It was working fine till Xcode 10.1 and Swift 4.2. Once I updated Xcode to 10.2.1 which support Swift 5.0, I started getting this error. I using Carthage manage dependencies.
Please add a link to a project we can download that reproduces the bug.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.