-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask_translate.go
51 lines (38 loc) · 1.31 KB
/
task_translate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// go-mirage-api
//
// Copyright 2023, Valerian Saliou
// Author: Valerian Saliou <[email protected]>
package mirage
// TranslateTextRequest mapping
type TranslateTextRequest struct {
Locale TranslateTextRequestLocale `json:"locale"`
Type *string `json:"type,omitempty"`
Text string `json:"text"`
}
// TranslateTextRequestLocale mapping
type TranslateTextRequestLocale struct {
From string `json:"from"`
To string `json:"to"`
}
// TranslateTextResponseData mapping
type TranslateTextResponseData struct {
Data *TranslateTextResponse `json:"data"`
}
// TranslateTextResponse mapping
type TranslateTextResponse struct {
Translation string `json:"translation"`
}
// String returns the string representation of TranslateTextResponse
func (instance TranslateTextResponse) String() string {
return Stringify(instance)
}
// TranslateText translate a provided text between two languages.
func (service *TaskService) TranslateText(ctx RequestContext, data TranslateTextRequest) (*TranslateTextResponse, error) {
req, _ := service.client.NewRequest("POST", "task/translate/text", data, ctx)
result := new(TranslateTextResponseData)
_, err := service.client.Do(req, result)
if err != nil {
return nil, err
}
return result.Data, err
}