Add separate service clients (#5)

This commit is contained in:
Janos Dobronszki
2021-09-14 16:36:40 +01:00
committed by GitHub
parent ba48658a46
commit 726d1ccef6
29 changed files with 2451 additions and 0 deletions

37
service/answer/answer.go Executable file
View File

@@ -0,0 +1,37 @@
package answer
import (
"github.com/m3o/m3o-go/client"
)
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"`
}