604 lines
22 KiB
Go
604 lines
22 KiB
Go
/*
|
|
* Firefly III API v2.0.14
|
|
*
|
|
* 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-04-20T05:28:29+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.14
|
|
* 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 PreferencesApiService service
|
|
|
|
/*
|
|
PreferencesApiService Return a single preference.
|
|
Return a single preference and the value.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param name The name of the preference.
|
|
* @param optional nil or *PreferencesApiGetPreferenceOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return PreferenceSingle
|
|
*/
|
|
|
|
type PreferencesApiGetPreferenceOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *PreferencesApiService) GetPreference(ctx context.Context, name string, localVarOptionals *PreferencesApiGetPreferenceOpts) (PreferenceSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue PreferenceSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/preferences/{name}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -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.api+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 PreferenceSingle
|
|
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
|
|
}
|
|
|
|
/*
|
|
PreferencesApiService List all users preferences.
|
|
List all of the preferences of the user.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param optional nil or *PreferencesApiListPreferenceOpts - 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 PreferenceArray
|
|
*/
|
|
|
|
type PreferencesApiListPreferenceOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
}
|
|
|
|
func (a *PreferencesApiService) ListPreference(ctx context.Context, localVarOptionals *PreferencesApiListPreferenceOpts) (PreferenceArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue PreferenceArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/preferences"
|
|
|
|
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.api+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 PreferenceArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
PreferencesApiService Store a new preference for this user.
|
|
This endpoint creates a new preference. The name and data are free-format, and entirely up to you. If the preference is not used in Firefly III itself it may not be configurable through the user interface, but you can use this endpoint to persist custom data for your own app.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param body JSON array with the necessary preference information or key=value pairs. See the model for the exact specifications.
|
|
* @param optional nil or *PreferencesApiStorePreferenceOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return PreferenceSingle
|
|
*/
|
|
|
|
type PreferencesApiStorePreferenceOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *PreferencesApiService) StorePreference(ctx context.Context, body Preference, localVarOptionals *PreferencesApiStorePreferenceOpts) (PreferenceSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Post")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue PreferenceSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/preferences"
|
|
|
|
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.api+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 PreferenceSingle
|
|
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
|
|
}
|
|
|
|
/*
|
|
PreferencesApiService Update preference
|
|
Update a user's preference.
|
|
* @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 preference information. See the model for the exact specifications.
|
|
* @param name The name of the preference. Will always overwrite. Will be created if it does not exist.
|
|
* @param optional nil or *PreferencesApiUpdatePreferenceOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return PreferenceSingle
|
|
*/
|
|
|
|
type PreferencesApiUpdatePreferenceOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *PreferencesApiService) UpdatePreference(ctx context.Context, body PreferenceUpdate, name string, localVarOptionals *PreferencesApiUpdatePreferenceOpts) (PreferenceSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Put")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue PreferenceSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/preferences/{name}"
|
|
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", fmt.Sprintf("%v", name), -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.api+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 PreferenceSingle
|
|
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
|
|
}
|