{"id":24969445,"url":"https://github.com/intrepidpursuits/prefab-api-client","last_synced_at":"2025-03-29T04:47:57.771Z","repository":{"id":83643447,"uuid":"79259619","full_name":"IntrepidPursuits/prefab-api-client","owner":"IntrepidPursuits","description":null,"archived":false,"fork":false,"pushed_at":"2017-10-26T15:49:46.000Z","size":253,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-02-03T14:46:21.627Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IntrepidPursuits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-17T18:46:25.000Z","updated_at":"2017-03-10T18:50:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"17e51f1f-0411-4035-8ef4-0adaff52d1ff","html_url":"https://github.com/IntrepidPursuits/prefab-api-client","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/IntrepidPursuits%2Fprefab-api-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2Fprefab-api-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2Fprefab-api-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IntrepidPursuits%2Fprefab-api-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IntrepidPursuits","download_url":"https://codeload.github.com/IntrepidPursuits/prefab-api-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140551,"owners_count":20729798,"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":"2025-02-03T14:38:15.058Z","updated_at":"2025-03-29T04:47:57.765Z","avatar_url":"https://github.com/IntrepidPursuits.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# APIClient\n\n[![Build Status](https://ci.intrepid.io/buildStatus/icon?job=api-client-ios)](https://ci.intrepid.io/job/api-client-ios/)\n[![Coverage](http://ci.intrepid.io:9913/jenkins/cobertura/api-client-ios/)](https://ci.intrepid.io/job/api-client-ios/cobertura/)\n\nThe purpose of this library is to provide a pre-fabricated solution for the\nnetworking layer of an iOS app.\n___\n# Table of Contents\n\n1. [Installation](#installation)\n    1. [Cocoapods](#cocoapods)\n1. [Architecture](#architecture)\n    1. [APIClient](#api-client)\n    1. [Request](#request)\n    1. [Third Party Libraries](#third-party-libraries)\n1. [History](#history)\n\n___\n\n# Installation\n## CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\nTo integrate APIClient into your Xcode project using CocoaPods, specify it in your `Podfile` (note: APIClient has not yet been added to a specs repository, so it must be referenced by either Github URL or local path):\n\n```ruby\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'APIClient', :git =\u003e 'https://github.com/IntrepidPursuits/prefab-api-client.git'\nend\n```\n\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n___\n\n# Architecture\n## APIClient\nThe main component of the library that is responsible for sending requests, handling response data and, optionally, mapping successful response data to expected object types. `APIClient` wraps an instance of `URLSession`, and provides a single function for executing a data task with a `URLRequest`. This core function parses response data to determine success or failure, and returns raw data for the success case and an appropriate `Error` for failure.\n\nA `Genome`-specific subspec is also available, adding mapping capabilities to the client object. Additional functions extend upon the core implementation of `sendRequest()` and include a final mapping step prior to completion, where an attempt is made to map response data to the expected type. This type can be a single `MappableObject`, and array of `MappableObject`s, or `Void`.\n\n## Request\nThe library also provides an interface for a request builder object, where application-specific endpoints will be implemented. This interface, which takes the form of a protocol called `Request`, exposes the various components of a `URLRequest` object, including URL, HTTP method, header values and body data. An extension of `Request` also implements a factory method for creating a `URLRequest` object based on the provided component values.\n\nUsage of the protocol is left entirely up to the user, and possible implementations are widely varied. One potential pattern would be to use an `enum` type that conforms to `Request`, with cases representing individual endpoints, similar to the [AlamoFire Router pattern](https://github.com/Alamofire/Alamofire#routing-requests).\n\n## Authentication\n`APIClient` provides an out-of-the-box solution for handling expired/invalid tokens for authenticated requests. The `AuthTokenRefresher` class is responsible for handling these failed requests and has the ability sign in, refresh the token, configure the original request with the new token, and retry that request. Several protocols must be adopted by types in the user's application in order to enable token refresh functionality.\n- `AuthClient`: Client object that exposes login function\n- `CredentialProviding`: Object that stores saved user credentials and auth token, and also knows how to configure requests with that token\n\nAdditionally, the instance of `AuthTokenRefresher` must be created by the user with references to an `APIClient`, `AuthClient` and `CredentialProviding`. The appropriate instance of `APIClient` must then be configured with the resulting refresher object.\n\n## Third Party Libraries\n- Intrepid SwiftWisdom\n- Genome (optional)\n___\n\n# History\nCurrently in development\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintrepidpursuits%2Fprefab-api-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintrepidpursuits%2Fprefab-api-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintrepidpursuits%2Fprefab-api-client/lists"}