-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathparameters.go
61 lines (49 loc) · 1.27 KB
/
parameters.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
52
53
54
55
56
57
58
59
60
61
package luis
import (
"bytes"
"fmt"
"io/ioutil"
"log"
)
func getBooleanString(b bool) string {
if b {
return "true"
} else {
return "false"
}
}
func getFileByteBuffer(path string) (*bytes.Buffer, error) {
fileData, err := ioutil.ReadFile(path)
if err != nil {
log.Println("File open err:", err)
return nil, err
}
return bytes.NewBuffer(fileData), nil
}
func getUrlByteBuffer(url string) *bytes.Buffer {
byteData := []byte(fmt.Sprintf(`{"url":"%s"}`, url))
return bytes.NewBuffer(byteData)
}
func getUserDataByteBuffer(userData string) *bytes.Buffer {
byteData := []byte(fmt.Sprintf(`{"userData":"%s"}`, userData))
return bytes.NewBuffer(byteData)
}
func getStringDataByteBuffer(userData string) *bytes.Buffer {
byteData := []byte(fmt.Sprintf(`["%s"]`, userData))
return bytes.NewBuffer(byteData)
}
//ExamplePayload :
type ExamplePayload struct {
ExampleText string `json:"text"`
SelectedIntentName string `json:"intentName"`
EntityLabels []struct {
EntityType string `json:"entityName"`
StartToken int `json:"startCharIndex"`
EndToken int `json:"endCharIndex"`
} `json:"entityLabels,omitempty"`
}
type PublishPayload struct {
VersionID string `json:"versionId"`
IsStaging bool `json:"isStaging"`
Region string `json:"region"`
}