intelygenz / Netclient Ios
Licence: mit
Versatile HTTP Networking in Swift
Stars: ✭ 117
Programming Languages
swift
15916 projects
Labels
Projects that are alternatives of or similar to Netclient Ios
Alamofire
Elegant HTTP Networking in Swift
Stars: ✭ 36,896 (+31435.04%)
Mutual labels: networking, request, alamofire, response, swift-package-manager
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
Stars: ✭ 3,188 (+2624.79%)
Mutual labels: networking, request, alamofire, response
Daisynet
1. - Alamofire与Cache封装 , 更容易存储请求数据. 2. - 封装Alamofire下载,使用更方便
Stars: ✭ 331 (+182.91%)
Mutual labels: json, cache, request, alamofire
Facil.io
Your high performance web application C framework
Stars: ✭ 1,393 (+1090.6%)
Mutual labels: json, framework, networking
izzyparser-ios
IzzyParser is an iOS library for serializing and deserializing JSON:API objects
Stars: ✭ 19 (-83.76%)
Mutual labels: swift-package-manager, request, response
Networking
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support
Stars: ✭ 1,269 (+984.62%)
Mutual labels: networking, alamofire, moya
Ws
⚠️ Deprecated - (in favour of Networking) ☁️ Elegantly connect to a JSON api. (Alamofire + Promises + JSON Parsing)
Stars: ✭ 352 (+200.85%)
Mutual labels: json, networking, alamofire
Restofire
Restofire is a protocol oriented networking client for Alamofire
Stars: ✭ 377 (+222.22%)
Mutual labels: networking, alamofire, moya
Taniwhatextfield
My first cocoapod framework
Stars: ✭ 26 (-77.78%)
Mutual labels: framework, swift-framework, swift-package-manager
Evreflection
Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift
Stars: ✭ 954 (+715.38%)
Mutual labels: json, alamofire, moya
Apicache
Simple API-caching middleware for Express/Node.
Stars: ✭ 957 (+717.95%)
Mutual labels: json, cache, response
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+908.55%)
Mutual labels: framework, swift-framework, swift-package-manager
Swiftyjson
The better way to deal with JSON data in Swift.
Stars: ✭ 21,042 (+17884.62%)
Mutual labels: json, request, response
Queuer
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).
Stars: ✭ 964 (+723.93%)
Mutual labels: asynchronous, task, swift-package-manager
Moyamapper
快速解析模型工具,支持RxSwift。同时支持缓存功能 【相关手册 https://MoyaMapper.github.io 】
Stars: ✭ 115 (-1.71%)
Mutual labels: json, cache, moya
Literoute
LiteRoute is easy transition for your app. Written on Swift 4
Stars: ✭ 90 (-23.08%)
Mutual labels: framework, swift-framework
Solarnetwork
Elegant network abstraction layer in Swift.
Stars: ✭ 99 (-15.38%)
Mutual labels: networking, alamofire
Swift
🥇Swift基础知识大全,🚀Swift学习从简单到复杂,不断地完善与更新, 欢迎Star❤️,欢迎Fork, iOS开发者交流:①群:446310206 ②群:426087546
Stars: ✭ 1,377 (+1076.92%)
Mutual labels: swift-framework, swift-package-manager
Net is a versatile HTTP networking library written in Swift.
🌟 Features
- [x] URL / JSON / Property List Parameter Encoding
- [x] Upload File / Data / Stream / Multipart Form Data
- [x] Download File using Request or Resume Data
- [x] Authentication with URLCredential
- [x] Basic, Bearer and Custom Authorization Handling
- [x] Default and Custom Cache Controls
- [x] Default and Custom Content Types
- [x] Upload and Download Progress Closures with Progress (only iOS >= 11)
- [x] cURL Command Debug Output
- [x] Request and Response Interceptors
- [x] Asynchronous and synchronous task execution
- [x] Inference of response object type
- [x] Network reachability
- [x] TLS Certificate and Public Key Pinning
- [x] Retry requests
- [x] Codable / Decodable / Encodable protocols compatible (JSON / Property List)
- [x] Customizable acceptable status codes range
- [x] watchOS Compatible
- [x] tvOS Compatible
- [x] macOS Compatible
- [x] Alamofire Implementation
- [x] MoyaProvider Extension
- [x] Kommander Extension
- [x] RxSwift Extension
- [x] Stub Implementation
📋 Requirements
- iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+
- Xcode 9.0+
- Swift 4.0+
📲 Installation
Net is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NetClient'
For Swift 3 compatibility use:
pod 'NetClient', '~> 0.2'
Carthage:
Or you can install it withgithub "intelygenz/NetClient-iOS"
Swift Package Manager:
Or install it withdependencies: [
.package(url: "https://github.com/intelygenz/NetClient-iOS.git")
]
🐒 Usage
Build a NetRequest
import Net
do {
let request = try NetRequest.builder("YOUR_URL")!
.setAccept(.json)
.setCache(.reloadIgnoringLocalCacheData)
.setMethod(.PATCH)
.setTimeout(20)
.setJSONBody(["foo", "bar"])
.setContentType(.json)
.setServiceType(.background)
.setCacheControls([.maxAge(500)])
.setURLParameters(["foo": "bar"])
.setAcceptEncodings([.gzip, .deflate])
.setContentEncodings([.gzip])
.setBasicAuthorization(user: "user", password: "password")
.setHeaders(["foo": "bar"])
.build()
} catch {
print("Request error: \(error)")
}
Request asynchronously
import Net
let net = NetURLSession()
net.data(URL(string: "YOUR_URL")!).async { (response, error) in
do {
if let object: [AnyHashable: Any] = try response?.object() {
print("Response dictionary: \(object)")
} else if let error = error {
print("Net error: \(error)")
}
} catch {
print("Parse error: \(error)")
}
}
Request synchronously
import Net
let net = NetURLSession()
do {
let object: [AnyHashable: Any] = try net.data("YOUR_URL").sync().object()
print("Response dictionary: \(object)")
} catch {
print("Error: \(error)")
}
Request from cache
import Net
let net = NetURLSession()
do {
let object: [AnyHashable: Any] = try net.data("YOUR_URL").cached().object()
print("Response dictionary: \(object)")
} catch {
print("Error: \(error)")
}
Track progress
import Net
let net = NetURLSession()
do {
let task = try net.data("YOUR_URL").progress({ progress in
print(progress)
}).sync()
} catch {
print("Error: \(error)")
}
Add interceptors for all requests
import Net
let net = NetURLSession()
net.addRequestInterceptor { request in
request.addHeader("foo", value: "bar")
request.setBearerAuthorization(token: "token")
return request
}
Retry requests
import Net
let net = NetURLSession()
net.retryClosure = { response, _, _ in response?.statusCode == XXX }
do {
let task = try net.data("YOUR_URL").retry({ response, error, retryCount in
return retryCount < 2
}).sync()
} catch {
print("Error: \(error)")
}
🧙♂️ Codable
Encodable
import Net
let request = NetRequest.builder("YOUR_URL")!
.setJSONObject(Encodable())
.build()
Decodable
import Net
let net = NetURLSession()
do {
let object: Decodable = try net.data("YOUR_URL").sync().decode()
print("Response object: \(object)")
} catch {
print("Error: \(error)")
}
🤝 Integrations
Alamofire?
Lovepod 'NetClient/Alamofire'
import Net
let net = NetAlamofire()
...
Moya?
Lovepod 'NetClient/Moya'
import Net
import Moya
let request = NetRequest("YOUR_URL")!
let provider = MoyaProvider<NetRequest>()
provider.request(request) { result in
switch result {
case let .success(response):
print("Response: \(response)")
case let .failure(error):
print("Error: \(error)")
}
}
Kommander?
Lovepod 'NetClient/Kommander'
import Net
import Kommander
let net = NetURLSession()
let kommander = Kommander.default
net.data(URL(string: "YOUR_URL")!).execute(by: kommander, onSuccess: { object in
print("Response dictionary: \(object as [AnyHashable: Any])")
}) { error in
print("Error: \(String(describing: error?.localizedDescription))")
}
net.data(URL(string: "YOUR_URL")!).executeDecoding(by: kommander, onSuccess: { object in
print("Response object: \(object as Decodable)")
}) { error in
print("Error: \(String(describing: error?.localizedDescription))")
}
RxSwift?
Lovepod 'NetClient/RxSwift'
import Net
import RxSwift
let request = NetRequest("YOUR_URL")!
_ = net.data(request).rx.response().observeOn(MainScheduler.instance).subscribe { print($0) }
Stub Implementation
pod 'NetClient/Stub'
import Net
let net = NetStub()
net.asyncBehavior = .delayed(.main, .seconds(10)) // If you want to delay the response.
net.nextResult = .response(NetResponse.builder()....build())
// Your test request here
net.nextResult = .error(.net(code: 500, message: "Your network error.", headers: ..., object: ..., underlying: ...))
// Your test request here
❤️ Etc.
- Contributions are very welcome.
- Attribution is appreciated (let's spread the word!), but not mandatory.
👨💻 Authors
alexruperez, [email protected]
👮♂️ License
Net is available under the MIT license. See the LICENSE file for more info.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].