GenericNetworking
Features
- GET / POST Methods
- Upload data
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
class GithubSDK {
public static func getGists(completion: @escaping GenericNetworkingCompletion<[Gist]>) {
// response is array of objects
GenericNetworking.requestJSON(baseURLString: "https://api.github.com", path: "/gists", method: .get, parameters: nil, headers: nil, completion: completion);
}
public static func getGistDetail(_ gistId: String, completion: @escaping GenericNetworkingCompletion<Gist>) {
// response is an object
let URLString = "https://api.github.com/gists/" + gistId
GenericNetworking.getJSON(URLString: URLString, completion: completion)
}
}
here you call GithubSDK like following
GithubSDK.getGists { (response) in
switch response {
case .success(let gists):
print(gists.count)
for gist in gists {
print("gist id:\(gist.identifider)")
}
case .error(let error):
print(error)
}
}
Requirements
- Swift 4.0
- Alamofire
Installation
GenericNetworking is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'GenericNetworking'
Author
alexiscn, [email protected]
License
GenericNetworking is available under the MIT license. See the LICENSE file for more info.