mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-21 15:05:01 +00:00
add vehicle api (#221)
* add vehicle api * Commit from GitHub Actions (Publish APIs & Clients) Co-authored-by: asim <asim@users.noreply.github.com>
This commit is contained in:
@@ -37,6 +37,7 @@ import (
|
||||
"github.com/micro/services/clients/go/twitter"
|
||||
"github.com/micro/services/clients/go/url"
|
||||
"github.com/micro/services/clients/go/user"
|
||||
"github.com/micro/services/clients/go/vehicle"
|
||||
"github.com/micro/services/clients/go/weather"
|
||||
)
|
||||
|
||||
@@ -80,6 +81,7 @@ func NewClient(token string) *Client {
|
||||
TwitterService: twitter.NewTwitterService(token),
|
||||
UrlService: url.NewUrlService(token),
|
||||
UserService: user.NewUserService(token),
|
||||
VehicleService: vehicle.NewVehicleService(token),
|
||||
WeatherService: weather.NewWeatherService(token),
|
||||
}
|
||||
}
|
||||
@@ -123,5 +125,6 @@ type Client struct {
|
||||
TwitterService *twitter.TwitterService
|
||||
UrlService *url.UrlService
|
||||
UserService *user.UserService
|
||||
VehicleService *vehicle.VehicleService
|
||||
WeatherService *weather.WeatherService
|
||||
}
|
||||
|
||||
61
clients/go/vehicle/vehicle.go
Executable file
61
clients/go/vehicle/vehicle.go
Executable file
@@ -0,0 +1,61 @@
|
||||
package vehicle
|
||||
|
||||
import (
|
||||
"github.com/m3o/m3o-go/client"
|
||||
)
|
||||
|
||||
func NewVehicleService(token string) *VehicleService {
|
||||
return &VehicleService{
|
||||
client: client.NewClient(&client.Options{
|
||||
Token: token,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
type VehicleService struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
// Lookup a UK vehicle by it's registration number
|
||||
func (t *VehicleService) Lookup(request *LookupRequest) (*LookupResponse, error) {
|
||||
rsp := &LookupResponse{}
|
||||
return rsp, t.client.Call("vehicle", "Lookup", request, rsp)
|
||||
}
|
||||
|
||||
type LookupRequest struct {
|
||||
// the vehicle registration number
|
||||
Registration string `json:"registration"`
|
||||
}
|
||||
|
||||
type LookupResponse struct {
|
||||
// co2 emmissions
|
||||
Co2emissions float64 `json:"co2emissions"`
|
||||
// colour of vehicle
|
||||
Colour string `json:"colour"`
|
||||
// engine capacity
|
||||
EngineCapacity int32 `json:"engineCapacity"`
|
||||
// fuel type e.g petrol, diesel
|
||||
FuelType string `json:"fuelType"`
|
||||
// date of last v5 issue
|
||||
LastV5issued string `json:"lastV5issued"`
|
||||
// make of vehicle
|
||||
Make string `json:"make"`
|
||||
// month of first registration
|
||||
MonthOfFirstRegistration string `json:"monthOfFirstRegistration"`
|
||||
// mot expiry
|
||||
MotExpiry string `json:"motExpiry"`
|
||||
// mot status
|
||||
MotStatus string `json:"motStatus"`
|
||||
// registration number
|
||||
Registration string `json:"registration"`
|
||||
// tax due data
|
||||
TaxDueDate string `json:"taxDueDate"`
|
||||
// tax status
|
||||
TaxStatus string `json:"taxStatus"`
|
||||
// type approvale
|
||||
TypeApproval string `json:"typeApproval"`
|
||||
// wheel plan
|
||||
Wheelplan string `json:"wheelplan"`
|
||||
// year of manufacture
|
||||
YearOfManufacture int32 `json:"yearOfManufacture"`
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import * as time from "./time";
|
||||
import * as twitter from "./twitter";
|
||||
import * as url from "./url";
|
||||
import * as user from "./user";
|
||||
import * as vehicle from "./vehicle";
|
||||
import * as weather from "./weather";
|
||||
|
||||
export class Client {
|
||||
@@ -74,6 +75,7 @@ export class Client {
|
||||
this.twitterService = new twitter.TwitterService(token);
|
||||
this.urlService = new url.UrlService(token);
|
||||
this.userService = new user.UserService(token);
|
||||
this.vehicleService = new vehicle.VehicleService(token);
|
||||
this.weatherService = new weather.WeatherService(token);
|
||||
}
|
||||
|
||||
@@ -113,5 +115,6 @@ export class Client {
|
||||
twitterService: twitter.TwitterService;
|
||||
urlService: url.UrlService;
|
||||
userService: user.UserService;
|
||||
vehicleService: vehicle.VehicleService;
|
||||
weatherService: weather.WeatherService;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
"./twitter": "./dist/twitter/index.js",
|
||||
"./url": "./dist/url/index.js",
|
||||
"./user": "./dist/user/index.js",
|
||||
"./vehicle": "./dist/vehicle/index.js",
|
||||
"./weather": "./dist/weather/index.js"
|
||||
},
|
||||
"license": "ISC",
|
||||
@@ -63,5 +64,5 @@
|
||||
},
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"version": "1.0.534"
|
||||
"version": "1.0.535"
|
||||
}
|
||||
55
clients/ts/vehicle/index.ts
Executable file
55
clients/ts/vehicle/index.ts
Executable file
@@ -0,0 +1,55 @@
|
||||
import * as m3o from "@m3o/m3o-node";
|
||||
|
||||
export class VehicleService {
|
||||
private client: m3o.Client;
|
||||
|
||||
constructor(token: string) {
|
||||
this.client = new m3o.Client({ token: token });
|
||||
}
|
||||
// Lookup a UK vehicle by it's registration number
|
||||
lookup(request: LookupRequest): Promise<LookupResponse> {
|
||||
return this.client.call(
|
||||
"vehicle",
|
||||
"Lookup",
|
||||
request
|
||||
) as Promise<LookupResponse>;
|
||||
}
|
||||
}
|
||||
|
||||
export interface LookupRequest {
|
||||
// the vehicle registration number
|
||||
registration?: string;
|
||||
}
|
||||
|
||||
export interface LookupResponse {
|
||||
// co2 emmissions
|
||||
co2Emissions?: number;
|
||||
// colour of vehicle
|
||||
colour?: string;
|
||||
// engine capacity
|
||||
engineCapacity?: number;
|
||||
// fuel type e.g petrol, diesel
|
||||
fuelType?: string;
|
||||
// date of last v5 issue
|
||||
lastV5Issued?: string;
|
||||
// make of vehicle
|
||||
make?: string;
|
||||
// month of first registration
|
||||
monthOfFirstRegistration?: string;
|
||||
// mot expiry
|
||||
motExpiry?: string;
|
||||
// mot status
|
||||
motStatus?: string;
|
||||
// registration number
|
||||
registration?: string;
|
||||
// tax due data
|
||||
taxDueDate?: string;
|
||||
// tax status
|
||||
taxStatus?: string;
|
||||
// type approvale
|
||||
typeApproval?: string;
|
||||
// wheel plan
|
||||
wheelplan?: string;
|
||||
// year of manufacture
|
||||
yearOfManufacture?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user