1+ // This file is auto-generated by @hey-api/openapi-ts
2+
3+ import { type Options , adminLookupQuote , resolveQuote , listAcceptedQuotes , listPendingQuotes , enquireQuote , lookupQuote , resolveOffer } from '../sdk.gen' ;
4+ import { queryOptions , type UseMutationOptions , type DefaultError } from '@tanstack/react-query' ;
5+ import type { AdminLookupQuoteData , ResolveQuoteData , ListAcceptedQuotesData , ListPendingQuotesData , EnquireQuoteData , EnquireQuoteResponse , LookupQuoteData , ResolveOfferData } from '../types.gen' ;
6+ import { client as _heyApiClient } from '../client.gen' ;
7+
8+ export type QueryKey < TOptions extends Options > = [
9+ Pick < TOptions , 'baseUrl' | 'body' | 'headers' | 'path' | 'query' > & {
10+ _id : string ;
11+ _infinite ?: boolean ;
12+ }
13+ ] ;
14+
15+ const createQueryKey = < TOptions extends Options > ( id : string , options ?: TOptions , infinite ?: boolean ) : [
16+ QueryKey < TOptions > [ 0 ]
17+ ] => {
18+ const params : QueryKey < TOptions > [ 0 ] = { _id : id , baseUrl : ( options ?. client ?? _heyApiClient ) . getConfig ( ) . baseUrl } as QueryKey < TOptions > [ 0 ] ;
19+ if ( infinite ) {
20+ params . _infinite = infinite ;
21+ }
22+ if ( options ?. body ) {
23+ params . body = options . body ;
24+ }
25+ if ( options ?. headers ) {
26+ params . headers = options . headers ;
27+ }
28+ if ( options ?. path ) {
29+ params . path = options . path ;
30+ }
31+ if ( options ?. query ) {
32+ params . query = options . query ;
33+ }
34+ return [
35+ params
36+ ] ;
37+ } ;
38+
39+ export const adminLookupQuoteQueryKey = ( options : Options < AdminLookupQuoteData > ) => createQueryKey ( 'adminLookupQuote' , options ) ;
40+
41+ export const adminLookupQuoteOptions = ( options : Options < AdminLookupQuoteData > ) => {
42+ return queryOptions ( {
43+ queryFn : async ( { queryKey, signal } ) => {
44+ const { data } = await adminLookupQuote ( {
45+ ...options ,
46+ ...queryKey [ 0 ] ,
47+ signal,
48+ throwOnError : true
49+ } ) ;
50+ return data ;
51+ } ,
52+ queryKey : adminLookupQuoteQueryKey ( options )
53+ } ) ;
54+ } ;
55+
56+ export const resolveQuoteQueryKey = ( options : Options < ResolveQuoteData > ) => createQueryKey ( 'resolveQuote' , options ) ;
57+
58+ export const resolveQuoteOptions = ( options : Options < ResolveQuoteData > ) => {
59+ return queryOptions ( {
60+ queryFn : async ( { queryKey, signal } ) => {
61+ const { data } = await resolveQuote ( {
62+ ...options ,
63+ ...queryKey [ 0 ] ,
64+ signal,
65+ throwOnError : true
66+ } ) ;
67+ return data ;
68+ } ,
69+ queryKey : resolveQuoteQueryKey ( options )
70+ } ) ;
71+ } ;
72+
73+ export const resolveQuoteMutation = ( options ?: Partial < Options < ResolveQuoteData > > ) => {
74+ const mutationOptions : UseMutationOptions < unknown , DefaultError , Options < ResolveQuoteData > > = {
75+ mutationFn : async ( localOptions ) => {
76+ const { data } = await resolveQuote ( {
77+ ...options ,
78+ ...localOptions ,
79+ throwOnError : true
80+ } ) ;
81+ return data ;
82+ }
83+ } ;
84+ return mutationOptions ;
85+ } ;
86+
87+ export const listAcceptedQuotesQueryKey = ( options ?: Options < ListAcceptedQuotesData > ) => createQueryKey ( 'listAcceptedQuotes' , options ) ;
88+
89+ export const listAcceptedQuotesOptions = ( options ?: Options < ListAcceptedQuotesData > ) => {
90+ return queryOptions ( {
91+ queryFn : async ( { queryKey, signal } ) => {
92+ const { data } = await listAcceptedQuotes ( {
93+ ...options ,
94+ ...queryKey [ 0 ] ,
95+ signal,
96+ throwOnError : true
97+ } ) ;
98+ return data ;
99+ } ,
100+ queryKey : listAcceptedQuotesQueryKey ( options )
101+ } ) ;
102+ } ;
103+
104+ export const listPendingQuotesQueryKey = ( options ?: Options < ListPendingQuotesData > ) => createQueryKey ( 'listPendingQuotes' , options ) ;
105+
106+ export const listPendingQuotesOptions = ( options ?: Options < ListPendingQuotesData > ) => {
107+ return queryOptions ( {
108+ queryFn : async ( { queryKey, signal } ) => {
109+ const { data } = await listPendingQuotes ( {
110+ ...options ,
111+ ...queryKey [ 0 ] ,
112+ signal,
113+ throwOnError : true
114+ } ) ;
115+ return data ;
116+ } ,
117+ queryKey : listPendingQuotesQueryKey ( options )
118+ } ) ;
119+ } ;
120+
121+ export const enquireQuoteQueryKey = ( options : Options < EnquireQuoteData > ) => createQueryKey ( 'enquireQuote' , options ) ;
122+
123+ export const enquireQuoteOptions = ( options : Options < EnquireQuoteData > ) => {
124+ return queryOptions ( {
125+ queryFn : async ( { queryKey, signal } ) => {
126+ const { data } = await enquireQuote ( {
127+ ...options ,
128+ ...queryKey [ 0 ] ,
129+ signal,
130+ throwOnError : true
131+ } ) ;
132+ return data ;
133+ } ,
134+ queryKey : enquireQuoteQueryKey ( options )
135+ } ) ;
136+ } ;
137+
138+ export const enquireQuoteMutation = ( options ?: Partial < Options < EnquireQuoteData > > ) => {
139+ const mutationOptions : UseMutationOptions < EnquireQuoteResponse , DefaultError , Options < EnquireQuoteData > > = {
140+ mutationFn : async ( localOptions ) => {
141+ const { data } = await enquireQuote ( {
142+ ...options ,
143+ ...localOptions ,
144+ throwOnError : true
145+ } ) ;
146+ return data ;
147+ }
148+ } ;
149+ return mutationOptions ;
150+ } ;
151+
152+ export const lookupQuoteQueryKey = ( options : Options < LookupQuoteData > ) => createQueryKey ( 'lookupQuote' , options ) ;
153+
154+ export const lookupQuoteOptions = ( options : Options < LookupQuoteData > ) => {
155+ return queryOptions ( {
156+ queryFn : async ( { queryKey, signal } ) => {
157+ const { data } = await lookupQuote ( {
158+ ...options ,
159+ ...queryKey [ 0 ] ,
160+ signal,
161+ throwOnError : true
162+ } ) ;
163+ return data ;
164+ } ,
165+ queryKey : lookupQuoteQueryKey ( options )
166+ } ) ;
167+ } ;
168+
169+ export const resolveOfferQueryKey = ( options : Options < ResolveOfferData > ) => createQueryKey ( 'resolveOffer' , options ) ;
170+
171+ export const resolveOfferOptions = ( options : Options < ResolveOfferData > ) => {
172+ return queryOptions ( {
173+ queryFn : async ( { queryKey, signal } ) => {
174+ const { data } = await resolveOffer ( {
175+ ...options ,
176+ ...queryKey [ 0 ] ,
177+ signal,
178+ throwOnError : true
179+ } ) ;
180+ return data ;
181+ } ,
182+ queryKey : resolveOfferQueryKey ( options )
183+ } ) ;
184+ } ;
185+
186+ export const resolveOfferMutation = ( options ?: Partial < Options < ResolveOfferData > > ) => {
187+ const mutationOptions : UseMutationOptions < unknown , DefaultError , Options < ResolveOfferData > > = {
188+ mutationFn : async ( localOptions ) => {
189+ const { data } = await resolveOffer ( {
190+ ...options ,
191+ ...localOptions ,
192+ throwOnError : true
193+ } ) ;
194+ return data ;
195+ }
196+ } ;
197+ return mutationOptions ;
198+ } ;
0 commit comments