Latest 1.0.0
Homepage https://github.com/malt03/Balblair
License MIT
Platforms ios 8.0
Authors

CI Status
Platform
Language
CocoaPods
License

Balblair is an api client library written in Swift.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

Initialize

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  Balblair.defaultConfiguration = Balblair.Configuration(baseUrl: "https://qiita.com/", header: [:])
  return true
}

Usage

Create Response Model

struct QiitaResult: Mappable {
  var title = ""

  init?(_ map: Map) {
    mapping(map)
  }

  mutating func mapping(map: Map) {
    title <- map["title"]
  }
}

Create Request Model

struct QiitaRequest: ApiRequest {
  typealias ResultType = [Result]

  let method = Balblair.Method.GET
  let path = "api/v2/items"
  let parameters = NoParamsModel.instance
}

Request

QiitaRequest().response.subscribe(onNext: { print($0) } )

Create customize configuration

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
  Balblair.defaultConfiguration = Configuration()
  return true
}

class Configuration: BalblairConfiguration {
  let baseUrl = "https://qiita.com/"
  var headerBuilder: BalblairHeaderBuilder = HeaderBuilder()
  func apiClientShouldBeginRequest(apiClient: Balblair, method: Balblair.Method, path: String, parameters: [String: AnyObject]?) -> Bool { return true }
  func apiClientShouldProgress(apiClient: Balblair, method: Balblair.Method, path: String, parameters: [String: AnyObject]?, progress: NSProgress) -> Bool { return true }
  func apiClientShouldSuccess(apiClient: Balblair, method: Balblair.Method, path: String, parameters: [String: AnyObject]?, result: AnyObject?) -> ErrorType? { return nil }
  func apiClientShouldFailure(apiClient: Balblair, method: Balblair.Method, path: String, parameters: [String: AnyObject]?, result: AnyObject?, error: ErrorType) -> Bool { return true }
}

class HeaderBuilder: BalblairHeaderBuilder {
  func build() -> [String : String] {
    return [:]
  }

}

Installation

Balblair is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Balblair"

Author

Koji Murata, [email protected]

License

Balblair is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Balblair",
    "version": "1.0.0",
    "summary": "Api client with ObjectMapper and SwiftTask.",
    "description": "This pod is api client.nThis is type safe.nThis is easy to use with ObjectMapper and SwiftTask.",
    "homepage": "https://github.com/malt03/Balblair",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Koji Murata": "[email protected]"
    },
    "source": {
        "git": "https://github.com/malt03/Balblair.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "pushed_with_swift_version": "3.0",
    "subspecs": [
        {
            "name": "Core",
            "source_files": "Balblair/Core/Classes/**/*",
            "dependencies": {
                "Alamofire": [
                    ">= 4.0"
                ]
            }
        },
        {
            "name": "ObjectMapper",
            "source_files": "Balblair/ObjectMapper/Classes/**/*",
            "dependencies": {
                "Balblair/Core": [],
                "ObjectMapper": [
                    ">= 2.0"
                ]
            }
        },
        {
            "name": "Rx",
            "source_files": "Balblair/Rx/Classes/**/*",
            "dependencies": {
                "Balblair/Core": [],
                "Balblair/ObjectMapper": [],
                "RxSwift": [
                    ">= 3.0"
                ]
            }
        }
    ]
}

Pin It on Pinterest

Share This