NBApollo: A wrapper library around Alamofire HTTP Network with codable objects.
If you want to use it with Swift 4 then move to tag 0.1.7
- HTTP Response Validation
- HTTP Request / Response Methods
- JSON Codable compatible objects to return
NBApollo use Alamofire
to make request.
- iOS 10.0+
- Xcode 11+
- Swift 5+
NBApollo is not on cocoapods yet, but you could install using Pod.
pod 'NBApollo', :git => 'https://github.com/josmanperez/NBApollo.git', :tag => '0.2.0'
If you API returns a object, something like this:
{
"id":"1234",
"valid": true
}
Then you need to create a Codable
object like this:
class Data: Decodable {
enum CodingKeys: String, CodingKey {
case id
case valid
}
var id: String
var valid: Bool
}
When you need to call your api to gather a JSON object (conforms Codable), just need to call
let apiRequest: ApiRestClient<Data> = {
let api = ApiRestClient<Data>(urlServer: "api endpoint")
return api
}()
When you need to call this method:
self.nodoRequest.request(with: headers, method: .get, parameters: nil) {
result in
case .failure(let error):
...
case .success(let response):
print(response)
}
NBApollo is released under the MIT license.