EV Chargers service (#219)

This commit is contained in:
Dominic Wong
2021-10-01 14:17:54 +01:00
committed by GitHub
parent 3c38d96881
commit f52cfba017
38 changed files with 14584 additions and 3 deletions

View File

@@ -0,0 +1,238 @@
package evchargers
import (
"github.com/m3o/m3o-go/client"
)
func NewEvchargersService(token string) *EvchargersService {
return &EvchargersService{
client: client.NewClient(&client.Options{
Token: token,
}),
}
}
type EvchargersService struct {
client *client.Client
}
// Retrieve reference data as used by this API
func (t *EvchargersService) ReferenceData(request *ReferenceDataRequest) (*ReferenceDataResponse, error) {
rsp := &ReferenceDataResponse{}
return rsp, t.client.Call("evchargers", "ReferenceData", request, rsp)
}
// Search by giving a coordinate and a max distance, or bounding box and optional filters
func (t *EvchargersService) Search(request *SearchRequest) (*SearchResponse, error) {
rsp := &SearchResponse{}
return rsp, t.client.Call("evchargers", "Search", request, rsp)
}
type Address struct {
// Any comments about how to access the charger
AccessComments string `json:"accessComments"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
Country *Country `json:"country"`
CountryId string `json:"countryId"`
Location *Coordinates `json:"location"`
Postcode string `json:"postcode"`
StateOrProvince string `json:"stateOrProvince"`
Title string `json:"title"`
Town string `json:"town"`
}
type BoundingBox struct {
BottomLeft *Coordinates `json:"bottomLeft"`
TopRight *Coordinates `json:"topRight"`
}
type ChargerType struct {
Comments string `json:"comments"`
Id string `json:"id"`
// Is this 40KW+
IsFastChargeCapable bool `json:"isFastChargeCapable"`
Title string `json:"title"`
}
type CheckinStatusType struct {
Id string `json:"id"`
IsAutomated bool `json:"isAutomated"`
IsPositive bool `json:"isPositive"`
Title string `json:"title"`
}
type Connection struct {
// The amps offered
Amps float64 `json:"amps"`
ConnectionType *ConnectionType `json:"connectionType"`
// The ID of the connection type
ConnectionTypeId string `json:"connectionTypeId"`
// The current
Current string `json:"current"`
// The level of charging power available
Level string `json:"level"`
// The power in KW
Power float64 `json:"power"`
Reference string `json:"reference"`
// The voltage offered
Voltage float64 `json:"voltage"`
}
type ConnectionType struct {
FormalName string `json:"formalName"`
Id string `json:"id"`
IsDiscontinued bool `json:"isDiscontinued"`
IsObsolete bool `json:"isObsolete"`
Title string `json:"title"`
}
type Coordinates struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
}
type Country struct {
ContinentCode string `json:"continentCode"`
Id string `json:"id"`
IsoCode string `json:"isoCode"`
Title string `json:"title"`
}
type CurrentType struct {
Description string `json:"description"`
Id string `json:"id"`
Title string `json:"title"`
}
type DataProvider struct {
Comments string `json:"comments"`
DataProviderStatusType *DataProviderStatusType `json:"dataProviderStatusType"`
Id string `json:"id"`
// How is this data licensed
License string `json:"license"`
Title string `json:"title"`
Website string `json:"website"`
}
type DataProviderStatusType struct {
Id string `json:"id"`
IsProviderEnabled bool `json:"isProviderEnabled"`
Title string `json:"title"`
}
type Operator struct {
Comments string `json:"comments"`
ContactEmail string `json:"contactEmail"`
FaultReportEmail string `json:"faultReportEmail"`
Id string `json:"id"`
// Is this operator a private individual vs a company
IsPrivateIndividual bool `json:"isPrivateIndividual"`
PhonePrimary string `json:"phonePrimary"`
PhoneSecondary string `json:"phoneSecondary"`
Title string `json:"title"`
Website string `json:"website"`
}
type Poi struct {
// The address
Address *Address `json:"address"`
// The connections available at this charge point
Connections []Connection `json:"connections"`
// The cost of charging
Cost string `json:"cost"`
// The ID of the data provider
DataProviderId string `json:"dataProviderId"`
// The ID of the charger
Id string `json:"id"`
// The number of charging points
NumPoints int64 `json:"numPoints,string"`
// The operator
Operator *Operator `json:"operator"`
// The ID of the operator of the charger
OperatorId string `json:"operatorId"`
// The type of usage
UsageType *UsageType `json:"usageType"`
// The type of usage for this charger point (is it public, membership required, etc)
UsageTypeId string `json:"usageTypeId"`
}
type ReferenceDataRequest struct {
}
type ReferenceDataResponse struct {
// The types of charger
ChargerTypes *ChargerType `json:"chargerTypes"`
// The types of checkin status
CheckinStatusTypes *CheckinStatusType `json:"checkinStatusTypes"`
// The types of connection
ConnectionTypes *ConnectionType `json:"connectionTypes"`
// The countries
Countries []Country `json:"countries"`
// The types of current
CurrentTypes *CurrentType `json:"currentTypes"`
// The providers of the charger data
DataProviders *DataProvider `json:"dataProviders"`
// The companies operating the chargers
Operators []Operator `json:"operators"`
// The status of the charger
StatusTypes *StatusType `json:"statusTypes"`
// The status of a submission
SubmissionStatusTypes *SubmissionStatusType `json:"submissionStatusTypes"`
// The different types of usage
UsageTypes *UsageType `json:"usageTypes"`
// The types of user comment
UserCommentTypes *UserCommentType `json:"userCommentTypes"`
}
type SearchRequest struct {
// Bounding box to search within (top left and bottom right coordinates)
Box *BoundingBox `json:"box"`
// IDs of the connection type
ConnectionTypes string `json:"connectionTypes"`
// Country ID
CountryId string `json:"countryId"`
// Search distance from point in metres, defaults to 5000m
Distance int64 `json:"distance,string"`
// Supported charging levels
Levels []string `json:"levels"`
// Coordinates from which to begin search
Location *Coordinates `json:"location"`
// Maximum number of results to return, defaults to 100
MaxResults int64 `json:"maxResults,string"`
// Minimum power in KW. Note: data not available for many chargers
MinPower int64 `json:"minPower,string"`
// IDs of the the EV charger operator
Operators []string `json:"operators"`
// Usage of the charge point (is it public, membership required, etc)
UsageTypes string `json:"usageTypes"`
}
type SearchResponse struct {
Pois []Poi `json:"pois"`
}
type StatusType struct {
Id string `json:"id"`
IsOperational bool `json:"isOperational"`
Title string `json:"title"`
}
type SubmissionStatusType struct {
Id string `json:"id"`
IsLive bool `json:"isLive"`
Title string `json:"title"`
}
type UsageType struct {
Id string `json:"id"`
IsAccessKeyRequired bool `json:"isAccessKeyRequired"`
IsMembershipRequired bool `json:"isMembershipRequired"`
IsPayAtLocation bool `json:"isPayAtLocation"`
Title string `json:"title"`
}
type UserCommentType struct {
Id string `json:"id"`
Title string `json:"title"`
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/micro/services/clients/go/db"
"github.com/micro/services/clients/go/email"
"github.com/micro/services/clients/go/emoji"
"github.com/micro/services/clients/go/evchargers"
"github.com/micro/services/clients/go/file"
"github.com/micro/services/clients/go/forex"
"github.com/micro/services/clients/go/geocoding"
@@ -51,6 +52,7 @@ func NewClient(token string) *Client {
DbService: db.NewDbService(token),
EmailService: email.NewEmailService(token),
EmojiService: emoji.NewEmojiService(token),
EvchargersService: evchargers.NewEvchargersService(token),
FileService: file.NewFileService(token),
ForexService: forex.NewForexService(token),
GeocodingService: geocoding.NewGeocodingService(token),
@@ -93,6 +95,7 @@ type Client struct {
DbService *db.DbService
EmailService *email.EmailService
EmojiService *emoji.EmojiService
EvchargersService *evchargers.EvchargersService
FileService *file.FileService
ForexService *forex.ForexService
GeocodingService *geocoding.GeocodingService

233
clients/ts/evchargers/index.ts Executable file
View File

@@ -0,0 +1,233 @@
import * as m3o from "@m3o/m3o-node";
export class EvchargersService {
private client: m3o.Client;
constructor(token: string) {
this.client = new m3o.Client({ token: token });
}
// Retrieve reference data as used by this API
referenceData(request: ReferenceDataRequest): Promise<ReferenceDataResponse> {
return this.client.call(
"evchargers",
"ReferenceData",
request
) as Promise<ReferenceDataResponse>;
}
// Search by giving a coordinate and a max distance, or bounding box and optional filters
search(request: SearchRequest): Promise<SearchResponse> {
return this.client.call(
"evchargers",
"Search",
request
) as Promise<SearchResponse>;
}
}
export interface Address {
// Any comments about how to access the charger
accessComments?: string;
addressLine1?: string;
addressLine2?: string;
country?: { [key: string]: any };
countryId?: string;
location?: Coordinates;
postcode?: string;
stateOrProvince?: string;
title?: string;
town?: string;
}
export interface BoundingBox {
bottomLeft?: Coordinates;
topRight?: Coordinates;
}
export interface ChargerType {
comments?: string;
id?: string;
// Is this 40KW+
isFastChargeCapable?: boolean;
title?: string;
}
export interface CheckinStatusType {
id?: string;
isAutomated?: boolean;
isPositive?: boolean;
title?: string;
}
export interface Connection {
// The amps offered
amps?: number;
connectionType?: ConnectionType;
// The ID of the connection type
connectionTypeId?: string;
// The current
current?: string;
// The level of charging power available
level?: string;
// The power in KW
power?: number;
reference?: string;
// The voltage offered
voltage?: number;
}
export interface ConnectionType {
formalName?: string;
id?: string;
isDiscontinued?: boolean;
isObsolete?: boolean;
title?: string;
}
export interface Coordinates {
latitude?: number;
longitude?: number;
}
export interface Country {
continentCode?: string;
id?: string;
isoCode?: string;
title?: string;
}
export interface CurrentType {
description?: string;
id?: string;
title?: string;
}
export interface DataProvider {
comments?: string;
dataProviderStatusType?: DataProviderStatusType;
id?: string;
// How is this data licensed
license?: string;
title?: string;
website?: string;
}
export interface DataProviderStatusType {
id?: string;
isProviderEnabled?: boolean;
title?: string;
}
export interface Operator {
comments?: string;
contactEmail?: string;
faultReportEmail?: string;
id?: string;
// Is this operator a private individual vs a company
isPrivateIndividual?: boolean;
phonePrimary?: string;
phoneSecondary?: string;
title?: string;
website?: string;
}
export interface Poi {
// The address
address?: { [key: string]: any };
// The connections available at this charge point
connections?: Connection[];
// The cost of charging
cost?: string;
// The ID of the data provider
dataProviderId?: string;
// The ID of the charger
id?: string;
// The number of charging points
numPoints?: number;
// The operator
operator?: { [key: string]: any };
// The ID of the operator of the charger
operatorId?: string;
// The type of usage
usageType?: UsageType;
// The type of usage for this charger point (is it public, membership required, etc)
usageTypeId?: string;
}
export interface ReferenceDataRequest {}
export interface ReferenceDataResponse {
// The types of charger
chargerTypes?: ChargerType;
// The types of checkin status
checkinStatusTypes?: CheckinStatusType;
// The types of connection
connectionTypes?: ConnectionType;
// The countries
countries?: Country[];
// The types of current
currentTypes?: CurrentType;
// The providers of the charger data
dataProviders?: DataProvider;
// The companies operating the chargers
operators?: Operator[];
// The status of the charger
statusTypes?: StatusType;
// The status of a submission
submissionStatusTypes?: SubmissionStatusType;
// The different types of usage
usageTypes?: UsageType;
// The types of user comment
userCommentTypes?: UserCommentType;
}
export interface SearchRequest {
// Bounding box to search within (top left and bottom right coordinates)
box?: BoundingBox;
// IDs of the connection type
connectionTypes?: string;
// Country ID
countryId?: string;
// Search distance from point in metres, defaults to 5000m
distance?: number;
// Supported charging levels
levels?: string[];
// Coordinates from which to begin search
location?: Coordinates;
// Maximum number of results to return, defaults to 100
maxResults?: number;
// Minimum power in KW. Note: data not available for many chargers
minPower?: number;
// IDs of the the EV charger operator
operators?: string[];
// Usage of the charge point (is it public, membership required, etc)
usageTypes?: string;
}
export interface SearchResponse {
pois?: Poi[];
}
export interface StatusType {
id?: string;
isOperational?: boolean;
title?: string;
}
export interface SubmissionStatusType {
id?: string;
isLive?: boolean;
title?: string;
}
export interface UsageType {
id?: string;
isAccessKeyRequired?: boolean;
isMembershipRequired?: boolean;
isPayAtLocation?: boolean;
title?: string;
}
export interface UserCommentType {
id?: string;
title?: string;
}

View File

@@ -6,6 +6,7 @@ import * as currency from "./currency";
import * as db from "./db";
import * as email from "./email";
import * as emoji from "./emoji";
import * as evchargers from "./evchargers";
import * as file from "./file";
import * as forex from "./forex";
import * as geocoding from "./geocoding";
@@ -45,6 +46,7 @@ export class Client {
this.dbService = new db.DbService(token);
this.emailService = new email.EmailService(token);
this.emojiService = new emoji.EmojiService(token);
this.evchargersService = new evchargers.EvchargersService(token);
this.fileService = new file.FileService(token);
this.forexService = new forex.ForexService(token);
this.geocodingService = new geocoding.GeocodingService(token);
@@ -83,6 +85,7 @@ export class Client {
dbService: db.DbService;
emailService: email.EmailService;
emojiService: emoji.EmojiService;
evchargersService: evchargers.EvchargersService;
fileService: file.FileService;
forexService: forex.ForexService;
geocodingService: geocoding.GeocodingService;

View File

@@ -17,6 +17,7 @@
"./db": "./dist/db/index.js",
"./email": "./dist/email/index.js",
"./emoji": "./dist/emoji/index.js",
"./evchargers": "./dist/evchargers/index.js",
"./file": "./dist/file/index.js",
"./forex": "./dist/forex/index.js",
"./geocoding": "./dist/geocoding/index.js",
@@ -62,5 +63,5 @@
},
"type": "module",
"types": "dist/index.d.ts",
"version": "1.0.531"
"version": "1.0.532"
}