1679 lines
62 KiB
Go
1679 lines
62 KiB
Go
|
/*
|
||
|
* Firefly III API v2.0.12
|
||
|
*
|
||
|
* This is the documentation of the Firefly III API. You can find accompanying documentation on the website of Firefly III itself (see below). Please report any bugs or issues. You may use the \"Authorize\" button to try the API below. This file was last generated on 2024-03-16T05:34:43+00:00 Please keep in mind that the demo site does not accept requests from curl, colly, wget, etc. You must use a browser or a tool like Postman to make requests. Too many script kiddies out there, sorry about that.
|
||
|
*
|
||
|
* API version: 2.0.12
|
||
|
* Contact: james@firefly-iii.org
|
||
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
||
|
*/
|
||
|
package firefly3
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
"github.com/antihax/optional"
|
||
|
"io/ioutil"
|
||
|
"net/http"
|
||
|
"net/url"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
// Linger please
|
||
|
var (
|
||
|
_ context.Context
|
||
|
)
|
||
|
|
||
|
type WebhooksApiService service
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Delete a webhook.
|
||
|
Delete a webhook.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param optional nil or *WebhooksApiDeleteWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiDeleteWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) DeleteWebhook(ctx context.Context, id string, localVarOptionals *WebhooksApiDeleteWebhookOpts) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Delete")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Delete a webhook message.
|
||
|
Delete a webhook message. Any time a webhook is triggered the message is stored before it's sent. You can delete them before or after sending.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param messageId The webhook message ID.
|
||
|
* @param optional nil or *WebhooksApiDeleteWebhookMessageOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiDeleteWebhookMessageOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) DeleteWebhookMessage(ctx context.Context, id string, messageId int32, localVarOptionals *WebhooksApiDeleteWebhookMessageOpts) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Delete")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages/{messageId}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"messageId"+"}", fmt.Sprintf("%v", messageId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Delete a webhook attempt.
|
||
|
Delete a webhook message attempt. If you delete all attempts for a webhook message, Firefly III will (once again) assume all is well with the webhook message and will try to send it again.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param messageId The webhook message ID.
|
||
|
* @param attemptId The webhook message attempt ID.
|
||
|
* @param optional nil or *WebhooksApiDeleteWebhookMessageAttemptOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiDeleteWebhookMessageAttemptOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) DeleteWebhookMessageAttempt(ctx context.Context, id string, messageId int32, attemptId int32, localVarOptionals *WebhooksApiDeleteWebhookMessageAttemptOpts) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Delete")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages/{messageId}/attempts/{attemptId}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"messageId"+"}", fmt.Sprintf("%v", messageId), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"attemptId"+"}", fmt.Sprintf("%v", attemptId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Get a single message from a webhook.
|
||
|
When a webhook is triggered it will store the actual content of the webhook in a webhook message. You can view and analyse a single one using this endpoint.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param messageId The webhook message ID.
|
||
|
* @param optional nil or *WebhooksApiGetSingleWebhookMessageOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookMessageSingle
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiGetSingleWebhookMessageOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) GetSingleWebhookMessage(ctx context.Context, id string, messageId int32, localVarOptionals *WebhooksApiGetSingleWebhookMessageOpts) (WebhookMessageSingle, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookMessageSingle
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages/{messageId}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"messageId"+"}", fmt.Sprintf("%v", messageId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookMessageSingle
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Get a single failed attempt from a single webhook message.
|
||
|
When a webhook message fails to send it will store the failure in an \"attempt\". You can view and analyse these. Webhooks messages that receive too many attempts (failures) will not be fired. You must first clear out old attempts and try again. This endpoint shows you the details of a single attempt. The ID of the attempt must match the corresponding webhook and webhook message.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param messageId The webhook message ID.
|
||
|
* @param attemptId The webhook attempt ID.
|
||
|
* @param optional nil or *WebhooksApiGetSingleWebhookMessageAttemptOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookAttemptSingle
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiGetSingleWebhookMessageAttemptOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) GetSingleWebhookMessageAttempt(ctx context.Context, id string, messageId int32, attemptId int32, localVarOptionals *WebhooksApiGetSingleWebhookMessageAttemptOpts) (WebhookAttemptSingle, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookAttemptSingle
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages/{messageId}/attempts/{attemptId}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"messageId"+"}", fmt.Sprintf("%v", messageId), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"attemptId"+"}", fmt.Sprintf("%v", attemptId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookAttemptSingle
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Get a single webhook.
|
||
|
Gets all info of a single webhook.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param optional nil or *WebhooksApiGetWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookSingle
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiGetWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) GetWebhook(ctx context.Context, id string, localVarOptionals *WebhooksApiGetWebhookOpts) (WebhookSingle, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookSingle
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookSingle
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Get all the failed attempts of a single webhook message.
|
||
|
When a webhook message fails to send it will store the failure in an \"attempt\". You can view and analyse these. Webhook messages that receive too many attempts (failures) will not be sent again. You must first clear out old attempts before the message can go out again.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param messageId The webhook message ID.
|
||
|
* @param optional nil or *WebhooksApiGetWebhookMessageAttemptsOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
* @param "Limit" (optional.Int32) - Number of items per page. The default pagination is per 50 items.
|
||
|
* @param "Page" (optional.Int32) - Page number. The default pagination is per 50 items.
|
||
|
@return WebhookAttemptArray
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiGetWebhookMessageAttemptsOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
Limit optional.Int32
|
||
|
Page optional.Int32
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) GetWebhookMessageAttempts(ctx context.Context, id string, messageId int32, localVarOptionals *WebhooksApiGetWebhookMessageAttemptsOpts) (WebhookAttemptArray, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookAttemptArray
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages/{messageId}/attempts"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"messageId"+"}", fmt.Sprintf("%v", messageId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
|
||
|
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.Page.IsSet() {
|
||
|
localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page.Value(), ""))
|
||
|
}
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookAttemptArray
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Get all the messages of a single webhook.
|
||
|
When a webhook is triggered the actual message that will be send is stored in a \"message\". You can view and analyse these messages.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param optional nil or *WebhooksApiGetWebhookMessagesOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookMessageArray
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiGetWebhookMessagesOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) GetWebhookMessages(ctx context.Context, id string, localVarOptionals *WebhooksApiGetWebhookMessagesOpts) (WebhookMessageArray, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookMessageArray
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/messages"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookMessageArray
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService List all webhooks.
|
||
|
List all the user's webhooks.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param optional nil or *WebhooksApiListWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
* @param "Limit" (optional.Int32) - Number of items per page. The default pagination is per 50 items.
|
||
|
* @param "Page" (optional.Int32) - Page number. The default pagination is per 50 items.
|
||
|
@return WebhookArray
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiListWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
Limit optional.Int32
|
||
|
Page optional.Int32
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) ListWebhook(ctx context.Context, localVarOptionals *WebhooksApiListWebhookOpts) (WebhookArray, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Get")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookArray
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks"
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
if localVarOptionals != nil && localVarOptionals.Limit.IsSet() {
|
||
|
localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), ""))
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.Page.IsSet() {
|
||
|
localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page.Value(), ""))
|
||
|
}
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookArray
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Store a new webhook
|
||
|
Creates a new webhook. The data required can be submitted as a JSON body or as a list of parameters. The webhook will be given a random secret.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param body JSON array or key=value pairs with the necessary webhook information. See the model for the exact specifications.
|
||
|
* @param optional nil or *WebhooksApiStoreWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookSingle
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiStoreWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) StoreWebhook(ctx context.Context, body WebhookStore, localVarOptionals *WebhooksApiStoreWebhookOpts) (WebhookSingle, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Post")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookSingle
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks"
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
// body params
|
||
|
localVarPostBody = &body
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookSingle
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 422 {
|
||
|
var v ValidationErrorResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Submit messages for a webhook.
|
||
|
This endpoint will submit any open messages for this webhook. This is an asynchronous operation, so you can't see the result. Refresh the webhook message and/or the webhook message attempts to see the results. This may take some time if the webhook receiver is slow.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param optional nil or *WebhooksApiSubmitWebookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiSubmitWebookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) SubmitWebook(ctx context.Context, id string, localVarOptionals *WebhooksApiSubmitWebookOpts) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Post")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/submit"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Trigger webhook for a given transaction.
|
||
|
This endpoint will execute this webhook for a given transaction ID. This is an asynchronous operation, so you can't see the result. Refresh the webhook message and/or the webhook message attempts to see the results. This may take some time if the webhook receiver is slow.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param id The webhook ID.
|
||
|
* @param transactionId The transaction ID.
|
||
|
* @param optional nil or *WebhooksApiTriggerTransactionWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiTriggerTransactionWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) TriggerTransactionWebhook(ctx context.Context, id string, transactionId string, localVarOptionals *WebhooksApiTriggerTransactionWebhookOpts) (*http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Post")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}/trigger-transaction/{transactionId}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"transactionId"+"}", fmt.Sprintf("%v", transactionId), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
return localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarHttpResponse, nil
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
WebhooksApiService Update existing webhook.
|
||
|
Update an existing webhook's information. If you wish to reset the secret, submit any value as the \"secret\". Firefly III will take this as a hint and reset the secret of the webhook.
|
||
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
||
|
* @param body JSON array with updated webhook information. See the model for the exact specifications.
|
||
|
* @param id The webhook ID.
|
||
|
* @param optional nil or *WebhooksApiUpdateWebhookOpts - Optional Parameters:
|
||
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
||
|
@return WebhookSingle
|
||
|
*/
|
||
|
|
||
|
type WebhooksApiUpdateWebhookOpts struct {
|
||
|
XTraceId optional.Interface
|
||
|
}
|
||
|
|
||
|
func (a *WebhooksApiService) UpdateWebhook(ctx context.Context, body WebhookUpdate, id string, localVarOptionals *WebhooksApiUpdateWebhookOpts) (WebhookSingle, *http.Response, error) {
|
||
|
var (
|
||
|
localVarHttpMethod = strings.ToUpper("Put")
|
||
|
localVarPostBody interface{}
|
||
|
localVarFileName string
|
||
|
localVarFileBytes []byte
|
||
|
localVarReturnValue WebhookSingle
|
||
|
)
|
||
|
|
||
|
// create path and map variables
|
||
|
localVarPath := a.client.cfg.BasePath + "/v1/webhooks/{id}"
|
||
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
||
|
|
||
|
localVarHeaderParams := make(map[string]string)
|
||
|
localVarQueryParams := url.Values{}
|
||
|
localVarFormParams := url.Values{}
|
||
|
|
||
|
// to determine the Content-Type header
|
||
|
localVarHttpContentTypes := []string{"application/json", "application/x-www-form-urlencoded"}
|
||
|
|
||
|
// set Content-Type header
|
||
|
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
|
||
|
if localVarHttpContentType != "" {
|
||
|
localVarHeaderParams["Content-Type"] = localVarHttpContentType
|
||
|
}
|
||
|
|
||
|
// to determine the Accept header
|
||
|
localVarHttpHeaderAccepts := []string{"application/vnd.firefly3+json", "application/json"}
|
||
|
|
||
|
// set Accept header
|
||
|
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
|
||
|
if localVarHttpHeaderAccept != "" {
|
||
|
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
|
||
|
}
|
||
|
if localVarOptionals != nil && localVarOptionals.XTraceId.IsSet() {
|
||
|
localVarHeaderParams["X-Trace-Id"] = parameterToString(localVarOptionals.XTraceId.Value(), "")
|
||
|
}
|
||
|
// body params
|
||
|
localVarPostBody = &body
|
||
|
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes)
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, nil, err
|
||
|
}
|
||
|
|
||
|
localVarHttpResponse, err := a.client.callAPI(r)
|
||
|
if err != nil || localVarHttpResponse == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
|
||
|
localVarHttpResponse.Body.Close()
|
||
|
if err != nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode < 300 {
|
||
|
// If we succeed, return the data, otherwise pass on to decode error.
|
||
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err == nil {
|
||
|
return localVarReturnValue, localVarHttpResponse, err
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if localVarHttpResponse.StatusCode >= 300 {
|
||
|
newErr := GenericSwaggerError{
|
||
|
body: localVarBody,
|
||
|
error: localVarHttpResponse.Status,
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 200 {
|
||
|
var v WebhookSingle
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 422 {
|
||
|
var v ValidationErrorResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 401 {
|
||
|
var v UnauthenticatedResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 404 {
|
||
|
var v NotFoundResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 400 {
|
||
|
var v BadRequestResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
if localVarHttpResponse.StatusCode == 500 {
|
||
|
var v InternalExceptionResponse
|
||
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
||
|
if err != nil {
|
||
|
newErr.error = err.Error()
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
newErr.model = v
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
return localVarReturnValue, localVarHttpResponse, newErr
|
||
|
}
|
||
|
|
||
|
return localVarReturnValue, localVarHttpResponse, nil
|
||
|
}
|