Type-safe Firebase HTTPS Callable Functions client using Decodable.
pod 'Callable'
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]
}
}
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
- function(Error)