Latest 1.0.5
Homepage https://github.com/ephedra-software/Buya
License MIT
Platforms ios 8.0
Authors ,

Buya Build Status Version codebeat badge codecov

Network abstraction framework

Features

  • [x] Interfaces are same as Moya
  • [x] Without Alamofire abstraction layer
  • [x] Included: AccessTokenPlugin, RefreshTokenPlugin, AccessRecoveryPlugin

Installation

CocoaPods

For Buya, use the following entry in your Podfile:

pod 'RxSwift', '~> 4.5'
pod 'RxCocoa', '~> 4.5'
pod 'Buya', '~> 1.0'

Then run pod install.

In any file you’d like to use Buya in, don’t forget to
import the framework with import Buya.

Usage

Using Buya is really simple. You can access an API like this:

authorizationProvider
    .request(Authorization.getData)
    .map(YourCodableStruct.self)
    .subscribe(
        onSuccess: { (data) in
            /// Doing something with data
        },
        onError: { (error) in
            print(error.localizedDescription)
        }
    )
    .disposed(by: self.disposeBag)

To do this, you must implement the following:

typealias AuthorizationProvider = Buya.Provider<Authorization>

enum Authorization {
    /// Authorization
    case authorize

    /// Return data
    case getData
}

extension Authorization: EndpointType, Buya.RefreshTokenApply {
    var path: String {
        switch self {
        case Authorization.authorize:
            return "/authorize"

        case Authorization.getData:
            return "/getData"
        }
    }

    var requestType: RequestType {
        switch self {
        case Authorization.authorize:
            return RequestType.post
        case Authorization.getData:
            return RequestType.get
        }
    }

    var requestInfo: RequestInfo {
        switch self {
        case let Authorization.authorize(login, password):
            let query = [
                "login" : login,
                "password": password
            ]
            return RequestInfo.query(parameters: query)

        case Authorization.getData:
            return RequestInfo.none
        }
    }

    var headers: [String : String]? {
        return [
            "Content-Type": "application/json",
            "Accept": "application/json"
        ]
    }

    var refreshTokenApply: Bool {
        switch self {
        case Authorization.getData: return true
        default:
            return false
        }
    }
}

License

RStorage is released under an MIT license. See LICENSE for more information.

Latest podspec

{
    "name": "Buya",
    "version": "1.0.5",
    "summary": "Network abstraction framework",
    "homepage": "https://github.com/ephedra-software/Buya",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Erik Basargin": "[email protected]",
        "Kirill Saltykov": "[email protected]"
    },
    "social_media_url": "https://twitter.com/Puasonych",
    "source": {
        "git": "https://github.com/ephedra-software/Buya.git",
        "tag": "1.0.5"
    },
    "swift_version": "5.0",
    "platforms": {
        "ios": "8.0"
    },
    "default_subspecs": "Core",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Buya/**/*.swift",
            "frameworks": "Foundation",
            "dependencies": {
                "RxSwift": [
                    "~> 4.5"
                ],
                "RxCocoa": [
                    "~> 4.5"
                ]
            }
        }
    ]
}

Pin It on Pinterest

Share This