Latest | 0.1.4 |
---|---|
Homepage | https://github.com/gearmamn06/ApiReachable |
License | MIT MIT License
Copyright (c) 2019 gearmamn06 Permission is hereby granted, free of charge, to any person obtaining a copy The above copyright notice and this permission notice shall be included in all THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
Platforms | ios 10.0, requires ARC |
Dependencies | ObjectMapper, Alamofire, RxSwift |
Authors |
Model based networking module using Alamofire
Requirements
iOS 10.0+
Installation
Cocoapods
pod 'ApiReachable'
Features
- Networking task using Alamofire for reach and get data model from your API
- Parsing using ObjectMapper or Decodable
- ApiReacbale + RxSwift
The Basics
An app typically manages data obtained by communicating with an external API as a model. What we want is a model, but the procedure to get it sometimes requires complex and redundant tasks.
ApiReachable allows you to focus on the model as you develop your app. Just explicitly declare how the model is transformed and how it calls the API.
If the model you are using follows the BaseMappable or Decodable protocol, you can use the reach function declared in ApiReachable by default as follows:
struct JazzMusic: Decodable {
let songID: String
let title: String
let artist: String
}
extension JazzMusic: ApiReachable {
/// Base URL of the API
static var baseURL: URL {
return URL(string: "https://www.mytestapi.com")
}
/// required path for each model.
static var endPoint: String {
return "songs"
}
/// Commonly required parameters for the same model
static var requiredParams: [String: Any] {
return [
"genre": "jazz"
]
}
}
...
// Pass the HTTP Method and the parameters required at runtime.
JazzMusic.reach(method: .get, queries: ["title": "my song"]) { result in
switch result {
case .success(let song):
print("found song: (song)")
case .failure(let error):
print("fetch error: (error)")
}
}
Latest podspec
{ "name": "ApiReachable", "version": "0.1.4", "summary": "Embed networking logic in your model.", "description": "Model based networking module using Alamofire", "homepage": "https://github.com/gearmamn06/ApiReachable", "license": { "type": "MIT", "text": " MIT LicensennCopyright (c) 2019 gearmamn06nnPermission is hereby granted, free of charge, to any person obtaining a copynof this software and associated documentation files (the "Software"), to dealnin the Software without restriction, including without limitation the rightsnto use, copy, modify, merge, publish, distribute, sublicense, and/or sellncopies of the Software, and to permit persons to whom the Software isnfurnished to do so, subject to the following conditions:nnThe above copyright notice and this permission notice shall be included in allncopies or substantial portions of the Software.nnTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORnIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEnAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERnLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THEnSOFTWARE.nn" }, "authors": { "gearmamn06": "[email protected]" }, "swift_version": "5.0", "platforms": { "ios": "10.0" }, "source_files": [ "Sources/*.swift", "Sources/ApiReachable.h" ], "public_header_files": [ "Sources/ApiReachable.h" ], "source": { "git": "https://github.com/gearmamn06/ApiReachable.git", "tag": "0.1.4" }, "requires_arc": true, "dependencies": { "ObjectMapper": [ "~> 3.4" ], "Alamofire": [ "~> 4.8.2" ], "RxSwift": [ "~> 5.0" ] } }
Sat, 01 Jun 2019 10:08:04 +0000