Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/starhoshi/callable
Type-safe Firebase HTTPS Callable Functions client using Decodable
https://github.com/starhoshi/callable
cloudfunctions cocoapods decodable firebase ios swift
Last synced: about 3 hours ago
JSON representation
Type-safe Firebase HTTPS Callable Functions client using Decodable
- Host: GitHub
- URL: https://github.com/starhoshi/callable
- Owner: starhoshi
- License: mit
- Created: 2018-03-23T11:56:53.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-06T00:04:39.000Z (about 2 years ago)
- Last Synced: 2024-11-18T03:35:47.051Z (about 20 hours ago)
- Topics: cloudfunctions, cocoapods, decodable, firebase, ios, swift
- Language: Ruby
- Size: 64.5 KB
- Stars: 6
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Callable
![](https://cocoapod-badges.herokuapp.com/v/Callable/badge.png)
![](https://cocoapod-badges.herokuapp.com/p/Callable/badge.png)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)Type-safe [Firebase HTTPS Callable Functions](https://firebase.google.com/docs/functions/callable) 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.```swift
struct SampleResponse: Decodable {
let name: String
}struct Sample: Callable {
typealias Response = SampleResponse
let name: Stringinit(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.
```swift
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