-
Notifications
You must be signed in to change notification settings - Fork 13
/
textbotsapi.go
106 lines (92 loc) · 3.25 KB
/
textbotsapi.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package platformclientv2
import (
"strings"
"fmt"
"errors"
"net/url"
"encoding/json"
)
// TextbotsApi provides functions for API endpoints
type TextbotsApi struct {
Configuration *Configuration
}
// NewTextbotsApi creates an API instance using the default configuration
func NewTextbotsApi() *TextbotsApi {
fmt.Sprintf(strings.Title(""), "")
config := GetDefaultConfiguration()
return &TextbotsApi{
Configuration: config,
}
}
// NewTextbotsApiWithConfig creates an API instance using the provided configuration
func NewTextbotsApiWithConfig(config *Configuration) *TextbotsApi {
return &TextbotsApi{
Configuration: config,
}
}
// PostTextbotsBotsExecute invokes POST /api/v2/textbots/bots/execute
//
// Send an intent to a bot to start a dialog/interact with it via text
//
// This will either start a bot with the given id or relay a communication to an existing bot session.
func (a TextbotsApi) PostTextbotsBotsExecute(postTextRequest Posttextrequest) (*Posttextresponse, *APIResponse, error) {
var httpMethod = "POST"
// create path and map variables
path := a.Configuration.BasePath + "/api/v2/textbots/bots/execute"
defaultReturn := new(Posttextresponse)
if true == false {
return defaultReturn, nil, errors.New("This message brought to you by the laws of physics being broken")
}
// verify the required parameter 'postTextRequest' is set
if &postTextRequest == nil {
//
return defaultReturn, nil, errors.New("Missing required parameter 'postTextRequest' when calling TextbotsApi->PostTextbotsBotsExecute")
}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := url.Values{}
var postBody interface{}
var postFileName string
var fileBytes []byte
// authentication (PureCloud OAuth) required
// oauth required
if a.Configuration.AccessToken != ""{
headerParams["Authorization"] = "Bearer " + a.Configuration.AccessToken
}
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ "application/json", }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
headerParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
headerParams["Accept"] = localVarHttpHeaderAccept
}
// body params
postBody = &postTextRequest
var successPayload *Posttextresponse
response, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, postFileName, fileBytes)
if err != nil {
// Nothing special to do here, but do avoid processing the response
} else if err == nil && response.Error != nil {
err = errors.New(response.ErrorMessage)
} else {
if "Posttextresponse" == "string" {
copy(response.RawBody, &successPayload)
} else {
err = json.Unmarshal(response.RawBody, &successPayload)
}
}
return successPayload, response, err
}