toolkit

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: MIT Imports: 6 Imported by: 3

README

OpenCars Toolkit

Docs Go Report Version

Overview

Download opencars toolkit with following command

go get -u github.com/opencars/toolkit

Example

Simple example of toolkit usage

package main

import (
    "fmt"
    "log"
    "os"

    "github.com/opencars/toolkit"
)

func main() {
    client := toolkit.New("https://api.opencars.app", os.Getenv("OPENCARS_API_KEY"))

    operations, err := client.Operation().FindByNumber("АА9359РС")
    if err != nil {
        log.Fatal(err)
    }

    for _, op := range operations {
        fmt.Println(op)
    }

License

Project released under the terms of the MIT license.

Documentation

Index

Examples

Constants

View Source
const (
	// APIKeyHeader ...
	APIKeyHeader = "X-Api-Key"
)

Variables

View Source
var (
	// ErrUnauthorized ...
	ErrUnauthorized = errors.New("unauthorized")
)

Functions

This section is empty.

Types

type ALPRClient added in v0.1.3

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

func (*ALPRClient) Recognize added in v0.1.3

func (client *ALPRClient) Recognize(url string) ([]ResultALPR, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	results, err := client.ALPR().Recognize("https://raw.githubusercontent.com/opencars/alpr/master/pkg/api/http/test/example.jpeg")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(results[0].Plate)
}
Output:

AA9008MT

type Client

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

func New

func New(uri string, token string) *Client

New initializes new instance of client structure.

func (*Client) ALPR added in v0.1.3

func (client *Client) ALPR() *ALPRClient

func (*Client) Operation added in v0.0.5

func (client *Client) Operation() *OperationClient

func (*Client) Registration added in v0.1.0

func (client *Client) Registration() *RegistrationClient

func (*Client) Wanted added in v0.1.0

func (client *Client) Wanted() *WantedClient

type CoordinateALPR added in v0.1.3

type CoordinateALPR struct {
	X int `json:"x"`
	Y int `json:"y"`
}

CoordinateALPR represents

type Error added in v0.1.3

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

Error represents error with http status code.

type Operation added in v0.0.5

type Operation struct {
	Person      string   `json:"person"`
	RegAddress  *string  `json:"reg_addr_koatuu"`
	RegCode     int16    `json:"registration_code"`
	Reg         string   `json:"registration"`
	Date        string   `json:"date"`
	DepCode     int32    `json:"dep_code"`
	Dep         string   `json:"dep"`
	Brand       string   `json:"brand"`
	Model       string   `json:"model"`
	Year        int16    `json:"year"`
	Color       string   `json:"color"`
	Kind        string   `json:"kind"`
	Body        string   `json:"body"`
	Purpose     string   `json:"purpose"`
	Fuel        *string  `json:"fuel"`
	Capacity    *int     `json:"capacity"`
	OwnWeight   *float64 `json:"own_weight"`
	TotalWeight *float64 `json:"total_weight"`
	Number      string   `json:"number"`
}

Operation represents public registrations of transport.

type OperationClient added in v0.1.0

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

func (*OperationClient) FindByNumber added in v0.1.0

func (client *OperationClient) FindByNumber(number string) ([]Operation, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	operations, err := client.Operation().FindByNumber("AA9359PC")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(operations[0].Number)
}
Output:

АА9359РС

type Registration added in v0.0.5

type Registration struct {
	Brand        *string  `json:"brand"`
	Capacity     *int     `json:"capacity"`
	Color        string   `json:"color"`
	FirstRegDate *string  `json:"first_reg_date"`
	Date         *string  `json:"date"`
	Fuel         *string  `json:"fuel"`
	Kind         *string  `json:"kind"`
	Year         int      `json:"year"`
	Model        *string  `json:"model"`
	Code         string   `json:"code"`
	Number       string   `json:"number"`
	NumSeating   *int     `json:"num_seating"`
	NumStanding  *int     `json:"num_standing"`
	OwnWeight    *float64 `json:"own_weight"`
	RankCategory *string  `json:"rank_category"`
	TotalWeight  *float64 `json:"total_weight"`
	VIN          *string  `json:"vin"`
}

Registration represents information from vehicle registration document.

type RegistrationClient added in v0.1.0

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

func (*RegistrationClient) FindByCode added in v0.1.0

func (client *RegistrationClient) FindByCode(code string) (*Registration, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	registration, err := client.Registration().FindByCode("CXH484154")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(registration.Code)
}
Output:

CXH484154

func (*RegistrationClient) FindByNumber added in v0.1.0

func (client *RegistrationClient) FindByNumber(number string) ([]Registration, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	registrations, err := client.Registration().FindByNumber("AA9359PC")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(registrations[0].Number)
}
Output:

AA9359PC

func (*RegistrationClient) FindByVIN added in v0.1.0

func (client *RegistrationClient) FindByVIN(vin string) ([]Registration, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	registrations, err := client.Registration().FindByVIN("5YJXCCE40GF010543")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(*registrations[0].VIN)
}
Output:

5YJXCCE40GF010543

type ResultALPR added in v0.1.3

type ResultALPR struct {
	Coordinates []CoordinateALPR `json:"coordinates"`
	Plate       string           `json:"plate"`
}

ResultALPR represents result of recognition.

type WantedClient added in v0.1.0

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

func (*WantedClient) FindByNumber added in v0.1.0

func (client *WantedClient) FindByNumber(number string) ([]WantedVehicle, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	wanted, err := client.Wanted().FindByNumber("AT4750CP")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(*wanted[0].Number)
}
Output:

АТ4750СР

func (*WantedClient) FindByVIN added in v0.1.0

func (client *WantedClient) FindByVIN(vin string) ([]WantedVehicle, error)
Example
package main

import (
	"fmt"
	"log"

	"github.com/opencars/toolkit"
)

func main() {
	client := toolkit.New("https://api.opencars.app", "jIidbA8wivROjFNv1H8SiEoFQFHZ0VzL")
	wanted, err := client.Wanted().FindByVIN("5YJSA1E28HF176944")
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(*wanted[0].BodyNumber)
}
Output:

5YJSA1E28HF176944

type WantedVehicle added in v0.1.0

type WantedVehicle struct {
	ID            string    `json:"id"`
	Brand         string    `json:"brand"`
	Maker         *string   `json:"maker,omitempty"`
	Model         *string   `json:"model,omitempty"`
	Color         *string   `json:"color,omitempty"`
	Number        *string   `json:"number,omitempty"`
	BodyNumber    *string   `json:"body_number,omitempty"`
	ChassisNumber *string   `json:"chassis_number,omitempty"`
	EngineNumber  *string   `json:"engine_number,omitempty"`
	OVD           string    `json:"ovd"`
	Kind          string    `json:"kind"`
	Status        string    `json:"status"`
	RevisionID    string    `json:"revision_id"`
	TheftDate     string    `json:"theft_date"`
	InsertDate    time.Time `json:"insert_date"`
}

WantedVehicle represents information about wanted vehicle.

Jump to

Keyboard shortcuts

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