Latest 0.9.0
Homepage https://github.com/gspd-mobi/rage-ios
License MIT
Platforms ios 9.0, requires ARC
Authors

Rage for iOS

Travis CI
Version
License
Platform

Pragmatic network abstraction layer for iOS applications.

:warning: Warning

Library is NOT production ready yet. Please don’t use it before it gets more stable.
There may be compatibility issues between newer and older versions of library until version 1.0.0.

Documentation now may differ from real API because it’s unstable and improving pretty fast.

Features

  • One liner request making. :dart:
  • Describing API spec in highly readable way. :books:
  • Optional RxSwift out of box. :rocket:
  • Optional JSON support by ObjectMapper out of box. :ledger:
  • Manipulating strictly typed objects instead of String dictionaries hell. :package:

Usage

You can check example implementation in RageExample project.

At first you need to create RageClient using builder pattern.

let client = Rage.builderWithBaseUrl("https://api.github.com")
    .withContentType(.json)
    .withTimeoutMillis(10 * 1000)
    .withHeaderDictionary([
            "Api-Version": "1.1",
            "Platform": "iOS"
    ])
    .withPlugin(LoggingPlugin(logLevel: .full))
    .withAuthenticator(MyAuthenticator())
    .withErrorsHandlersClosure {
        [AuthErrorHandler()]
    }
    .build()

Then describe your API requests like these. It is a generic way to declare requests and their background execution.

func getUser(username: String, completion: @escaping Result<RageResponse, RageError> -> ()) {
    client.get("/users/{user}")
        .path("user", username)
        .enqueue(completion)
}

// Async
func getRepositoriesForOrganization(organizationTitle: String, completion: @escaping Result<RageResponse, RageError> -> ()) {
    client.get("/orgs/{org}/repos")
        .path("org", organizationTitle)
        .enqueue(completion)
}

// Sync
func getRepositoriesForOrganizationSync(organizationTitle: String) -> Result<RageResponse, RageError> {
    return client.get("/orgs/{org}/repos")
        .path("org", organizationTitle)
        .execute()
}

Using both RxSwift and ObjectMapper you can declare API in such awesome way.

func getUser(username: String) -> Observable<GithubUser> {
    return client.get("/users/{user}")
        .path("user", username)
        .executeObjectObservable()
}

func getRepositoriesForOrganization(organizationTitle: String) -> Observable<[GithubRepository]> {
    return client.get("/orgs/{org}/repos")
        .path("org", organizationTitle)
        .executeObjectObservable()
}

That’s it. Compact but powerful.

Installation (CocoaPods)

Add this dependency to Podfile and pod install

# Core subspec of Rage
pod 'Rage', '~> 0.9.0'

Or if you want to use RxSwift and ObjectMapper features you should use these Rage subspecs

# RxSwift only
pod "Rage/RxSwift", "~> 0.9.0"
# ObjectMapper only
pod "Rage/ObjectMapper", "~> 0.9.0"
# Both RxSwift and ObjectMapper
pod "Rage/RxSwiftAndObjectMapper", "~> 0.9.0"

License

The MIT License (MIT)

Copyright (c) 2016 gspd.mobi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Latest podspec

{
    "name": "Rage",
    "version": "0.9.0",
    "summary": "Pragmatic network abstraction layer for iOS applications",
    "homepage": "https://github.com/gspd-mobi/rage-ios",
    "license": "MIT",
    "authors": {
        "Pavel Korolev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/gspd-mobi/rage-ios.git",
        "tag": "0.9.0"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "default_subspecs": "Core",
    "pushed_with_swift_version": "3.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": [
                "Rage/*.swift",
                "Rage/Plugins/*.swift"
            ],
            "frameworks": "Foundation",
            "dependencies": {
                "Result": [
                    "~> 3.1.0"
                ]
            }
        },
        {
            "name": "RxSwift",
            "source_files": "Rage/Dependencies/RxSwift/*.swift",
            "dependencies": {
                "Rage/Core": [],
                "RxSwift": [
                    "~> 3.0.1"
                ]
            }
        },
        {
            "name": "ObjectMapper",
            "source_files": "Rage/Dependencies/ObjectMapper/*.swift",
            "dependencies": {
                "Rage/Core": [],
                "ObjectMapper": [
                    "~> 2.1.0"
                ]
            }
        },
        {
            "name": "RxSwiftAndObjectMapper",
            "source_files": "Rage/Dependencies/RxSwiftAndObjectMapper/*.swift",
            "dependencies": {
                "Rage/Core": [],
                "Rage/RxSwift": [],
                "Rage/ObjectMapper": []
            }
        }
    ]
}

Pin It on Pinterest

Share This