// This file is auto-generated by @hey-api/openapi-ts

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import type { Observable } from 'rxjs';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { GetBootstrapBootstrapGetResponse, LoginForAccessTokenTokenPostData, LoginForAccessTokenTokenPostResponse, UploadUploadTypeFieldIdPostData, UploadUploadTypeFieldIdPostResponse, MakeAttachmentsTarFileMakeAttachmentsTarFileGetResponse, LogoutLogoutGetResponse, GetTrailsTrailGetResponse, GetTrailAllDetailsTrailDetailsGetResponse, GetTreeTrailTreeTrailGetResponse, GetTreesTreeGetResponse, AddTreeTreePostData, AddTreeTreePostResponse, GetPoisPoiGetResponse, GetZonesZoneGetResponse, GetStylesStyleGetResponse, UploadTrailPhotoTrailPhotoIdFileNamePutData, UploadTrailPhotoTrailPhotoIdFileNamePutResponse, UploadTreePhotoTreePhotoIdFileNamePutData, UploadTreePhotoTreePhotoIdFileNamePutResponse } from './types.gen';

@Injectable({
    providedIn: 'root'
})
export class DefaultService {
    constructor(public readonly http: HttpClient) { }
    
    /**
     * Get Bootstrap
     * @returns Bootstrap Successful Response
     * @throws ApiError
     */
    public getBootstrapBootstrapGet(): Observable<GetBootstrapBootstrapGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/bootstrap'
        });
    }
    
    /**
     * Login For Access Token
     * @param data The data for the request.
     * @param data.formData
     * @returns Token Successful Response
     * @throws ApiError
     */
    public loginForAccessTokenTokenPost(data: LoginForAccessTokenTokenPostData): Observable<LoginForAccessTokenTokenPostResponse> {
        return __request(OpenAPI, this.http, {
            method: 'POST',
            url: '/token',
            formData: data.formData,
            mediaType: 'application/x-www-form-urlencoded',
            errors: {
                422: 'Validation Error'
            }
        });
    }
    
    /**
     * Upload
     * @param data The data for the request.
     * @param data.type
     * @param data.field
     * @param data.id
     * @param data.formData
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public uploadUploadTypeFieldIdPost(data: UploadUploadTypeFieldIdPostData): Observable<UploadUploadTypeFieldIdPostResponse> {
        return __request(OpenAPI, this.http, {
            method: 'POST',
            url: '/upload/{type}/{field}/{id}',
            path: {
                type: data.type,
                field: data.field,
                id: data.id
            },
            formData: data.formData,
            mediaType: 'multipart/form-data',
            errors: {
                422: 'Validation Error'
            }
        });
    }
    
    /**
     * Makeattachmentstarfile
     * Create a tar file with all photos, used to feed clients' caches
     * for offline use
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public makeAttachmentsTarFileMakeAttachmentsTarFileGet(): Observable<MakeAttachmentsTarFileMakeAttachmentsTarFileGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/makeAttachmentsTarFile'
        });
    }
    
    /**
     * Logout
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public logoutLogoutGet(): Observable<LogoutLogoutGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/logout'
        });
    }
    
    /**
     * Get Trails
     * Get all trails
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public getTrailsTrailGet(): Observable<GetTrailsTrailGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/trail'
        });
    }
    
    /**
     * Get Trail All Details
     * Get details of all trails
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public getTrailAllDetailsTrailDetailsGet(): Observable<GetTrailAllDetailsTrailDetailsGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/trail/details'
        });
    }
    
    /**
     * Get Tree Trail
     * Get all relations between trees and trails.
     * Note that these are not checked for permissions, as there's no really
     * valuable information.
     * @returns TreeTrail Successful Response
     * @throws ApiError
     */
    public getTreeTrailTreeTrailGet(): Observable<GetTreeTrailTreeTrailGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/tree-trail'
        });
    }
    
    /**
     * Get Trees
     * Get all trees
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public getTreesTreeGet(): Observable<GetTreesTreeGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/tree'
        });
    }
    
    /**
     * Addtree
     * @param data The data for the request.
     * @param data.formData
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public addTreeTreePost(data: AddTreeTreePostData): Observable<AddTreeTreePostResponse> {
        return __request(OpenAPI, this.http, {
            method: 'POST',
            url: '/tree',
            formData: data.formData,
            mediaType: 'application/x-www-form-urlencoded',
            errors: {
                422: 'Validation Error'
            }
        });
    }
    
    /**
     * Get Pois
     * Get all POI
     * @returns POI Successful Response
     * @throws ApiError
     */
    public getPoisPoiGet(): Observable<GetPoisPoiGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/poi'
        });
    }
    
    /**
     * Get Zones
     * Get all Zones
     * @returns Zone Successful Response
     * @throws ApiError
     */
    public getZonesZoneGet(): Observable<GetZonesZoneGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/zone'
        });
    }
    
    /**
     * Get Styles
     * Get all Styles
     * @returns MapStyle Successful Response
     * @throws ApiError
     */
    public getStylesStyleGet(): Observable<GetStylesStyleGetResponse> {
        return __request(OpenAPI, this.http, {
            method: 'GET',
            url: '/style'
        });
    }
    
    /**
     * Upload Trail Photo
     * This was tested with QGis, provided the properties for the trail layer
     * have been defined correctly.
     * This includes: in "Attributes Form", field "photo", "Widget Type"
     * is set as WebDav storage, with store URL set correcly with a URL like:
     * * 'http://localhost:4200/v1/trail/photo/' || "id" || '/' || file_name(@selected_file_path)
     * * 'https://treetrail.avcsr.org/v1/trail/' || "id" || '/' || file_name(@selected_file_path)
     * ## XXX: probably broken info as paths have changed
     * @param data The data for the request.
     * @param data.id
     * @param data.fileName
     * @param data.formData
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public uploadTrailPhotoTrailPhotoIdFileNamePut(data: UploadTrailPhotoTrailPhotoIdFileNamePutData): Observable<UploadTrailPhotoTrailPhotoIdFileNamePutResponse> {
        return __request(OpenAPI, this.http, {
            method: 'PUT',
            url: '/trail/photo/{id}/{file_name}',
            path: {
                id: data.id,
                file_name: data.fileName
            },
            formData: data.formData,
            mediaType: 'multipart/form-data',
            errors: {
                422: 'Validation Error'
            }
        });
    }
    
    /**
     * Upload Tree Photo
     * This was tested with QGis, provided the properties for the tree layer
     * have been defined correctly.
     * This includes: in "Attributes Form", field "photo", "Widget Type"
     * is set as WebDav storage, with store URL set correcly with a URL like:
     * * 'http://localhost:4200/v1/tree/photo/' || "id" || '/' || file_name(@selected_file_path)
     * * 'https://treetrail.avcsr.org/v1/tree/' || "id" || '/' || file_name(@selected_file_path)
     * ## XXX: probably broken info as paths have changed
     * @param data The data for the request.
     * @param data.id
     * @param data.fileName
     * @param data.formData
     * @returns unknown Successful Response
     * @throws ApiError
     */
    public uploadTreePhotoTreePhotoIdFileNamePut(data: UploadTreePhotoTreePhotoIdFileNamePutData): Observable<UploadTreePhotoTreePhotoIdFileNamePutResponse> {
        return __request(OpenAPI, this.http, {
            method: 'PUT',
            url: '/tree/photo/{id}/{file_name}',
            path: {
                id: data.id,
                file_name: data.fileName
            },
            formData: data.formData,
            mediaType: 'multipart/form-data',
            errors: {
                422: 'Validation Error'
            }
        });
    }
    
}