UNPKG

ev-recharge-sdk

Version:

This API Product provides the option to manage charging at all public Shell Recharge locations. The end points provides control to start, stop and get status of the charging session.

160 lines 10.8 kB
"use strict"; /** * Shell EVLib * * This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ). */ exports.__esModule = true; exports.ChargingController = void 0; var tslib_1 = require("tslib"); var activeResponse200Json_1 = require("../models/activeResponse200Json"); var chargesessionStartBody_1 = require("../models/chargesessionStartBody"); var getChargeSessionRetrieveResponse200Json_1 = require("../models/getChargeSessionRetrieveResponse200Json"); var inlineResponse202_1 = require("../models/inlineResponse202"); var inlineResponse2021_1 = require("../models/inlineResponse2021"); var schema_1 = require("../schema"); var baseController_1 = require("./baseController"); var badRequestError_1 = require("../errors/badRequestError"); var internalServerError_1 = require("../errors/internalServerError"); var notFoundError_1 = require("../errors/notFoundError"); var serviceunavailableError_1 = require("../errors/serviceunavailableError"); var tooManyRequestsError_1 = require("../errors/tooManyRequestsError"); var unauthorizedError_1 = require("../errors/unauthorizedError"); var ChargingController = /** @class */ (function (_super) { tslib_1.__extends(ChargingController, _super); function ChargingController() { return _super !== null && _super.apply(this, arguments) || this; } /** * This endpoint start the charging session for the user. * * @param requestId RequestId must be unique identifier value that can be used * by the consumer to correlate each request /response . * <br>Format.<br> Its canonical textual representation, the 16 * octets of a UUID are represented as 32 hexadecimal (base-16) * digits, displayed in five groups separated by hyphens, in the * form 8-4-4-4-12 for a total of 36 characters (32 hexadecimal * characters and 4 hyphens) <br> * @param body * @return Response from the API call */ ChargingController.prototype.start = function (requestId, body, requestOptions) { return tslib_1.__awaiter(this, void 0, void 0, function () { var req, mapped; return tslib_1.__generator(this, function (_a) { req = this.createRequest('POST', '/charge-session/start'); mapped = req.prepareArgs({ requestId: [requestId, (0, schema_1.string)()], body: [body, (0, schema_1.optional)(chargesessionStartBody_1.chargesessionStartBodySchema)] }); req.header('RequestId', mapped.requestId); req.header('Content-Type', 'application/json'); req.json(mapped.body); req.throwOn(400, badRequestError_1.BadRequestError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).'); req.throwOn(401, unauthorizedError_1.UnauthorizedError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(404, notFoundError_1.NotFoundError, 'Location Not Found'); req.throwOn(429, tooManyRequestsError_1.TooManyRequestsError, 'The Request reached maximum allocated rate limit'); req.throwOn(500, internalServerError_1.InternalServerError, 'Internal Server error'); req.throwOn(503, serviceunavailableError_1.ServiceunavailableError, 'Service unavailable'); req.authenticate([{ bearerAuth: true }]); return [2 /*return*/, req.callAsJson(inlineResponse202_1.inlineResponse202Schema, requestOptions)]; }); }); }; /** * Accepts a request to stop an active session when a valid session id is provided. * * @param requestId RequestId must be unique identifier value that can be used by the consumer to * correlate each request /response .<br>Format.<br> Its canonical textual representation, * the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed * in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 * characters (32 hexadecimal characters and 4 hyphens) <br> * @param sessionId Session Id * @return Response from the API call */ ChargingController.prototype.stop = function (requestId, sessionId, requestOptions) { return tslib_1.__awaiter(this, void 0, void 0, function () { var req, mapped; return tslib_1.__generator(this, function (_a) { req = this.createRequest('POST', '/charge-session/stop'); mapped = req.prepareArgs({ requestId: [requestId, (0, schema_1.string)()], sessionId: [sessionId, (0, schema_1.string)()] }); req.header('RequestId', mapped.requestId); req.query('sessionId', mapped.sessionId); req.throwOn(400, badRequestError_1.BadRequestError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).'); req.throwOn(401, unauthorizedError_1.UnauthorizedError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(404, notFoundError_1.NotFoundError, 'Location Not Found'); req.throwOn(429, tooManyRequestsError_1.TooManyRequestsError, 'The Request reached maximum allocated rate limit'); req.throwOn(500, internalServerError_1.InternalServerError, 'Internal Server error'); req.throwOn(503, serviceunavailableError_1.ServiceunavailableError, 'Service unavailable'); req.authenticate([{ bearerAuth: true }]); return [2 /*return*/, req.callAsJson(inlineResponse2021_1.inlineResponse2021Schema, requestOptions)]; }); }); }; /** * This endpoint returns the details of the session if the session is found. * * @param requestId RequestId must be unique identifier value that can be used by the consumer to * correlate each request /response .<br>Format.<br> Its canonical textual representation, * the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed * in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 * characters (32 hexadecimal characters and 4 hyphens) <br> * @param sessionId Session Id * @return Response from the API call */ ChargingController.prototype.getChargeSessionRetrieve = function (requestId, sessionId, requestOptions) { return tslib_1.__awaiter(this, void 0, void 0, function () { var req, mapped; return tslib_1.__generator(this, function (_a) { req = this.createRequest('GET', '/charge-session/retrieve'); mapped = req.prepareArgs({ requestId: [requestId, (0, schema_1.string)()], sessionId: [sessionId, (0, schema_1.string)()] }); req.header('RequestId', mapped.requestId); req.query('sessionId', mapped.sessionId); req.throwOn(400, badRequestError_1.BadRequestError, 'The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).'); req.throwOn(401, unauthorizedError_1.UnauthorizedError, 'The request has not been applied because it lacks valid authentication credentials for the target resource.'); req.throwOn(404, notFoundError_1.NotFoundError, 'Location Not Found'); req.throwOn(429, tooManyRequestsError_1.TooManyRequestsError, 'The Request reached maximum allocated rate limit'); req.throwOn(500, internalServerError_1.InternalServerError, 'Internal Server error'); req.throwOn(503, serviceunavailableError_1.ServiceunavailableError, 'Service unavailable'); req.authenticate([{ bearerAuth: true }]); return [2 /*return*/, req.callAsJson(getChargeSessionRetrieveResponse200Json_1.getChargeSessionRetrieveResponse200JsonSchema, requestOptions)]; }); }); }; /** * Fetrches the active sessions for user. * * @param requestId RequestId must be unique identifier value that can be used by the consumer to * correlate each request /response .<br>Format.<br> Its canonical textual representation, * the 16 octets of a UUID are represented as 32 hexadecimal (base-16) digits, displayed * in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 * characters (32 hexadecimal characters and 4 hyphens) <br> * @param emaId Emobility Account Identifier(Ema-ID) * @return Response from the API call */ ChargingController.prototype.active = function (requestId, emaId, requestOptions) { return tslib_1.__awaiter(this, void 0, void 0, function () { var req, mapped; return tslib_1.__generator(this, function (_a) { req = this.createRequest('GET', '/charge-session/active'); mapped = req.prepareArgs({ requestId: [requestId, (0, schema_1.string)()], emaId: [emaId, (0, schema_1.string)()] }); req.header('RequestId', mapped.requestId); req.query('emaId', mapped.emaId); req.authenticate([{ bearerAuth: true }]); return [2 /*return*/, req.callAsJson(activeResponse200Json_1.activeResponse200JsonSchema, requestOptions)]; }); }); }; return ChargingController; }(baseController_1.BaseController)); exports.ChargingController = ChargingController; //# sourceMappingURL=chargingController.js.map