2024-04-10 12:14:55 +03:00
|
|
|
/*
|
2024-05-11 14:43:57 +03:00
|
|
|
* Firefly III API v2.0.14
|
2024-04-10 12:14:55 +03:00
|
|
|
*
|
2024-05-11 15:15:59 +03:00
|
|
|
* 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.
|
2024-04-10 12:14:55 +03:00
|
|
|
*
|
2024-05-11 14:43:57 +03:00
|
|
|
* API version: 2.0.14
|
2024-04-10 12:14:55 +03:00
|
|
|
* Contact: james@firefly-iii.org
|
|
|
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
|
|
*/
|
2024-05-11 15:26:56 +03:00
|
|
|
package firefly3
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-05-11 15:15:59 +03:00
|
|
|
"fmt"
|
|
|
|
"github.com/antihax/optional"
|
2024-04-10 12:14:55 +03:00
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"net/url"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Linger please
|
|
|
|
var (
|
|
|
|
_ context.Context
|
|
|
|
)
|
|
|
|
|
|
|
|
type CategoriesApiService service
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService Delete a category.
|
|
|
|
Delete a category. Transactions will not be removed.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param id The ID of the category.
|
|
|
|
* @param optional nil or *CategoriesApiDeleteCategoryOpts - Optional Parameters:
|
|
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiDeleteCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) DeleteCategory(ctx context.Context, id string, localVarOptionals *CategoriesApiDeleteCategoryOpts) (*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/categories/{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{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService Get a single category.
|
|
|
|
Get a single category.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param id The ID of the category.
|
|
|
|
* @param optional nil or *CategoriesApiGetCategoryOpts - Optional Parameters:
|
|
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
2024-05-11 15:15:59 +03:00
|
|
|
* @param "Start" (optional.String) - A date formatted YYYY-MM-DD, to show spent and earned info.
|
|
|
|
* @param "End" (optional.String) - A date formatted YYYY-MM-DD, to show spent and earned info.
|
2024-04-10 12:14:55 +03:00
|
|
|
@return CategorySingle
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiGetCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
|
|
|
Start optional.String
|
|
|
|
End optional.String
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) GetCategory(ctx context.Context, id string, localVarOptionals *CategoriesApiGetCategoryOpts) (CategorySingle, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue CategorySingle
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories/{id}"
|
|
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1)
|
|
|
|
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
|
|
localVarQueryParams := url.Values{}
|
|
|
|
localVarFormParams := url.Values{}
|
|
|
|
|
|
|
|
if localVarOptionals != nil && localVarOptionals.Start.IsSet() {
|
|
|
|
localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), ""))
|
|
|
|
}
|
|
|
|
if localVarOptionals != nil && localVarOptionals.End.IsSet() {
|
|
|
|
localVarQueryParams.Add("end", parameterToString(localVarOptionals.End.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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v CategorySingle
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService Lists all attachments.
|
|
|
|
Lists all attachments.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param id The ID of the category.
|
|
|
|
* @param optional nil or *CategoriesApiListAttachmentByCategoryOpts - 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 AttachmentArray
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiListAttachmentByCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
|
|
|
Limit optional.Int32
|
|
|
|
Page optional.Int32
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) ListAttachmentByCategory(ctx context.Context, id string, localVarOptionals *CategoriesApiListAttachmentByCategoryOpts) (AttachmentArray, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue AttachmentArray
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories/{id}/attachments"
|
|
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v AttachmentArray
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService List all categories.
|
|
|
|
List all categories.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param optional nil or *CategoriesApiListCategoryOpts - 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 CategoryArray
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiListCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
|
|
|
Limit optional.Int32
|
|
|
|
Page optional.Int32
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) ListCategory(ctx context.Context, localVarOptionals *CategoriesApiListCategoryOpts) (CategoryArray, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue CategoryArray
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories"
|
|
|
|
|
|
|
|
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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v CategoryArray
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService List all transactions in a category.
|
|
|
|
List all transactions in a category, optionally limited to the date ranges specified.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param id The ID of the category.
|
|
|
|
* @param optional nil or *CategoriesApiListTransactionByCategoryOpts - 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
* @param "Start" (optional.String) - A date formatted YYYY-MM-DD, to limit the result list.
|
|
|
|
* @param "End" (optional.String) - A date formatted YYYY-MM-DD, to limit the result list.
|
2024-04-10 12:14:55 +03:00
|
|
|
* @param "Type_" (optional.Interface of TransactionTypeFilter) - Optional filter on the transaction type(s) returned
|
|
|
|
@return TransactionArray
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiListTransactionByCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
|
|
|
Limit optional.Int32
|
|
|
|
Page optional.Int32
|
|
|
|
Start optional.String
|
|
|
|
End optional.String
|
|
|
|
Type_ optional.Interface
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) ListTransactionByCategory(ctx context.Context, id string, localVarOptionals *CategoriesApiListTransactionByCategoryOpts) (TransactionArray, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue TransactionArray
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories/{id}/transactions"
|
|
|
|
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -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(), ""))
|
|
|
|
}
|
|
|
|
if localVarOptionals != nil && localVarOptionals.Start.IsSet() {
|
|
|
|
localVarQueryParams.Add("start", parameterToString(localVarOptionals.Start.Value(), ""))
|
|
|
|
}
|
|
|
|
if localVarOptionals != nil && localVarOptionals.End.IsSet() {
|
|
|
|
localVarQueryParams.Add("end", parameterToString(localVarOptionals.End.Value(), ""))
|
|
|
|
}
|
|
|
|
if localVarOptionals != nil && localVarOptionals.Type_.IsSet() {
|
|
|
|
localVarQueryParams.Add("type", parameterToString(localVarOptionals.Type_.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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v TransactionArray
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService Store a new category
|
|
|
|
Creates a new category. The data required can be submitted as a JSON body or as a list of parameters.
|
|
|
|
* @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 category information. See the model for the exact specifications.
|
|
|
|
* @param optional nil or *CategoriesApiStoreCategoryOpts - Optional Parameters:
|
|
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
|
|
@return CategorySingle
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiStoreCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) StoreCategory(ctx context.Context, body Category, localVarOptionals *CategoriesApiStoreCategoryOpts) (CategorySingle, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Post")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue CategorySingle
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories"
|
|
|
|
|
|
|
|
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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v CategorySingle
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 422 {
|
|
|
|
var v ValidationErrorResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|
2024-05-11 15:15:59 +03:00
|
|
|
|
2024-04-10 12:14:55 +03:00
|
|
|
/*
|
|
|
|
CategoriesApiService Update existing category.
|
|
|
|
Update existing category.
|
|
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
|
|
* @param body JSON array with updated category information. See the model for the exact specifications.
|
|
|
|
* @param id The ID of the category.
|
|
|
|
* @param optional nil or *CategoriesApiUpdateCategoryOpts - Optional Parameters:
|
|
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
|
|
@return CategorySingle
|
|
|
|
*/
|
|
|
|
|
|
|
|
type CategoriesApiUpdateCategoryOpts struct {
|
2024-05-11 15:15:59 +03:00
|
|
|
XTraceId optional.Interface
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *CategoriesApiService) UpdateCategory(ctx context.Context, body CategoryUpdate, id string, localVarOptionals *CategoriesApiUpdateCategoryOpts) (CategorySingle, *http.Response, error) {
|
|
|
|
var (
|
2024-05-11 15:15:59 +03:00
|
|
|
localVarHttpMethod = strings.ToUpper("Put")
|
|
|
|
localVarPostBody interface{}
|
|
|
|
localVarFileName string
|
|
|
|
localVarFileBytes []byte
|
2024-04-10 12:14:55 +03:00
|
|
|
localVarReturnValue CategorySingle
|
|
|
|
)
|
|
|
|
|
|
|
|
// create path and map variables
|
|
|
|
localVarPath := a.client.cfg.BasePath + "/v1/categories/{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
|
2024-05-11 14:43:57 +03:00
|
|
|
localVarHttpHeaderAccepts := []string{"application/vnd.api+json", "application/json"}
|
2024-04-10 12:14:55 +03:00
|
|
|
|
|
|
|
// 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.
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err == nil {
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if localVarHttpResponse.StatusCode >= 300 {
|
|
|
|
newErr := GenericSwaggerError{
|
2024-05-11 15:15:59 +03:00
|
|
|
body: localVarBody,
|
2024-04-10 12:14:55 +03:00
|
|
|
error: localVarHttpResponse.Status,
|
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
|
|
var v CategorySingle
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 422 {
|
|
|
|
var v ValidationErrorResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 401 {
|
|
|
|
var v UnauthenticatedResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 404 {
|
|
|
|
var v NotFoundResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 400 {
|
|
|
|
var v BadRequestResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
if localVarHttpResponse.StatusCode == 500 {
|
|
|
|
var v InternalExceptionResponse
|
2024-05-11 15:15:59 +03:00
|
|
|
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
|
|
|
|
if err != nil {
|
|
|
|
newErr.error = err.Error()
|
2024-04-10 12:14:55 +03:00
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-05-11 15:15:59 +03:00
|
|
|
}
|
|
|
|
newErr.model = v
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
2024-04-10 12:14:55 +03:00
|
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
|
|
}
|
|
|
|
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
|
|
}
|