autoria

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2023 License: BSD-3-Clause Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go AutoRIA

Go Reference Go Report Card

Бібліотека для використання api auto.ria.com

Для використання вам потрібен токен, який можна отримати на сайті RIA Developers
Використання
package main

import (
	"fmt"
	"time"

	"github.com/fairytale5571/autoria"
)

const (
	APIKey = "123"
)

func main() {
	ria := autoria.New(autoria.Opts{
		APIKey:  APIKey,
		Timeout: 10 * time.Second,
	})
	cars, err := ria.GetMarksByCategory(autoria.CategoryCars)
	if err != nil {
		panic(err)
	}
	for _, car := range cars {
		fmt.Printf("%s: %d\n", car.Name, car.Value)
	}
}

TODO:
  • Типи транспорту
  • Типи кузова
  • Марки
  • Моделі
  • Покоління
  • Модифікації
  • Області
  • Міста
  • Типи приводу
  • Типи палива
  • Коробки передач
  • Опції
  • Кольори
  • Країна виробник
  • Пошук оголошень
  • Підрахунок середньої ціни
  • Інформація по id оголошення

Documentation

Index

Constants

View Source
const (
	// ErrorCodeApiKeyMissing	API ключ не було вказано. Детальніше про використання API ключа дивитись у розділі "Використання API Key" .
	ErrorCodeApiKeyMissing = "API_KEY_MISSING"
	// ErrorCodeApiKeyInvalid Було вказано неправильний ключ API. Переконайтеся, що було вказано коректний API ключ, або зареєструйтеся для отримання ключа.
	ErrorCodeApiKeyInvalid = "API_KEY_INVALID"
	// ErrorCodeApiKeyDisabled API ключ було вимкнено адміністратором. Будь ласка зв'яжіться з нами для допомоги.
	ErrorCodeApiKeyDisabled = "API_KEY_DISABLED"
	// ErrorCodeApiKeyUnauthorized API ключ не авторизований для доступу до цього сервісу. Будь ласка зв'яжіться з нами для допомоги.
	ErrorCodeApiKeyUnauthorized = "API_KEY_UNAUTHORIZED"
	// ErrorCodeApiKeyUnverified API ключ не підтверджено. Перевірте свою електронну пошту для підтвердження API ключа. Будь ласка зв'яжіться з нами для допомоги.
	ErrorCodeApiKeyUnverified = "API_KEY_UNVERIFIED"
	// ErrorCodeHttpsRequired Запити до цього API мають бути зроблені за HTTPS протоколом. Переконайтеся, будь ласка, що Ви використовуєте HTTPS протокол для Вашого запиту.
	ErrorCodeHttpsRequired = "HTTPS_REQUIRED"
	// ErrorCodeOverRateLimit Перевищено ліміт запитів для цього API ключа. Зв'яжіться з нами для отримання додаткової інформації про ліміти веб-сервісів .
	ErrorCodeOverRateLimit = "OVER_RATE_LIMIT"
	// ErrorCodeNotFound Не вдалося знайти API за цією URL-адресою. Перевірте свій URL.
	ErrorCodeNotFound = "NOT_FOUND"
)
View Source
const (
	// CategoryCars Легкові
	CategoryCars = iota + 1
	// CategoryMoto Мото
	CategoryMoto
	// CategoryWaterTransport Водний транспорт
	CategoryWaterTransport
	// CategorySpecialMachinery Спецтехніка
	CategorySpecialMachinery
	// CategoryTrailers Причепи
	CategoryTrailers
	// CategoryTrucks Вантажівки
	CategoryTrucks
	// CategoryBuses Автобуси
	CategoryBuses
	// CategoryAutoBuildings Автобудинки
	CategoryAutoBuildings
	// CategoryAirTransport Повітряний транспорт
	CategoryAirTransport
	// CategoryAgriculturalMachinery Сільгосптехніка
	CategoryAgriculturalMachinery
)
View Source
const (
	APIBaseURL = "https://developers.ria.com"
)

Variables

View Source
var (
	// ErrInvalidAPIKey is returned when API key is invalid
	ErrInvalidAPIKey = errors.New("invalid api key")

	// ErrTooManyRequests is returned when too many requests
	ErrTooManyRequests = errors.New("too many requests")

	// ErrInvalidRequest is returned when request is invalid
	ErrInvalidRequest = errors.New("invalid request")
)

Functions

This section is empty.

Types

type Base

type Base struct {
	Name  string `json:"name"`
	Value int    `json:"value"`
}

Base is a base struct for all categories

type BaseWithParentID

type BaseWithParentID struct {
	Base
	ParentID int `json:"parent_id"`
}

type Categories

type Categories []Base

Categories тип з категоріями авто Categories is a slice of Base

type ColorTypes

type ColorTypes []Base

ColorTypes тип з модифікаціями авто Example: ColorTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type CountryTypes

type CountryTypes []Base

CountryTypes тип з модифікаціями авто Example: CountryTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type DriverTypes

type DriverTypes []Base

DriverTypes тип з модифікаціями авто Example: DriverTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type ErrorBody

type ErrorBody struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

type FuelTypes

type FuelTypes []Base

FuelTypes тип з модифікаціями авто Example: FuelTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type GearboxesTypes

type GearboxesTypes []Base

