1174 lines
43 KiB
Go
1174 lines
43 KiB
Go
/*
|
|
* Firefly III API v2.0.12
|
|
*
|
|
* This is the documentation of the Firefly III API. You can find accompanying documentation on the website of Firefly III itself (see below). Please report any bugs or issues. You may use the \"Authorize\" button to try the API below. This file was last generated on 2024-03-16T05:34:43+00:00 Please keep in mind that the demo site does not accept requests from curl, colly, wget, etc. You must use a browser or a tool like Postman to make requests. Too many script kiddies out there, sorry about that.
|
|
*
|
|
* API version: 2.0.12
|
|
* Contact: james@firefly-iii.org
|
|
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
|
|
*/
|
|
package firefly3
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/antihax/optional"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/url"
|
|
"strings"
|
|
)
|
|
|
|
// Linger please
|
|
var (
|
|
_ context.Context
|
|
)
|
|
|
|
type BillsApiService service
|
|
|
|
/*
|
|
BillsApiService Delete a bill.
|
|
Delete a bill. This will not delete any associated rules. Will not remove associated transactions. WILL remove all associated 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 bill.
|
|
* @param optional nil or *BillsApiDeleteBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
|
|
*/
|
|
|
|
type BillsApiDeleteBillOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *BillsApiService) DeleteBill(ctx context.Context, id string, localVarOptionals *BillsApiDeleteBillOpts) (*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/bills/{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
|
|
}
|
|
|
|
/*
|
|
BillsApiService Get a single bill.
|
|
Get a single bill.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the bill.
|
|
* @param optional nil or *BillsApiGetBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
* @param "Start" (optional.String) - A date formatted YYYY-MM-DD. If it is are added to the request, Firefly III will calculate the appropriate payment and paid dates.
|
|
* @param "End" (optional.String) - A date formatted YYYY-MM-DD. If it is added to the request, Firefly III will calculate the appropriate payment and paid dates.
|
|
@return BillSingle
|
|
*/
|
|
|
|
type BillsApiGetBillOpts struct {
|
|
XTraceId optional.Interface
|
|
Start optional.String
|
|
End optional.String
|
|
}
|
|
|
|
func (a *BillsApiService) GetBill(ctx context.Context, id string, localVarOptionals *BillsApiGetBillOpts) (BillSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue BillSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/bills/{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
|
|
localVarHttpHeaderAccepts := []string{"application/json", "application/vnd.firefly3+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 BillSingle
|
|
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
|
|
}
|
|
|
|
/*
|
|
BillsApiService List all attachments uploaded to the bill.
|
|
This endpoint will list all attachments linked to the bill.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the bill.
|
|
* @param optional nil or *BillsApiListAttachmentByBillOpts - 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 BillsApiListAttachmentByBillOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
}
|
|
|
|
func (a *BillsApiService) ListAttachmentByBill(ctx context.Context, id string, localVarOptionals *BillsApiListAttachmentByBillOpts) (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/bills/{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.firefly3+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
|
|
}
|
|
|
|
/*
|
|
BillsApiService List all bills.
|
|
This endpoint will list all the user's bills.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param optional nil or *BillsApiListBillOpts - 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. If it is are added to the request, Firefly III will calculate the appropriate payment and paid dates.
|
|
* @param "End" (optional.String) - A date formatted YYYY-MM-DD. If it is added to the request, Firefly III will calculate the appropriate payment and paid dates.
|
|
@return BillArray
|
|
*/
|
|
|
|
type BillsApiListBillOpts struct {
|
|
XTraceId optional.Interface
|
|
Limit optional.Int32
|
|
Page optional.Int32
|
|
Start optional.String
|
|
End optional.String
|
|
}
|
|
|
|
func (a *BillsApiService) ListBill(ctx context.Context, localVarOptionals *BillsApiListBillOpts) (BillArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue BillArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/bills"
|
|
|
|
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(), ""))
|
|
}
|
|
// 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.firefly3+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 BillArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
BillsApiService List all rules associated with the bill.
|
|
This endpoint will list all rules that have an action to set the bill to this bill.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the bill.
|
|
* @param optional nil or *BillsApiListRuleByBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return RuleArray
|
|
*/
|
|
|
|
type BillsApiListRuleByBillOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *BillsApiService) ListRuleByBill(ctx context.Context, id string, localVarOptionals *BillsApiListRuleByBillOpts) (RuleArray, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Get")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue RuleArray
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/bills/{id}/rules"
|
|
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", "application/vnd.firefly3+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 RuleArray
|
|
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
|
|
}
|
|
|
|
/*
|
|
BillsApiService List all transactions associated with the bill.
|
|
This endpoint will list all transactions linked to this bill.
|
|
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
* @param id The ID of the bill.
|
|
* @param optional nil or *BillsApiListTransactionByBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
* @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 BillsApiListTransactionByBillOpts struct {
|
|
XTraceId optional.Interface
|
|
Start optional.String
|
|
End optional.String
|
|
Type_ optional.Interface
|
|
}
|
|
|
|
func (a *BillsApiService) ListTransactionByBill(ctx context.Context, id string, localVarOptionals *BillsApiListTransactionByBillOpts) (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/bills/{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.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.firefly3+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
|
|
}
|
|
|
|
/*
|
|
BillsApiService Store a new bill
|
|
Creates a new bill. 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 bill information. See the model for the exact specifications.
|
|
* @param optional nil or *BillsApiStoreBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return BillSingle
|
|
*/
|
|
|
|
type BillsApiStoreBillOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *BillsApiService) StoreBill(ctx context.Context, body BillStore, localVarOptionals *BillsApiStoreBillOpts) (BillSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Post")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue BillSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/bills"
|
|
|
|
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.firefly3+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 == 200 {
|
|
var v BillSingle
|
|
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
|
|
}
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
}
|
|
|
|
/*
|
|
BillsApiService Update existing bill.
|
|
Update existing bill.
|
|
* @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 updated bill information. See the model for the exact specifications.
|
|
* @param id The ID of the bill.
|
|
* @param optional nil or *BillsApiUpdateBillOpts - Optional Parameters:
|
|
* @param "XTraceId" (optional.Interface of string) - Unique identifier associated with this request.
|
|
@return BillSingle
|
|
*/
|
|
|
|
type BillsApiUpdateBillOpts struct {
|
|
XTraceId optional.Interface
|
|
}
|
|
|
|
func (a *BillsApiService) UpdateBill(ctx context.Context, body BillUpdate, id string, localVarOptionals *BillsApiUpdateBillOpts) (BillSingle, *http.Response, error) {
|
|
var (
|
|
localVarHttpMethod = strings.ToUpper("Put")
|
|
localVarPostBody interface{}
|
|
localVarFileName string
|
|
localVarFileBytes []byte
|
|
localVarReturnValue BillSingle
|
|
)
|
|
|
|
// create path and map variables
|
|
localVarPath := a.client.cfg.BasePath + "/v1/bills/{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.firefly3+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 == 200 {
|
|
var v BillSingle
|
|
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
|
|
}
|
|
return localVarReturnValue, localVarHttpResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHttpResponse, nil
|
|
}
|