Swiftpack.co - AmrKoritem/AKApiManager as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AmrKoritem.
AmrKoritem/AKApiManager v1.1.0
AKApiManager is a layer built on top of Alamofire to facilitate restful api requests.
⭐️ 0
🕓 51 weeks ago
iOS tvOS
.package(url: "https://github.com/AmrKoritem/AKApiManager.git", from: "v1.1.0")

Swift iOS tvOS CocoaPods Swift Package Manager

AKApiManager

AKApiManager is a layer built on top of Alamofire to facilitate using restful api requests. This pod suits small and medium sized applications best.

Installation

AKApiManager can be installed using CocoaPods. Add the following lines to your Podfile:

pod 'AKApiManager'

You can also install it using swift package manager as well.

dependencies: [
    .package(url: "https://github.com/AmrKoritem/AKApiManager.git", .upToNextMajor(from: "1.1.0"))
]

Setup

All you need is to set your base url before usage. For example, you can set it in the AppDelegate.application(_:didFinishLaunchingWithOptions:) method.

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        AKApiManager.shared.baseUrl = "https://www.example.com"
        return true
    }

Usage

For a simple api you can do just that:

    let request = DataRequest(
        url: "url-path",
        method: .post // Any http method.
    )
    AKApiManager.shared.request(request)

You can also pass your body parameters as well as the api headers:

    let request = DataRequest(
        url: "url-path",
        method: .post, // Any http method.
        parameters: ["param1-key": "param1-value"],
        headers: ["auth": "token"]
    )
    AKApiManager.shared.request(request) { responseStatus, response in
        // Deal with the response here.
    }

You can upload any data using:

    let request = UploadRequest(
        url: "url-path",
        data: Data(),
        fileName: "name",
        mimeType: "file-type"
    )
    AKApiManager.shared.upload(request) { responseStatus, response in
        // Deal with the response here.
    }

Examples

You can check the example project here to see AKApiManager in action 🥳.
You can check a full set of examples here as well.

Contribution 🎉

All contributions are welcome. Feel free to check the Known issues and Future plans sections if you don't know where to start. And of course feel free to raise your own issues and create PRs for them 💪

Known issues 🫣

Thankfully, there are no known issues at the moment.

Future plans 🧐

1 - Add a way for request cancelation.

Find me 🥰

LinkedIn

License

Please check the license file.

GitHub

link
Stars: 0
Last commit: 49 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Release Notes

Fixing issues
52 weeks ago

Fixing return type issue

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics