import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::dispatch
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:23
* @route '/api/quotes/dispatch'
*/
export const dispatch = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: dispatch.url(options),
    method: 'post',
})

dispatch.definition = {
    methods: ["post"],
    url: '/api/quotes/dispatch',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::dispatch
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:23
* @route '/api/quotes/dispatch'
*/
dispatch.url = (options?: RouteQueryOptions) => {
    return dispatch.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::dispatch
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:23
* @route '/api/quotes/dispatch'
*/
dispatch.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: dispatch.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::dispatch
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:23
* @route '/api/quotes/dispatch'
*/
const dispatchForm = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: dispatch.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::dispatch
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:23
* @route '/api/quotes/dispatch'
*/
dispatchForm.post = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: dispatch.url(options),
    method: 'post',
})

dispatch.form = dispatchForm

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
export const status = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: status.url(args, options),
    method: 'get',
})

status.definition = {
    methods: ["get","head"],
    url: '/api/quotes/{externalQuoteId}/status',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
status.url = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { externalQuoteId: args }
    }

    if (Array.isArray(args)) {
        args = {
            externalQuoteId: args[0],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        externalQuoteId: args.externalQuoteId,
    }

    return status.definition.url
            .replace('{externalQuoteId}', parsedArgs.externalQuoteId.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
status.get = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: status.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
status.head = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: status.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
const statusForm = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: status.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
statusForm.get = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: status.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\Api\QuoteIntegrationController::status
* @see app/Http/Controllers/Api/QuoteIntegrationController.php:120
* @route '/api/quotes/{externalQuoteId}/status'
*/
statusForm.head = (args: { externalQuoteId: string | number } | [externalQuoteId: string | number ] | string | number, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: status.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

status.form = statusForm

const quotes = {
    dispatch: Object.assign(dispatch, dispatch),
    status: Object.assign(status, status),
}

export default quotes