-
Notifications
You must be signed in to change notification settings - Fork 13
/
webmessagingapi.go
106 lines (90 loc) · 3.25 KB
/
webmessagingapi.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"
)
// WebMessagingApi provides functions for API endpoints
type WebMessagingApi struct {
Configuration *Configuration
}
// NewWebMessagingApi creates an API instance using the default configuration
func NewWebMessagingApi() *WebMessagingApi {
fmt.Sprintf(strings.Title(""), "")
config := GetDefaultConfiguration()
return &WebMessagingApi{
Configuration: config,
}
}
// NewWebMessagingApiWithConfig creates an API instance using the provided configuration
func NewWebMessagingApiWithConfig(config *Configuration) *WebMessagingApi {
return &WebMessagingApi{
Configuration: config,
}
}
// GetWebmessagingMessages invokes GET /api/v2/webmessaging/messages
//
// Get the messages for a web messaging session.
func (a WebMessagingApi) GetWebmessagingMessages(pageSize int, pageNumber int) (*Webmessagingmessageentitylist, *APIResponse, error) {
var httpMethod = "GET"
// create path and map variables
path := a.Configuration.BasePath + "/api/v2/webmessaging/messages"
defaultReturn := new(Webmessagingmessageentitylist)
if true == false {
return defaultReturn, nil, errors.New("This message brought to you by the laws of physics being broken")
}
headerParams := make(map[string]string)
queryParams := make(map[string]string)
formParams := url.Values{}
var postBody interface{}
var postFileName string
var fileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
headerParams[key] = a.Configuration.DefaultHeader[key]
}
queryParams["pageSize"] = a.Configuration.APIClient.ParameterToString(pageSize, "")
queryParams["pageNumber"] = a.Configuration.APIClient.ParameterToString(pageNumber, "")
// Find an replace keys that were altered to avoid clashes with go keywords
correctedQueryParams := make(map[string]string)
for k, v := range queryParams {
if k == "varType" {
correctedQueryParams["type"] = v
continue
}
correctedQueryParams[k] = v
}
queryParams = correctedQueryParams
// 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
}
var successPayload *Webmessagingmessageentitylist
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 response.HasBody {
if "Webmessagingmessageentitylist" == "string" {
copy(response.RawBody, &successPayload)
} else {
err = json.Unmarshal(response.RawBody, &successPayload)
}
}
return successPayload, response, err
}