Files
m3o-go/emoji/emoji.go
2022-02-19 18:01:25 +00:00

79 lines
1.6 KiB
Go
Executable File

package emoji
import (
"go.m3o.com/client"
)
type Emoji interface {
Find(*FindRequest) (*FindResponse, error)
Flag(*FlagRequest) (*FlagResponse, error)
Print(*PrintRequest) (*PrintResponse, 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)
}
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"`
}