Quotes
Quotes are available on a ready questionnaire as q.quotes.
if (q.ready) { const quoteSet = await q.quotes.wait();}Reference
Section titled “Reference”q.quotes.wait(options?)
Section titled “q.quotes.wait(options?)”Polls until the quote set settles, honouring the server’s Retry-After.
options.timeoutMs(optional): default120000. Rejects withTimeoutErrorafter this.options.signal(optional): anAbortSignal.
Returns Promise<QuoteSet>.
Caveats: if quoting fails, rejects with QuoteFailedError. Call its retry().
q.quotes.get()
Section titled “q.quotes.get()”Polls once. Returns { state: "quoting", retryAfterMs } or { state: "quoted", quoteSet }.
QuoteSet
Section titled “QuoteSet”quotes:Quote[].quoteComparisonUrl: the signed URL to send the customer to. Pass it through untouched.raw: the response body.
The wire fields (id, insurer, decision, premium, policy_expiry, …) plus:
quote.detail()
Section titled “quote.detail()”Returns Promise<QuoteDetail>: covers, insurer responses and reference.
quote.select()
Section titled “quote.select()”Chooses this quote; it’s carried to purchase. Returns Promise<void>.
Caveats: referred and declined quotes can’t be selected: this throws AffordanceUnavailableError.
Select the first selectable quote
Section titled “Select the first selectable quote”const quoteSet = await q.quotes.wait();const quote = quoteSet.quotes.find((x) => x.decision === 'quoted');if (quote) await quote.select();location.assign(quoteSet.quoteComparisonUrl);Show quotes in a UI
Section titled “Show quotes in a UI”Use toQuoteCards for formatted premiums and a selectable flag.