Documentation
¶
Overview ¶
Package autoapi provides a client for the auto-api.com car listings API.
Index ¶
- type ApiError
- type AuthError
- type ChangeIDResponse
- type ChangeItem
- type ChangesMeta
- type ChangesResponse
- type Client
- func (c *Client) GetChangeID(ctx context.Context, source string, date string) (int, error)
- func (c *Client) GetChanges(ctx context.Context, source string, changeID int) (*ChangesResponse, error)
- func (c *Client) GetFilters(ctx context.Context, source string) (map[string]interface{}, error)
- func (c *Client) GetOffer(ctx context.Context, source string, innerID string) (*OffersResponse, error)
- func (c *Client) GetOfferByURL(ctx context.Context, offerURL string) (map[string]interface{}, error)
- func (c *Client) GetOffers(ctx context.Context, source string, params *OffersParams) (*OffersResponse, error)
- func (c *Client) SetAPIVersion(version string)
- func (c *Client) SetBaseURL(baseURL string)
- type Meta
- type OfferData
- type OfferItem
- type OffersParams
- type OffersResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct {
StatusCode int
Message string
Body json.RawMessage
}
ApiError represents a non-auth API error response.
type ChangeIDResponse ¶
type ChangeIDResponse struct {
ChangeID int `json:"change_id"`
}
ChangeIDResponse is the response from GetChangeID.
type ChangeItem ¶
type ChangeItem struct {
ID int `json:"id"`
InnerID string `json:"inner_id"`
ChangeType string `json:"change_type"`
CreatedAt string `json:"created_at"`
Data json.RawMessage `json:"data"`
}
ChangeItem is a single item in the changes result array.
type ChangesMeta ¶
type ChangesMeta struct {
CurChangeID int `json:"cur_change_id"`
NextChangeID int `json:"next_change_id"`
Limit int `json:"limit"`
}
ChangesMeta holds pagination info for changes.
type ChangesResponse ¶
type ChangesResponse struct {
Result []ChangeItem `json:"result"`
Meta ChangesMeta `json:"meta"`
}
ChangesResponse is the response from GetChanges.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the auto-api.com API client.
func (*Client) GetChangeID ¶
GetChangeID returns a change_id for the given date (format: yyyy-mm-dd).
func (*Client) GetChanges ¶
func (c *Client) GetChanges(ctx context.Context, source string, changeID int) (*ChangesResponse, error)
GetChanges returns a changes feed (added/changed/removed) starting from change_id.
func (*Client) GetFilters ¶
GetFilters returns available filters for a source (brands, models, body types, etc.)
func (*Client) GetOffer ¶
func (c *Client) GetOffer(ctx context.Context, source string, innerID string) (*OffersResponse, error)
GetOffer returns a single offer by inner_id.
func (*Client) GetOfferByURL ¶
func (c *Client) GetOfferByURL(ctx context.Context, offerURL string) (map[string]interface{}, error)
GetOfferByURL returns offer data by its URL on the marketplace.
func (*Client) GetOffers ¶
func (c *Client) GetOffers(ctx context.Context, source string, params *OffersParams) (*OffersResponse, error)
GetOffers returns a paginated list of offers with optional filters.
func (*Client) SetAPIVersion ¶
SetAPIVersion overrides the default API version (default: "v2").
func (*Client) SetBaseURL ¶
SetBaseURL overrides the default base URL.
type Meta ¶
type Meta struct {
Page int `json:"page"`
NextPage int `json:"next_page"`
Limit int `json:"limit"`
}
Meta holds pagination info for offers.
type OfferData ¶
type OfferData struct {
InnerID string `json:"inner_id"`
URL string `json:"url"`
Mark string `json:"mark"`
Model string `json:"model"`
Generation string `json:"generation"`
Configuration string `json:"configuration"`
Complectation string `json:"complectation"`
Year string `json:"year"`
Color string `json:"color"`
Price string `json:"price"`
KmAge string `json:"km_age"`
EngineType string `json:"engine_type"`
TransmissionType string `json:"transmission_type"`
BodyType string `json:"body_type"`
Address string `json:"address"`
SellerType string `json:"seller_type"`
IsDealer bool `json:"is_dealer"`
Displacement string `json:"displacement"`
OfferCreated string `json:"offer_created"`
Images []string `json:"images"`
}
OfferData holds common offer fields shared across all sources. Since each source may have additional fields, use json.RawMessage from OfferItem.Data and unmarshal into your own struct if needed.
type OfferItem ¶
type OfferItem struct {
ID int `json:"id"`
InnerID string `json:"inner_id"`
ChangeType string `json:"change_type"`
CreatedAt string `json:"created_at"`
Data json.RawMessage `json:"data"`
}
OfferItem is a single item in the offers result array.
type OffersParams ¶
type OffersParams struct {
Page int `url:"page"`
Brand string `url:"brand,omitempty"`
Model string `url:"model,omitempty"`
Configuration string `url:"configuration,omitempty"`
Complectation string `url:"complectation,omitempty"`
Transmission string `url:"transmission,omitempty"`
Color string `url:"color,omitempty"`
BodyType string `url:"body_type,omitempty"`
EngineType string `url:"engine_type,omitempty"`
YearFrom int `url:"year_from,omitempty"`
YearTo int `url:"year_to,omitempty"`
MileageFrom int `url:"mileage_from,omitempty"`
MileageTo int `url:"mileage_to,omitempty"`
PriceFrom int `url:"price_from,omitempty"`
PriceTo int `url:"price_to,omitempty"`
}
OffersParams holds query parameters for GetOffers.
type OffersResponse ¶
OffersResponse is the response from GetOffers.