UI protocol: Allow to send some relevant commands to several charging… (#152)
[e-mobility-charging-stations-simulator.git] / src / types / UIProtocol.ts
CommitLineData
89b7a234 1import { JsonObject } from './JsonType';
d1888640 2
4198ad5c
JB
3export enum Protocol {
4 UI = 'ui',
5}
8244f5f0 6
675fa8e3
JB
7export enum ApplicationProtocol {
8 HTTP = 'http',
9 WS = 'ws',
10}
11
8244f5f0
JB
12export enum ProtocolVersion {
13 '0.0.1' = '0.0.1',
8244f5f0
JB
14}
15
89b7a234
JB
16export type ProtocolRequest = [string, ProcedureName, RequestPayload];
17export type ProtocolResponse = [string, ResponsePayload];
18
19export type ProtocolRequestHandler = (
4e3ff94d
JB
20 uuid?: string,
21 payload?: RequestPayload
6c8f5d90 22) => undefined | Promise<undefined> | ResponsePayload | Promise<ResponsePayload>;
89b7a234 23
32de5a57 24export enum ProcedureName {
ee0f106b 25 LIST_CHARGING_STATIONS = 'listChargingStations',
89b7a234
JB
26 START_CHARGING_STATION = 'startChargingStation',
27 STOP_CHARGING_STATION = 'stopChargingStation',
8244f5f0
JB
28 START_TRANSACTION = 'startTransaction',
29 STOP_TRANSACTION = 'stopTransaction',
32de5a57
LM
30 START_SIMULATOR = 'startSimulator',
31 STOP_SIMULATOR = 'stopSimulator',
db2336d9
JB
32 OPEN_CONNECTION = 'openConnection',
33 CLOSE_CONNECTION = 'closeConnection',
8244f5f0 34}
5612b691 35
89b7a234
JB
36export interface RequestPayload extends JsonObject {
37 hashId?: string;
4eca248c 38 hashIds?: string[];
89b7a234 39}
8244f5f0 40
32de5a57
LM
41export enum ResponseStatus {
42 SUCCESS = 'success',
43 FAILURE = 'failure',
44}
45
46export interface ResponsePayload extends JsonObject {
47 status: ResponseStatus;
48}