autotrader-connect-api
Version:
Production-ready TypeScript wrapper for Auto Trader UK Connect APIs
296 lines • 6.62 kB
TypeScript
/**
* Search-related types for AutoTrader API
*/
import { VehicleSearchParams, VehicleResponse } from './vehicle';
import { PaginatedResponse, Location } from './common';
/**
* Search facets for filtering results
*/
export interface SearchFacets {
makes?: FacetOption[];
models?: FacetOption[];
bodyTypes?: FacetOption[];
fuelTypes?: FacetOption[];
transmissions?: FacetOption[];
colours?: FacetOption[];
dealers?: FacetOption[];
priceRanges?: FacetRange[];
yearRanges?: FacetRange[];
mileageRanges?: FacetRange[];
engineSizeRanges?: FacetRange[];
}
/**
* Facet option with count
*/
export interface FacetOption {
value: string;
label: string;
count: number;
selected?: boolean;
}
/**
* Facet range with count
*/
export interface FacetRange {
min: number;
max: number;
label: string;
count: number;
selected?: boolean;
}
/**
* Search suggestions
*/
export interface SearchSuggestions {
makes?: string[];
models?: string[];
locations?: LocationSuggestion[];
dealers?: DealerSuggestion[];
}
/**
* Location suggestion
*/
export interface LocationSuggestion {
name: string;
type: 'City' | 'Town' | 'County' | 'Postcode';
postcode?: string;
coordinates?: {
latitude: number;
longitude: number;
};
}
/**
* Dealer suggestion
*/
export interface DealerSuggestion {
id: string;
name: string;
location: string;
rating?: number;
vehicleCount?: number;
}
/**
* Search filters (extends VehicleSearchParams with UI-specific options)
*/
export interface SearchFilters extends VehicleSearchParams {
saveSearch?: boolean;
searchName?: string;
alertFrequency?: 'Daily' | 'Weekly' | 'Immediately';
includeNationwide?: boolean;
hideTradeSellerAds?: boolean;
hideDuplicateAds?: boolean;
onlyRecentlyAdded?: boolean;
onlyPriceReduced?: boolean;
onlyWithPhotos?: boolean;
onlyWithVideo?: boolean;
preferredDealers?: string[];
excludedDealers?: string[];
dealerRatingMin?: number;
financeRequired?: boolean;
monthlyBudget?: number;
depositAmount?: number;
creditRating?: 'Excellent' | 'Good' | 'Fair' | 'Poor';
}
/**
* Enhanced search response
*/
export interface SearchResponse extends PaginatedResponse<VehicleResponse> {
searchId: string;
facets?: SearchFacets;
suggestions?: SearchSuggestions;
searchMetadata: SearchMetadata;
relatedSearches?: RelatedSearch[];
marketInsights?: MarketInsights;
}
/**
* Search metadata
*/
export interface SearchMetadata {
query: SearchFilters;
executionTime: number;
totalResults: number;
searchLocation?: Location;
appliedFilters: AppliedFilter[];
sortOptions: SortOption[];
availableViews: ViewOption[];
}
/**
* Applied filter
*/
export interface AppliedFilter {
type: string;
field: string;
value: string | number | string[] | number[];
label: string;
removable: boolean;
}
/**
* Sort option
*/
export interface SortOption {
value: string;
label: string;
direction: 'asc' | 'desc';
active: boolean;
}
/**
* View option
*/
export interface ViewOption {
type: 'grid' | 'list' | 'map';
label: string;
active: boolean;
}
/**
* Related search suggestion
*/
export interface RelatedSearch {
query: string;
filters: Partial<SearchFilters>;
resultCount: number;
description: string;
}
/**
* Market insights for search results
*/
export interface MarketInsights {
averagePrice?: number;
priceRange?: {
min: number;
max: number;
};
averageMileage?: number;
averageAge?: number;
mostPopularMake?: string;
mostPopularBodyType?: string;
mostPopularFuelType?: string;
dealershipTypes?: {
franchise: number;
independent: number;
private: number;
};
priceDistribution?: PriceDistribution[];
marketTrends?: MarketTrend[];
}
/**
* Price distribution data
*/
export interface PriceDistribution {
range: string;
count: number;
percentage: number;
}
/**
* Market trend data
*/
export interface MarketTrend {
period: string;
averagePrice: number;
volume: number;
priceChange: number;
priceChangePercentage: number;
}
/**
* Saved search
*/
export interface SavedSearch {
id: string;
name: string;
filters: SearchFilters;
alertSettings: AlertSettings;
createdAt: string;
lastExecuted: string;
resultCount: number;
newResultsSinceLastCheck: number;
active: boolean;
}
/**
* Alert settings for saved searches
*/
export interface AlertSettings {
enabled: boolean;
frequency: 'Immediately' | 'Daily' | 'Weekly';
email?: string;
sms?: string;
pushNotification?: boolean;
maxAlerts?: number;
filters?: {
onlyNewResults?: boolean;
onlyPriceReduced?: boolean;
priceThreshold?: number;
};
}
/**
* Search analytics
*/
export interface SearchAnalytics {
searchId: string;
query: SearchFilters;
timestamp: string;
resultCount: number;
clickedResults: string[];
viewedDetails: string[];
savedResults: string[];
enquiredResults: string[];
sessionDuration: number;
bounced: boolean;
convertedToEnquiry: boolean;
userAgent?: string;
referrer?: string;
}
/**
* Search comparison
*/
export interface SearchComparison {
vehicles: VehicleResponse[];
comparisonFields: ComparisonField[];
recommendations?: string[];
}
/**
* Comparison field
*/
export interface ComparisonField {
field: string;
label: string;
type: 'string' | 'number' | 'boolean' | 'currency' | 'percentage';
values: (string | number | boolean)[];
highlights?: {
best?: number;
worst?: number;
unique?: number[];
};
}
/**
* Quick search parameters (simplified for autocomplete/suggestions)
*/
export interface QuickSearchParams {
query?: string;
make?: string;
model?: string;
postcode?: string;
maxPrice?: number;
radius?: number;
limit?: number;
}
/**
* Search history entry
*/
export interface SearchHistoryEntry {
id: string;
query: SearchFilters;
timestamp: string;
resultCount: number;
clickedVehicles: string[];
sessionId?: string;
}
/**
* Popular searches
*/
export interface PopularSearch {
query: string;
filters: Partial<SearchFilters>;
searchCount: number;
trending: boolean;
category: 'Make' | 'Model' | 'Location' | 'Price Range' | 'Body Type';
}
//# sourceMappingURL=search.d.ts.map