{"id":18863950,"url":"https://github.com/hellc/catalystnet","last_synced_at":"2026-02-11T04:30:19.762Z","repository":{"id":56905715,"uuid":"276391481","full_name":"hellc/CatalystNet","owner":"hellc","description":"Universal AppleOS Apps Networking kit","archived":false,"fork":false,"pushed_at":"2022-06-05T16:56:44.000Z","size":58,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T02:04:07.220Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-01T13:54:41.000Z","updated_at":"2022-05-26T16:30:26.000Z","dependencies_parsed_at":"2022-08-21T02:20:55.385Z","dependency_job_id":null,"html_url":"https://github.com/hellc/CatalystNet","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellc%2FCatalystNet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellc%2FCatalystNet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellc%2FCatalystNet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellc%2FCatalystNet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellc","download_url":"https://codeload.github.com/hellc/CatalystNet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239808523,"owners_count":19700451,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T04:39:11.538Z","updated_at":"2026-02-11T04:30:19.733Z","avatar_url":"https://github.com/hellc.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CatalystNet\nUniversal AppleOS Apps Networking kit\n\n![badge](https://action-badges.now.sh/hellc/CatalystNet)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CatalystNet.svg)](https://img.shields.io/cocoapods/v/CatalystNet.svg)\n![iOS](https://img.shields.io/badge/Swift-5.0-orange)\n![iOS](https://img.shields.io/badge/iOS-11.0-green)\n![macOS](https://img.shields.io/badge/macOS-10.15-green)\n![macOS](https://img.shields.io/badge/watchOS-4.0-green)\n![MIT](https://cocoapod-badges.herokuapp.com/l/NSStringMask/badge.png)\n\n## Installation:\n\n### CocoaPods\n\n[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CatalystNet into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'CatalystNet', '~\u003e 1.1.0'\n```\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler.\n\nOnce you have your Swift package set up, adding CatalystNet as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/hellc/CatalystNet.git\", .upToNextMajor(from: \"1.1.0\"))\n]\n```\n\n### Manually\n\nIf you prefer not to use any of the aforementioned dependency managers, you can integrate CatalystNet into your project manually.\n\n## Usage:\n\n### Http client:\n\n#### Import package\n\n```swift\nimport CatalystNet\n```\n\n#### Defining model:\n\n```swift\nstruct Photo: Decodable {\n    let albumId: Int\n    let id: Int\n    let title: String?\n    let url: String?\n    let thumbnailUrl: String?\n}\n\nstruct CustomError: Decodable {\n    let message: String?\n    let code: Int?\n}\n```\n\n#### Defining base Api class:\n\n```swift\nclass ExampleApi: Api {\n    private let client: HttpClient!\n    \n    init(baseUrl: String = \"https://jsonplaceholder.typicode.com\") {\n        self.client = HttpClient(baseUrl: baseUrl)\n    }\n    \n    func load\u003cT, E\u003e(_ resource: Resource\u003cT, E\u003e,\n                    multitasking: Bool = false,\n                    completion: @escaping (Result\u003cT, E\u003e) -\u003e Void) {\n        // Setup auth policy if needed\n        // Also you could extend \"Resource\" model with authentication method for simply calling \"resource.authenticate()\" when needed\n        super.load(resource, self.client, multitasking: multitasking, completion: completion)\n    }\n}\n```\n\n##### Defining Asynchronous Functions (iOS \u003e= 13.0.0)\n```swift\n@available(iOS 13.0.0, *)\n@available(macOS 10.15.0, *)\nextension ExampleApi {\n    func load\u003cT, E\u003e(_ resource: Resource\u003cT, E\u003e) async throws -\u003e T {\n        // Setup auth policy here if needed\n        return try await super.load(resource, self.client)\n    }\n}\n\n```\n\n#### Defining Api class methods:\n```swift\nclass PhotosApi: ExampleApi {\n    private struct Endpoints {\n        static let photos: String = \"/photos\"\n    }\n\n    func photo(with id: Int, completion: @escaping (Photo?, CatalystError\u003cCustomError\u003e?) -\u003e Void) {\n        var resource = Resource\u003cPhoto, CustomError\u003e(path: Api.resource(Endpoints.photos, with: id))\n        \n        resource.method = .get\n        \n        // resource.authenticate() // if needed\n        \n        self.load(resource) { response in\n            switch response {\n            case .success(let photo):\n                completion(photo, nil)\n            case .failure(let error):\n                completion(nil, error)\n            }\n        }\n    }\n}\n```\n\n##### Defining Asynchronous Functions (iOS \u003e= 13.0.0)\n```swift\n@available(iOS 13.0.0, *)\n@available(macOS 10.15.0, *)\nextension PhotosApi {\n    func photo(with id: Int) async throws -\u003e Photo {\n        var resource = Resource\u003cPhoto, CustomError\u003e(path: Api.resource(Endpoints.photos, with: id))\n        \n        resource.method = .get\n        \n        // resource.authenticate() // if needed\n        \n        return try await self.load(resource)\n    }\n}\n```\n\n#### Try it:\n\n```swift\nlet photosApi = PhotosApi()\n\nlet photoId: Int = 42\nself.photosApi.photo(with: photoId) { (photo, error) in\n    print(photo)\n}\n```\n##### Try it asynchronously:\n\n```swift\nlet photoId: Int = 42\ndo {\n    let photo = try await self.photosApi.photo(with: photoId)\n    print(photo)\n} catch {\n    print(error)\n    // TODO: Proceed \"error\" object\n}\n```\nOutput:\n```\nPhoto(\n    albumId: 1,\n    id: 42,\n    title: Optional(\"voluptatibus a autem molestias voluptas architecto culpa\"),\n    url: Optional(\"https://via.placeholder.com/600/ca50ac\"),\n    thumbnailUrl: Optional(\"https://via.placeholder.com/150/ca50ac\")\n)\n```\n\nPlease follow Tests/ExampleTests.swift file for more usage examples \u003c3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellc%2Fcatalystnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellc%2Fcatalystnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellc%2Fcatalystnet/lists"}