This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks_api.go
240 lines (209 loc) · 10.3 KB
/
hooks_api.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* Meltwater Streaming API v2
*
* The Meltwater Streaming API provides the needed resources for Meltwater clients to create & delete REST Hooks and stream Meltwater search results to your specified destination.
*
* OpenAPI spec version: 2.0.0
* Contact: support@api.meltwater.com
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
package swagger
import (
"net/url"
"strings"
"encoding/json"
"fmt"
)
type HooksApi struct {
Configuration *Configuration
}
func NewHooksApi() *HooksApi {
configuration := NewConfiguration()
return &HooksApi{
Configuration: configuration,
}
}
func NewHooksApiWithBasePath(basePath string) *HooksApi {
configuration := NewConfiguration()
configuration.BasePath = basePath
return &HooksApi{
Configuration: configuration,
}
}
/**
* Creates a hook for one of your predefined searches.
* Creates a hook for one of your predefined searches. Delivers search results for the query referenced by the `search_id` to the `target_url` via HTTP POST. Note that a `hook_id` will be returned on successful creation, this id is needed to delete the hook. We are also returning the header: `X-Hook-Secret`, a shared secret used to sign the document body pushed to your `target_url`. Requires an OAuth access token.
*
* @param userKey The `user_key` from [developer.meltwater.com](https://developer.meltwater.com/admin/applications/).
* @param authorization `Oauth Access Token` OAuth access token (RFC 6749). Must contain the access token type `Bearer` followed by an OAuth access token. #### Example: Bearer KKwmfHwxsEoeMDTMAfxOpO...
* @param v2Hooks
* @param xHookSecret Shared secret for content signing/verification. The shared secret header is optional and can be provided by the user or will be set by the API. Must be between 16 and 64 characters. Obtain the shared secret from the response header `X-Hook-Secret`. #### Example: e2d264b524240b9572ebc2fc7eebd980
* @return *Hook
*/
func (a HooksApi) CreateHook(userKey string, authorization string, v2Hooks PostV2Hooks, xHookSecret string) (*Hook, *APIResponse, error) {
var localVarHttpMethod = strings.ToUpper("Post")
// create path and map variables
localVarPath := a.Configuration.BasePath + "/v2/hooks"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := make(map[string]string)
var localVarPostBody interface{}
var localVarFileName string
var localVarFileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
localVarHeaderParams[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 != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// header params "user-key"
localVarHeaderParams["user-key"] = a.Configuration.APIClient.ParameterToString(userKey, "")
// header params "Authorization"
localVarHeaderParams["Authorization"] = a.Configuration.APIClient.ParameterToString(authorization, "")
// header params "X-Hook-Secret"
localVarHeaderParams["X-Hook-Secret"] = a.Configuration.APIClient.ParameterToString(xHookSecret, "")
// body params
localVarPostBody = &v2Hooks
var successPayload = new(Hook)
localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
var localVarURL, _ = url.Parse(localVarPath)
localVarURL.RawQuery = localVarQueryParams.Encode()
var localVarAPIResponse = &APIResponse{Operation: "CreateHook", Method: localVarHttpMethod, RequestURL: localVarURL.String()}
if localVarHttpResponse != nil {
localVarAPIResponse.Response = localVarHttpResponse.RawResponse
localVarAPIResponse.Payload = localVarHttpResponse.Body()
}
if err != nil {
return successPayload, localVarAPIResponse, err
}
err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload)
return successPayload, localVarAPIResponse, err
}
/**
* Delete an existing hook.
* Delete an existing hook. Removes the hook and stops sending any search results to the target_url. Requires an OAuth access token.
*
* @param userKey The `user_key` from [developer.meltwater.com](https://developer.meltwater.com/admin/applications/).
* @param authorization `Oauth Access Token` OAuth access token (RFC 6749). Must contain the access token type `Bearer` followed by an OAuth access token. #### Example: Bearer KKwmfHwxsEoeMDTMAfxOpO...
* @param hookId Hook ID received from creating a hook
* @return void
*/
func (a HooksApi) DeleteHook(userKey string, authorization string, hookId string) (*APIResponse, error) {
var localVarHttpMethod = strings.ToUpper("Delete")
// create path and map variables
localVarPath := a.Configuration.BasePath + "/v2/hooks/{hook_id}"
localVarPath = strings.Replace(localVarPath, "{"+"hook_id"+"}", fmt.Sprintf("%v", hookId), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := make(map[string]string)
var localVarPostBody interface{}
var localVarFileName string
var localVarFileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
localVarHeaderParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// header params "user-key"
localVarHeaderParams["user-key"] = a.Configuration.APIClient.ParameterToString(userKey, "")
// header params "Authorization"
localVarHeaderParams["Authorization"] = a.Configuration.APIClient.ParameterToString(authorization, "")
localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
var localVarURL, _ = url.Parse(localVarPath)
localVarURL.RawQuery = localVarQueryParams.Encode()
var localVarAPIResponse = &APIResponse{Operation: "DeleteHook", Method: localVarHttpMethod, RequestURL: localVarURL.String()}
if localVarHttpResponse != nil {
localVarAPIResponse.Response = localVarHttpResponse.RawResponse
localVarAPIResponse.Payload = localVarHttpResponse.Body()
}
if err != nil {
return localVarAPIResponse, err
}
return localVarAPIResponse, err
}
/**
* List all hooks.
* List all hooks. Delivers all previously generated hooks. Requires an OAuth access token.
*
* @param userKey The `user_key` from [developer.meltwater.com](https://developer.meltwater.com/admin/applications/).
* @param authorization `Oauth Access Token` OAuth access token (RFC 6749). Must contain the access token type `Bearer` followed by an OAuth access token. #### Example: Bearer KKwmfHwxsEoeMDTMAfxOpO...
* @return *HooksCollection
*/
func (a HooksApi) GetAllHooks(userKey string, authorization string) (*HooksCollection, *APIResponse, error) {
var localVarHttpMethod = strings.ToUpper("Get")
// create path and map variables
localVarPath := a.Configuration.BasePath + "/v2/hooks"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := make(map[string]string)
var localVarPostBody interface{}
var localVarFileName string
var localVarFileBytes []byte
// add default headers if any
for key := range a.Configuration.DefaultHeader {
localVarHeaderParams[key] = a.Configuration.DefaultHeader[key]
}
// to determine the Content-Type header
localVarHttpContentTypes := []string{ }
// set Content-Type header
localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}
// to determine the Accept header
localVarHttpHeaderAccepts := []string{
"application/json",
}
// set Accept header
localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
// header params "user-key"
localVarHeaderParams["user-key"] = a.Configuration.APIClient.ParameterToString(userKey, "")
// header params "Authorization"
localVarHeaderParams["Authorization"] = a.Configuration.APIClient.ParameterToString(authorization, "")
var successPayload = new(HooksCollection)
localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
var localVarURL, _ = url.Parse(localVarPath)
localVarURL.RawQuery = localVarQueryParams.Encode()
var localVarAPIResponse = &APIResponse{Operation: "GetAllHooks", Method: localVarHttpMethod, RequestURL: localVarURL.String()}
if localVarHttpResponse != nil {
localVarAPIResponse.Response = localVarHttpResponse.RawResponse
localVarAPIResponse.Payload = localVarHttpResponse.Body()
}
if err != nil {
return successPayload, localVarAPIResponse, err
}
err = json.Unmarshal(localVarHttpResponse.Body(), &successPayload)
return successPayload, localVarAPIResponse, err
}