mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-23 23:21:27 +00:00
Commit from m3o/m3o action
This commit is contained in:
43
joke/joke.go
Executable file
43
joke/joke.go
Executable 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"`
|
||||
}
|
||||
Reference in New Issue
Block a user