mirror of
https://github.com/go-micro/go-micro.git
synced 2025-01-29 18:04:17 +02:00
remove services
This commit is contained in:
parent
aaca7c27da
commit
e8604f065c
@ -1,104 +0,0 @@
|
||||
# Services
|
||||
|
||||
[Micro Services](https://github.com/micro/services) provide additional functionality via external third party services.
|
||||
|
||||
## Overview
|
||||
|
||||
Go Micro provides core abstractions for building distributed systems which are likely
|
||||
direct dependencies on locally hosted infrastructure. In the case of external services
|
||||
such as sending email, sms, etc we leave this up to the user. Yet they are becoming
|
||||
more core to all forms of distributed systems development beyond infrastructure.
|
||||
|
||||
This directory serves as guidance for accessing external Micro services managed
|
||||
and hosted by [M3O](https://m3o.com) and powered by [Micro](https://github.com/micro/micro).
|
||||
|
||||
## Features
|
||||
|
||||
The types of services available are as follows:
|
||||
|
||||
- [Address](https://m3o.com/address) - Address lookup by postcode
|
||||
- [Answer](https://m3o.com/answer) - Instant answers to any question
|
||||
- [Cache](https://m3o.com/cache) - Quick access key-value storage
|
||||
- [Crypto](https://m3o.com/crypto) - Cryptocurrency prices, quotes, and news
|
||||
- [Currency](https://m3o.com/currency) - Exchange rates and currency conversion
|
||||
- [Db](https://m3o.com/db) - Simple database service
|
||||
- [Email](https://m3o.com/email) - Send emails in a flash
|
||||
- [Emoji](https://m3o.com/emoji) - All the emojis you need 🎉
|
||||
- [File](https://m3o.com/file) - Store, list, and retrieve text files
|
||||
- [Forex](https://m3o.com/forex) - Foreign exchange (FX) rates
|
||||
- [Geocoding](https://m3o.com/geocoding) - Geocode an address to gps location and the reverse.
|
||||
- [Helloworld](https://m3o.com/helloworld) - Just saying hello world
|
||||
- [Holidays](https://m3o.com/holidays) - Find the holidays observed in a particular country
|
||||
- [Id](https://m3o.com/id) - Generate unique IDs (uuid, snowflake, etc)
|
||||
- [Image](https://m3o.com/image) - Quickly upload, resize, and convert images
|
||||
- [Ip](https://m3o.com/ip) - IP to geolocation lookup
|
||||
- [Location](https://m3o.com/location) - Real time GPS location tracking and search
|
||||
- [Otp](https://m3o.com/otp) - One time password generation
|
||||
- [Postcode](https://m3o.com/postcode) - Fast UK postcode lookup
|
||||
- [Prayer](https://m3o.com/prayer) - Islamic prayer times
|
||||
- [Qr](https://m3o.com/qr) - QR code generator
|
||||
- [Quran](https://m3o.com/quran) - The Holy Quran
|
||||
- [Routing](https://m3o.com/routing) - Etas, routes and turn by turn directions
|
||||
- [Rss](https://m3o.com/rss) - RSS feed crawler and reader
|
||||
- [Sentiment](https://m3o.com/sentiment) - Real time sentiment analysis
|
||||
- [Sms](https://m3o.com/sms) - Send an SMS message
|
||||
- [Stock](https://m3o.com/stock) - Live stock quotes and prices
|
||||
- [Stream](https://m3o.com/stream) - Publish and subscribe to messages
|
||||
- [Sunnah](https://m3o.com/sunnah) - Traditions and practices of the Islamic prophet, Muhammad (pbuh)
|
||||
- [Thumbnail](https://m3o.com/thumbnail) - Create website thumbnails
|
||||
- [Time](https://m3o.com/time) - Time, date, and timezone info
|
||||
- [Twitter](https://m3o.com/twitter) - Realtime twitter timeline & search
|
||||
- [Url](https://m3o.com/url) - URL shortening, sharing, and tracking
|
||||
- [User](https://m3o.com/user) - User management and authentication
|
||||
- [Weather](https://m3o.com/weather) - Real time weather forecast
|
||||
|
||||
## Explore
|
||||
|
||||
The source code for all services exist in [github.com/micro/services](https://github.com/micro/services).
|
||||
|
||||
The hosted versions of all services can be found on [m3o.com](https://m3o.com).
|
||||
|
||||
## Usage
|
||||
|
||||
- Head to [m3o.com](https://m3o.com) and signup for a free account.
|
||||
- Generate an API key on the [Settings page](https://m3o.com/settings/keys).
|
||||
- Browse the APIs on the [Explore page](https://m3o.com/explore).
|
||||
- Call any API using your token in the `Authorization: Bearer [Token]` header and `https://api.m3o.com/v1/[service]/[endpoint]` url.
|
||||
|
||||
## Example
|
||||
|
||||
Find the service you're looking for and browse to its API page e.g [https://m3o.com/currency/api](https://m3o.com/currency/api).
|
||||
|
||||
Copy the example for the relevant endpoint
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"go-micro.dev/v4/services/currency"
|
||||
)
|
||||
|
||||
var (
|
||||
token = os.Getenv("MICRO_API_TOKEN")
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
currencyService := currency.NewCurrencyService(token)
|
||||
|
||||
rsp, err := currencyService.Convert(¤cy.ConvertRequest{
|
||||
From: "USD",
|
||||
To: "GBP",
|
||||
})
|
||||
|
||||
// {
|
||||
// "from": "USD",
|
||||
// "to": "GBP",
|
||||
// "rate": 0.7104
|
||||
// }
|
||||
fmt.Println(rsp, err)
|
||||
}
|
||||
```
|
@ -1,63 +0,0 @@
|
||||
package address
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Address interface {
|
||||
LookupPostcode(*LookupPostcodeRequest) (*LookupPostcodeResponse, error)
|
||||
}
|
||||
|
||||
func NewAddressService(token string) *AddressService {
|
||||
return &AddressService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AddressService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup a list of UK addresses by postcode
|
||||
func (t *AddressService) LookupPostcode(request *LookupPostcodeRequest) (*LookupPostcodeResponse, error) {
|
||||
|
||||
rsp := &LookupPostcodeResponse{}
|
||||
return rsp, t.client.Call("address", "LookupPostcode", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type LookupPostcodeRequest struct {
|
||||
// UK postcode e.g SW1A 2AA
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
type LookupPostcodeResponse struct {
|
||||
Addresses []Record `json:"addresses"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
// building name
|
||||
BuildingName string `json:"building_name"`
|
||||
// the county
|
||||
County string `json:"county"`
|
||||
// line one of address
|
||||
LineOne string `json:"line_one"`
|
||||
// line two of address
|
||||
LineTwo string `json:"line_two"`
|
||||
// dependent locality
|
||||
Locality string `json:"locality"`
|
||||
// organisation if present
|
||||
Organisation string `json:"organisation"`
|
||||
// the postcode
|
||||
Postcode string `json:"postcode"`
|
||||
// the premise
|
||||
Premise string `json:"premise"`
|
||||
// street name
|
||||
Street string `json:"street"`
|
||||
// the complete address
|
||||
Summary string `json:"summary"`
|
||||
// post town
|
||||
Town string `json:"town"`
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package answer
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Answer interface {
|
||||
Question(*QuestionRequest) (*QuestionResponse, error)
|
||||
}
|
||||
|
||||
func NewAnswerService(token string) *AnswerService {
|
||||
return &AnswerService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AnswerService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Ask a question and receive an instant answer
|
||||
func (t *AnswerService) Question(request *QuestionRequest) (*QuestionResponse, error) {
|
||||
|
||||
rsp := &QuestionResponse{}
|
||||
return rsp, t.client.Call("answer", "Question", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type QuestionRequest struct {
|
||||
// the question to answer
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type QuestionResponse struct {
|
||||
// the answer to your question
|
||||
Answer string `json:"answer"`
|
||||
// any related image
|
||||
Image string `json:"image"`
|
||||
// a related url
|
||||
Url string `json:"url"`
|
||||
}
|
@ -1,213 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type App interface {
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Regions(*RegionsRequest) (*RegionsResponse, error)
|
||||
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
||||
Resolve(*ResolveRequest) (*ResolveResponse, error)
|
||||
Run(*RunRequest) (*RunResponse, error)
|
||||
Status(*StatusRequest) (*StatusResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewAppService(token string) *AppService {
|
||||
return &AppService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AppService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Delete an app
|
||||
func (t *AppService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("app", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all the apps
|
||||
func (t *AppService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("app", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return the support regions
|
||||
func (t *AppService) Regions(request *RegionsRequest) (*RegionsResponse, error) {
|
||||
|
||||
rsp := &RegionsResponse{}
|
||||
return rsp, t.client.Call("app", "Regions", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Reserve apps beyond the free quota. Call Run after.
|
||||
func (t *AppService) Reserve(request *ReserveRequest) (*ReserveResponse, error) {
|
||||
|
||||
rsp := &ReserveResponse{}
|
||||
return rsp, t.client.Call("app", "Reserve", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Resolve an app by id to its raw backend endpoint
|
||||
func (t *AppService) Resolve(request *ResolveRequest) (*ResolveResponse, error) {
|
||||
|
||||
rsp := &ResolveResponse{}
|
||||
return rsp, t.client.Call("app", "Resolve", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Run an app from source
|
||||
func (t *AppService) Run(request *RunRequest) (*RunResponse, error) {
|
||||
|
||||
rsp := &RunResponse{}
|
||||
return rsp, t.client.Call("app", "Run", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the status of an app
|
||||
func (t *AppService) Status(request *StatusRequest) (*StatusResponse, error) {
|
||||
|
||||
rsp := &StatusResponse{}
|
||||
return rsp, t.client.Call("app", "Status", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update the app. The latest source code will be downloaded, built and deployed.
|
||||
func (t *AppService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("app", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// all the apps
|
||||
Services []Service `json:"services"`
|
||||
}
|
||||
|
||||
type RegionsRequest struct {
|
||||
}
|
||||
|
||||
type RegionsResponse struct {
|
||||
Regions []string `json:"regions"`
|
||||
}
|
||||
|
||||
type Reservation struct {
|
||||
// time of reservation
|
||||
Created string `json:"created"`
|
||||
// time reservation expires
|
||||
Expires string `json:"expires"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// owner id
|
||||
Owner string `json:"owner"`
|
||||
// associated token
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type ReserveRequest struct {
|
||||
// name of your app e.g helloworld
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ReserveResponse struct {
|
||||
// The app reservation
|
||||
Reservation *Reservation `json:"reservation"`
|
||||
}
|
||||
|
||||
type ResolveRequest struct {
|
||||
// the service id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ResolveResponse struct {
|
||||
// the end provider url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type RunRequest struct {
|
||||
// branch. defaults to master
|
||||
Branch string `json:"branch"`
|
||||
// associated env vars to pass in
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// port to run on
|
||||
Port int32 `json:"port"`
|
||||
// region to run in
|
||||
Region string `json:"region"`
|
||||
// source repository
|
||||
Repo string `json:"repo"`
|
||||
}
|
||||
|
||||
type RunResponse struct {
|
||||
// The running service
|
||||
Service *Service `json:"service"`
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
// branch of code
|
||||
Branch string `json:"branch"`
|
||||
// time of creation
|
||||
Created string `json:"created"`
|
||||
// custom domains
|
||||
CustomDomains string `json:"custom_domains"`
|
||||
// associated env vars
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// unique id
|
||||
Id string `json:"id"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// port running on
|
||||
Port int32 `json:"port"`
|
||||
// region running in
|
||||
Region string `json:"region"`
|
||||
// source repository
|
||||
Repo string `json:"repo"`
|
||||
// status of the app
|
||||
Status string `json:"status"`
|
||||
// last updated
|
||||
Updated string `json:"updated"`
|
||||
// app url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type StatusRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type StatusResponse struct {
|
||||
// running service info
|
||||
Service *Service `json:"service"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package avatar
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Avatar interface {
|
||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||
}
|
||||
|
||||
func NewAvatarService(token string) *AvatarService {
|
||||
return &AvatarService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type AvatarService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
func (t *AvatarService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
return rsp, t.client.Call("avatar", "Generate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// encode format of avatar image, `png` or `jpeg`, default is `jpeg`
|
||||
Format string `json:"format"`
|
||||
// avatar's gender, `male` or `female`, default is `male`
|
||||
Gender string `json:"gender"`
|
||||
// if upload to m3o CDN, default is `false`
|
||||
// if update = true, then it'll return the CDN url
|
||||
Upload bool `json:"upload"`
|
||||
// avatar's username, unique username will generates the unique avatar;
|
||||
// if username == "", will generate a random avatar in every request
|
||||
// if upload == true, username will be used as CDN filename rather than a random uuid string
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// base64encode string of the avatar image
|
||||
Base64 string `json:"base64"`
|
||||
// Micro's CDN url of the avatar image
|
||||
Url string `json:"url"`
|
||||
}
|
147
services/cache/cache.go
vendored
147
services/cache/cache.go
vendored
@ -1,147 +0,0 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Cache interface {
|
||||
Decrement(*DecrementRequest) (*DecrementResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Get(*GetRequest) (*GetResponse, error)
|
||||
Increment(*IncrementRequest) (*IncrementResponse, error)
|
||||
ListKeys(*ListKeysRequest) (*ListKeysResponse, error)
|
||||
Set(*SetRequest) (*SetResponse, error)
|
||||
}
|
||||
|
||||
func NewCacheService(token string) *CacheService {
|
||||
return &CacheService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CacheService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Decrement a value (if it's a number). If key not found it is equivalent to set.
|
||||
func (t *CacheService) Decrement(request *DecrementRequest) (*DecrementResponse, error) {
|
||||
|
||||
rsp := &DecrementResponse{}
|
||||
return rsp, t.client.Call("cache", "Decrement", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a value from the cache. If key not found a success response is returned.
|
||||
func (t *CacheService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("cache", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get an item from the cache by key. If key is not found, an empty response is returned.
|
||||
func (t *CacheService) Get(request *GetRequest) (*GetResponse, error) {
|
||||
|
||||
rsp := &GetResponse{}
|
||||
return rsp, t.client.Call("cache", "Get", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Increment a value (if it's a number). If key not found it is equivalent to set.
|
||||
func (t *CacheService) Increment(request *IncrementRequest) (*IncrementResponse, error) {
|
||||
|
||||
rsp := &IncrementResponse{}
|
||||
return rsp, t.client.Call("cache", "Increment", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all the available keys
|
||||
func (t *CacheService) ListKeys(request *ListKeysRequest) (*ListKeysResponse, error) {
|
||||
|
||||
rsp := &ListKeysResponse{}
|
||||
return rsp, t.client.Call("cache", "ListKeys", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Set an item in the cache. Overwrites any existing value already set.
|
||||
func (t *CacheService) Set(request *SetRequest) (*SetResponse, error) {
|
||||
|
||||
rsp := &SetResponse{}
|
||||
return rsp, t.client.Call("cache", "Set", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type DecrementRequest struct {
|
||||
// The key to decrement
|
||||
Key string `json:"key"`
|
||||
// The amount to decrement the value by
|
||||
Value int64 `json:"value,string"`
|
||||
}
|
||||
|
||||
type DecrementResponse struct {
|
||||
// The key decremented
|
||||
Key string `json:"key"`
|
||||
// The new value
|
||||
Value int64 `json:"value,string"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// The key to delete
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
// Returns "ok" if successful
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type GetRequest struct {
|
||||
// The key to retrieve
|
||||
Key string `json:"key"`
|
||||
}
|
||||
|
||||
type GetResponse struct {
|
||||
// The key
|
||||
Key string `json:"key"`
|
||||
// Time to live in seconds
|
||||
Ttl int64 `json:"ttl,string"`
|
||||
// The value
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type IncrementRequest struct {
|
||||
// The key to increment
|
||||
Key string `json:"key"`
|
||||
// The amount to increment the value by
|
||||
Value int64 `json:"value,string"`
|
||||
}
|
||||
|
||||
type IncrementResponse struct {
|
||||
// The key incremented
|
||||
Key string `json:"key"`
|
||||
// The new value
|
||||
Value int64 `json:"value,string"`
|
||||
}
|
||||
|
||||
type ListKeysRequest struct {
|
||||
}
|
||||
|
||||
type ListKeysResponse struct {
|
||||
Keys []string `json:"keys"`
|
||||
}
|
||||
|
||||
type SetRequest struct {
|
||||
// The key to update
|
||||
Key string `json:"key"`
|
||||
// Time to live in seconds
|
||||
Ttl int64 `json:"ttl,string"`
|
||||
// The value to set
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type SetResponse struct {
|
||||
// Returns "ok" if successful
|
||||
Status string `json:"status"`
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package carbon
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Carbon interface {
|
||||
Offset(*OffsetRequest) (*OffsetResponse, error)
|
||||
}
|
||||
|
||||
func NewCarbonService(token string) *CarbonService {
|
||||
return &CarbonService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CarbonService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Purchase 1KG (0.001 tonne) of carbon offsets in a single request
|
||||
func (t *CarbonService) Offset(request *OffsetRequest) (*OffsetResponse, error) {
|
||||
|
||||
rsp := &OffsetResponse{}
|
||||
return rsp, t.client.Call("carbon", "Offset", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type OffsetRequest struct {
|
||||
}
|
||||
|
||||
type OffsetResponse struct {
|
||||
// the metric used e.g KG or Tonnes
|
||||
Metric string `json:"metric"`
|
||||
// projects it was allocated to
|
||||
Projects []Project `json:"projects"`
|
||||
// number of tonnes
|
||||
Tonnes float64 `json:"tonnes"`
|
||||
// number of units purchased
|
||||
Units int32 `json:"units"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
// name of the project
|
||||
Name string `json:"name"`
|
||||
// percentage that went to this
|
||||
Percentage float64 `json:"percentage"`
|
||||
// amount in tonnes
|
||||
Tonnes float64 `json:"tonnes"`
|
||||
}
|
@ -1,200 +0,0 @@
|
||||
package contact
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Contact interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewContactService(token string) *ContactService {
|
||||
return &ContactService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ContactService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
//
|
||||
func (t *ContactService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("contact", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func (t *ContactService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("contact", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func (t *ContactService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("contact", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func (t *ContactService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("contact", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
func (t *ContactService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("contact", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
// the label of the address
|
||||
Label string `json:"label"`
|
||||
// the address location
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ContactInfo struct {
|
||||
// the address
|
||||
Addresses []Address `json:"addresses"`
|
||||
// the birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// create date string in RFC3339
|
||||
CreatedAt string `json:"created_at"`
|
||||
// the emails
|
||||
Emails []Email `json:"emails"`
|
||||
// contact id
|
||||
Id string `json:"id"`
|
||||
// the contact links
|
||||
Links []Link `json:"links"`
|
||||
// the contact name
|
||||
Name string `json:"name"`
|
||||
// note of the contact
|
||||
Note string `json:"note"`
|
||||
// the phone numbers
|
||||
Phones []Phone `json:"phones"`
|
||||
// the social media username
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
// update date string in RFC3339
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// optional, location
|
||||
Addresses []Address `json:"addresses"`
|
||||
// optional, birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// optional, emails
|
||||
Emails []Email `json:"emails"`
|
||||
// optional, links
|
||||
Links []Link `json:"links"`
|
||||
// required, the name of the contact
|
||||
Name string `json:"name"`
|
||||
// optional, note of the contact
|
||||
Note string `json:"note"`
|
||||
// optional, phone numbers
|
||||
Phones []Phone `json:"phones"`
|
||||
// optional, social media
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// the id of the contact
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type Email struct {
|
||||
// the email address
|
||||
Address string `json:"address"`
|
||||
// the label of the email
|
||||
Label string `json:"label"`
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
// the label of the link
|
||||
Label string `json:"label"`
|
||||
// the url of the contact
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// optional, default is 30
|
||||
Limit int32 `json:"limit"`
|
||||
// optional
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Contacts []ContactInfo `json:"contacts"`
|
||||
}
|
||||
|
||||
type Phone struct {
|
||||
// the label of the phone number
|
||||
Label string `json:"label"`
|
||||
// phone number
|
||||
Number string `json:"number"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
||||
|
||||
type SocialMedia struct {
|
||||
// the label of the social
|
||||
Label string `json:"label"`
|
||||
// the username of social media
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// optional, addresses
|
||||
Addresses []Address `json:"addresses"`
|
||||
// optional, birthday
|
||||
Birthday string `json:"birthday"`
|
||||
// optional, emails
|
||||
Emails []Email `json:"emails"`
|
||||
// required, the contact id
|
||||
Id string `json:"id"`
|
||||
// optional, links
|
||||
Links []Link `json:"links"`
|
||||
// required, the name
|
||||
Name string `json:"name"`
|
||||
// optional, note
|
||||
Note string `json:"note"`
|
||||
// optional, phone number
|
||||
Phones []Phone `json:"phones"`
|
||||
// optional, social media
|
||||
SocialMedias *SocialMedia `json:"social_medias"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
Contact *ContactInfo `json:"contact"`
|
||||
}
|
@ -1,135 +0,0 @@
|
||||
package crypto
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Crypto interface {
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
News(*NewsRequest) (*NewsResponse, error)
|
||||
Price(*PriceRequest) (*PriceResponse, error)
|
||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
||||
}
|
||||
|
||||
func NewCryptoService(token string) *CryptoService {
|
||||
return &CryptoService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CryptoService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Returns the history for the previous close
|
||||
func (t *CryptoService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("crypto", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get news related to a currency
|
||||
func (t *CryptoService) News(request *NewsRequest) (*NewsResponse, error) {
|
||||
|
||||
rsp := &NewsResponse{}
|
||||
return rsp, t.client.Call("crypto", "News", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last price for a given crypto ticker
|
||||
func (t *CryptoService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||
|
||||
rsp := &PriceResponse{}
|
||||
return rsp, t.client.Call("crypto", "Price", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last quote for a given crypto ticker
|
||||
func (t *CryptoService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||
|
||||
rsp := &QuoteResponse{}
|
||||
return rsp, t.client.Call("crypto", "Quote", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
// the date published
|
||||
Date string `json:"date"`
|
||||
// its description
|
||||
Description string `json:"description"`
|
||||
// the source
|
||||
Source string `json:"source"`
|
||||
// title of the article
|
||||
Title string `json:"title"`
|
||||
// the source url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
// the crypto symbol e.g BTCUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
// the close price
|
||||
Close float64 `json:"close"`
|
||||
// the date
|
||||
Date string `json:"date"`
|
||||
// the peak price
|
||||
High float64 `json:"high"`
|
||||
// the low price
|
||||
Low float64 `json:"low"`
|
||||
// the open price
|
||||
Open float64 `json:"open"`
|
||||
// the crypto symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the volume
|
||||
Volume float64 `json:"volume"`
|
||||
}
|
||||
|
||||
type NewsRequest struct {
|
||||
// cryptocurrency ticker to request news for e.g BTC
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type NewsResponse struct {
|
||||
// list of articles
|
||||
Articles []Article `json:"articles"`
|
||||
// symbol requested for
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type PriceRequest struct {
|
||||
// the crypto symbol e.g BTCUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type PriceResponse struct {
|
||||
// the last price
|
||||
Price float64 `json:"price"`
|
||||
// the crypto symbol e.g BTCUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteRequest struct {
|
||||
// the crypto symbol e.g BTCUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
// the ask size
|
||||
AskSize float64 `json:"ask_size"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
// the bid size
|
||||
BidSize float64 `json:"bid_size"`
|
||||
// the crypto symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
package currency
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Currency interface {
|
||||
Codes(*CodesRequest) (*CodesResponse, error)
|
||||
Convert(*ConvertRequest) (*ConvertResponse, error)
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
Rates(*RatesRequest) (*RatesResponse, error)
|
||||
}
|
||||
|
||||
func NewCurrencyService(token string) *CurrencyService {
|
||||
return &CurrencyService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type CurrencyService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Codes returns the supported currency codes for the API
|
||||
func (t *CurrencyService) Codes(request *CodesRequest) (*CodesResponse, error) {
|
||||
|
||||
rsp := &CodesResponse{}
|
||||
return rsp, t.client.Call("currency", "Codes", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Convert returns the currency conversion rate between two pairs e.g USD/GBP
|
||||
func (t *CurrencyService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||
|
||||
rsp := &ConvertResponse{}
|
||||
return rsp, t.client.Call("currency", "Convert", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Returns the historic rates for a currency on a given date
|
||||
func (t *CurrencyService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("currency", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Rates returns the currency rates for a given code e.g USD
|
||||
func (t *CurrencyService) Rates(request *RatesRequest) (*RatesResponse, error) {
|
||||
|
||||
rsp := &RatesResponse{}
|
||||
return rsp, t.client.Call("currency", "Rates", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Code struct {
|
||||
// e.g United States Dollar
|
||||
Currency string `json:"currency"`
|
||||
// e.g USD
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type CodesRequest struct {
|
||||
}
|
||||
|
||||
type CodesResponse struct {
|
||||
Codes []Code `json:"codes"`
|
||||
}
|
||||
|
||||
type ConvertRequest struct {
|
||||
// optional amount to convert e.g 10.0
|
||||
Amount float64 `json:"amount"`
|
||||
// base code to convert from e.g USD
|
||||
From string `json:"from"`
|
||||
// target code to convert to e.g GBP
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type ConvertResponse struct {
|
||||
// converted amount e.g 7.10
|
||||
Amount float64 `json:"amount"`
|
||||
// the base code e.g USD
|
||||
From string `json:"from"`
|
||||
// conversion rate e.g 0.71
|
||||
Rate float64 `json:"rate"`
|
||||
// the target code e.g GBP
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
// currency code e.g USD
|
||||
Code string `json:"code"`
|
||||
// date formatted as YYYY-MM-DD
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
// The code of the request
|
||||
Code string `json:"code"`
|
||||
// The date requested
|
||||
Date string `json:"date"`
|
||||
// The rate for the day as code:rate
|
||||
Rates map[string]float64 `json:"rates"`
|
||||
}
|
||||
|
||||
type RatesRequest struct {
|
||||
// The currency code to get rates for e.g USD
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type RatesResponse struct {
|
||||
// The code requested e.g USD
|
||||
Code string `json:"code"`
|
||||
// The rates for the given code as key-value pairs code:rate
|
||||
Rates map[string]float64 `json:"rates"`
|
||||
}
|
@ -1,205 +0,0 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Db interface {
|
||||
Count(*CountRequest) (*CountResponse, error)
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
DropTable(*DropTableRequest) (*DropTableResponse, error)
|
||||
ListTables(*ListTablesRequest) (*ListTablesResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
RenameTable(*RenameTableRequest) (*RenameTableResponse, error)
|
||||
Truncate(*TruncateRequest) (*TruncateResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewDbService(token string) *DbService {
|
||||
return &DbService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type DbService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Count records in a table
|
||||
func (t *DbService) Count(request *CountRequest) (*CountResponse, error) {
|
||||
|
||||
rsp := &CountResponse{}
|
||||
return rsp, t.client.Call("db", "Count", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Create a record in the database. Optionally include an "id" field otherwise it's set automatically.
|
||||
func (t *DbService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("db", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a record in the database by id.
|
||||
func (t *DbService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("db", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Drop a table in the DB
|
||||
func (t *DbService) DropTable(request *DropTableRequest) (*DropTableResponse, error) {
|
||||
|
||||
rsp := &DropTableResponse{}
|
||||
return rsp, t.client.Call("db", "DropTable", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List tables in the DB
|
||||
func (t *DbService) ListTables(request *ListTablesRequest) (*ListTablesResponse, error) {
|
||||
|
||||
rsp := &ListTablesResponse{}
|
||||
return rsp, t.client.Call("db", "ListTables", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read data from a table. Lookup can be by ID or via querying any field in the record.
|
||||
func (t *DbService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("db", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Rename a table
|
||||
func (t *DbService) RenameTable(request *RenameTableRequest) (*RenameTableResponse, error) {
|
||||
|
||||
rsp := &RenameTableResponse{}
|
||||
return rsp, t.client.Call("db", "RenameTable", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Truncate the records in a table
|
||||
func (t *DbService) Truncate(request *TruncateRequest) (*TruncateResponse, error) {
|
||||
|
||||
rsp := &TruncateResponse{}
|
||||
return rsp, t.client.Call("db", "Truncate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a record in the database. Include an "id" in the record to update.
|
||||
func (t *DbService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("db", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CountRequest struct {
|
||||
// specify the table name
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type CountResponse struct {
|
||||
// the number of records in the table
|
||||
Count int32 `json:"count"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// optional record id to use
|
||||
Id string `json:"id"`
|
||||
// JSON encoded record or records (can be array or object)
|
||||
Record map[string]interface{} `json:"record"`
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// The id of the record (either specified or automatically created)
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// id of the record
|
||||
Id string `json:"id"`
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type DropTableRequest struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type DropTableResponse struct {
|
||||
}
|
||||
|
||||
type ListTablesRequest struct {
|
||||
}
|
||||
|
||||
type ListTablesResponse struct {
|
||||
// list of tables
|
||||
Tables []string `json:"tables"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// Read by id. Equivalent to 'id == "your-id"'
|
||||
Id string `json:"id"`
|
||||
// Maximum number of records to return. Default limit is 25.
|
||||
// Maximum limit is 1000. Anything higher will return an error.
|
||||
Limit int32 `json:"limit"`
|
||||
Offset int32 `json:"offset"`
|
||||
// 'asc' (default), 'desc'
|
||||
Order string `json:"order"`
|
||||
// field name to order by
|
||||
OrderBy string `json:"orderBy"`
|
||||
// Examples: 'age >= 18', 'age >= 18 and verified == true'
|
||||
// Comparison operators: '==', '!=', '<', '>', '<=', '>='
|
||||
// Logical operator: 'and'
|
||||
// Dot access is supported, eg: 'user.age == 11'
|
||||
// Accessing list elements is not supported yet.
|
||||
Query string `json:"query"`
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// JSON encoded records
|
||||
Records []map[string]interface{} `json:"records"`
|
||||
}
|
||||
|
||||
type RenameTableRequest struct {
|
||||
// current table name
|
||||
From string `json:"from"`
|
||||
// new table name
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type RenameTableResponse struct {
|
||||
}
|
||||
|
||||
type TruncateRequest struct {
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type TruncateResponse struct {
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// The id of the record. If not specified it is inferred from the 'id' field of the record
|
||||
Id string `json:"id"`
|
||||
// record, JSON object
|
||||
Record map[string]interface{} `json:"record"`
|
||||
// Optional table name. Defaults to 'default'
|
||||
Table string `json:"table"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package email
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Email interface {
|
||||
Parse(*ParseRequest) (*ParseResponse, error)
|
||||
Send(*SendRequest) (*SendResponse, error)
|
||||
Validate(*ValidateRequest) (*ValidateResponse, error)
|
||||
}
|
||||
|
||||
func NewEmailService(token string) *EmailService {
|
||||
return &EmailService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type EmailService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Parse an RFC5322 address e.g "Joe Blogs <joe@example.com>"
|
||||
func (t *EmailService) Parse(request *ParseRequest) (*ParseResponse, error) {
|
||||
|
||||
rsp := &ParseResponse{}
|
||||
return rsp, t.client.Call("email", "Parse", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an email by passing in from, to, subject, and a text or html body
|
||||
func (t *EmailService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("email", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Validate an email address format
|
||||
func (t *EmailService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
|
||||
|
||||
rsp := &ValidateResponse{}
|
||||
return rsp, t.client.Call("email", "Validate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ParseRequest struct {
|
||||
// The address to parse. Can be of the format "Joe Blogs <joe@example.com>" or "joe@example.com"
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type ParseResponse struct {
|
||||
// the email address
|
||||
Address string `json:"address"`
|
||||
// associated name e.g Joe Blogs
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// the display name of the sender
|
||||
From string `json:"from"`
|
||||
// the html body
|
||||
HtmlBody string `json:"html_body"`
|
||||
// an optional reply to email address
|
||||
ReplyTo string `json:"reply_to"`
|
||||
// the email subject
|
||||
Subject string `json:"subject"`
|
||||
// the text body
|
||||
TextBody string `json:"text_body"`
|
||||
// the email address of the recipient
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type ValidateResponse struct {
|
||||
IsValid bool `json:"is_valid"`
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package emoji
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Emoji interface {
|
||||
Find(*FindRequest) (*FindResponse, error)
|
||||
Flag(*FlagRequest) (*FlagResponse, error)
|
||||
Print(*PrintRequest) (*PrintResponse, error)
|
||||
Send(*SendRequest) (*SendResponse, error)
|
||||
}
|
||||
|
||||
func NewEmojiService(token string) *EmojiService {
|
||||
return &EmojiService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type EmojiService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Find an emoji by its alias e.g :beer:
|
||||
func (t *EmojiService) Find(request *FindRequest) (*FindResponse, error) {
|
||||
|
||||
rsp := &FindResponse{}
|
||||
return rsp, t.client.Call("emoji", "Find", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the flag for a country. Requires country code e.g GB for great britain
|
||||
func (t *EmojiService) Flag(request *FlagRequest) (*FlagResponse, error) {
|
||||
|
||||
rsp := &FlagResponse{}
|
||||
return rsp, t.client.Call("emoji", "Flag", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Print text and renders the emojis with aliases e.g
|
||||
// let's grab a :beer: becomes let's grab a 🍺
|
||||
func (t *EmojiService) Print(request *PrintRequest) (*PrintResponse, error) {
|
||||
|
||||
rsp := &PrintResponse{}
|
||||
return rsp, t.client.Call("emoji", "Print", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an emoji to anyone via SMS. Messages are sent in the form '<message> Sent from <from>'
|
||||
func (t *EmojiService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("emoji", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type FindRequest struct {
|
||||
// the alias code e.g :beer:
|
||||
Alias string `json:"alias"`
|
||||
}
|
||||
|
||||
type FindResponse struct {
|
||||
// the unicode emoji 🍺
|
||||
Emoji string `json:"emoji"`
|
||||
}
|
||||
|
||||
type FlagRequest struct {
|
||||
// country code e.g GB
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type FlagResponse struct {
|
||||
// the emoji flag
|
||||
Flag string `json:"flag"`
|
||||
}
|
||||
|
||||
type PrintRequest struct {
|
||||
// text including any alias e.g let's grab a :beer:
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type PrintResponse struct {
|
||||
// text with rendered emojis
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// the name of the sender from e.g Alice
|
||||
From string `json:"from"`
|
||||
// message to send including emoji aliases
|
||||
Message string `json:"message"`
|
||||
// phone number to send to (including international dialing code)
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
// whether or not it succeeded
|
||||
Success bool `json:"success"`
|
||||
}
|
@ -1,249 +0,0 @@
|
||||
package evchargers
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Evchargers interface {
|
||||
ReferenceData(*ReferenceDataRequest) (*ReferenceDataResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewEvchargersService(token string) *EvchargersService {
|
||||
return &EvchargersService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type EvchargersService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Retrieve reference data as used by this API and in conjunction with the Search endpoint
|
||||
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
|
||||
|
||||
rsp := &ReferenceDataResponse{}
|
||||
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search by giving a coordinate and a max distance, or bounding box and optional filters
|
||||
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("evchargers", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
// Any comments about how to access the charger
|
||||
AccessComments string `json:"access_comments"`
|
||||
AddressLine1 string `json:"address_line_1"`
|
||||
AddressLine2 string `json:"address_line_2"`
|
||||
Country *Country `json:"country"`
|
||||
CountryId string `json:"country_id"`
|
||||
LatLng string `json:"lat_lng"`
|
||||
Location *Coordinates `json:"location"`
|
||||
Postcode string `json:"postcode"`
|
||||
StateOrProvince string `json:"state_or_province"`
|
||||
Title string `json:"title"`
|
||||
Town string `json:"town"`
|
||||
}
|
||||
|
||||
type BoundingBox struct {
|
||||
BottomLeft *Coordinates `json:"bottom_left"`
|
||||
TopRight *Coordinates `json:"top_right"`
|
||||
}
|
||||
|
||||
type ChargerType struct {
|
||||
Comments string `json:"comments"`
|
||||
Id string `json:"id"`
|
||||
// Is this 40KW+
|
||||
IsFastChargeCapable bool `json:"is_fast_charge_capable"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CheckinStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsAutomated bool `json:"is_automated"`
|
||||
IsPositive bool `json:"is_positive"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Connection struct {
|
||||
// The amps offered
|
||||
Amps float64 `json:"amps"`
|
||||
ConnectionType *ConnectionType `json:"connection_type"`
|
||||
// The ID of the connection type
|
||||
ConnectionTypeId string `json:"connection_type_id"`
|
||||
// The current
|
||||
Current string `json:"current"`
|
||||
Level *ChargerType `json:"level"`
|
||||
// The level of charging power available
|
||||
LevelId string `json:"level_id"`
|
||||
// The power in KW
|
||||
Power float64 `json:"power"`
|
||||
Reference string `json:"reference"`
|
||||
// The voltage offered
|
||||
Voltage float64 `json:"voltage"`
|
||||
}
|
||||
|
||||
type ConnectionType struct {
|
||||
FormalName string `json:"formal_name"`
|
||||
Id string `json:"id"`
|
||||
IsDiscontinued bool `json:"is_discontinued"`
|
||||
IsObsolete bool `json:"is_obsolete"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Coordinates struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
ContinentCode string `json:"continent_code"`
|
||||
Id string `json:"id"`
|
||||
IsoCode string `json:"iso_code"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CurrentType struct {
|
||||
Description string `json:"description"`
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type DataProvider struct {
|
||||
Comments string `json:"comments"`
|
||||
DataProviderStatusType *DataProviderStatusType `json:"data_provider_status_type"`
|
||||
Id string `json:"id"`
|
||||
// How is this data licensed
|
||||
License string `json:"license"`
|
||||
Title string `json:"title"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
|
||||
type DataProviderStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsProviderEnabled bool `json:"is_provider_enabled"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Operator struct {
|
||||
Comments string `json:"comments"`
|
||||
ContactEmail string `json:"contact_email"`
|
||||
FaultReportEmail string `json:"fault_report_email"`
|
||||
Id string `json:"id"`
|
||||
// Is this operator a private individual vs a company
|
||||
IsPrivateIndividual bool `json:"is_private_individual"`
|
||||
PhonePrimary string `json:"phone_primary"`
|
||||
PhoneSecondary string `json:"phone_secondary"`
|
||||
Title string `json:"title"`
|
||||
Website string `json:"website"`
|
||||
}
|
||||
|
||||
type Poi struct {
|
||||
// The address
|
||||
Address *Address `json:"address"`
|
||||
// The connections available at this charge point
|
||||
Connections []Connection `json:"connections"`
|
||||
// The cost of charging
|
||||
Cost string `json:"cost"`
|
||||
// The ID of the data provider
|
||||
DataProviderId string `json:"data_provider_id"`
|
||||
// The ID of the charger
|
||||
Id string `json:"id"`
|
||||
// The number of charging points
|
||||
NumPoints int64 `json:"num_points,string"`
|
||||
// The operator
|
||||
Operator *Operator `json:"operator"`
|
||||
// The ID of the operator of the charger
|
||||
OperatorId string `json:"operator_id"`
|
||||
// The type of usage
|
||||
UsageType *UsageType `json:"usage_type"`
|
||||
// The type of usage for this charger point (is it public, membership required, etc)
|
||||
UsageTypeId string `json:"usage_type_id"`
|
||||
}
|
||||
|
||||
type ReferenceDataRequest struct {
|
||||
}
|
||||
|
||||
type ReferenceDataResponse struct {
|
||||
// The types of charger
|
||||
ChargerTypes *ChargerType `json:"charger_types"`
|
||||
// The types of checkin status
|
||||
CheckinStatusTypes *CheckinStatusType `json:"checkin_status_types"`
|
||||
// The types of connection
|
||||
ConnectionTypes *ConnectionType `json:"connection_types"`
|
||||
// The countries
|
||||
Countries []Country `json:"countries"`
|
||||
// The types of current
|
||||
CurrentTypes *CurrentType `json:"current_types"`
|
||||
// The providers of the charger data
|
||||
DataProviders *DataProvider `json:"data_providers"`
|
||||
// The companies operating the chargers
|
||||
Operators []Operator `json:"operators"`
|
||||
// The status of the charger
|
||||
StatusTypes *StatusType `json:"status_types"`
|
||||
// The status of a submission
|
||||
SubmissionStatusTypes *SubmissionStatusType `json:"submission_status_types"`
|
||||
// The different types of usage
|
||||
UsageTypes *UsageType `json:"usage_types"`
|
||||
// The types of user comment
|
||||
UserCommentTypes *UserCommentType `json:"user_comment_types"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Bounding box to search within (top left and bottom right coordinates)
|
||||
Box *BoundingBox `json:"box"`
|
||||
// IDs of the connection type
|
||||
ConnectionTypes string `json:"connection_types"`
|
||||
// Country ID
|
||||
CountryId string `json:"country_id"`
|
||||
// Search distance from point in metres, defaults to 5000m
|
||||
Distance int64 `json:"distance,string"`
|
||||
// Supported charging levels
|
||||
Levels []string `json:"levels"`
|
||||
// Coordinates from which to begin search
|
||||
Location *Coordinates `json:"location"`
|
||||
// Maximum number of results to return, defaults to 100
|
||||
MaxResults int64 `json:"max_results,string"`
|
||||
// Minimum power in KW. Note: data not available for many chargers
|
||||
MinPower int64 `json:"min_power,string"`
|
||||
// IDs of the the EV charger operator
|
||||
Operators []string `json:"operators"`
|
||||
// Usage of the charge point (is it public, membership required, etc)
|
||||
UsageTypes string `json:"usage_types"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
Pois []Poi `json:"pois"`
|
||||
}
|
||||
|
||||
type StatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsOperational bool `json:"is_operational"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type SubmissionStatusType struct {
|
||||
Id string `json:"id"`
|
||||
IsLive bool `json:"is_live"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type UsageType struct {
|
||||
Id string `json:"id"`
|
||||
IsAccessKeyRequired bool `json:"is_access_key_required"`
|
||||
IsMembershipRequired bool `json:"is_membership_required"`
|
||||
IsPayAtLocation bool `json:"is_pay_at_location"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type UserCommentType struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package event
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Event interface {
|
||||
Consume(*ConsumeRequest) (*ConsumeResponseStream, error)
|
||||
Publish(*PublishRequest) (*PublishResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
}
|
||||
|
||||
func NewEventService(token string) *EventService {
|
||||
return &EventService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type EventService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Consume events from a given topic.
|
||||
func (t *EventService) Consume(request *ConsumeRequest) (*ConsumeResponseStream, error) {
|
||||
stream, err := t.client.Stream("event", "Consume", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &ConsumeResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type ConsumeResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *ConsumeResponseStream) Recv() (*ConsumeResponse, error) {
|
||||
var rsp ConsumeResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
// Publish a event to the event stream.
|
||||
func (t *EventService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("event", "Publish", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read stored events
|
||||
func (t *EventService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("event", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ConsumeRequest struct {
|
||||
// Optional group for the subscription
|
||||
Group string `json:"group"`
|
||||
// Optional offset to read from e.g "2006-01-02T15:04:05.999Z07:00"
|
||||
Offset string `json:"offset"`
|
||||
// The topic to subscribe to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type ConsumeResponse struct {
|
||||
// Unique message id
|
||||
Id string `json:"id"`
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// Timestamp of publishing
|
||||
Timestamp string `json:"timestamp"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type Ev struct {
|
||||
// event id
|
||||
Id string `json:"id"`
|
||||
// event message
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// event timestamp
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type PublishRequest struct {
|
||||
// The json message to publish
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic to publish to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type PublishResponse struct {
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// number of events to read; default 25
|
||||
Limit int32 `json:"limit"`
|
||||
// offset for the events; default 0
|
||||
Offset int32 `json:"offset"`
|
||||
// topic to read from
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// the events
|
||||
Events []Ev `json:"events"`
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type File interface {
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Save(*SaveRequest) (*SaveResponse, error)
|
||||
}
|
||||
|
||||
func NewFileService(token string) *FileService {
|
||||
return &FileService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type FileService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Delete a file by project name/path
|
||||
func (t *FileService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("file", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List files by their project and optionally a path.
|
||||
func (t *FileService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("file", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read a file by path
|
||||
func (t *FileService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("file", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Save a file
|
||||
func (t *FileService) Save(request *SaveRequest) (*SaveResponse, error) {
|
||||
|
||||
rsp := &SaveResponse{}
|
||||
return rsp, t.client.Call("file", "Save", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// Path to the file
|
||||
Path string `json:"path"`
|
||||
// The project name
|
||||
Project string `json:"project"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// Defaults to '/', ie. lists all files in a project.
|
||||
// Supply path to a folder if you want to list
|
||||
// files inside that folder
|
||||
// eg. '/docs'
|
||||
Path string `json:"path"`
|
||||
// Project, required for listing.
|
||||
Project string `json:"project"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Files []Record `json:"files"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// Path to the file
|
||||
Path string `json:"path"`
|
||||
// Project name
|
||||
Project string `json:"project"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// Returns the file
|
||||
File *Record `json:"file"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
// File contents
|
||||
Content string `json:"content"`
|
||||
// Time the file was created e.g 2021-05-20T13:37:21Z
|
||||
Created string `json:"created"`
|
||||
// Any other associated metadata as a map of key-value pairs
|
||||
Metadata map[string]string `json:"metadata"`
|
||||
// Path to file or folder eg. '/documents/text-files/file.txt'.
|
||||
Path string `json:"path"`
|
||||
// A custom project to group files
|
||||
// eg. file-of-mywebsite.com
|
||||
Project string `json:"project"`
|
||||
// Time the file was updated e.g 2021-05-20T13:37:21Z
|
||||
Updated string `json:"updated"`
|
||||
}
|
||||
|
||||
type SaveRequest struct {
|
||||
// The file to save
|
||||
File *Record `json:"file"`
|
||||
// Make the file public: true or false
|
||||
Public bool `json:"public"`
|
||||
}
|
||||
|
||||
type SaveResponse struct {
|
||||
// The permalink for the file if made public
|
||||
Url string `json:"url"`
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package forex
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Forex interface {
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
Price(*PriceRequest) (*PriceResponse, error)
|
||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
||||
}
|
||||
|
||||
func NewForexService(token string) *ForexService {
|
||||
return &ForexService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ForexService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Returns the data for the previous close
|
||||
func (t *ForexService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("forex", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the latest price for a given forex ticker
|
||||
func (t *ForexService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||
|
||||
rsp := &PriceResponse{}
|
||||
return rsp, t.client.Call("forex", "Price", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the latest quote for the forex
|
||||
func (t *ForexService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||
|
||||
rsp := &QuoteResponse{}
|
||||
return rsp, t.client.Call("forex", "Quote", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
// the forex symbol e.g GBPUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
// the close price
|
||||
Close float64 `json:"close"`
|
||||
// the date
|
||||
Date string `json:"date"`
|
||||
// the peak price
|
||||
High float64 `json:"high"`
|
||||
// the low price
|
||||
Low float64 `json:"low"`
|
||||
// the open price
|
||||
Open float64 `json:"open"`
|
||||
// the forex symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the volume
|
||||
Volume float64 `json:"volume"`
|
||||
}
|
||||
|
||||
type PriceRequest struct {
|
||||
// forex symbol e.g GBPUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type PriceResponse struct {
|
||||
// the last price
|
||||
Price float64 `json:"price"`
|
||||
// the forex symbol e.g GBPUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteRequest struct {
|
||||
// the forex symbol e.g GBPUSD
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
// the forex symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
package function
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Function interface {
|
||||
Call(*CallRequest) (*CallResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Deploy(*DeployRequest) (*DeployResponse, error)
|
||||
Describe(*DescribeRequest) (*DescribeResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Proxy(*ProxyRequest) (*ProxyResponse, error)
|
||||
Regions(*RegionsRequest) (*RegionsResponse, error)
|
||||
Reserve(*ReserveRequest) (*ReserveResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewFunctionService(token string) *FunctionService {
|
||||
return &FunctionService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type FunctionService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Call a function by name
|
||||
func (t *FunctionService) Call(request *CallRequest) (*CallResponse, error) {
|
||||
|
||||
rsp := &CallResponse{}
|
||||
return rsp, t.client.Call("function", "Call", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a function by name
|
||||
func (t *FunctionService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("function", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Deploy a group of functions
|
||||
func (t *FunctionService) Deploy(request *DeployRequest) (*DeployResponse, error) {
|
||||
|
||||
rsp := &DeployResponse{}
|
||||
return rsp, t.client.Call("function", "Deploy", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the info for a deployed function
|
||||
func (t *FunctionService) Describe(request *DescribeRequest) (*DescribeResponse, error) {
|
||||
|
||||
rsp := &DescribeResponse{}
|
||||
return rsp, t.client.Call("function", "Describe", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all the deployed functions
|
||||
func (t *FunctionService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("function", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return the backend url for proxying
|
||||
func (t *FunctionService) Proxy(request *ProxyRequest) (*ProxyResponse, error) {
|
||||
|
||||
rsp := &ProxyResponse{}
|
||||
return rsp, t.client.Call("function", "Proxy", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return a list of supported regions
|
||||
func (t *FunctionService) Regions(request *RegionsRequest) (*RegionsResponse, error) {
|
||||
|
||||
rsp := &RegionsResponse{}
|
||||
return rsp, t.client.Call("function", "Regions", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Reserve function names and resources beyond free quota
|
||||
func (t *FunctionService) Reserve(request *ReserveRequest) (*ReserveResponse, error) {
|
||||
|
||||
rsp := &ReserveResponse{}
|
||||
return rsp, t.client.Call("function", "Reserve", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a function. Downloads the source, builds and redeploys
|
||||
func (t *FunctionService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("function", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CallRequest struct {
|
||||
// Name of the function
|
||||
Name string `json:"name"`
|
||||
// Request body that will be passed to the function
|
||||
Request map[string]interface{} `json:"request"`
|
||||
}
|
||||
|
||||
type CallResponse struct {
|
||||
// Response body that the function returned
|
||||
Response map[string]interface{} `json:"response"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// The name of the function
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type DeployRequest struct {
|
||||
// branch to deploy. defaults to master
|
||||
Branch string `json:"branch"`
|
||||
// entry point, ie. handler name in the source code
|
||||
// if not provided, defaults to the name parameter
|
||||
Entrypoint string `json:"entrypoint"`
|
||||
// environment variables to pass in at runtime
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// function name
|
||||
Name string `json:"name"`
|
||||
// region to deploy in. defaults to europe-west1
|
||||
Region string `json:"region"`
|
||||
// github url to repo
|
||||
Repo string `json:"repo"`
|
||||
// runtime/lanaguage of the function e.g php74,
|
||||
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16,
|
||||
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
||||
// python37, python38, python39
|
||||
Runtime string `json:"runtime"`
|
||||
// optional subfolder path
|
||||
Subfolder string `json:"subfolder"`
|
||||
}
|
||||
|
||||
type DeployResponse struct {
|
||||
Function *Func `json:"function"`
|
||||
}
|
||||
|
||||
type DescribeRequest struct {
|
||||
// The name of the function
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DescribeResponse struct {
|
||||
// The function requested
|
||||
Function *Func `json:"function"`
|
||||
}
|
||||
|
||||
type Func struct {
|
||||
// branch to deploy. defaults to master
|
||||
Branch string `json:"branch"`
|
||||
// time of creation
|
||||
Created string `json:"created"`
|
||||
// name of handler in source code
|
||||
Entrypoint string `json:"entrypoint"`
|
||||
// associated env vars
|
||||
EnvVars map[string]string `json:"env_vars"`
|
||||
// id of the function
|
||||
Id string `json:"id"`
|
||||
// function name
|
||||
// limitation: must be unique across projects
|
||||
Name string `json:"name"`
|
||||
// region to deploy in. defaults to europe-west1
|
||||
Region string `json:"region"`
|
||||
// git repo address
|
||||
Repo string `json:"repo"`
|
||||
// runtime/language of the function e.g php74,
|
||||
// nodejs6, nodejs8, nodejs10, nodejs12, nodejs14, nodejs16,
|
||||
// dotnet3, java11, ruby26, ruby27, go111, go113, go116,
|
||||
// python37, python38, python39
|
||||
Runtime string `json:"runtime"`
|
||||
// eg. ACTIVE, DEPLOY_IN_PROGRESS, OFFLINE etc
|
||||
Status string `json:"status"`
|
||||
// subfolder path to entrypoint
|
||||
Subfolder string `json:"subfolder"`
|
||||
// time it was updated
|
||||
Updated string `json:"updated"`
|
||||
// unique url of the function
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// List of functions deployed
|
||||
Functions []Func `json:"functions"`
|
||||
}
|
||||
|
||||
type ProxyRequest struct {
|
||||
// id of the function
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ProxyResponse struct {
|
||||
// backend url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type RegionsRequest struct {
|
||||
}
|
||||
|
||||
type RegionsResponse struct {
|
||||
Regions []string `json:"regions"`
|
||||
}
|
||||
|
||||
type Reservation struct {
|
||||
// time of reservation
|
||||
Created string `json:"created"`
|
||||
// time reservation expires
|
||||
Expires string `json:"expires"`
|
||||
// name of the app
|
||||
Name string `json:"name"`
|
||||
// owner id
|
||||
Owner string `json:"owner"`
|
||||
// associated token
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type ReserveRequest struct {
|
||||
// name of your app e.g helloworld
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ReserveResponse struct {
|
||||
// The app reservation
|
||||
Reservation *Reservation `json:"reservation"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// function name
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package geocoding
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Geocoding interface {
|
||||
Lookup(*LookupRequest) (*LookupResponse, error)
|
||||
Reverse(*ReverseRequest) (*ReverseResponse, error)
|
||||
}
|
||||
|
||||
func NewGeocodingService(token string) *GeocodingService {
|
||||
return &GeocodingService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type GeocodingService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup returns a geocoded address including normalized address and gps coordinates. All fields are optional, provide more to get more accurate results
|
||||
func (t *GeocodingService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||
|
||||
rsp := &LookupResponse{}
|
||||
return rsp, t.client.Call("geocoding", "Lookup", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Reverse lookup an address from gps coordinates
|
||||
func (t *GeocodingService) Reverse(request *ReverseRequest) (*ReverseResponse, error) {
|
||||
|
||||
rsp := &ReverseResponse{}
|
||||
return rsp, t.client.Call("geocoding", "Reverse", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
City string `json:"city"`
|
||||
Country string `json:"country"`
|
||||
LineOne string `json:"line_one"`
|
||||
LineTwo string `json:"line_two"`
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type LookupRequest struct {
|
||||
Address string `json:"address"`
|
||||
City string `json:"city"`
|
||||
Country string `json:"country"`
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
type LookupResponse struct {
|
||||
Address *Address `json:"address"`
|
||||
Location *Location `json:"location"`
|
||||
}
|
||||
|
||||
type ReverseRequest struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type ReverseResponse struct {
|
||||
Address *Address `json:"address"`
|
||||
Location *Location `json:"location"`
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package gifs
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Gifs interface {
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewGifsService(token string) *GifsService {
|
||||
return &GifsService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type GifsService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Search for a GIF
|
||||
func (t *GifsService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("gifs", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Gif struct {
|
||||
// URL used for embedding the GIF
|
||||
EmbedUrl string `json:"embed_url"`
|
||||
// The ID of the GIF
|
||||
Id string `json:"id"`
|
||||
// The different formats available for this GIF
|
||||
Images *ImageFormats `json:"images"`
|
||||
// The content rating for the GIF
|
||||
Rating string `json:"rating"`
|
||||
// A short URL for this GIF
|
||||
ShortUrl string `json:"short_url"`
|
||||
// The slug used in the GIF's URL
|
||||
Slug string `json:"slug"`
|
||||
// The page on which this GIF was found
|
||||
Source string `json:"source"`
|
||||
// The title for this GIF
|
||||
Title string `json:"title"`
|
||||
// The URL for this GIF
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type ImageFormat struct {
|
||||
// height
|
||||
Height int32 `json:"height"`
|
||||
// size of the MP4 version
|
||||
Mp4Size int32 `json:"mp4_size"`
|
||||
// URL to an MP4 version of the gif
|
||||
Mp4Url string `json:"mp4_url"`
|
||||
// size in bytes
|
||||
Size int32 `json:"size"`
|
||||
// URL of the gif
|
||||
Url string `json:"url"`
|
||||
// size of the webp version
|
||||
WebpSize int32 `json:"webp_size"`
|
||||
// URL to a webp version of the gif
|
||||
WebpUrl string `json:"webp_url"`
|
||||
// width
|
||||
Width int32 `json:"width"`
|
||||
}
|
||||
|
||||
type ImageFormats struct {
|
||||
// A downsized version of the GIF < 2MB
|
||||
Downsized *ImageFormat `json:"downsized"`
|
||||
// A downsized version of the GIF < 8MB
|
||||
DownsizedLarge *ImageFormat `json:"downsized_large"`
|
||||
// A downsized version of the GIF < 5MB
|
||||
DownsizedMedium *ImageFormat `json:"downsized_medium"`
|
||||
// A downsized version of the GIF < 200kb
|
||||
DownsizedSmall *ImageFormat `json:"downsized_small"`
|
||||
// Static image of the downsized version of the GIF
|
||||
DownsizedStill *ImageFormat `json:"downsized_still"`
|
||||
// Version of the GIF with fixed height of 200 pixels. Good for mobile use
|
||||
FixedHeight *ImageFormat `json:"fixed_height"`
|
||||
// Version of the GIF with fixed height of 200 pixels and number of frames reduced to 6
|
||||
FixedHeightDownsampled *ImageFormat `json:"fixed_height_downsampled"`
|
||||
// Version of the GIF with fixed height of 100 pixels. Good for mobile keyboards
|
||||
FixedHeightSmall *ImageFormat `json:"fixed_height_small"`
|
||||
// Static image of the GIF with fixed height of 100 pixels
|
||||
FixedHeightSmallStill *ImageFormat `json:"fixed_height_small_still"`
|
||||
// Static image of the GIF with fixed height of 200 pixels
|
||||
FixedHeightStill *ImageFormat `json:"fixed_height_still"`
|
||||
// Version of the GIF with fixed width of 200 pixels. Good for mobile use
|
||||
FixedWidth *ImageFormat `json:"fixed_width"`
|
||||
// Version of the GIF with fixed width of 200 pixels and number of frames reduced to 6
|
||||
FixedWidthDownsampled *ImageFormat `json:"fixed_width_downsampled"`
|
||||
// Version of the GIF with fixed width of 100 pixels. Good for mobile keyboards
|
||||
FixedWidthSmall *ImageFormat `json:"fixed_width_small"`
|
||||
// Static image of the GIF with fixed width of 100 pixels
|
||||
FixedWidthSmallStill *ImageFormat `json:"fixed_width_small_still"`
|
||||
// Static image of the GIF with fixed width of 200 pixels
|
||||
FixedWidthStill *ImageFormat `json:"fixed_width_still"`
|
||||
// 15 second version of the GIF looping
|
||||
Looping *ImageFormat `json:"looping"`
|
||||
// The original GIF. Good for desktop use
|
||||
Original *ImageFormat `json:"original"`
|
||||
// Static image of the original version of the GIF
|
||||
OriginalStill *ImageFormat `json:"original_still"`
|
||||
// mp4 version of the GIF <50kb displaying first 1-2 secs
|
||||
Preview *ImageFormat `json:"preview"`
|
||||
// Version of the GIF <50kb displaying first 1-2 secs
|
||||
PreviewGif *ImageFormat `json:"preview_gif"`
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
// total number returned in this response
|
||||
Count int32 `json:"count"`
|
||||
// position in pagination
|
||||
Offset int32 `json:"offset"`
|
||||
// total number of results available
|
||||
TotalCount int32 `json:"total_count"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// ISO 2 letter language code for regional content
|
||||
Lang string `json:"lang"`
|
||||
// Max number of gifs to return. Defaults to 25
|
||||
Limit int32 `json:"limit"`
|
||||
// The start position of results (used with pagination)
|
||||
Offset int32 `json:"offset"`
|
||||
// The search term
|
||||
Query string `json:"query"`
|
||||
// Apply age related content filter. "g", "pg", "pg-13", or "r". Defaults to "g"
|
||||
Rating string `json:"rating"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// list of results
|
||||
Data []Gif `json:"data"`
|
||||
// information on pagination
|
||||
Pagination *Pagination `json:"pagination"`
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package google
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Google interface {
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewGoogleService(token string) *GoogleService {
|
||||
return &GoogleService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type GoogleService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Search for videos on Google
|
||||
func (t *GoogleService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("google", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Query to search for
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// List of results for the query
|
||||
Results []SearchResult `json:"results"`
|
||||
}
|
||||
|
||||
type SearchResult struct {
|
||||
// abridged version of this search result’s URL, e.g. www.exampe.com
|
||||
DisplayUrl string `json:"display_url"`
|
||||
// id of the result
|
||||
Id string `json:"id"`
|
||||
// kind of result; "search"
|
||||
Kind string `json:"kind"`
|
||||
// the result snippet
|
||||
Snippet string `json:"snippet"`
|
||||
// title of the result
|
||||
Title string `json:"title"`
|
||||
// the full url for the result
|
||||
Url string `json:"url"`
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package helloworld
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Helloworld interface {
|
||||
Call(*CallRequest) (*CallResponse, error)
|
||||
Stream(*StreamRequest) (*StreamResponseStream, error)
|
||||
}
|
||||
|
||||
func NewHelloworldService(token string) *HelloworldService {
|
||||
return &HelloworldService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type HelloworldService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Call returns a personalised "Hello $name" response
|
||||
func (t *HelloworldService) Call(request *CallRequest) (*CallResponse, error) {
|
||||
|
||||
rsp := &CallResponse{}
|
||||
return rsp, t.client.Call("helloworld", "Call", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Stream returns a stream of "Hello $name" responses
|
||||
func (t *HelloworldService) Stream(request *StreamRequest) (*StreamResponseStream, error) {
|
||||
stream, err := t.client.Stream("helloworld", "Stream", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &StreamResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type StreamResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *StreamResponseStream) Recv() (*StreamResponse, error) {
|
||||
var rsp StreamResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
type CallRequest struct {
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type CallResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
type StreamRequest struct {
|
||||
// the number of messages to send back
|
||||
Messages int64 `json:"messages,string"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type StreamResponse struct {
|
||||
Message string `json:"message"`
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package holidays
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Holidays interface {
|
||||
Countries(*CountriesRequest) (*CountriesResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
}
|
||||
|
||||
func NewHolidaysService(token string) *HolidaysService {
|
||||
return &HolidaysService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type HolidaysService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the list of countries that are supported by this API
|
||||
func (t *HolidaysService) Countries(request *CountriesRequest) (*CountriesResponse, error) {
|
||||
|
||||
rsp := &CountriesResponse{}
|
||||
return rsp, t.client.Call("holidays", "Countries", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List the holiday dates for a given country and year
|
||||
func (t *HolidaysService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("holidays", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CountriesRequest struct {
|
||||
}
|
||||
|
||||
type CountriesResponse struct {
|
||||
Countries []Country `json:"countries"`
|
||||
}
|
||||
|
||||
type Country struct {
|
||||
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||
Code string `json:"code"`
|
||||
// The English name of the country
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type Holiday struct {
|
||||
// the country this holiday occurs in
|
||||
CountryCode string `json:"country_code"`
|
||||
// date of the holiday in yyyy-mm-dd format
|
||||
Date string `json:"date"`
|
||||
// the local name of the holiday
|
||||
LocalName string `json:"local_name"`
|
||||
// the name of the holiday in English
|
||||
Name string `json:"name"`
|
||||
// the regions within the country that observe this holiday (if not all of them)
|
||||
Regions []string `json:"regions"`
|
||||
// the type of holiday Public, Bank, School, Authorities, Optional, Observance
|
||||
Types []string `json:"types"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// The 2 letter country code (as defined in ISO 3166-1 alpha-2)
|
||||
CountryCode string `json:"country_code"`
|
||||
// The year to list holidays for
|
||||
Year int64 `json:"year,string"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Holidays []Holiday `json:"holidays"`
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package id
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Id interface {
|
||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||
Types(*TypesRequest) (*TypesResponse, error)
|
||||
}
|
||||
|
||||
func NewIdService(token string) *IdService {
|
||||
return &IdService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type IdService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Generate a unique ID. Defaults to uuid.
|
||||
func (t *IdService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
return rsp, t.client.Call("id", "Generate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List the types of IDs available. No query params needed.
|
||||
func (t *IdService) Types(request *TypesRequest) (*TypesResponse, error) {
|
||||
|
||||
rsp := &TypesResponse{}
|
||||
return rsp, t.client.Call("id", "Types", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// type of id e.g uuid, shortid, snowflake (64 bit), bigflake (128 bit)
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// the unique id generated
|
||||
Id string `json:"id"`
|
||||
// the type of id generated
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type TypesRequest struct {
|
||||
}
|
||||
|
||||
type TypesResponse struct {
|
||||
Types []string `json:"types"`
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Image interface {
|
||||
Convert(*ConvertRequest) (*ConvertResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Resize(*ResizeRequest) (*ResizeResponse, error)
|
||||
Upload(*UploadRequest) (*UploadResponse, error)
|
||||
}
|
||||
|
||||
func NewImageService(token string) *ImageService {
|
||||
return &ImageService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ImageService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Convert an image from one format (jpeg, png etc.) to an other either on the fly (from base64 to base64),
|
||||
// or by uploading the conversion result.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Convert(request *ConvertRequest) (*ConvertResponse, error) {
|
||||
|
||||
rsp := &ConvertResponse{}
|
||||
return rsp, t.client.Call("image", "Convert", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete an image previously uploaded.
|
||||
func (t *ImageService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("image", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Resize an image on the fly without storing it (by sending and receiving a base64 encoded image), or resize and upload depending on parameters.
|
||||
// If one of width or height is 0, the image aspect ratio is preserved.
|
||||
// Optional cropping.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Resize(request *ResizeRequest) (*ResizeResponse, error) {
|
||||
|
||||
rsp := &ResizeResponse{}
|
||||
return rsp, t.client.Call("image", "Resize", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Upload an image by either sending a base64 encoded image to this endpoint or a URL.
|
||||
// To resize an image before uploading, see the Resize endpoint.
|
||||
// To use the file parameter you need to send the request as a multipart/form-data rather than the usual application/json
|
||||
// with each parameter as a form field.
|
||||
func (t *ImageService) Upload(request *UploadRequest) (*UploadResponse, error) {
|
||||
|
||||
rsp := &UploadResponse{}
|
||||
return rsp, t.client.Call("image", "Upload", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ConvertRequest struct {
|
||||
// base64 encoded image to resize,
|
||||
Base64 string `json:"base64"`
|
||||
// The image file to convert
|
||||
File string `json:"file"`
|
||||
// output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// make output a URL and not a base64 response
|
||||
OutputUrl bool `json:"outputURL"`
|
||||
// url of the image to resize
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type ConvertResponse struct {
|
||||
Base64 string `json:"base64"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type CropOptions struct {
|
||||
// Crop anchor point: "top", "top left", "top right",
|
||||
// "left", "center", "right"
|
||||
// "bottom left", "bottom", "bottom right".
|
||||
// Optional. Defaults to center.
|
||||
Anchor string `json:"anchor"`
|
||||
// height to crop to
|
||||
Height int32 `json:"height"`
|
||||
// width to crop to
|
||||
Width int32 `json:"width"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// url of the image to delete e.g. https://cdn.m3ocontent.com/micro/images/micro/41e23b39-48dd-42b6-9738-79a313414bb8/cat.jpeg
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
X int32 `json:"x"`
|
||||
Y int32 `json:"y"`
|
||||
}
|
||||
|
||||
type Rectangle struct {
|
||||
Max *Point `json:"max"`
|
||||
Min *Point `json:"min"`
|
||||
}
|
||||
|
||||
type ResizeRequest struct {
|
||||
// base64 encoded image to resize,
|
||||
Base64 string `json:"base64"`
|
||||
// optional crop options
|
||||
// if provided, after resize, the image
|
||||
// will be cropped
|
||||
CropOptions *CropOptions `json:"cropOptions"`
|
||||
// The image file to resize
|
||||
File string `json:"file"`
|
||||
Height int64 `json:"height,string"`
|
||||
// output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// make output a URL and not a base64 response
|
||||
OutputUrl bool `json:"outputURL"`
|
||||
// url of the image to resize
|
||||
Url string `json:"url"`
|
||||
Width int64 `json:"width,string"`
|
||||
}
|
||||
|
||||
type ResizeResponse struct {
|
||||
Base64 string `json:"base64"`
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type UploadRequest struct {
|
||||
// Base64 encoded image to upload,
|
||||
Base64 string `json:"base64"`
|
||||
// The image file to upload
|
||||
File string `json:"file"`
|
||||
// Output name of the image including extension, ie. "cat.png"
|
||||
Name string `json:"name"`
|
||||
// URL of the image to upload
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type UploadResponse struct {
|
||||
Url string `json:"url"`
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package ip
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Ip interface {
|
||||
Lookup(*LookupRequest) (*LookupResponse, error)
|
||||
}
|
||||
|
||||
func NewIpService(token string) *IpService {
|
||||
return &IpService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type IpService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup the geolocation information for an IP address
|
||||
func (t *IpService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||
|
||||
rsp := &LookupResponse{}
|
||||
return rsp, t.client.Call("ip", "Lookup", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type LookupRequest struct {
|
||||
// IP to lookup
|
||||
Ip string `json:"ip"`
|
||||
}
|
||||
|
||||
type LookupResponse struct {
|
||||
// Autonomous system number
|
||||
Asn int32 `json:"asn"`
|
||||
// Name of the city
|
||||
City string `json:"city"`
|
||||
// Name of the continent
|
||||
Continent string `json:"continent"`
|
||||
// Name of the country
|
||||
Country string `json:"country"`
|
||||
// IP of the query
|
||||
Ip string `json:"ip"`
|
||||
// Latitude e.g 52.523219
|
||||
Latitude float64 `json:"latitude"`
|
||||
// Longitude e.g 13.428555
|
||||
Longitude float64 `json:"longitude"`
|
||||
// Timezone e.g Europe/Rome
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package joke
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Joke interface {
|
||||
Random(*RandomRequest) (*RandomResponse, error)
|
||||
}
|
||||
|
||||
func NewJokeService(token string) *JokeService {
|
||||
return &JokeService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type JokeService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get a random joke
|
||||
func (t *JokeService) Random(request *RandomRequest) (*RandomResponse, error) {
|
||||
|
||||
rsp := &RandomResponse{}
|
||||
return rsp, t.client.Call("joke", "Random", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type JokeInfo struct {
|
||||
Body string `json:"body"`
|
||||
Category string `json:"category"`
|
||||
Id string `json:"id"`
|
||||
Source string `json:"source"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type RandomRequest struct {
|
||||
// the count of random jokes want, maximum: 10
|
||||
Count int32 `json:"count"`
|
||||
}
|
||||
|
||||
type RandomResponse struct {
|
||||
Jokes []JokeInfo `json:"jokes"`
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package location
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Location interface {
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Save(*SaveRequest) (*SaveResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewLocationService(token string) *LocationService {
|
||||
return &LocationService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type LocationService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Read an entity by its ID
|
||||
func (t *LocationService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("location", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Save an entity's current position
|
||||
func (t *LocationService) Save(request *SaveRequest) (*SaveResponse, error) {
|
||||
|
||||
rsp := &SaveResponse{}
|
||||
return rsp, t.client.Call("location", "Save", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search for entities in a given radius
|
||||
func (t *LocationService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("location", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Entity struct {
|
||||
Id string `json:"id"`
|
||||
Location *Point `json:"location"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Timestamp int64 `json:"timestamp,string"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// the entity id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
Entity *Entity `json:"entity"`
|
||||
}
|
||||
|
||||
type SaveRequest struct {
|
||||
Entity *Entity `json:"entity"`
|
||||
}
|
||||
|
||||
type SaveResponse struct {
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Central position to search from
|
||||
Center *Point `json:"center"`
|
||||
// Maximum number of entities to return
|
||||
NumEntities int64 `json:"numEntities,string"`
|
||||
// radius in meters
|
||||
Radius float64 `json:"radius"`
|
||||
// type of entities to filter
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
Entities []Entity `json:"entities"`
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package minecraft
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Minecraft interface {
|
||||
Ping(*PingRequest) (*PingResponse, error)
|
||||
}
|
||||
|
||||
func NewMinecraftService(token string) *MinecraftService {
|
||||
return &MinecraftService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type MinecraftService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Ping a minecraft server
|
||||
func (t *MinecraftService) Ping(request *PingRequest) (*PingResponse, error) {
|
||||
|
||||
rsp := &PingResponse{}
|
||||
return rsp, t.client.Call("minecraft", "Ping", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type PingRequest struct {
|
||||
// address of the server
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type PingResponse struct {
|
||||
// Favicon in base64
|
||||
Favicon string `json:"favicon"`
|
||||
// Latency (ms) between us and the server (EU)
|
||||
Latency int32 `json:"latency"`
|
||||
// Max players ever
|
||||
MaxPlayers int32 `json:"max_players"`
|
||||
// Message of the day
|
||||
Motd string `json:"motd"`
|
||||
// Number of players online
|
||||
Players int32 `json:"players"`
|
||||
// Protocol number of the server
|
||||
Protocol int32 `json:"protocol"`
|
||||
// List of connected players
|
||||
Sample []PlayerSample `json:"sample"`
|
||||
// Version of the server
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
type PlayerSample struct {
|
||||
// name of the player
|
||||
Name string `json:"name"`
|
||||
// unique id of player
|
||||
Uuid string `json:"uuid"`
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
package movie
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Movie interface {
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewMovieService(token string) *MovieService {
|
||||
return &MovieService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type MovieService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Search for movies by simple text search
|
||||
func (t *MovieService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("movie", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type MovieInfo struct {
|
||||
Adult bool `json:"adult"`
|
||||
BackdropPath string `json:"backdrop_path"`
|
||||
GenreIds int32 `json:"genre_ids"`
|
||||
Id int32 `json:"id"`
|
||||
OriginalLanguage string `json:"original_language"`
|
||||
OriginalTitle string `json:"original_title"`
|
||||
Overview string `json:"overview"`
|
||||
Popularity float64 `json:"popularity"`
|
||||
PosterPath string `json:"poster_path"`
|
||||
ReleaseDate string `json:"release_date"`
|
||||
Title string `json:"title"`
|
||||
Video bool `json:"video"`
|
||||
VoteAverage float64 `json:"vote_average"`
|
||||
VoteCount int32 `json:"vote_count"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// a ISO 639-1 value to display translated data
|
||||
Language string `json:"language"`
|
||||
// page to query
|
||||
Page int32 `json:"page"`
|
||||
// year of release
|
||||
PrimaryReleaseYear int32 `json:"primary_release_year"`
|
||||
// a text query to search
|
||||
Query string `json:"query"`
|
||||
// a ISO 3166-1 code to filter release dates.
|
||||
Region string `json:"region"`
|
||||
// year of making
|
||||
Year int32 `json:"year"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
Page int32 `json:"page"`
|
||||
Results []MovieInfo `json:"results"`
|
||||
TotalPages int32 `json:"total_pages"`
|
||||
TotalResults int32 `json:"total_results"`
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
package mq
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Mq interface {
|
||||
Publish(*PublishRequest) (*PublishResponse, error)
|
||||
Subscribe(*SubscribeRequest) (*SubscribeResponseStream, error)
|
||||
}
|
||||
|
||||
func NewMqService(token string) *MqService {
|
||||
return &MqService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type MqService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Publish a message. Specify a topic to group messages for a specific topic.
|
||||
func (t *MqService) Publish(request *PublishRequest) (*PublishResponse, error) {
|
||||
|
||||
rsp := &PublishResponse{}
|
||||
return rsp, t.client.Call("mq", "Publish", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Subscribe to messages for a given topic.
|
||||
func (t *MqService) Subscribe(request *SubscribeRequest) (*SubscribeResponseStream, error) {
|
||||
stream, err := t.client.Stream("mq", "Subscribe", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &SubscribeResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type SubscribeResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *SubscribeResponseStream) Recv() (*SubscribeResponse, error) {
|
||||
var rsp SubscribeResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
type PublishRequest struct {
|
||||
// The json message to publish
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic to publish to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type PublishResponse struct {
|
||||
}
|
||||
|
||||
type SubscribeRequest struct {
|
||||
// The topic to subscribe to
|
||||
Topic string `json:"topic"`
|
||||
}
|
||||
|
||||
type SubscribeResponse struct {
|
||||
// The next json message on the topic
|
||||
Message map[string]interface{} `json:"message"`
|
||||
// The topic subscribed to
|
||||
Topic string `json:"topic"`
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package news
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type News interface {
|
||||
Headlines(*HeadlinesRequest) (*HeadlinesResponse, error)
|
||||
}
|
||||
|
||||
func NewNewsService(token string) *NewsService {
|
||||
return &NewsService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type NewsService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the latest news headlines
|
||||
func (t *NewsService) Headlines(request *HeadlinesRequest) (*HeadlinesResponse, error) {
|
||||
|
||||
rsp := &HeadlinesResponse{}
|
||||
return rsp, t.client.Call("news", "Headlines", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Article struct {
|
||||
// categories
|
||||
Categories []string `json:"categories"`
|
||||
// article description
|
||||
Description string `json:"description"`
|
||||
// article id
|
||||
Id string `json:"id"`
|
||||
// image url
|
||||
ImageUrl string `json:"image_url"`
|
||||
// related keywords
|
||||
Keywords string `json:"keywords"`
|
||||
// the article language
|
||||
Language string `json:"language"`
|
||||
// the locale
|
||||
Locale string `json:"locale"`
|
||||
// time it was published
|
||||
PublishedAt string `json:"published_at"`
|
||||
// first 60 characters of article body
|
||||
Snippet string `json:"snippet"`
|
||||
// source of news
|
||||
Source string `json:"source"`
|
||||
// article title
|
||||
Title string `json:"title"`
|
||||
// url of the article
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type HeadlinesRequest struct {
|
||||
// date published on in YYYY-MM-DD format
|
||||
Date string `json:"date"`
|
||||
// comma separated list of languages to retrieve in e.g en,es
|
||||
Language string `json:"language"`
|
||||
// comma separated list of countries to include e.g us,ca
|
||||
Locale string `json:"locale"`
|
||||
}
|
||||
|
||||
type HeadlinesResponse struct {
|
||||
Articles []Article `json:"articles"`
|
||||
}
|
@ -1,192 +0,0 @@
|
||||
package nft
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Nft interface {
|
||||
Assets(*AssetsRequest) (*AssetsResponse, error)
|
||||
Collections(*CollectionsRequest) (*CollectionsResponse, error)
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
}
|
||||
|
||||
func NewNftService(token string) *NftService {
|
||||
return &NftService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type NftService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Return a list of assets
|
||||
func (t *NftService) Assets(request *AssetsRequest) (*AssetsResponse, error) {
|
||||
|
||||
rsp := &AssetsResponse{}
|
||||
return rsp, t.client.Call("nft", "Assets", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get a list of collections
|
||||
func (t *NftService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
||||
|
||||
rsp := &CollectionsResponse{}
|
||||
return rsp, t.client.Call("nft", "Collections", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Create your own NFT (coming soon)
|
||||
func (t *NftService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("nft", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Asset struct {
|
||||
// associated collection
|
||||
Collection *Collection `json:"collection"`
|
||||
// asset contract
|
||||
Contract *Contract `json:"contract"`
|
||||
// Creator of the NFT
|
||||
Creator *User `json:"creator"`
|
||||
// related description
|
||||
Description string `json:"description"`
|
||||
// id of the asset
|
||||
Id int32 `json:"id"`
|
||||
// the image url
|
||||
ImageUrl string `json:"image_url"`
|
||||
// last time sold
|
||||
LastSale *Sale `json:"last_sale"`
|
||||
// listing date
|
||||
ListingDate string `json:"listing_date"`
|
||||
// name of the asset
|
||||
Name string `json:"name"`
|
||||
// Owner of the NFT
|
||||
Owner *User `json:"owner"`
|
||||
// the permalink
|
||||
Permalink string `json:"permalink"`
|
||||
// is it a presale
|
||||
Presale bool `json:"presale"`
|
||||
// number of sales
|
||||
Sales int32 `json:"sales"`
|
||||
// the token id
|
||||
TokenId string `json:"token_id"`
|
||||
}
|
||||
|
||||
type AssetsRequest struct {
|
||||
// limit to members of a collection by slug name (case sensitive)
|
||||
Collection string `json:"collection"`
|
||||
// limit returned assets
|
||||
Limit int32 `json:"limit"`
|
||||
// offset for pagination
|
||||
Offset int32 `json:"offset"`
|
||||
// order "asc" or "desc"
|
||||
Order string `json:"order"`
|
||||
// order by "sale_date", "sale_count", "sale_price", "total_price"
|
||||
OrderBy string `json:"order_by"`
|
||||
}
|
||||
|
||||
type AssetsResponse struct {
|
||||
// list of assets
|
||||
Assets []Asset `json:"assets"`
|
||||
}
|
||||
|
||||
type Collection struct {
|
||||
CreatedAt string `json:"created_at"`
|
||||
Description string `json:"description"`
|
||||
ImageUrl string `json:"image_url"`
|
||||
Name string `json:"name"`
|
||||
PayoutAddress string `json:"payout_address"`
|
||||
Slug string `json:"slug"`
|
||||
}
|
||||
|
||||
type CollectionsRequest struct {
|
||||
Limit int32 `json:"limit"`
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
type CollectionsResponse struct {
|
||||
Collections []Collection `json:"collections"`
|
||||
}
|
||||
|
||||
type Contract struct {
|
||||
// ethereum address
|
||||
Address string `json:"address"`
|
||||
// timestamp of creation
|
||||
CreatedAt string `json:"created_at"`
|
||||
// description of contract
|
||||
Description string `json:"description"`
|
||||
// name of contract
|
||||
Name string `json:"name"`
|
||||
// owner id
|
||||
Owner int32 `json:"owner"`
|
||||
// payout address
|
||||
PayoutAddress string `json:"payout_address"`
|
||||
// aka "ERC1155"
|
||||
Schema string `json:"schema"`
|
||||
// seller fees
|
||||
SellerFees string `json:"seller_fees"`
|
||||
// related symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// type of contract e.g "semi-fungible"
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// data if not image
|
||||
Data string `json:"data"`
|
||||
// description
|
||||
Description string `json:"description"`
|
||||
// image data
|
||||
Image string `json:"image"`
|
||||
// name of the NFT
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
Asset *Asset `json:"asset"`
|
||||
}
|
||||
|
||||
type Sale struct {
|
||||
AssetDecimals int32 `json:"asset_decimals"`
|
||||
AssetTokenId string `json:"asset_token_id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
EventTimestamp string `json:"event_timestamp"`
|
||||
EventType string `json:"event_type"`
|
||||
PaymentToken *Token `json:"payment_token"`
|
||||
Quantity string `json:"quantity"`
|
||||
TotalPrice string `json:"total_price"`
|
||||
Transaction *Transaction `json:"transaction"`
|
||||
}
|
||||
|
||||
type Token struct {
|
||||
Address string `json:"address"`
|
||||
Decimals int32 `json:"decimals"`
|
||||
EthPrice string `json:"eth_price"`
|
||||
Id int32 `json:"id"`
|
||||
ImageUrl string `json:"image_url"`
|
||||
Name string `json:"name"`
|
||||
Symbol string `json:"symbol"`
|
||||
UsdPrice string `json:"usd_price"`
|
||||
}
|
||||
|
||||
type Transaction struct {
|
||||
BlockHash string `json:"block_hash"`
|
||||
BlockNumber string `json:"block_number"`
|
||||
FromAccount *User `json:"from_account"`
|
||||
Id int32 `json:"id"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
ToAccount *User `json:"to_account"`
|
||||
TransactionHash string `json:"transaction_hash"`
|
||||
TransactionIndex string `json:"transaction_index"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Address string `json:"address"`
|
||||
ProfileUrl string `json:"profile_url"`
|
||||
Username string `json:"username"`
|
||||
}
|
@ -1,162 +0,0 @@
|
||||
package notes
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Notes interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Events(*EventsRequest) (*EventsResponseStream, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
}
|
||||
|
||||
func NewNotesService(token string) *NotesService {
|
||||
return &NotesService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type NotesService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a new note
|
||||
func (t *NotesService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("notes", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a note
|
||||
func (t *NotesService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("notes", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Subscribe to notes events
|
||||
func (t *NotesService) Events(request *EventsRequest) (*EventsResponseStream, error) {
|
||||
stream, err := t.client.Stream("notes", "Events", request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &EventsResponseStream{
|
||||
stream: stream,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
type EventsResponseStream struct {
|
||||
stream *client.Stream
|
||||
}
|
||||
|
||||
func (t *EventsResponseStream) Recv() (*EventsResponse, error) {
|
||||
var rsp EventsResponse
|
||||
if err := t.stream.Recv(&rsp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &rsp, nil
|
||||
}
|
||||
|
||||
// List all the notes
|
||||
func (t *NotesService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("notes", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read a note
|
||||
func (t *NotesService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("notes", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update a note
|
||||
func (t *NotesService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("notes", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// note text
|
||||
Text string `json:"text"`
|
||||
// note title
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// The created note
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// specify the id of the note
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type EventsRequest struct {
|
||||
// optionally specify a note id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type EventsResponse struct {
|
||||
// the event which occured; create, delete, update
|
||||
Event string `json:"event"`
|
||||
// the note which the operation occured on
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
// the list of notes
|
||||
Notes []Note `json:"notes"`
|
||||
}
|
||||
|
||||
type Note struct {
|
||||
// time at which the note was created
|
||||
Created string `json:"created"`
|
||||
// unique id for the note, generated if not specified
|
||||
Id string `json:"id"`
|
||||
// text within the note
|
||||
Text string `json:"text"`
|
||||
// title of the note
|
||||
Title string `json:"title"`
|
||||
// time at which the note was updated
|
||||
Updated string `json:"updated"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// the note id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// The note
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
Note *Note `json:"note"`
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package otp
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Otp interface {
|
||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||
Validate(*ValidateRequest) (*ValidateResponse, error)
|
||||
}
|
||||
|
||||
func NewOtpService(token string) *OtpService {
|
||||
return &OtpService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type OtpService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Generate an OTP (one time pass) code
|
||||
func (t *OtpService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
return rsp, t.client.Call("otp", "Generate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Validate the OTP code
|
||||
func (t *OtpService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
|
||||
|
||||
rsp := &ValidateResponse{}
|
||||
return rsp, t.client.Call("otp", "Validate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// expiration in seconds (default: 60)
|
||||
Expiry int64 `json:"expiry,string"`
|
||||
// unique id, email or user to generate an OTP for
|
||||
Id string `json:"id"`
|
||||
// number of characters (default: 6)
|
||||
Size int64 `json:"size,string"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// one time pass code
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
// one time pass code to validate
|
||||
Code string `json:"code"`
|
||||
// unique id, email or user for which the code was generated
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type ValidateResponse struct {
|
||||
// returns true if the code is valid for the ID
|
||||
Success bool `json:"success"`
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package ping
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Ping interface {
|
||||
Ip(*IpRequest) (*IpResponse, error)
|
||||
Tcp(*TcpRequest) (*TcpResponse, error)
|
||||
Url(*UrlRequest) (*UrlResponse, error)
|
||||
}
|
||||
|
||||
func NewPingService(token string) *PingService {
|
||||
return &PingService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PingService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Ping an IP address
|
||||
func (t *PingService) Ip(request *IpRequest) (*IpResponse, error) {
|
||||
|
||||
rsp := &IpResponse{}
|
||||
return rsp, t.client.Call("ping", "Ip", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Ping a TCP port is open
|
||||
func (t *PingService) Tcp(request *TcpRequest) (*TcpResponse, error) {
|
||||
|
||||
rsp := &TcpResponse{}
|
||||
return rsp, t.client.Call("ping", "Tcp", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Ping a HTTP URL
|
||||
func (t *PingService) Url(request *UrlRequest) (*UrlResponse, error) {
|
||||
|
||||
rsp := &UrlResponse{}
|
||||
return rsp, t.client.Call("ping", "Url", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type IpRequest struct {
|
||||
// address to ping
|
||||
Address string `json:"address"`
|
||||
}
|
||||
|
||||
type IpResponse struct {
|
||||
// average latency e.g 10ms
|
||||
Latency string `json:"latency"`
|
||||
// response status
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type TcpRequest struct {
|
||||
// address to dial
|
||||
Address string `json:"address"`
|
||||
// optional data to send
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type TcpResponse struct {
|
||||
// response data if any
|
||||
Data string `json:"data"`
|
||||
// response status
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
type UrlRequest struct {
|
||||
// address to use
|
||||
Address string `json:"address"`
|
||||
// method of the call
|
||||
Method string `json:"method"`
|
||||
}
|
||||
|
||||
type UrlResponse struct {
|
||||
// the response code
|
||||
Code int32 `json:"code"`
|
||||
// the response status
|
||||
Status string `json:"status"`
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package place
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Place interface {
|
||||
Nearby(*NearbyRequest) (*NearbyResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewPlaceService(token string) *PlaceService {
|
||||
return &PlaceService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PlaceService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Find places nearby using a location
|
||||
func (t *PlaceService) Nearby(request *NearbyRequest) (*NearbyResponse, error) {
|
||||
|
||||
rsp := &NearbyResponse{}
|
||||
return rsp, t.client.Call("place", "Nearby", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search for places by text query
|
||||
func (t *PlaceService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("place", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type AutocompleteRequest struct {
|
||||
}
|
||||
|
||||
type AutocompleteResponse struct {
|
||||
}
|
||||
|
||||
type NearbyRequest struct {
|
||||
// Keyword to include in the search
|
||||
Keyword string `json:"keyword"`
|
||||
// specify the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
Location string `json:"location"`
|
||||
// Name of the place to search for
|
||||
Name string `json:"name"`
|
||||
// Whether the place is open now
|
||||
OpenNow bool `json:"open_now"`
|
||||
// radius in meters within which to search
|
||||
Radius int32 `json:"radius"`
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type NearbyResponse struct {
|
||||
Results []Result `json:"results"`
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
// address of place
|
||||
Address string `json:"address"`
|
||||
// url of an icon
|
||||
IconUrl string `json:"icon_url"`
|
||||
// lat/lng of place
|
||||
Location string `json:"location"`
|
||||
// name of the place
|
||||
Name string `json:"name"`
|
||||
// open now
|
||||
OpenNow bool `json:"open_now"`
|
||||
// opening hours
|
||||
OpeningHours string `json:"opening_hours"`
|
||||
// rating from 1.0 to 5.0
|
||||
Rating float64 `json:"rating"`
|
||||
// type of location
|
||||
Type string `json:"type"`
|
||||
// feature types
|
||||
Types []string `json:"types"`
|
||||
// simplified address
|
||||
Vicinity string `json:"vicinity"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// the location by lat,lng e.g -33.8670522,-151.1957362
|
||||
Location string `json:"location"`
|
||||
// Whether the place is open now
|
||||
OpenNow bool `json:"open_now"`
|
||||
// the text string on which to search, for example: "restaurant"
|
||||
Query string `json:"query"`
|
||||
// radius in meters within which to search
|
||||
Radius int32 `json:"radius"`
|
||||
// Type of place. https://developers.google.com/maps/documentation/places/web-service/supported_types
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
Results []Result `json:"results"`
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
package postcode
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Postcode interface {
|
||||
Lookup(*LookupRequest) (*LookupResponse, error)
|
||||
Random(*RandomRequest) (*RandomResponse, error)
|
||||
Validate(*ValidateRequest) (*ValidateResponse, error)
|
||||
}
|
||||
|
||||
func NewPostcodeService(token string) *PostcodeService {
|
||||
return &PostcodeService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PostcodeService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup a postcode to retrieve the related region, county, etc
|
||||
func (t *PostcodeService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||
|
||||
rsp := &LookupResponse{}
|
||||
return rsp, t.client.Call("postcode", "Lookup", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Return a random postcode and its related info
|
||||
func (t *PostcodeService) Random(request *RandomRequest) (*RandomResponse, error) {
|
||||
|
||||
rsp := &RandomResponse{}
|
||||
return rsp, t.client.Call("postcode", "Random", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Validate a postcode.
|
||||
func (t *PostcodeService) Validate(request *ValidateRequest) (*ValidateResponse, error) {
|
||||
|
||||
rsp := &ValidateResponse{}
|
||||
return rsp, t.client.Call("postcode", "Validate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type LookupRequest struct {
|
||||
// UK postcode e.g SW1A 2AA
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
type LookupResponse struct {
|
||||
// country e.g United Kingdom
|
||||
Country string `json:"country"`
|
||||
// e.g Westminster
|
||||
District string `json:"district"`
|
||||
// e.g 51.50354
|
||||
Latitude float64 `json:"latitude"`
|
||||
// e.g -0.127695
|
||||
Longitude float64 `json:"longitude"`
|
||||
// UK postcode e.g SW1A 2AA
|
||||
Postcode string `json:"postcode"`
|
||||
// related region e.g London
|
||||
Region string `json:"region"`
|
||||
// e.g St James's
|
||||
Ward string `json:"ward"`
|
||||
}
|
||||
|
||||
type RandomRequest struct {
|
||||
}
|
||||
|
||||
type RandomResponse struct {
|
||||
// country e.g United Kingdom
|
||||
Country string `json:"country"`
|
||||
// e.g Westminster
|
||||
District string `json:"district"`
|
||||
// e.g 51.50354
|
||||
Latitude float64 `json:"latitude"`
|
||||
// e.g -0.127695
|
||||
Longitude float64 `json:"longitude"`
|
||||
// UK postcode e.g SW1A 2AA
|
||||
Postcode string `json:"postcode"`
|
||||
// related region e.g London
|
||||
Region string `json:"region"`
|
||||
// e.g St James's
|
||||
Ward string `json:"ward"`
|
||||
}
|
||||
|
||||
type ValidateRequest struct {
|
||||
// UK postcode e.g SW1A 2AA
|
||||
Postcode string `json:"postcode"`
|
||||
}
|
||||
|
||||
type ValidateResponse struct {
|
||||
// Is the postcode valid (true) or not (false)
|
||||
Valid bool `json:"valid"`
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package prayer
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Prayer interface {
|
||||
Times(*TimesRequest) (*TimesResponse, error)
|
||||
}
|
||||
|
||||
func NewPrayerService(token string) *PrayerService {
|
||||
return &PrayerService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type PrayerService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the prayer (salah) times for a location on a given date
|
||||
func (t *PrayerService) Times(request *TimesRequest) (*TimesResponse, error) {
|
||||
|
||||
rsp := &TimesResponse{}
|
||||
return rsp, t.client.Call("prayer", "Times", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type PrayerTime struct {
|
||||
// asr time
|
||||
Asr string `json:"asr"`
|
||||
// date for prayer times in YYYY-MM-DD format
|
||||
Date string `json:"date"`
|
||||
// fajr time
|
||||
Fajr string `json:"fajr"`
|
||||
// isha time
|
||||
Isha string `json:"isha"`
|
||||
// maghrib time
|
||||
Maghrib string `json:"maghrib"`
|
||||
// time of sunrise
|
||||
Sunrise string `json:"sunrise"`
|
||||
// zuhr time
|
||||
Zuhr string `json:"zuhr"`
|
||||
}
|
||||
|
||||
type TimesRequest struct {
|
||||
// optional date in YYYY-MM-DD format, otherwise uses today
|
||||
Date string `json:"date"`
|
||||
// number of days to request times for
|
||||
Days int32 `json:"days"`
|
||||
// optional latitude used in place of location
|
||||
Latitude float64 `json:"latitude"`
|
||||
// location to retrieve prayer times for.
|
||||
// this can be a specific address, city, etc
|
||||
Location string `json:"location"`
|
||||
// optional longitude used in place of location
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type TimesResponse struct {
|
||||
// date of request
|
||||
Date string `json:"date"`
|
||||
// number of days
|
||||
Days int32 `json:"days"`
|
||||
// latitude of location
|
||||
Latitude float64 `json:"latitude"`
|
||||
// location for the request
|
||||
Location string `json:"location"`
|
||||
// longitude of location
|
||||
Longitude float64 `json:"longitude"`
|
||||
// prayer times for the given location
|
||||
Times []PrayerTime `json:"times"`
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package qr
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Qr interface {
|
||||
Generate(*GenerateRequest) (*GenerateResponse, error)
|
||||
}
|
||||
|
||||
func NewQrService(token string) *QrService {
|
||||
return &QrService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type QrService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Generate a QR code with a specific text and size
|
||||
func (t *QrService) Generate(request *GenerateRequest) (*GenerateResponse, error) {
|
||||
|
||||
rsp := &GenerateResponse{}
|
||||
return rsp, t.client.Call("qr", "Generate", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type GenerateRequest struct {
|
||||
// the size (height and width) in pixels of the generated QR code. Defaults to 256
|
||||
Size int64 `json:"size,string"`
|
||||
// the text to encode as a QR code (URL, phone number, email, etc)
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type GenerateResponse struct {
|
||||
// link to the QR code image in PNG format
|
||||
Qr string `json:"qr"`
|
||||
}
|
@ -1,233 +0,0 @@
|
||||
package quran
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Quran interface {
|
||||
Chapters(*ChaptersRequest) (*ChaptersResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
Summary(*SummaryRequest) (*SummaryResponse, error)
|
||||
Verses(*VersesRequest) (*VersesResponse, error)
|
||||
}
|
||||
|
||||
func NewQuranService(token string) *QuranService {
|
||||
return &QuranService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type QuranService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// List the Chapters (surahs) of the Quran
|
||||
func (t *QuranService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) {
|
||||
|
||||
rsp := &ChaptersResponse{}
|
||||
return rsp, t.client.Call("quran", "Chapters", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search the Quran for any form of query or questions
|
||||
func (t *QuranService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("quran", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get a summary for a given chapter (surah)
|
||||
func (t *QuranService) Summary(request *SummaryRequest) (*SummaryResponse, error) {
|
||||
|
||||
rsp := &SummaryResponse{}
|
||||
return rsp, t.client.Call("quran", "Summary", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Lookup the verses (ayahs) for a chapter including
|
||||
// translation, interpretation and breakdown by individual
|
||||
// words.
|
||||
func (t *QuranService) Verses(request *VersesRequest) (*VersesResponse, error) {
|
||||
|
||||
rsp := &VersesResponse{}
|
||||
return rsp, t.client.Call("quran", "Verses", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Chapter struct {
|
||||
// The arabic name of the chapter
|
||||
ArabicName string `json:"arabic_name"`
|
||||
// The complex name of the chapter
|
||||
ComplexName string `json:"complex_name"`
|
||||
// The id of the chapter as a number e.g 1
|
||||
Id int32 `json:"id"`
|
||||
// The simple name of the chapter
|
||||
Name string `json:"name"`
|
||||
// The pages from and to e.g 1, 1
|
||||
Pages []int32 `json:"pages"`
|
||||
// Should the chapter start with bismillah
|
||||
PrefixBismillah bool `json:"prefix_bismillah"`
|
||||
// The order in which it was revealed
|
||||
RevelationOrder int32 `json:"revelation_order"`
|
||||
// The place of revelation
|
||||
RevelationPlace string `json:"revelation_place"`
|
||||
// The translated name
|
||||
TranslatedName string `json:"translated_name"`
|
||||
// The number of verses in the chapter
|
||||
Verses int32 `json:"verses"`
|
||||
}
|
||||
|
||||
type ChaptersRequest struct {
|
||||
// Specify the language e.g en
|
||||
Language string `json:"language"`
|
||||
}
|
||||
|
||||
type ChaptersResponse struct {
|
||||
Chapters []Chapter `json:"chapters"`
|
||||
}
|
||||
|
||||
type Interpretation struct {
|
||||
// The unique id of the interpretation
|
||||
Id int32 `json:"id"`
|
||||
// The source of the interpretation
|
||||
Source string `json:"source"`
|
||||
// The translated text
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type Result struct {
|
||||
// The associated arabic text
|
||||
Text string `json:"text"`
|
||||
// The related translations to the text
|
||||
Translations []Translation `json:"translations"`
|
||||
// The unique verse id across the Quran
|
||||
VerseId int32 `json:"verse_id"`
|
||||
// The verse key e.g 1:1
|
||||
VerseKey string `json:"verse_key"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// The language for translation
|
||||
Language string `json:"language"`
|
||||
// The number of results to return
|
||||
Limit int32 `json:"limit"`
|
||||
// The pagination number
|
||||
Page int32 `json:"page"`
|
||||
// The query to ask
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// The current page
|
||||
Page int32 `json:"page"`
|
||||
// The question asked
|
||||
Query string `json:"query"`
|
||||
// The results for the query
|
||||
Results []Result `json:"results"`
|
||||
// The total pages
|
||||
TotalPages int32 `json:"total_pages"`
|
||||
// The total results returned
|
||||
TotalResults int32 `json:"total_results"`
|
||||
}
|
||||
|
||||
type SummaryRequest struct {
|
||||
// The chapter id e.g 1
|
||||
Chapter int32 `json:"chapter"`
|
||||
// Specify the language e.g en
|
||||
Language string `json:"language"`
|
||||
}
|
||||
|
||||
type SummaryResponse struct {
|
||||
// The chapter id
|
||||
Chapter int32 `json:"chapter"`
|
||||
// The source of the summary
|
||||
Source string `json:"source"`
|
||||
// The short summary for the chapter
|
||||
Summary string `json:"summary"`
|
||||
// The full description for the chapter
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type Translation struct {
|
||||
// The unique id of the translation
|
||||
Id int32 `json:"id"`
|
||||
// The source of the translation
|
||||
Source string `json:"source"`
|
||||
// The translated text
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type Verse struct {
|
||||
// The unique id of the verse in the whole book
|
||||
Id int32 `json:"id"`
|
||||
// The interpretations of the verse
|
||||
Interpretations []Interpretation `json:"interpretations"`
|
||||
// The key of this verse (chapter:verse) e.g 1:1
|
||||
Key string `json:"key"`
|
||||
// The verse number in this chapter
|
||||
Number int32 `json:"number"`
|
||||
// The page of the Quran this verse is on
|
||||
Page int32 `json:"page"`
|
||||
// The arabic text for this verse
|
||||
Text string `json:"text"`
|
||||
// The basic translation of the verse
|
||||
TranslatedText string `json:"translated_text"`
|
||||
// The alternative translations for the verse
|
||||
Translations []Translation `json:"translations"`
|
||||
// The phonetic transliteration from arabic
|
||||
Transliteration string `json:"transliteration"`
|
||||
// The individual words within the verse (Ayah)
|
||||
Words []Word `json:"words"`
|
||||
}
|
||||
|
||||
type VersesRequest struct {
|
||||
// The chapter id to retrieve
|
||||
Chapter int32 `json:"chapter"`
|
||||
// Return the interpretation (tafsir)
|
||||
Interpret bool `json:"interpret"`
|
||||
// The language of translation
|
||||
Language string `json:"language"`
|
||||
// The verses per page
|
||||
Limit int32 `json:"limit"`
|
||||
// The page number to request
|
||||
Page int32 `json:"page"`
|
||||
// Return alternate translations
|
||||
Translate bool `json:"translate"`
|
||||
// Return the individual words with the verses
|
||||
Words bool `json:"words"`
|
||||
}
|
||||
|
||||
type VersesResponse struct {
|
||||
// The chapter requested
|
||||
Chapter int32 `json:"chapter"`
|
||||
// The page requested
|
||||
Page int32 `json:"page"`
|
||||
// The total pages
|
||||
TotalPages int32 `json:"total_pages"`
|
||||
// The verses on the page
|
||||
Verses []Verse `json:"verses"`
|
||||
}
|
||||
|
||||
type Word struct {
|
||||
// The character type e.g word, end
|
||||
CharType string `json:"char_type"`
|
||||
// The QCF v2 font code
|
||||
Code string `json:"code"`
|
||||
// The id of the word within the verse
|
||||
Id int32 `json:"id"`
|
||||
// The line number
|
||||
Line int32 `json:"line"`
|
||||
// The page number
|
||||
Page int32 `json:"page"`
|
||||
// The position of the word
|
||||
Position int32 `json:"position"`
|
||||
// The arabic text for this word
|
||||
Text string `json:"text"`
|
||||
// The translated text
|
||||
Translation string `json:"translation"`
|
||||
// The transliteration text
|
||||
Transliteration string `json:"transliteration"`
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package routing
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Routing interface {
|
||||
Directions(*DirectionsRequest) (*DirectionsResponse, error)
|
||||
Eta(*EtaRequest) (*EtaResponse, error)
|
||||
Route(*RouteRequest) (*RouteResponse, error)
|
||||
}
|
||||
|
||||
func NewRoutingService(token string) *RoutingService {
|
||||
return &RoutingService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type RoutingService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Turn by turn directions from a start point to an end point including maneuvers and bearings
|
||||
func (t *RoutingService) Directions(request *DirectionsRequest) (*DirectionsResponse, error) {
|
||||
|
||||
rsp := &DirectionsResponse{}
|
||||
return rsp, t.client.Call("routing", "Directions", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the eta for a route from origin to destination. The eta is an estimated time based on car routes
|
||||
func (t *RoutingService) Eta(request *EtaRequest) (*EtaResponse, error) {
|
||||
|
||||
rsp := &EtaResponse{}
|
||||
return rsp, t.client.Call("routing", "Eta", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Retrieve a route as a simple list of gps points along with total distance and estimated duration
|
||||
func (t *RoutingService) Route(request *RouteRequest) (*RouteResponse, error) {
|
||||
|
||||
rsp := &RouteResponse{}
|
||||
return rsp, t.client.Call("routing", "Route", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Direction struct {
|
||||
// distance to travel in meters
|
||||
Distance float64 `json:"distance"`
|
||||
// duration to travel in seconds
|
||||
Duration float64 `json:"duration"`
|
||||
// human readable instruction
|
||||
Instruction string `json:"instruction"`
|
||||
// intersections on route
|
||||
Intersections []Intersection `json:"intersections"`
|
||||
// maneuver to take
|
||||
Maneuver *Maneuver `json:"maneuver"`
|
||||
// street name or location
|
||||
Name string `json:"name"`
|
||||
// alternative reference
|
||||
Reference string `json:"reference"`
|
||||
}
|
||||
|
||||
type DirectionsRequest struct {
|
||||
// The destination of the journey
|
||||
Destination *Point `json:"destination"`
|
||||
// The staring point for the journey
|
||||
Origin *Point `json:"origin"`
|
||||
}
|
||||
|
||||
type DirectionsResponse struct {
|
||||
// Turn by turn directions
|
||||
Directions []Direction `json:"directions"`
|
||||
// Estimated distance of the route in meters
|
||||
Distance float64 `json:"distance"`
|
||||
// Estimated duration of the route in seconds
|
||||
Duration float64 `json:"duration"`
|
||||
// The waypoints on the route
|
||||
Waypoints []Waypoint `json:"waypoints"`
|
||||
}
|
||||
|
||||
type EtaRequest struct {
|
||||
// The end point for the eta calculation
|
||||
Destination *Point `json:"destination"`
|
||||
// The starting point for the eta calculation
|
||||
Origin *Point `json:"origin"`
|
||||
// speed in kilometers
|
||||
Speed float64 `json:"speed"`
|
||||
// type of transport. Only "car" is supported currently.
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type EtaResponse struct {
|
||||
// eta in seconds
|
||||
Duration float64 `json:"duration"`
|
||||
}
|
||||
|
||||
type Intersection struct {
|
||||
Bearings []float64 `json:"bearings"`
|
||||
Location *Point `json:"location"`
|
||||
}
|
||||
|
||||
type Maneuver struct {
|
||||
Action string `json:"action"`
|
||||
BearingAfter float64 `json:"bearing_after"`
|
||||
BearingBefore float64 `json:"bearing_before"`
|
||||
Direction string `json:"direction"`
|
||||
Location *Point `json:"location"`
|
||||
}
|
||||
|
||||
type Point struct {
|
||||
// Lat e.g 52.523219
|
||||
Latitude float64 `json:"latitude"`
|
||||
// Long e.g 13.428555
|
||||
Longitude float64 `json:"longitude"`
|
||||
}
|
||||
|
||||
type RouteRequest struct {
|
||||
// Point of destination for the trip
|
||||
Destination *Point `json:"destination"`
|
||||
// Point of origin for the trip
|
||||
Origin *Point `json:"origin"`
|
||||
}
|
||||
|
||||
type RouteResponse struct {
|
||||
// estimated distance in meters
|
||||
Distance float64 `json:"distance"`
|
||||
// estimated duration in seconds
|
||||
Duration float64 `json:"duration"`
|
||||
// waypoints on the route
|
||||
Waypoints []Waypoint `json:"waypoints"`
|
||||
}
|
||||
|
||||
type Waypoint struct {
|
||||
// gps point coordinates
|
||||
Location *Point `json:"location"`
|
||||
// street name or related reference
|
||||
Name string `json:"name"`
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
package rss
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Rss interface {
|
||||
Add(*AddRequest) (*AddResponse, error)
|
||||
Feed(*FeedRequest) (*FeedResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Remove(*RemoveRequest) (*RemoveResponse, error)
|
||||
}
|
||||
|
||||
func NewRssService(token string) *RssService {
|
||||
return &RssService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type RssService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Add a new RSS feed with a name, url, and category
|
||||
func (t *RssService) Add(request *AddRequest) (*AddResponse, error) {
|
||||
|
||||
rsp := &AddResponse{}
|
||||
return rsp, t.client.Call("rss", "Add", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get an RSS feed by name. If no name is given, all feeds are returned. Default limit is 25 entries.
|
||||
func (t *RssService) Feed(request *FeedRequest) (*FeedResponse, error) {
|
||||
|
||||
rsp := &FeedResponse{}
|
||||
return rsp, t.client.Call("rss", "Feed", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List the saved RSS fields
|
||||
func (t *RssService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("rss", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Remove an RSS feed by name
|
||||
func (t *RssService) Remove(request *RemoveRequest) (*RemoveResponse, error) {
|
||||
|
||||
rsp := &RemoveResponse{}
|
||||
return rsp, t.client.Call("rss", "Remove", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type AddRequest struct {
|
||||
// category to add e.g news
|
||||
Category string `json:"category"`
|
||||
// rss feed name
|
||||
// eg. a16z
|
||||
Name string `json:"name"`
|
||||
// rss feed url
|
||||
// eg. http://a16z.com/feed/
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type AddResponse struct {
|
||||
}
|
||||
|
||||
type Entry struct {
|
||||
// article content
|
||||
Content string `json:"content"`
|
||||
// data of the entry
|
||||
Date string `json:"date"`
|
||||
// the rss feed where it came from
|
||||
Feed string `json:"feed"`
|
||||
// unique id of the entry
|
||||
Id string `json:"id"`
|
||||
// rss feed url of the entry
|
||||
Link string `json:"link"`
|
||||
// article summary
|
||||
Summary string `json:"summary"`
|
||||
// title of the entry
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type Feed struct {
|
||||
// category of the feed e.g news
|
||||
Category string `json:"category"`
|
||||
// unique id
|
||||
Id string `json:"id"`
|
||||
// rss feed name
|
||||
// eg. a16z
|
||||
Name string `json:"name"`
|
||||
// rss feed url
|
||||
// eg. http://a16z.com/feed/
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type FeedRequest struct {
|
||||
// limit entries returned
|
||||
Limit int64 `json:"limit,string"`
|
||||
// rss feed name
|
||||
Name string `json:"name"`
|
||||
// offset entries
|
||||
Offset int64 `json:"offset,string"`
|
||||
}
|
||||
|
||||
type FeedResponse struct {
|
||||
Entries []Entry `json:"entries"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Feeds []Feed `json:"feeds"`
|
||||
}
|
||||
|
||||
type RemoveRequest struct {
|
||||
// rss feed name
|
||||
// eg. a16z
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type RemoveResponse struct {
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
package search
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Search interface {
|
||||
CreateIndex(*CreateIndexRequest) (*CreateIndexResponse, error)
|
||||
DeleteIndex(*DeleteIndexRequest) (*DeleteIndexResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Index(*IndexRequest) (*IndexResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewSearchService(token string) *SearchService {
|
||||
return &SearchService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SearchService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create an index by name
|
||||
func (t *SearchService) CreateIndex(request *CreateIndexRequest) (*CreateIndexResponse, error) {
|
||||
|
||||
rsp := &CreateIndexResponse{}
|
||||
return rsp, t.client.Call("search", "CreateIndex", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete an index by name
|
||||
func (t *SearchService) DeleteIndex(request *DeleteIndexRequest) (*DeleteIndexResponse, error) {
|
||||
|
||||
rsp := &DeleteIndexResponse{}
|
||||
return rsp, t.client.Call("search", "DeleteIndex", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete a document given its ID
|
||||
func (t *SearchService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("search", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Index a document i.e. insert a document to search for.
|
||||
func (t *SearchService) Index(request *IndexRequest) (*IndexResponse, error) {
|
||||
|
||||
rsp := &IndexResponse{}
|
||||
return rsp, t.client.Call("search", "Index", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search for documents in a given in index
|
||||
func (t *SearchService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("search", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CreateIndexRequest struct {
|
||||
// The name of the index
|
||||
Index string `json:"index"`
|
||||
}
|
||||
|
||||
type CreateIndexResponse struct {
|
||||
}
|
||||
|
||||
type DeleteIndexRequest struct {
|
||||
// The name of the index to delete
|
||||
Index string `json:"index"`
|
||||
}
|
||||
|
||||
type DeleteIndexResponse struct {
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// The ID of the document to delete
|
||||
Id string `json:"id"`
|
||||
// The index the document belongs to
|
||||
Index string `json:"index"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
// The JSON contents of the document
|
||||
Contents map[string]interface{} `json:"contents"`
|
||||
// The ID for this document. If blank, one will be generated
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type Field struct {
|
||||
// The name of the field. Use a `.` separator to define nested fields e.g. foo.bar
|
||||
Name string `json:"name"`
|
||||
// The type of the field - string, number
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type IndexRequest struct {
|
||||
// The document to index
|
||||
Document *Document `json:"document"`
|
||||
// The index this document belongs to
|
||||
Index string `json:"index"`
|
||||
}
|
||||
|
||||
type IndexResponse struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// The index the document belongs to
|
||||
Index string `json:"index"`
|
||||
// The query. See docs for query language examples
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// The matching documents
|
||||
Documents []Document `json:"documents"`
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package sentiment
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Sentiment interface {
|
||||
Analyze(*AnalyzeRequest) (*AnalyzeResponse, error)
|
||||
}
|
||||
|
||||
func NewSentimentService(token string) *SentimentService {
|
||||
return &SentimentService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SentimentService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Analyze and score a piece of text
|
||||
func (t *SentimentService) Analyze(request *AnalyzeRequest) (*AnalyzeResponse, error) {
|
||||
|
||||
rsp := &AnalyzeResponse{}
|
||||
return rsp, t.client.Call("sentiment", "Analyze", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type AnalyzeRequest struct {
|
||||
// The language. Defaults to english.
|
||||
Lang string `json:"lang"`
|
||||
// The text to analyze
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type AnalyzeResponse struct {
|
||||
// The score of the text {positive is 1, negative is 0}
|
||||
Score float64 `json:"score"`
|
||||
}
|
@ -1,193 +0,0 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/services/address"
|
||||
"go-micro.dev/v4/services/answer"
|
||||
"go-micro.dev/v4/services/app"
|
||||
"go-micro.dev/v4/services/avatar"
|
||||
"go-micro.dev/v4/services/cache"
|
||||
"go-micro.dev/v4/services/carbon"
|
||||
"go-micro.dev/v4/services/contact"
|
||||
"go-micro.dev/v4/services/crypto"
|
||||
"go-micro.dev/v4/services/currency"
|
||||
"go-micro.dev/v4/services/db"
|
||||
"go-micro.dev/v4/services/email"
|
||||
"go-micro.dev/v4/services/emoji"
|
||||
"go-micro.dev/v4/services/evchargers"
|
||||
"go-micro.dev/v4/services/event"
|
||||
"go-micro.dev/v4/services/file"
|
||||
"go-micro.dev/v4/services/forex"
|
||||
"go-micro.dev/v4/services/function"
|
||||
"go-micro.dev/v4/services/geocoding"
|
||||
"go-micro.dev/v4/services/gifs"
|
||||
"go-micro.dev/v4/services/google"
|
||||
"go-micro.dev/v4/services/helloworld"
|
||||
"go-micro.dev/v4/services/holidays"
|
||||
"go-micro.dev/v4/services/id"
|
||||
"go-micro.dev/v4/services/image"
|
||||
"go-micro.dev/v4/services/ip"
|
||||
"go-micro.dev/v4/services/joke"
|
||||
"go-micro.dev/v4/services/location"
|
||||
"go-micro.dev/v4/services/minecraft"
|
||||
"go-micro.dev/v4/services/movie"
|
||||
"go-micro.dev/v4/services/mq"
|
||||
"go-micro.dev/v4/services/news"
|
||||
"go-micro.dev/v4/services/nft"
|
||||
"go-micro.dev/v4/services/notes"
|
||||
"go-micro.dev/v4/services/otp"
|
||||
"go-micro.dev/v4/services/ping"
|
||||
"go-micro.dev/v4/services/place"
|
||||
"go-micro.dev/v4/services/postcode"
|
||||
"go-micro.dev/v4/services/prayer"
|
||||
"go-micro.dev/v4/services/qr"
|
||||
"go-micro.dev/v4/services/quran"
|
||||
"go-micro.dev/v4/services/routing"
|
||||
"go-micro.dev/v4/services/rss"
|
||||
"go-micro.dev/v4/services/search"
|
||||
"go-micro.dev/v4/services/sentiment"
|
||||
"go-micro.dev/v4/services/sms"
|
||||
"go-micro.dev/v4/services/space"
|
||||
"go-micro.dev/v4/services/spam"
|
||||
"go-micro.dev/v4/services/stock"
|
||||
"go-micro.dev/v4/services/stream"
|
||||
"go-micro.dev/v4/services/sunnah"
|
||||
"go-micro.dev/v4/services/thumbnail"
|
||||
"go-micro.dev/v4/services/time"
|
||||
"go-micro.dev/v4/services/translate"
|
||||
"go-micro.dev/v4/services/twitter"
|
||||
"go-micro.dev/v4/services/url"
|
||||
"go-micro.dev/v4/services/user"
|
||||
"go-micro.dev/v4/services/vehicle"
|
||||
"go-micro.dev/v4/services/weather"
|
||||
"go-micro.dev/v4/services/youtube"
|
||||
)
|
||||
|
||||
func NewClient(token string) *Client {
|
||||
return &Client{
|
||||
token: token,
|
||||
|
||||
AddressService: address.NewAddressService(token),
|
||||
AnswerService: answer.NewAnswerService(token),
|
||||
AppService: app.NewAppService(token),
|
||||
AvatarService: avatar.NewAvatarService(token),
|
||||
CacheService: cache.NewCacheService(token),
|
||||
CarbonService: carbon.NewCarbonService(token),
|
||||
ContactService: contact.NewContactService(token),
|
||||
CryptoService: crypto.NewCryptoService(token),
|
||||
CurrencyService: currency.NewCurrencyService(token),
|
||||
DbService: db.NewDbService(token),
|
||||
EmailService: email.NewEmailService(token),
|
||||
EmojiService: emoji.NewEmojiService(token),
|
||||
EvchargersService: evchargers.NewEvchargersService(token),
|
||||
EventService: event.NewEventService(token),
|
||||
FileService: file.NewFileService(token),
|
||||
ForexService: forex.NewForexService(token),
|
||||
FunctionService: function.NewFunctionService(token),
|
||||
GeocodingService: geocoding.NewGeocodingService(token),
|
||||
GifsService: gifs.NewGifsService(token),
|
||||
GoogleService: google.NewGoogleService(token),
|
||||
HelloworldService: helloworld.NewHelloworldService(token),
|
||||
HolidaysService: holidays.NewHolidaysService(token),
|
||||
IdService: id.NewIdService(token),
|
||||
ImageService: image.NewImageService(token),
|
||||
IpService: ip.NewIpService(token),
|
||||
JokeService: joke.NewJokeService(token),
|
||||
LocationService: location.NewLocationService(token),
|
||||
MinecraftService: minecraft.NewMinecraftService(token),
|
||||
MovieService: movie.NewMovieService(token),
|
||||
MqService: mq.NewMqService(token),
|
||||
NewsService: news.NewNewsService(token),
|
||||
NftService: nft.NewNftService(token),
|
||||
NotesService: notes.NewNotesService(token),
|
||||
OtpService: otp.NewOtpService(token),
|
||||
PingService: ping.NewPingService(token),
|
||||
PlaceService: place.NewPlaceService(token),
|
||||
PostcodeService: postcode.NewPostcodeService(token),
|
||||
PrayerService: prayer.NewPrayerService(token),
|
||||
QrService: qr.NewQrService(token),
|
||||
QuranService: quran.NewQuranService(token),
|
||||
RoutingService: routing.NewRoutingService(token),
|
||||
RssService: rss.NewRssService(token),
|
||||
SearchService: search.NewSearchService(token),
|
||||
SentimentService: sentiment.NewSentimentService(token),
|
||||
SmsService: sms.NewSmsService(token),
|
||||
SpaceService: space.NewSpaceService(token),
|
||||
SpamService: spam.NewSpamService(token),
|
||||
StockService: stock.NewStockService(token),
|
||||
StreamService: stream.NewStreamService(token),
|
||||
SunnahService: sunnah.NewSunnahService(token),
|
||||
ThumbnailService: thumbnail.NewThumbnailService(token),
|
||||
TimeService: time.NewTimeService(token),
|
||||
TranslateService: translate.NewTranslateService(token),
|
||||
TwitterService: twitter.NewTwitterService(token),
|
||||
UrlService: url.NewUrlService(token),
|
||||
UserService: user.NewUserService(token),
|
||||
VehicleService: vehicle.NewVehicleService(token),
|
||||
WeatherService: weather.NewWeatherService(token),
|
||||
YoutubeService: youtube.NewYoutubeService(token),
|
||||
}
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
token string
|
||||
|
||||
AddressService *address.AddressService
|
||||
AnswerService *answer.AnswerService
|
||||
AppService *app.AppService
|
||||
AvatarService *avatar.AvatarService
|
||||
CacheService *cache.CacheService
|
||||
CarbonService *carbon.CarbonService
|
||||
ContactService *contact.ContactService
|
||||
CryptoService *crypto.CryptoService
|
||||
CurrencyService *currency.CurrencyService
|
||||
DbService *db.DbService
|
||||
EmailService *email.EmailService
|
||||
EmojiService *emoji.EmojiService
|
||||
EvchargersService *evchargers.EvchargersService
|
||||
EventService *event.EventService
|
||||
FileService *file.FileService
|
||||
ForexService *forex.ForexService
|
||||
FunctionService *function.FunctionService
|
||||
GeocodingService *geocoding.GeocodingService
|
||||
GifsService *gifs.GifsService
|
||||
GoogleService *google.GoogleService
|
||||
HelloworldService *helloworld.HelloworldService
|
||||
HolidaysService *holidays.HolidaysService
|
||||
IdService *id.IdService
|
||||
ImageService *image.ImageService
|
||||
IpService *ip.IpService
|
||||
JokeService *joke.JokeService
|
||||
LocationService *location.LocationService
|
||||
MinecraftService *minecraft.MinecraftService
|
||||
MovieService *movie.MovieService
|
||||
MqService *mq.MqService
|
||||
NewsService *news.NewsService
|
||||
NftService *nft.NftService
|
||||
NotesService *notes.NotesService
|
||||
OtpService *otp.OtpService
|
||||
PingService *ping.PingService
|
||||
PlaceService *place.PlaceService
|
||||
PostcodeService *postcode.PostcodeService
|
||||
PrayerService *prayer.PrayerService
|
||||
QrService *qr.QrService
|
||||
QuranService *quran.QuranService
|
||||
RoutingService *routing.RoutingService
|
||||
RssService *rss.RssService
|
||||
SearchService *search.SearchService
|
||||
SentimentService *sentiment.SentimentService
|
||||
SmsService *sms.SmsService
|
||||
SpaceService *space.SpaceService
|
||||
SpamService *spam.SpamService
|
||||
StockService *stock.StockService
|
||||
StreamService *stream.StreamService
|
||||
SunnahService *sunnah.SunnahService
|
||||
ThumbnailService *thumbnail.ThumbnailService
|
||||
TimeService *time.TimeService
|
||||
TranslateService *translate.TranslateService
|
||||
TwitterService *twitter.TwitterService
|
||||
UrlService *url.UrlService
|
||||
UserService *user.UserService
|
||||
VehicleService *vehicle.VehicleService
|
||||
WeatherService *weather.WeatherService
|
||||
YoutubeService *youtube.YoutubeService
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package sms
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Sms interface {
|
||||
Send(*SendRequest) (*SendResponse, error)
|
||||
}
|
||||
|
||||
func NewSmsService(token string) *SmsService {
|
||||
return &SmsService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SmsService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Send an SMS.
|
||||
func (t *SmsService) Send(request *SendRequest) (*SendResponse, error) {
|
||||
|
||||
rsp := &SendResponse{}
|
||||
return rsp, t.client.Call("sms", "Send", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type SendRequest struct {
|
||||
// who is the message from? The message will be suffixed with "Sent from <from>"
|
||||
From string `json:"from"`
|
||||
// the main body of the message to send
|
||||
Message string `json:"message"`
|
||||
// the destination phone number including the international dialling code (e.g. +44)
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type SendResponse struct {
|
||||
// any additional info
|
||||
Info string `json:"info"`
|
||||
// will return "ok" if successful
|
||||
Status string `json:"status"`
|
||||
}
|
@ -1,213 +0,0 @@
|
||||
package space
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Space interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
Download(*DownloadRequest) (*DownloadResponse, error)
|
||||
Head(*HeadRequest) (*HeadResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
Upload(*UploadRequest) (*UploadResponse, error)
|
||||
}
|
||||
|
||||
func NewSpaceService(token string) *SpaceService {
|
||||
return &SpaceService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SpaceService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create an object. Returns error if object with this name already exists. Max object size of 10MB, see Upload endpoint for larger objects. If you want to update an existing object use the `Update` endpoint
|
||||
func (t *SpaceService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("space", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete an object from space
|
||||
func (t *SpaceService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("space", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Download an object via a presigned url
|
||||
func (t *SpaceService) Download(request *DownloadRequest) (*DownloadResponse, error) {
|
||||
|
||||
rsp := &DownloadResponse{}
|
||||
return rsp, t.client.Call("space", "Download", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Retrieve meta information about an object
|
||||
func (t *SpaceService) Head(request *HeadRequest) (*HeadResponse, error) {
|
||||
|
||||
rsp := &HeadResponse{}
|
||||
return rsp, t.client.Call("space", "Head", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List the objects in space
|
||||
func (t *SpaceService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("space", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read an object in space
|
||||
func (t *SpaceService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("space", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update an object. If an object with this name does not exist, creates a new one.
|
||||
func (t *SpaceService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("space", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Upload a large object (> 10MB). Returns a time limited presigned URL to be used for uploading the object
|
||||
func (t *SpaceService) Upload(request *UploadRequest) (*UploadResponse, error) {
|
||||
|
||||
rsp := &UploadResponse{}
|
||||
return rsp, t.client.Call("space", "Upload", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg
|
||||
Name string `json:"name"`
|
||||
// The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format
|
||||
Object string `json:"object"`
|
||||
// Who can see this object? "public" or "private", defaults to "private"
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
// A public URL to access the object if visibility is "public"
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// Name of the object
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type DownloadRequest struct {
|
||||
// name of object
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type DownloadResponse struct {
|
||||
// presigned url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type HeadObject struct {
|
||||
// when was this created
|
||||
Created string `json:"created"`
|
||||
// when was this last modified
|
||||
Modified string `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
// URL to access the object if it is public
|
||||
Url string `json:"url"`
|
||||
// is this public or private
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type HeadRequest struct {
|
||||
// name of the object
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type HeadResponse struct {
|
||||
Object *HeadObject `json:"object"`
|
||||
}
|
||||
|
||||
type ListObject struct {
|
||||
Created string `json:"created"`
|
||||
// when was this last modified
|
||||
Modified string `json:"modified"`
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// optional prefix for the name e.g. to return all the objects in the images directory pass images/
|
||||
Prefix string `json:"prefix"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Objects []ListObject `json:"objects"`
|
||||
}
|
||||
|
||||
type Object struct {
|
||||
// when was this created
|
||||
Created string `json:"created"`
|
||||
// the data within the object
|
||||
Data string `json:"data"`
|
||||
// when was this last modified
|
||||
Modified string `json:"modified"`
|
||||
// name of object
|
||||
Name string `json:"name"`
|
||||
// URL to access the object if it is public
|
||||
Url string `json:"url"`
|
||||
// is this public or private
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// name of the object
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
// The object itself
|
||||
Object *Object `json:"object"`
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// The name of the object. Use forward slash delimiter to implement a nested directory-like structure e.g. images/foo.jpg
|
||||
Name string `json:"name"`
|
||||
// The contents of the object. Either base64 encoded if sending request as application/json or raw bytes if using multipart/form-data format
|
||||
Object string `json:"object"`
|
||||
// Who can see this object? "public" or "private", defaults to "private"
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
// A public URL to access the object if visibility is "public"
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type UploadRequest struct {
|
||||
Name string `json:"name"`
|
||||
// is this object public or private
|
||||
Visibility string `json:"visibility"`
|
||||
}
|
||||
|
||||
type UploadResponse struct {
|
||||
// a presigned url to be used for uploading. To use the URL call it with HTTP PUT and pass the object as the request data
|
||||
Url string `json:"url"`
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package spam
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Spam interface {
|
||||
Classify(*ClassifyRequest) (*ClassifyResponse, error)
|
||||
}
|
||||
|
||||
func NewSpamService(token string) *SpamService {
|
||||
return &SpamService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SpamService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Check whether an email is likely to be spam based on its attributes
|
||||
func (t *SpamService) Classify(request *ClassifyRequest) (*ClassifyResponse, error) {
|
||||
|
||||
rsp := &ClassifyResponse{}
|
||||
return rsp, t.client.Call("spam", "Classify", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ClassifyRequest struct {
|
||||
// The raw body of the email including headers etc per RFC 822. Alternatively, use the other parameters to correctly format the message
|
||||
EmailBody string `json:"email_body"`
|
||||
// The email address it has been sent from
|
||||
From string `json:"from"`
|
||||
// the HTML version of the email body
|
||||
HtmlBody string `json:"html_body"`
|
||||
// The subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// the plain text version of the email body
|
||||
TextBody string `json:"text_body"`
|
||||
// The email address it is being sent to
|
||||
To string `json:"to"`
|
||||
}
|
||||
|
||||
type ClassifyResponse struct {
|
||||
// The rules that have contributed to this score
|
||||
Details []string `json:"details"`
|
||||
// Is it spam? Returns true if its score is > 5
|
||||
IsSpam bool `json:"is_spam"`
|
||||
// The score evaluated for this email. A higher number means it is more likely to be spam
|
||||
Score float64 `json:"score"`
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
package stock
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Stock interface {
|
||||
History(*HistoryRequest) (*HistoryResponse, error)
|
||||
OrderBook(*OrderBookRequest) (*OrderBookResponse, error)
|
||||
Price(*PriceRequest) (*PriceResponse, error)
|
||||
Quote(*QuoteRequest) (*QuoteResponse, error)
|
||||
}
|
||||
|
||||
func NewStockService(token string) *StockService {
|
||||
return &StockService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type StockService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the historic open-close for a given day
|
||||
func (t *StockService) History(request *HistoryRequest) (*HistoryResponse, error) {
|
||||
|
||||
rsp := &HistoryResponse{}
|
||||
return rsp, t.client.Call("stock", "History", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the historic order book and each trade by timestamp
|
||||
func (t *StockService) OrderBook(request *OrderBookRequest) (*OrderBookResponse, error) {
|
||||
|
||||
rsp := &OrderBookResponse{}
|
||||
return rsp, t.client.Call("stock", "OrderBook", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last price for a given stock ticker
|
||||
func (t *StockService) Price(request *PriceRequest) (*PriceResponse, error) {
|
||||
|
||||
rsp := &PriceResponse{}
|
||||
return rsp, t.client.Call("stock", "Price", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the last quote for the stock
|
||||
func (t *StockService) Quote(request *QuoteRequest) (*QuoteResponse, error) {
|
||||
|
||||
rsp := &QuoteResponse{}
|
||||
return rsp, t.client.Call("stock", "Quote", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type HistoryRequest struct {
|
||||
// date to retrieve as YYYY-MM-DD
|
||||
Date string `json:"date"`
|
||||
// the stock symbol e.g AAPL
|
||||
Stock string `json:"stock"`
|
||||
}
|
||||
|
||||
type HistoryResponse struct {
|
||||
// the close price
|
||||
Close float64 `json:"close"`
|
||||
// the date
|
||||
Date string `json:"date"`
|
||||
// the peak price
|
||||
High float64 `json:"high"`
|
||||
// the low price
|
||||
Low float64 `json:"low"`
|
||||
// the open price
|
||||
Open float64 `json:"open"`
|
||||
// the stock symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the volume
|
||||
Volume int32 `json:"volume"`
|
||||
}
|
||||
|
||||
type Order struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
// the ask size
|
||||
AskSize int32 `json:"ask_size"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
// the bid size
|
||||
BidSize int32 `json:"bid_size"`
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type OrderBookRequest struct {
|
||||
// the date in format YYYY-MM-dd
|
||||
Date string `json:"date"`
|
||||
// optional RFC3339Nano end time e.g 2006-01-02T15:04:05.999999999Z07:00
|
||||
End string `json:"end"`
|
||||
// limit number of prices
|
||||
Limit int32 `json:"limit"`
|
||||
// optional RFC3339Nano start time e.g 2006-01-02T15:04:05.999999999Z07:00
|
||||
Start string `json:"start"`
|
||||
// stock to retrieve e.g AAPL
|
||||
Stock string `json:"stock"`
|
||||
}
|
||||
|
||||
type OrderBookResponse struct {
|
||||
// date of the request
|
||||
Date string `json:"date"`
|
||||
// list of orders
|
||||
Orders []Order `json:"orders"`
|
||||
// the stock symbol
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type PriceRequest struct {
|
||||
// stock symbol e.g AAPL
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type PriceResponse struct {
|
||||
// the last price
|
||||
Price float64 `json:"price"`
|
||||
// the stock symbol e.g AAPL
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteRequest struct {
|
||||
// the stock symbol e.g AAPL
|
||||
Symbol string `json:"symbol"`
|
||||
}
|
||||
|
||||
type QuoteResponse struct {
|
||||
// the asking price
|
||||
AskPrice float64 `json:"ask_price"`
|
||||
// the ask size
|
||||
AskSize int32 `json:"ask_size"`
|
||||
// the bidding price
|
||||
BidPrice float64 `json:"bid_price"`
|
||||
// the bid size
|
||||
BidSize int32 `json:"bid_size"`
|
||||
// the stock symbol
|
||||
Symbol string `json:"symbol"`
|
||||
// the UTC timestamp of the quote
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package stream
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Stream interface {
|
||||
CreateChannel(*CreateChannelRequest) (*CreateChannelResponse, error)
|
||||
ListChannels(*ListChannelsRequest) (*ListChannelsResponse, error)
|
||||
ListMessages(*ListMessagesRequest) (*ListMessagesResponse, error)
|
||||
SendMessage(*SendMessageRequest) (*SendMessageResponse, error)
|
||||
}
|
||||
|
||||
func NewStreamService(token string) *StreamService {
|
||||
return &StreamService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type StreamService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a channel with a given name and description. Channels are created automatically but
|
||||
// this allows you to specify a description that's persisted for the lifetime of the channel.
|
||||
func (t *StreamService) CreateChannel(request *CreateChannelRequest) (*CreateChannelResponse, error) {
|
||||
|
||||
rsp := &CreateChannelResponse{}
|
||||
return rsp, t.client.Call("stream", "CreateChannel", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all the active channels
|
||||
func (t *StreamService) ListChannels(request *ListChannelsRequest) (*ListChannelsResponse, error) {
|
||||
|
||||
rsp := &ListChannelsResponse{}
|
||||
return rsp, t.client.Call("stream", "ListChannels", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List messages for a given channel
|
||||
func (t *StreamService) ListMessages(request *ListMessagesRequest) (*ListMessagesResponse, error) {
|
||||
|
||||
rsp := &ListMessagesResponse{}
|
||||
return rsp, t.client.Call("stream", "ListMessages", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send a message to the stream.
|
||||
func (t *StreamService) SendMessage(request *SendMessageRequest) (*SendMessageResponse, error) {
|
||||
|
||||
rsp := &SendMessageResponse{}
|
||||
return rsp, t.client.Call("stream", "SendMessage", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
// description for the channel
|
||||
Description string `json:"description"`
|
||||
// last activity time
|
||||
LastActive string `json:"last_active"`
|
||||
// name of the channel
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type CreateChannelRequest struct {
|
||||
// description for the channel
|
||||
Description string `json:"description"`
|
||||
// name of the channel
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type CreateChannelResponse struct {
|
||||
}
|
||||
|
||||
type ListChannelsRequest struct {
|
||||
}
|
||||
|
||||
type ListChannelsResponse struct {
|
||||
Channels []Channel `json:"channels"`
|
||||
}
|
||||
|
||||
type ListMessagesRequest struct {
|
||||
// The channel to subscribe to
|
||||
Channel string `json:"channel"`
|
||||
// number of message to return
|
||||
Limit int32 `json:"limit"`
|
||||
}
|
||||
|
||||
type ListMessagesResponse struct {
|
||||
// The channel subscribed to
|
||||
Channel string `json:"channel"`
|
||||
// Messages are chronological order
|
||||
Messages []Message `json:"messages"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
// the channel name
|
||||
Channel string `json:"channel"`
|
||||
// id of the message
|
||||
Id string `json:"id"`
|
||||
// the associated metadata
|
||||
Metadata map[string]string `json:"metadata"`
|
||||
// text of the message
|
||||
Text string `json:"text"`
|
||||
// time of message creation
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
type SendMessageRequest struct {
|
||||
// The channel to send to
|
||||
Channel string `json:"channel"`
|
||||
// The message text to send
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type SendMessageResponse struct {
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package sunnah
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Sunnah interface {
|
||||
Books(*BooksRequest) (*BooksResponse, error)
|
||||
Chapters(*ChaptersRequest) (*ChaptersResponse, error)
|
||||
Collections(*CollectionsRequest) (*CollectionsResponse, error)
|
||||
Hadiths(*HadithsRequest) (*HadithsResponse, error)
|
||||
}
|
||||
|
||||
func NewSunnahService(token string) *SunnahService {
|
||||
return &SunnahService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type SunnahService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get a list of books from within a collection. A book can contain many chapters
|
||||
// each with its own hadiths.
|
||||
func (t *SunnahService) Books(request *BooksRequest) (*BooksResponse, error) {
|
||||
|
||||
rsp := &BooksResponse{}
|
||||
return rsp, t.client.Call("sunnah", "Books", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get all the chapters of a given book within a collection.
|
||||
func (t *SunnahService) Chapters(request *ChaptersRequest) (*ChaptersResponse, error) {
|
||||
|
||||
rsp := &ChaptersResponse{}
|
||||
return rsp, t.client.Call("sunnah", "Chapters", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
func (t *SunnahService) Collections(request *CollectionsRequest) (*CollectionsResponse, error) {
|
||||
|
||||
rsp := &CollectionsResponse{}
|
||||
return rsp, t.client.Call("sunnah", "Collections", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||
// given book within a collection.
|
||||
func (t *SunnahService) Hadiths(request *HadithsRequest) (*HadithsResponse, error) {
|
||||
|
||||
rsp := &HadithsResponse{}
|
||||
return rsp, t.client.Call("sunnah", "Hadiths", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Book struct {
|
||||
// arabic name of the book
|
||||
ArabicName string `json:"arabic_name"`
|
||||
// number of hadiths in the book
|
||||
Hadiths int32 `json:"hadiths"`
|
||||
// number of the book e.g 1
|
||||
Id int32 `json:"id"`
|
||||
// name of the book
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type BooksRequest struct {
|
||||
// Name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// Limit the number of books returned
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
}
|
||||
|
||||
type BooksResponse struct {
|
||||
// A list of books
|
||||
Books []Book `json:"books"`
|
||||
// Name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// The limit specified
|
||||
Limit int32 `json:"limit"`
|
||||
// The page requested
|
||||
Page int32 `json:"page"`
|
||||
// The total overall books
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
type Chapter struct {
|
||||
// arabic title
|
||||
ArabicTitle string `json:"arabic_title"`
|
||||
// the book number
|
||||
Book int32 `json:"book"`
|
||||
// the chapter id e.g 1
|
||||
Id int32 `json:"id"`
|
||||
// the chapter key e.g 1.00
|
||||
Key string `json:"key"`
|
||||
// title of the chapter
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type ChaptersRequest struct {
|
||||
// number of the book
|
||||
Book int32 `json:"book"`
|
||||
// name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// Limit the number of chapters returned
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
}
|
||||
|
||||
type ChaptersResponse struct {
|
||||
// number of the book
|
||||
Book int32 `json:"book"`
|
||||
// The chapters of the book
|
||||
Chapters []Chapter `json:"chapters"`
|
||||
// name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// Limit the number of chapters returned
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
// Total chapters in the book
|
||||
Total int32 `json:"total"`
|
||||
}
|
||||
|
||||
type Collection struct {
|
||||
// Arabic title if available
|
||||
ArabicTitle string `json:"arabic_title"`
|
||||
// Total hadiths in the collection
|
||||
Hadiths int32 `json:"hadiths"`
|
||||
// Name of the collection e.g bukhari
|
||||
Name string `json:"name"`
|
||||
// An introduction explaining the collection
|
||||
Summary string `json:"summary"`
|
||||
// Title of the collection e.g Sahih al-Bukhari
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
type CollectionsRequest struct {
|
||||
// Number of collections to limit to
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
}
|
||||
|
||||
type CollectionsResponse struct {
|
||||
Collections []Collection `json:"collections"`
|
||||
}
|
||||
|
||||
type Hadith struct {
|
||||
// the arabic chapter title
|
||||
ArabicChapterTitle string `json:"arabic_chapter_title"`
|
||||
// the arabic text
|
||||
ArabicText string `json:"arabic_text"`
|
||||
// the chapter id
|
||||
Chapter int32 `json:"chapter"`
|
||||
// the chapter key
|
||||
ChapterKey string `json:"chapter_key"`
|
||||
// the chapter title
|
||||
ChapterTitle string `json:"chapter_title"`
|
||||
// hadith id
|
||||
Id int32 `json:"id"`
|
||||
// hadith text
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
type HadithsRequest struct {
|
||||
// number of the book
|
||||
Book int32 `json:"book"`
|
||||
// name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// Limit the number of hadiths
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
}
|
||||
|
||||
type HadithsResponse struct {
|
||||
// number of the book
|
||||
Book int32 `json:"book"`
|
||||
// name of the collection
|
||||
Collection string `json:"collection"`
|
||||
// The hadiths of the book
|
||||
Hadiths []Hadith `json:"hadiths"`
|
||||
// Limit the number of hadiths returned
|
||||
Limit int32 `json:"limit"`
|
||||
// The page in the pagination
|
||||
Page int32 `json:"page"`
|
||||
// Total hadiths in the book
|
||||
Total int32 `json:"total"`
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package thumbnail
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Thumbnail interface {
|
||||
Screenshot(*ScreenshotRequest) (*ScreenshotResponse, error)
|
||||
}
|
||||
|
||||
func NewThumbnailService(token string) *ThumbnailService {
|
||||
return &ThumbnailService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type ThumbnailService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a thumbnail screenshot by passing in a url, height and width
|
||||
func (t *ThumbnailService) Screenshot(request *ScreenshotRequest) (*ScreenshotResponse, error) {
|
||||
|
||||
rsp := &ScreenshotResponse{}
|
||||
return rsp, t.client.Call("thumbnail", "Screenshot", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ScreenshotRequest struct {
|
||||
// height of the browser window, optional
|
||||
Height int32 `json:"height"`
|
||||
Url string `json:"url"`
|
||||
// width of the browser window. optional
|
||||
Width int32 `json:"width"`
|
||||
}
|
||||
|
||||
type ScreenshotResponse struct {
|
||||
ImageUrl string `json:"imageURL"`
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
package time
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Time interface {
|
||||
Now(*NowRequest) (*NowResponse, error)
|
||||
Zone(*ZoneRequest) (*ZoneResponse, error)
|
||||
}
|
||||
|
||||
func NewTimeService(token string) *TimeService {
|
||||
return &TimeService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TimeService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the current time
|
||||
func (t *TimeService) Now(request *NowRequest) (*NowResponse, error) {
|
||||
|
||||
rsp := &NowResponse{}
|
||||
return rsp, t.client.Call("time", "Now", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the timezone info for a specific location
|
||||
func (t *TimeService) Zone(request *ZoneRequest) (*ZoneResponse, error) {
|
||||
|
||||
rsp := &ZoneResponse{}
|
||||
return rsp, t.client.Call("time", "Zone", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type NowRequest struct {
|
||||
// optional location, otherwise returns UTC
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type NowResponse struct {
|
||||
// the current time as HH:MM:SS
|
||||
Localtime string `json:"localtime"`
|
||||
// the location as Europe/London
|
||||
Location string `json:"location"`
|
||||
// timestamp as 2006-01-02T15:04:05.999999999Z07:00
|
||||
Timestamp string `json:"timestamp"`
|
||||
// the timezone as BST
|
||||
Timezone string `json:"timezone"`
|
||||
// the unix timestamp
|
||||
Unix int64 `json:"unix,string"`
|
||||
}
|
||||
|
||||
type ZoneRequest struct {
|
||||
// location to lookup e.g postcode, city, ip address
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ZoneResponse struct {
|
||||
// the abbreviated code e.g BST
|
||||
Abbreviation string `json:"abbreviation"`
|
||||
// country of the timezone
|
||||
Country string `json:"country"`
|
||||
// is daylight savings
|
||||
Dst bool `json:"dst"`
|
||||
// e.g 51.42
|
||||
Latitude float64 `json:"latitude"`
|
||||
// the local time
|
||||
Localtime string `json:"localtime"`
|
||||
// location requested
|
||||
Location string `json:"location"`
|
||||
// e.g -0.37
|
||||
Longitude float64 `json:"longitude"`
|
||||
// region of timezone
|
||||
Region string `json:"region"`
|
||||
// the timezone e.g Europe/London
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
package translate
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Translate interface {
|
||||
Text(*TextRequest) (*TextResponse, error)
|
||||
}
|
||||
|
||||
func NewTranslateService(token string) *TranslateService {
|
||||
return &TranslateService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TranslateService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Basic text translation
|
||||
func (t *TranslateService) Text(request *TextRequest) (*TextResponse, error) {
|
||||
|
||||
rsp := &TextResponse{}
|
||||
return rsp, t.client.Call("translate", "Text", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type TextRequest struct {
|
||||
// The contents to be translated
|
||||
Content string `json:"content"`
|
||||
// The string format, `text` or `html`
|
||||
Format string `json:"format"`
|
||||
// The model to use for translation, `nmt` or `base`,
|
||||
// See https://cloud.google.com/translate/docs/advanced/translating-text-v3#comparing-models for more information
|
||||
Model string `json:"model"`
|
||||
// Source language, format in ISO-639-1 codes
|
||||
// See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for more information
|
||||
Source string `json:"source"`
|
||||
// Target language, format in ISO-639-1 codes
|
||||
// See https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes for more information
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
type TextResponse struct {
|
||||
// The translated text
|
||||
Translation *Translation `json:"translation"`
|
||||
}
|
||||
|
||||
type Translation struct {
|
||||
// The model used in translation
|
||||
Model string `json:"model"`
|
||||
// The source of the query string
|
||||
Source string `json:"source"`
|
||||
// The translation result
|
||||
Text string `json:"text"`
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
package twitter
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Twitter interface {
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
Timeline(*TimelineRequest) (*TimelineResponse, error)
|
||||
Trends(*TrendsRequest) (*TrendsResponse, error)
|
||||
User(*UserRequest) (*UserResponse, error)
|
||||
}
|
||||
|
||||
func NewTwitterService(token string) *TwitterService {
|
||||
return &TwitterService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type TwitterService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Search for tweets with a simple query
|
||||
func (t *TwitterService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("twitter", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the timeline for a given user
|
||||
func (t *TwitterService) Timeline(request *TimelineRequest) (*TimelineResponse, error) {
|
||||
|
||||
rsp := &TimelineResponse{}
|
||||
return rsp, t.client.Call("twitter", "Timeline", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the current global trending topics
|
||||
func (t *TwitterService) Trends(request *TrendsRequest) (*TrendsResponse, error) {
|
||||
|
||||
rsp := &TrendsResponse{}
|
||||
return rsp, t.client.Call("twitter", "Trends", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get a user's twitter profile
|
||||
func (t *TwitterService) User(request *UserRequest) (*UserResponse, error) {
|
||||
|
||||
rsp := &UserResponse{}
|
||||
return rsp, t.client.Call("twitter", "User", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Profile struct {
|
||||
// the account creation date
|
||||
CreatedAt string `json:"created_at"`
|
||||
// the user description
|
||||
Description string `json:"description"`
|
||||
// the follower count
|
||||
Followers int64 `json:"followers,string"`
|
||||
// the user id
|
||||
Id int64 `json:"id,string"`
|
||||
// The user's profile picture
|
||||
ImageUrl string `json:"image_url"`
|
||||
// the user's location
|
||||
Location string `json:"location"`
|
||||
// display name of the user
|
||||
Name string `json:"name"`
|
||||
// if the account is private
|
||||
Private bool `json:"private"`
|
||||
// the username
|
||||
Username string `json:"username"`
|
||||
// if the account is verified
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// number of tweets to return. default: 20
|
||||
Limit int32 `json:"limit"`
|
||||
// the query to search for
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// the related tweets for the search
|
||||
Tweets []Tweet `json:"tweets"`
|
||||
}
|
||||
|
||||
type TimelineRequest struct {
|
||||
// number of tweets to return. default: 20
|
||||
Limit int32 `json:"limit"`
|
||||
// the username to request the timeline for
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type TimelineResponse struct {
|
||||
// The recent tweets for the user
|
||||
Tweets []Tweet `json:"tweets"`
|
||||
}
|
||||
|
||||
type Trend struct {
|
||||
// name of the trend
|
||||
Name string `json:"name"`
|
||||
// the volume of tweets in last 24 hours
|
||||
TweetVolume int64 `json:"tweet_volume,string"`
|
||||
// the twitter url
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type TrendsRequest struct {
|
||||
}
|
||||
|
||||
type TrendsResponse struct {
|
||||
// a list of trending topics
|
||||
Trends []Trend `json:"trends"`
|
||||
}
|
||||
|
||||
type Tweet struct {
|
||||
// time of tweet
|
||||
CreatedAt string `json:"created_at"`
|
||||
// number of times favourited
|
||||
FavouritedCount int64 `json:"favourited_count,string"`
|
||||
// id of the tweet
|
||||
Id int64 `json:"id,string"`
|
||||
// number of times retweeted
|
||||
RetweetedCount int64 `json:"retweeted_count,string"`
|
||||
// text of the tweet
|
||||
Text string `json:"text"`
|
||||
// username of the person who tweeted
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type UserRequest struct {
|
||||
// the username to lookup
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
// The requested user profile
|
||||
Profile *Profile `json:"profile"`
|
||||
// the current user status
|
||||
Status *Tweet `json:"status"`
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DIR=/tmp/services
|
||||
CDIR=`pwd`
|
||||
REPO=https://github.com/m3o/m3o-go
|
||||
|
||||
git clone $REPO $DIR
|
||||
cd $DIR
|
||||
|
||||
# move/delete
|
||||
rm -rf .git .github go.mod go.sum README.md CNAME Makefile TODO.md LICENSE client cmd examples
|
||||
mv m3o.go services.go
|
||||
|
||||
# rewrite
|
||||
grep -r "go.m3o.com" | cut -f 1 -d : | xargs sed -i 's@go.m3o.com/client@go-micro.dev/v4/api/client@g'
|
||||
sed -i 's@go.m3o.com@go-micro.dev/v4/services@g' services.go
|
||||
sed -i 's@package m3o@package services@g' services.go
|
||||
|
||||
# sync
|
||||
cd $CDIR
|
||||
rsync -avz $DIR/ .
|
||||
|
||||
# cleanup
|
||||
rm -rf $DIR
|
@ -1,85 +0,0 @@
|
||||
package url
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Url interface {
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Proxy(*ProxyRequest) (*ProxyResponse, error)
|
||||
Shorten(*ShortenRequest) (*ShortenResponse, error)
|
||||
}
|
||||
|
||||
func NewUrlService(token string) *UrlService {
|
||||
return &UrlService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type UrlService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// List all the shortened URLs
|
||||
func (t *UrlService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("url", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Proxy returns the destination URL of a short URL.
|
||||
func (t *UrlService) Proxy(request *ProxyRequest) (*ProxyResponse, error) {
|
||||
|
||||
rsp := &ProxyResponse{}
|
||||
return rsp, t.client.Call("url", "Proxy", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Shorten a long URL
|
||||
func (t *UrlService) Shorten(request *ShortenRequest) (*ShortenResponse, error) {
|
||||
|
||||
rsp := &ShortenResponse{}
|
||||
return rsp, t.client.Call("url", "Shorten", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// filter by short URL, optional
|
||||
ShortUrl string `json:"shortURL"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
UrlPairs *URLPair `json:"urlPairs"`
|
||||
}
|
||||
|
||||
type ProxyRequest struct {
|
||||
// short url ID, without the domain, eg. if your short URL is
|
||||
// `m3o.one/u/someshorturlid` then pass in `someshorturlid`
|
||||
ShortUrl string `json:"shortURL"`
|
||||
}
|
||||
|
||||
type ProxyResponse struct {
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
}
|
||||
|
||||
type ShortenRequest struct {
|
||||
// the url to shorten
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
}
|
||||
|
||||
type ShortenResponse struct {
|
||||
// the shortened url
|
||||
ShortUrl string `json:"shortURL"`
|
||||
}
|
||||
|
||||
type URLPair struct {
|
||||
// time of creation
|
||||
Created string `json:"created"`
|
||||
// destination url
|
||||
DestinationUrl string `json:"destinationURL"`
|
||||
// shortened url
|
||||
ShortUrl string `json:"shortURL"`
|
||||
}
|
@ -1,391 +0,0 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type User interface {
|
||||
Create(*CreateRequest) (*CreateResponse, error)
|
||||
Delete(*DeleteRequest) (*DeleteResponse, error)
|
||||
List(*ListRequest) (*ListResponse, error)
|
||||
Login(*LoginRequest) (*LoginResponse, error)
|
||||
Logout(*LogoutRequest) (*LogoutResponse, error)
|
||||
Read(*ReadRequest) (*ReadResponse, error)
|
||||
ReadSession(*ReadSessionRequest) (*ReadSessionResponse, error)
|
||||
ResetPassword(*ResetPasswordRequest) (*ResetPasswordResponse, error)
|
||||
SendMagicLink(*SendMagicLinkRequest) (*SendMagicLinkResponse, error)
|
||||
SendPasswordResetEmail(*SendPasswordResetEmailRequest) (*SendPasswordResetEmailResponse, error)
|
||||
SendVerificationEmail(*SendVerificationEmailRequest) (*SendVerificationEmailResponse, error)
|
||||
UpdatePassword(*UpdatePasswordRequest) (*UpdatePasswordResponse, error)
|
||||
Update(*UpdateRequest) (*UpdateResponse, error)
|
||||
VerifyEmail(*VerifyEmailRequest) (*VerifyEmailResponse, error)
|
||||
VerifyToken(*VerifyTokenRequest) (*VerifyTokenResponse, error)
|
||||
}
|
||||
|
||||
func NewUserService(token string) *UserService {
|
||||
return &UserService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type UserService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Create a new user account. The email address and username for the account must be unique.
|
||||
func (t *UserService) Create(request *CreateRequest) (*CreateResponse, error) {
|
||||
|
||||
rsp := &CreateResponse{}
|
||||
return rsp, t.client.Call("user", "Create", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Delete an account by id
|
||||
func (t *UserService) Delete(request *DeleteRequest) (*DeleteResponse, error) {
|
||||
|
||||
rsp := &DeleteResponse{}
|
||||
return rsp, t.client.Call("user", "Delete", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// List all users. Returns a paged list of results
|
||||
func (t *UserService) List(request *ListRequest) (*ListResponse, error) {
|
||||
|
||||
rsp := &ListResponse{}
|
||||
return rsp, t.client.Call("user", "List", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Login using username or email. The response will return a new session for successful login,
|
||||
// 401 in the case of login failure and 500 for any other error
|
||||
func (t *UserService) Login(request *LoginRequest) (*LoginResponse, error) {
|
||||
|
||||
rsp := &LoginResponse{}
|
||||
return rsp, t.client.Call("user", "Login", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Logout a user account
|
||||
func (t *UserService) Logout(request *LogoutRequest) (*LogoutResponse, error) {
|
||||
|
||||
rsp := &LogoutResponse{}
|
||||
return rsp, t.client.Call("user", "Logout", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read an account by id, username or email. Only one need to be specified.
|
||||
func (t *UserService) Read(request *ReadRequest) (*ReadResponse, error) {
|
||||
|
||||
rsp := &ReadResponse{}
|
||||
return rsp, t.client.Call("user", "Read", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Read a session by the session id. In the event it has expired or is not found and error is returned.
|
||||
func (t *UserService) ReadSession(request *ReadSessionRequest) (*ReadSessionResponse, error) {
|
||||
|
||||
rsp := &ReadSessionResponse{}
|
||||
return rsp, t.client.Call("user", "ReadSession", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Reset password with the code sent by the "SendPasswordResetEmail" endoint.
|
||||
func (t *UserService) ResetPassword(request *ResetPasswordRequest) (*ResetPasswordResponse, error) {
|
||||
|
||||
rsp := &ResetPasswordResponse{}
|
||||
return rsp, t.client.Call("user", "ResetPassword", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Login using email only - Passwordless
|
||||
func (t *UserService) SendMagicLink(request *SendMagicLinkRequest) (*SendMagicLinkResponse, error) {
|
||||
|
||||
rsp := &SendMagicLinkResponse{}
|
||||
return rsp, t.client.Call("user", "SendMagicLink", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send an email with a verification code to reset password.
|
||||
// Call "ResetPassword" endpoint once user provides the code.
|
||||
func (t *UserService) SendPasswordResetEmail(request *SendPasswordResetEmailRequest) (*SendPasswordResetEmailResponse, error) {
|
||||
|
||||
rsp := &SendPasswordResetEmailResponse{}
|
||||
return rsp, t.client.Call("user", "SendPasswordResetEmail", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Send a verification email to a user.
|
||||
// Email "from" will be 'noreply@email.m3ocontent.com'.
|
||||
// The verification link will be injected in the email
|
||||
// as a template variable, $micro_verification_link e.g
|
||||
// 'Welcome to M3O! Use the link below to verify your email: $micro_verification_link'
|
||||
// The variable will be replaced with a url similar to:
|
||||
// 'https://user.m3o.com/user/verify?token=a-verification-token&redirectUrl=your-redir-url'
|
||||
func (t *UserService) SendVerificationEmail(request *SendVerificationEmailRequest) (*SendVerificationEmailResponse, error) {
|
||||
|
||||
rsp := &SendVerificationEmailResponse{}
|
||||
return rsp, t.client.Call("user", "SendVerificationEmail", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update the account password
|
||||
func (t *UserService) UpdatePassword(request *UpdatePasswordRequest) (*UpdatePasswordResponse, error) {
|
||||
|
||||
rsp := &UpdatePasswordResponse{}
|
||||
return rsp, t.client.Call("user", "UpdatePassword", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Update the account username or email
|
||||
func (t *UserService) Update(request *UpdateRequest) (*UpdateResponse, error) {
|
||||
|
||||
rsp := &UpdateResponse{}
|
||||
return rsp, t.client.Call("user", "Update", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Verify the email address of an account from a token sent in an email to the user.
|
||||
func (t *UserService) VerifyEmail(request *VerifyEmailRequest) (*VerifyEmailResponse, error) {
|
||||
|
||||
rsp := &VerifyEmailResponse{}
|
||||
return rsp, t.client.Call("user", "VerifyEmail", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Check whether the token attached to MagicLink is valid or not.
|
||||
// Ideally, you need to call this endpoint from your http request
|
||||
// handler that handles the endpoint which is specified in the
|
||||
// SendMagicLink request.
|
||||
func (t *UserService) VerifyToken(request *VerifyTokenRequest) (*VerifyTokenResponse, error) {
|
||||
|
||||
rsp := &VerifyTokenResponse{}
|
||||
return rsp, t.client.Call("user", "VerifyToken", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Account struct {
|
||||
// unix timestamp
|
||||
Created int64 `json:"created,string"`
|
||||
// an email address
|
||||
Email string `json:"email"`
|
||||
// unique account id
|
||||
Id string `json:"id"`
|
||||
// Store any custom data you want about your users in this fields.
|
||||
Profile map[string]string `json:"profile"`
|
||||
// unix timestamp
|
||||
Updated int64 `json:"updated,string"`
|
||||
// alphanumeric username
|
||||
Username string `json:"username"`
|
||||
// date of verification
|
||||
VerificationDate int64 `json:"verificationDate,string"`
|
||||
// if the account is verified
|
||||
Verified bool `json:"verified"`
|
||||
}
|
||||
|
||||
type CreateRequest struct {
|
||||
// the email address
|
||||
Email string `json:"email"`
|
||||
// optional account id
|
||||
Id string `json:"id"`
|
||||
// the user password
|
||||
Password string `json:"password"`
|
||||
// optional user profile as map<string,string>
|
||||
Profile map[string]string `json:"profile"`
|
||||
// the username
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type CreateResponse struct {
|
||||
Account *Account `json:"account"`
|
||||
}
|
||||
|
||||
type DeleteRequest struct {
|
||||
// the account id
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type DeleteResponse struct {
|
||||
}
|
||||
|
||||
type ListRequest struct {
|
||||
// Maximum number of records to return. Default limit is 25.
|
||||
// Maximum limit is 1000. Anything higher will return an error.
|
||||
Limit int32 `json:"limit"`
|
||||
Offset int32 `json:"offset"`
|
||||
}
|
||||
|
||||
type ListResponse struct {
|
||||
Users []Account `json:"users"`
|
||||
}
|
||||
|
||||
type LoginRequest struct {
|
||||
// The email address of the user
|
||||
Email string `json:"email"`
|
||||
// The password of the user
|
||||
Password string `json:"password"`
|
||||
// The username of the user
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
// The session of the logged in user
|
||||
Session *Session `json:"session"`
|
||||
}
|
||||
|
||||
type LogoutRequest struct {
|
||||
// the session id for the user to logout
|
||||
SessionId string `json:"sessionId"`
|
||||
}
|
||||
|
||||
type LogoutResponse struct {
|
||||
}
|
||||
|
||||
type ReadRequest struct {
|
||||
// the account email
|
||||
Email string `json:"email"`
|
||||
// the account id
|
||||
Id string `json:"id"`
|
||||
// the account username
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type ReadResponse struct {
|
||||
Account *Account `json:"account"`
|
||||
}
|
||||
|
||||
type ReadSessionRequest struct {
|
||||
// The unique session id
|
||||
SessionId string `json:"sessionId"`
|
||||
}
|
||||
|
||||
type ReadSessionResponse struct {
|
||||
// the session for the user
|
||||
Session *Session `json:"session"`
|
||||
}
|
||||
|
||||
type ResetPasswordRequest struct {
|
||||
// The code from the verification email
|
||||
Code string `json:"code"`
|
||||
// confirm new password
|
||||
ConfirmPassword string `json:"confirmPassword"`
|
||||
// the email to reset the password for
|
||||
Email string `json:"email"`
|
||||
// the new password
|
||||
NewPassword string `json:"newPassword"`
|
||||
}
|
||||
|
||||
type ResetPasswordResponse struct {
|
||||
}
|
||||
|
||||
type SendMagicLinkRequest struct {
|
||||
// Your web site address, example www.example.com or user.example.com
|
||||
Address string `json:"address"`
|
||||
// the email address of the user
|
||||
Email string `json:"email"`
|
||||
// Endpoint name where your http request handler handles MagicLink by
|
||||
// calling M3O VerifyToken endpoint. You can return as a result a success,
|
||||
// failed or redirect to another page.
|
||||
Endpoint string `json:"endpoint"`
|
||||
// Display name of the sender for the email. Note: the email address will still be 'support@m3o.com'
|
||||
FromName string `json:"fromName"`
|
||||
Subject string `json:"subject"`
|
||||
// Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link
|
||||
// HTML emails are not available currently.
|
||||
TextContent string `json:"textContent"`
|
||||
}
|
||||
|
||||
type SendMagicLinkResponse struct {
|
||||
}
|
||||
|
||||
type SendPasswordResetEmailRequest struct {
|
||||
// email address to send reset for
|
||||
Email string `json:"email"`
|
||||
// Display name of the sender for the email. Note: the email address will still be 'noreply@email.m3ocontent.com'
|
||||
FromName string `json:"fromName"`
|
||||
// subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// Text content of the email. Don't forget to include the string '$code' which will be replaced by the real verification link
|
||||
// HTML emails are not available currently.
|
||||
TextContent string `json:"textContent"`
|
||||
}
|
||||
|
||||
type SendPasswordResetEmailResponse struct {
|
||||
}
|
||||
|
||||
type SendVerificationEmailRequest struct {
|
||||
// email address to send the verification code
|
||||
Email string `json:"email"`
|
||||
// The url to redirect to incase of failure
|
||||
FailureRedirectUrl string `json:"failureRedirectUrl"`
|
||||
// Display name of the sender for the email. Note: the email address will still be 'noreply@email.m3ocontent.com'
|
||||
FromName string `json:"fromName"`
|
||||
// The url to redirect to after successful verification
|
||||
RedirectUrl string `json:"redirectUrl"`
|
||||
// subject of the email
|
||||
Subject string `json:"subject"`
|
||||
// Text content of the email. Don't forget to include the string '$micro_verification_link' which will be replaced by the real verification link
|
||||
// HTML emails are not available currently.
|
||||
TextContent string `json:"textContent"`
|
||||
}
|
||||
|
||||
type SendVerificationEmailResponse struct {
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
// unix timestamp
|
||||
Created int64 `json:"created,string"`
|
||||
// unix timestamp
|
||||
Expires int64 `json:"expires,string"`
|
||||
// the session id
|
||||
Id string `json:"id"`
|
||||
// the associated user id
|
||||
UserId string `json:"userId"`
|
||||
}
|
||||
|
||||
type UpdatePasswordRequest struct {
|
||||
// confirm new password
|
||||
ConfirmPassword string `json:"confirm_password"`
|
||||
// the new password
|
||||
NewPassword string `json:"newPassword"`
|
||||
// the old password
|
||||
OldPassword string `json:"oldPassword"`
|
||||
// the account id
|
||||
UserId string `json:"userId"`
|
||||
}
|
||||
|
||||
type UpdatePasswordResponse struct {
|
||||
}
|
||||
|
||||
type UpdateRequest struct {
|
||||
// the new email address
|
||||
Email string `json:"email"`
|
||||
// the account id
|
||||
Id string `json:"id"`
|
||||
// the user profile as map<string,string>
|
||||
Profile map[string]string `json:"profile"`
|
||||
// the new username
|
||||
Username string `json:"username"`
|
||||
}
|
||||
|
||||
type UpdateResponse struct {
|
||||
}
|
||||
|
||||
type VerifyEmailRequest struct {
|
||||
// The token from the verification email
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type VerifyEmailResponse struct {
|
||||
}
|
||||
|
||||
type VerifyTokenRequest struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type VerifyTokenResponse struct {
|
||||
IsValid bool `json:"is_valid"`
|
||||
Message string `json:"message"`
|
||||
Session *Session `json:"session"`
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package vehicle
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Vehicle interface {
|
||||
Lookup(*LookupRequest) (*LookupResponse, error)
|
||||
}
|
||||
|
||||
func NewVehicleService(token string) *VehicleService {
|
||||
return &VehicleService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type VehicleService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup a UK vehicle by it's registration number
|
||||
func (t *VehicleService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||
|
||||
rsp := &LookupResponse{}
|
||||
return rsp, t.client.Call("vehicle", "Lookup", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type LookupRequest struct {
|
||||
// the vehicle registration number
|
||||
Registration string `json:"registration"`
|
||||
}
|
||||
|
||||
type LookupResponse struct {
|
||||
// co2 emmissions
|
||||
Co2Emissions float64 `json:"co2_emissions"`
|
||||
// colour of vehicle
|
||||
Colour string `json:"colour"`
|
||||
// engine capacity
|
||||
EngineCapacity int32 `json:"engine_capacity"`
|
||||
// fuel type e.g petrol, diesel
|
||||
FuelType string `json:"fuel_type"`
|
||||
// date of last v5 issue
|
||||
LastV5Issued string `json:"last_v5_issued"`
|
||||
// make of vehicle
|
||||
Make string `json:"make"`
|
||||
// month of first registration
|
||||
MonthOfFirstRegistration string `json:"month_of_first_registration"`
|
||||
// mot expiry
|
||||
MotExpiry string `json:"mot_expiry"`
|
||||
// mot status
|
||||
MotStatus string `json:"mot_status"`
|
||||
// registration number
|
||||
Registration string `json:"registration"`
|
||||
// tax due data
|
||||
TaxDueDate string `json:"tax_due_date"`
|
||||
// tax status
|
||||
TaxStatus string `json:"tax_status"`
|
||||
// type approvale
|
||||
TypeApproval string `json:"type_approval"`
|
||||
// wheel plan
|
||||
Wheelplan string `json:"wheelplan"`
|
||||
// year of manufacture
|
||||
YearOfManufacture int32 `json:"year_of_manufacture"`
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
package weather
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Weather interface {
|
||||
Forecast(*ForecastRequest) (*ForecastResponse, error)
|
||||
Now(*NowRequest) (*NowResponse, error)
|
||||
}
|
||||
|
||||
func NewWeatherService(token string) *WeatherService {
|
||||
return &WeatherService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type WeatherService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Get the weather forecast for the next 1-10 days
|
||||
func (t *WeatherService) Forecast(request *ForecastRequest) (*ForecastResponse, error) {
|
||||
|
||||
rsp := &ForecastResponse{}
|
||||
return rsp, t.client.Call("weather", "Forecast", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Get the current weather report for a location by postcode, city, zip code, ip address
|
||||
func (t *WeatherService) Now(request *NowRequest) (*NowResponse, error) {
|
||||
|
||||
rsp := &NowResponse{}
|
||||
return rsp, t.client.Call("weather", "Now", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type Forecast struct {
|
||||
// the average temp in celsius
|
||||
AvgTempC float64 `json:"avg_temp_c"`
|
||||
// the average temp in fahrenheit
|
||||
AvgTempF float64 `json:"avg_temp_f"`
|
||||
// chance of rain (percentage)
|
||||
ChanceOfRain int32 `json:"chance_of_rain"`
|
||||
// forecast condition
|
||||
Condition string `json:"condition"`
|
||||
// date of the forecast
|
||||
Date string `json:"date"`
|
||||
// the URL of forecast condition icon. Simply prefix with either http or https to use it
|
||||
IconUrl string `json:"icon_url"`
|
||||
// max temp in celsius
|
||||
MaxTempC float64 `json:"max_temp_c"`
|
||||
// max temp in fahrenheit
|
||||
MaxTempF float64 `json:"max_temp_f"`
|
||||
// minimum temp in celsius
|
||||
MinTempC float64 `json:"min_temp_c"`
|
||||
// minimum temp in fahrenheit
|
||||
MinTempF float64 `json:"min_temp_f"`
|
||||
// time of sunrise
|
||||
Sunrise string `json:"sunrise"`
|
||||
// time of sunset
|
||||
Sunset string `json:"sunset"`
|
||||
// will it rain
|
||||
WillItRain bool `json:"will_it_rain"`
|
||||
}
|
||||
|
||||
type ForecastRequest struct {
|
||||
// number of days. default 1, max 10
|
||||
Days int32 `json:"days"`
|
||||
// location of the forecase
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ForecastResponse struct {
|
||||
// country of the request
|
||||
Country string `json:"country"`
|
||||
// forecast for the next number of days
|
||||
Forecast []Forecast `json:"forecast"`
|
||||
// e.g 37.55
|
||||
Latitude float64 `json:"latitude"`
|
||||
// the local time
|
||||
LocalTime string `json:"local_time"`
|
||||
// location of the request
|
||||
Location string `json:"location"`
|
||||
// e.g -77.46
|
||||
Longitude float64 `json:"longitude"`
|
||||
// region related to the location
|
||||
Region string `json:"region"`
|
||||
// timezone of the location
|
||||
Timezone string `json:"timezone"`
|
||||
}
|
||||
|
||||
type NowRequest struct {
|
||||
// location to get weather e.g postcode, city
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type NowResponse struct {
|
||||
// cloud cover percentage
|
||||
Cloud int32 `json:"cloud"`
|
||||
// the weather condition
|
||||
Condition string `json:"condition"`
|
||||
// country of the request
|
||||
Country string `json:"country"`
|
||||
// whether its daytime
|
||||
Daytime bool `json:"daytime"`
|
||||
// feels like in celsius
|
||||
FeelsLikeC float64 `json:"feels_like_c"`
|
||||
// feels like in fahrenheit
|
||||
FeelsLikeF float64 `json:"feels_like_f"`
|
||||
// the humidity percentage
|
||||
Humidity int32 `json:"humidity"`
|
||||
// the URL of the related icon. Simply prefix with either http or https to use it
|
||||
IconUrl string `json:"icon_url"`
|
||||
// e.g 37.55
|
||||
Latitude float64 `json:"latitude"`
|
||||
// the local time
|
||||
LocalTime string `json:"local_time"`
|
||||
// location of the request
|
||||
Location string `json:"location"`
|
||||
// e.g -77.46
|
||||
Longitude float64 `json:"longitude"`
|
||||
// region related to the location
|
||||
Region string `json:"region"`
|
||||
// temperature in celsius
|
||||
TempC float64 `json:"temp_c"`
|
||||
// temperature in fahrenheit
|
||||
TempF float64 `json:"temp_f"`
|
||||
// timezone of the location
|
||||
Timezone string `json:"timezone"`
|
||||
// wind degree
|
||||
WindDegree int32 `json:"wind_degree"`
|
||||
// wind direction
|
||||
WindDirection string `json:"wind_direction"`
|
||||
// wind in kph
|
||||
WindKph float64 `json:"wind_kph"`
|
||||
// wind in mph
|
||||
WindMph float64 `json:"wind_mph"`
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package youtube
|
||||
|
||||
import (
|
||||
"go-micro.dev/v4/api/client"
|
||||
)
|
||||
|
||||
type Youtube interface {
|
||||
Embed(*EmbedRequest) (*EmbedResponse, error)
|
||||
Search(*SearchRequest) (*SearchResponse, error)
|
||||
}
|
||||
|
||||
func NewYoutubeService(token string) *YoutubeService {
|
||||
return &YoutubeService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type YoutubeService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Embed a YouTube video
|
||||
func (t *YoutubeService) Embed(request *EmbedRequest) (*EmbedResponse, error) {
|
||||
|
||||
rsp := &EmbedResponse{}
|
||||
return rsp, t.client.Call("youtube", "Embed", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
// Search for videos on YouTube
|
||||
func (t *YoutubeService) Search(request *SearchRequest) (*SearchResponse, error) {
|
||||
|
||||
rsp := &SearchResponse{}
|
||||
return rsp, t.client.Call("youtube", "Search", request, rsp)
|
||||
|
||||
}
|
||||
|
||||
type EmbedRequest struct {
|
||||
// provide the youtube url e.g https://www.youtube.com/watch?v=GWRWZu7XsJ0
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type EmbedResponse struct {
|
||||
// the embeddable link e.g https://www.youtube.com/watch?v=GWRWZu7XsJ0
|
||||
EmbedUrl string `json:"embed_url"`
|
||||
// the script code
|
||||
HtmlScript string `json:"html_script"`
|
||||
// the full url
|
||||
LongUrl string `json:"long_url"`
|
||||
// the short url
|
||||
ShortUrl string `json:"short_url"`
|
||||
}
|
||||
|
||||
type SearchRequest struct {
|
||||
// Query to search for
|
||||
Query string `json:"query"`
|
||||
}
|
||||
|
||||
type SearchResponse struct {
|
||||
// List of results for the query
|
||||
Results []SearchResult `json:"results"`
|
||||
}
|
||||
|
||||
type SearchResult struct {
|
||||
// if live broadcast then indicates activity.
|
||||
// none, upcoming, live, completed
|
||||
Broadcasting string `json:"broadcasting"`
|
||||
// the channel id
|
||||
ChannelId string `json:"channel_id"`
|
||||
// the channel title
|
||||
ChannelTitle string `json:"channel_title"`
|
||||
// the result description
|
||||
Description string `json:"description"`
|
||||
// id of the result
|
||||
Id string `json:"id"`
|
||||
// kind of result; "video", "channel", "playlist"
|
||||
Kind string `json:"kind"`
|
||||
// published at time
|
||||
PublishedAt string `json:"published_at"`
|
||||
// title of the result
|
||||
Title string `json:"title"`
|
||||
// the associated url
|
||||
Url string `json:"url"`
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user