NetworkS

5.0.1

Classic networking package for iOS
presscorp/NetworkS

What's New

Release 5.0.1

2023-09-26T07:32:00Z

5.0.1 (2023-09-26)

NetworkS

Classic networking package for iOS (version >= 13.0)


List of features

  • NetworkS utilizes fundamental URLSession under the hood
  • NetworkS uses callback based approach for request making
  • All interactions with NetworkS are based on protocols, so you can make your own implementations of NetworkSessionInterface, NetworkService
  • NetworkS provides logger that prints beautifully crafted request/response events into Xcode console
  • NetworkS provides the opportunity to renew session by updating authorization
  • NetworkS supports SSL certificate pinning along with default challenge
  • NetworkS supports easily implemented response mocking
  • NetworkS supports response caching feature

Example of use

Creating URL list

import NetworkS

struct HttpbinOrgURL: RequestURLExtensible {

    let path: String
    var host: String { "httpbin.org" }
}

extension HttpbinOrgURL {

    static let uuid = Self("/uuid")
}

Describing request

import NetworkS

class UUIDRequest: NetworkRequest {

    var url: RequestURL { HttpbinOrgURL.uuid }
    var method: RequestMethod { .GET }
    var encoding: RequestContentEncoding { .url }
}

Making the request

import NetworkS

// Create session interface and use it across the app
let sessionAdapter = NetworkSessionAdapter()
sessionAdapter.defaultSSLChallengeEnabled = true

// Work with a new instance of network service
let worker = NetworkWorker(sessionInterface: sessionAdapter)

let request = UUIDRequest()
let task = worker.buildTask(from: request) { response in
    if response.success,
       let body = response.jsonBody,
       let uuidString = body["uuid"] as? String {
        print("UUID: " + uuidString)
    }
}

task?.run()

License

NetworkS is released under the MIT license

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Oct 26 2024 15:16:44 GMT-0900 (Hawaii-Aleutian Daylight Time)