Latest 0.4.0
Homepage https://github.com/starhoshi/Callable
License MIT
Platforms ios 10.0, requires ARC
Dependencies Firebase/Functions, Result
Authors

Callable
Callable
License: MIT

Type-safe Firebase HTTPS Callable Functions client using Decodable.

Installation

pod 'Callable'

Usage

Define endpoint and Response

You need to define Response extend Decodable.

  • path
    • The name of the Callable HTTPS trigger.
  • parameter
    • Parameters to pass to the trigger.
struct SampleResponse: Decodable {
    let name: String
}

struct Sample: Callable {
    typealias Response = SampleResponse
    let name: String

    init(name: String) {
        self.name = name
    }

    var path: String {
        return "httpcallable"
    }

    var parameter: [String: Any]? {
        return ["name": name]
    }
}

Call endpoint

If the request succeeds, Response type will be returned.

let sample = Sample(name: "Jobs")
sample.call { result in
    switch result {
    case .success(let resonse):
        print(resonse)
    case .failure(let error):
        print(error)
    }
}
  • CallableError
    • function(Error)
      • server threw an error or if the resulting promise was rejected.
    • decode(Error)
      • decode failed
    • illegalCombination(Any?, Error?)
      • both result and error exist, or nil

Latest podspec

{
    "name": "Callable",
    "version": "0.4.0",
    "summary": "Type-safe Firebase HTTPS Callable Functions client using Decodable",
    "homepage": "https://github.com/starhoshi/Callable",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "star__hoshi": "[email protected]"
    },
    "social_media_url": "https://twitter.com/star__hoshi",
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/starhoshi/Callable.git",
        "tag": "0.4.0"
    },
    "source_files": "Callable/**/*.swift",
    "requires_arc": true,
    "static_framework": true,
    "dependencies": {
        "Firebase/Functions": [],
        "Result": []
    }
}

Pin It on Pinterest

Share This