/* 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 {
  JournalEntry,
} from '../models';
import {
    JournalEntryFromJSON,
    JournalEntryToJSON,
} from '../models';

export interface DeleteJournalEntryForDateRequest {
    date: Date;
}

export interface GetJournalEntryForDateRequest {
    date: Date;
}

export interface WriteJournalEntryRequest {
    journalEntry: JournalEntry;
}

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

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

        return new runtime.VoidApiResponse(response);
    }

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

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

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

    /**
     */
    async getJournalEntryForDate(requestParameters: GetJournalEntryForDateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JournalEntry> {
        const response = await this.getJournalEntryForDateRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

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

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

        return new runtime.VoidApiResponse(response);
    }

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

}