GearboxesTypes тип з модифікаціями авто Example: GearboxesTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type Generation

type Generation struct {
	Name         string `json:"name"`
	Eng          string `json:"eng"`
	GenerationId int    `json:"generationId"`
	YearFrom     int    `json:"yearFrom"`
	YearTo       int    `json:"yearTo"`
	ModelId      int    `json:"modelId"`
}

type Generations

type Generations struct {
	Name        string       `json:"name"`
	Generations []Generation `json:"generations"`
	ID          int          `json:"id"`
}

type Marks

type Marks []Base

Marks тип з марками авто Example: Marks{{Name: "Audi", Value: 1}, {Name: "BMW", Value: 2}}

type Models

type Models []Base

Models тип з моделями авто Example: Models{{Name: "A4", Value: 1}, {Name: "A6", Value: 2}}

type Modifications

type Modifications []Base

Modifications тип з модифікаціями авто Example: Modifications{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type ObjectOrArray

type ObjectOrArray any

type OptionTypes

type OptionTypes []Base

OptionTypes тип з модифікаціями авто Example: OptionTypes{{Name: "1.8", Value: 1}, {Name: "2.0", Value: 2}}

type Opts

type Opts struct {
	APIKey  string
	Debug   bool
	Timeout time.Duration
}

type RestError

type RestError struct {
	ErrorBody `json:"error"`
}

func (RestError) Error

func (e RestError) Error() string

type Service added in v0.0.4

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(opts Opts) *Service

func (*Service) GetApiKey added in v0.0.4

func (s *Service) GetApiKey() string

func (*Service) GetBodyStyles added in v0.0.4

func (s *Service) GetBodyStyles(parentID int) ([]BaseWithParentID, error)

GetBodyStyles returns all body styles for given parentID Example: GetBodyStyles(1) returns all body styles for "Легкові"

func (*Service) GetBodyStylesWithGroups added in v0.0.4

func (s *Service) GetBodyStylesWithGroups(parentID int) ([][]BaseWithParentID, error)

GetBodyStylesWithGroups returns all body styles for given parentID grouped by type Example: GetBodyStylesWithGroups(1) returns all body styles for "Легкові" grouped by type

func (*Service) GetCategories added in v0.0.4

func (s *Service) GetCategories() (Categories, error)

GetCategories returns all categories Легкові, грузові, причепи і т.д. в массиві

func (*Service) GetCities added in v0.0.4

func (s *Service) GetCities(stateID int) (States, error)

GetCities returns all cities for given stateID

func (*Service) GetColors added in v0.0.4

func (s *Service) GetColors() (ColorTypes, error)

GetColors returns all colors Кольори

func (*Service) GetCountries added in v0.0.4

func (s *Service) GetCountries() (CountryTypes, error)

GetCountries returns all countries

func (*Service) GetDriverTypes added in v0.0.4

func (s *Service) GetDriverTypes(categoryID int) (DriverTypes, error)

GetDriverTypes returns all driver types Типи приводу

func (*Service) GetFuelTypes added in v0.0.4

func (s *Service) GetFuelTypes() (FuelTypes, error)

GetFuelTypes returns all fuel types Типи палива

func (*Service) GetGearboxTypes added in v0.0.4

func (s *Service) GetGearboxTypes(categoryID int) (GearboxesTypes, error)

GetGearboxTypes returns all gearbox types Типи коробки передач

func (*Service) GetGenerationsByModelID added in v0.0.4

func (s *Service) GetGenerationsByModelID(modelID int) ([]Generations, error)

func (*Service) GetMarksByCategory added in v0.0.4

func (s *Service) GetMarksByCategory(categoryID int) (Marks, error)

GetMarksByCategory returns all marks for given categoryID Example: GetMarksByCategory(1) returns all marks for "Легкові"

func (*Service) GetModelsByCategoryAndMarkID added in v0.0.4

func (s *Service) GetModelsByCategoryAndMarkID(categoryID, markID int) (Models, error)

GetModelsByCategoryAndMarkID returns all models for given categoryID and markID Example: GetModelsByCategoryAndMarkID(1, 1) returns all models for "Легкові" and "Acura"

func (*Service) GetModelsByCategoryAndMarkIDWithGroups added in v0.0.4

func (s *Service) GetModelsByCategoryAndMarkIDWithGroups(categoryID, markID int) (Models, error)

GetModelsByCategoryAndMarkIDWithGroups returns all models for given categoryID and markID grouped by type Example: GetModelsByCategoryAndMarkIDWithGroups(1, 1) returns all models for "Легкові" and "Acura" grouped by type

func (*Service) GetModificationsByGenerationID added in v0.0.4

func (s *Service) GetModificationsByGenerationID(generationID int) (Modifications, error)

GetModificationsByGenerationID returns all modifications for given generationID Example: GetModificationsByGenerationID(1) де 1 - це id покоління з слайсу GetGenerationsByModelID

func (*Service) GetOptions added in v0.0.4

func (s *Service) GetOptions(categoryID int) (OptionTypes, error)

GetOptions returns all options Опції

func (*Service) GetStates added in v0.0.4

func (s *Service) GetStates() (States, error)

GetStates returns all states of Ukraine

type States

type States []Base

States області України Example: States{{Name: "Вінницька", Value: 1}, {Name: "Волинська", Value: 18}}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL