/* tslint:disable */
/* eslint-disable */
/**
 * Dash API
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 0.1
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  TrackingCategories,
  TrackingEntry,
} from '../models';
import {
    TrackingCategoriesFromJSON,
    TrackingCategoriesToJSON,
    TrackingEntryFromJSON,
    TrackingEntryToJSON,
} from '../models';

export interface GetTrackingEntryForDateRequest {
    date: Date;
}

export interface WriteTrackingEntryRequest {
    trackingEntry: TrackingEntry;
}

/**
 * 
 */
export class TrackingApi extends runtime.BaseAPI {

    /**
     */
    async getTrackingCategoriesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TrackingCategories>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/tracking/categories`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => TrackingCategoriesFromJSON(jsonValue));
    }

    /**
     */
    async getTrackingCategories(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TrackingCategories> {
        const response = await this.getTrackingCategoriesRaw(initOverrides);
        return await response.value();
    }

    /**
     */
    async getTrackingEntryForDateRaw(requestParameters: GetTrackingEntryForDateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TrackingEntry>> {
        if (requestParameters.date === null || requestParameters.date === undefined) {
            throw new runtime.RequiredError('date','Required parameter requestParameters.date was null or undefined when calling getTrackingEntryForDate.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/tracking/entry/{date}`.replace(`{${"date"}}`, encodeURIComponent(String(requestParameters.date.toISOString().substring(0,10)))),
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => TrackingEntryFromJSON(jsonValue));
    }

    /**
     */
    async getTrackingEntryForDate(requestParameters: GetTrackingEntryForDateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TrackingEntry> {
        const response = await this.getTrackingEntryForDateRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async writeTrackingEntryRaw(requestParameters: WriteTrackingEntryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters.trackingEntry === null || requestParameters.trackingEntry === undefined) {
            throw new runtime.RequiredError('trackingEntry','Required parameter requestParameters.trackingEntry was null or undefined when calling writeTrackingEntry.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        const response = await this.request({
            path: `/tracking/entry`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: TrackingEntryToJSON(requestParameters.trackingEntry),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     */
    async writeTrackingEntry(requestParameters: WriteTrackingEntryRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.writeTrackingEntryRaw(requestParameters, initOverrides);
    }

}
