1189 lines
44 KiB
Go
1189 lines
44 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 AccountsApiService service
|
|
|
|
/*
|
|
AccountsApiService Permanently delete account.
|
|
Will permanently delete an account. Any associated transactions and piggy banks are ALSO deleted. Cannot be recovered from.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the account.
|
|
* @param optional nil or *AccountsApiDeleteAccountOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
|
|
*/
|
|
|
|
type AccountsApiDeleteAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *AccountsApiService) DeleteAccount(ctx context.Context, id string, localVarOptionals *AccountsApiDeleteAccountOpts) (*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/accounts/{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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService Get single account.
|
|
Returns a single account by its ID.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the account.
|
|
* @param optional nil or *AccountsApiGetAccountOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
* @param "Date" (optional.String) - A date formatted YYYY-MM-DD. When added to the request, Firefly III will show the account's balance on that day.
|
|
@return AccountSingle
|
|
*/
|
|
|
|
type AccountsApiGetAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
Date optional.String
|
|
}
|
|
|
|
func (a *AccountsApiService) GetAccount(ctx context.Context, id string, localVarOptionals *AccountsApiGetAccountOpts) (AccountSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue AccountSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts/{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.Date.IsSet() {
|
|
localVarQueryParams.Add("date", parameterToString(localVarOptionals.Date.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/json", "application/vnd.api+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 == 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
|
|
}
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v AccountSingle
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService List all accounts.
|
|
This endpoint returns a list of all the accounts owned by the authenticated user.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param optional nil or *AccountsApiListAccountOpts - 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.
|
|
* @param "Date" (optional.String) - A date formatted YYYY-MM-DD. When added to the request, Firefly III will show the account's balance on that day.
|
|
* @param "Type_" (optional.Interface of AccountTypeFilter) - Optional filter on the account type(s) returned
|
|
@return AccountArray
|
|
*/
|
|
|
|
type AccountsApiListAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
Date optional.String
|
|
Type_ optional.Interface
|
|
}
|
|
|
|
func (a *AccountsApiService) ListAccount(ctx context.Context, localVarOptionals *AccountsApiListAccountOpts) (AccountArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue AccountArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts"
|
|
|
|
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.Date.IsSet() {
|
|
localVarQueryParams.Add("date", parameterToString(localVarOptionals.Date.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
|
|
localVarHttpHeaderAccepts := []string{"application/json", "application/vnd.api+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 == 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
|
|
}
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v AccountArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService 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 account.
|
|
* @param optional nil or *AccountsApiListAttachmentByAccountOpts - 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 AccountsApiListAttachmentByAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
}
|
|
|
|
func (a *AccountsApiService) ListAttachmentByAccount(ctx context.Context, id string, localVarOptionals *AccountsApiListAttachmentByAccountOpts) (AttachmentArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue AttachmentArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts/{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
|
|
localVarHttpHeaderAccepts := []string{"application/json", "application/vnd.api+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 == 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
|
|
}
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v AttachmentArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService List all piggy banks related to the account.
|
|
This endpoint returns a list of all the piggy banks connected to the account.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the account.
|
|
* @param optional nil or *AccountsApiListPiggyBankByAccountOpts - 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 PiggyBankArray
|
|
*/
|
|
|
|
type AccountsApiListPiggyBankByAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
}
|
|
|
|
func (a *AccountsApiService) ListPiggyBankByAccount(ctx context.Context, id string, localVarOptionals *AccountsApiListPiggyBankByAccountOpts) (PiggyBankArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue PiggyBankArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts/{id}/piggy-banks"
|
|
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
|
|
localVarHttpHeaderAccepts := []string{"application/json", "application/vnd.api+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 == 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
|
|
}
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v PiggyBankArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService List all transactions related to the account.
|
|
This endpoint returns a list of all the transactions connected to the account.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the account.
|
|
* @param optional nil or *AccountsApiListTransactionByAccountOpts - 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.
|
|
* @param "Start" (optional.String) - A date formatted YYYY-MM-DD.
|
|
* @param "End" (optional.String) - A date formatted YYYY-MM-DD.
|
|
* @param "Type_" (optional.Interface of TransactionTypeFilter) - Optional filter on the transaction type(s) returned.
|
|
@return TransactionArray
|
|
*/
|
|
|
|
type AccountsApiListTransactionByAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
Start optional.String
|
|
End optional.String
|
|
Type_ optional.Interface
|
|
}
|
|
|
|
func (a *AccountsApiService) ListTransactionByAccount(ctx context.Context, id string, localVarOptionals *AccountsApiListTransactionByAccountOpts) (TransactionArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue TransactionArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts/{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
|
|
localVarHttpHeaderAccepts := []string{"application/json", "application/vnd.api+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 == 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
|
|
}
|
|
if localVarHttpResponse.StatusCode == 200 {
|
|
var v TransactionArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService Create new account.
|
|
Creates a new account. The data required can be submitted as a JSON body or as a list of parameters (in key=value pairs, like a webform).
|
|
* @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 account information or key=value pairs. See the model for the exact specifications.
|
|
* @param optional nil or *AccountsApiStoreAccountOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return AccountSingle
|
|
*/
|
|
|
|
type AccountsApiStoreAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *AccountsApiService) StoreAccount(ctx context.Context, body AccountStore, localVarOptionals *AccountsApiStoreAccountOpts) (AccountSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Post")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue AccountSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts"
|
|
|
|
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/json", "application/vnd.api+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 == 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
|
|
}
|
|
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 == 200 {
|
|
var v AccountSingle
|
|
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
|
|
}
|
|
|
|
/*
|
|
AccountsApiService Update existing account.
|
|
Used to update a single account. All fields that are not submitted will be cleared (set to NULL). The model will tell you which fields are mandatory.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param body JSON array or formdata with updated account information. See the model for the exact specifications.
|
|
* @param id The ID of the account.
|
|
* @param optional nil or *AccountsApiUpdateAccountOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return AccountSingle
|
|
*/
|
|
|
|
type AccountsApiUpdateAccountOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *AccountsApiService) UpdateAccount(ctx context.Context, body AccountUpdate, id string, localVarOptionals *AccountsApiUpdateAccountOpts) (AccountSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Put")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue AccountSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/accounts/{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/json", "application/vnd.api+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 == 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
|
|
}
|
|
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 == 200 {
|
|
var v AccountSingle
|
|
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
|
|
}
|