Type-safe Firebase HTTPS Callable Functions client using Decodable
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Callable.xcodeproj
Callable.xcworkspace
Callable
CallableTests
Demo
.gitignore
.swift-version
.travis.yml
Callable.podspec
Gemfile
Gemfile.lock
LICENSE
Podfile
Podfile.lock
README.md

README.md

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