Commit from m3o/m3o action

This commit is contained in:
m3o-actions
2021-12-08 10:41:28 +00:00
parent e56ccf9c5a
commit 18f89d3897
20 changed files with 886 additions and 788 deletions

43
joke/joke.go Executable file
View File

@@ -0,0 +1,43 @@
package joke
import (
"go.m3o.com/client"
)
func NewJokeService(token string) *JokeService {
return &JokeService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type JokeService struct {
client *client.Client
}
//
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"`
// the source of joke
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"`
}