GitXplorerGitXplorer
n

apirequest

public
15 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
3907f4b0b97ca0b69956b77502522eeec7764394

Create FUNDING.yml

nnathanfallet committed 2 years ago
Verified
65e3de829461d860db10564f06c329a16a37a760

Adding link to Android package

nnathanfallet committed 3 years ago
Unverified
7cf9ec73e14151f62536475b7682b468411b9017

Add support for content type header

nnathanfallet committed 4 years ago
Unverified
b6f30028028b63f4927f9419b7ebd985d617c9f6

Fixing offline detection

nnathanfallet committed 4 years ago
Verified
8d5a531f96befb75a51d09d5a910ed1bb4bd63fd

Update README.md

nnathanfallet committed 4 years ago
Unverified
32a37eacc67cad47355ca6c90fccbe8650c44474

Adding the ability to cancel a request

nnathanfallet committed 4 years ago

README

The README file for this repository.

APIRequest

License Issues Pull Requests Code Size CodeFactor Open Source Helpers

A swift package/android library to interact with a REST API.

Installation

iOS

Add https://github.com/NathanFallet/APIRequest.git to your Swift Package configuration (or using the Xcode menu: File > Swift Packages > Add Package Dependency)

Android

Add the following to your build.gradle file:

repositories {
    mavenCentral()
}

dependencies {
    implementation 'me.nathanfallet.apirequest:apirequest:1.0.4'
}

Usage

iOS

// Import the package
import APIRequest

// When your app starts, set the default configuration
APIConfiguration.current = APIConfiguration(host: "api.example.com")

// And then call your API
// This is an equivalent to get `https://api.example.com/path/to/api?custom=parameter` and parse the response from JSON to a dictionary [String: String]
APIRequest("GET", path: "/path/to/api").with(name: "custom", value: "parameter").execute([String: String].self) { data, status in
    // Check the data and status
    if let data = data, status == .ok {
        // Do what you want with your data
        
    } else {
        // Something went wrong, check the value of `status`
        
    }
}

See the full documentation for a complete guide.

Android

// When your app starts, set the default configuration
APIConfiguration.current = APIConfiguration("api.example.com")

// And then call your API
// This is an equivalent to get `https://api.example.com/path/to/api?custom=parameter` and parse the response from JSON
APIRequest("GET", "/path/to/api")
    .with("custom", "parameter")
    .execute { result, status ->
        
    }

See the full documentation for a complete guide.

Examples

Full example project

Check out the full example project made in a youtube tutorial.

Donate to the developer

Feel free to make a donation to help the developer to make more great content! Donate now