/**
* BeNomad BeMap JavaScript API - ChargingTimeResponse (v1.5)
*
* Strongly-typed response from `POST service/chargingTime/1.0`. The server
* payload is `{chargingTime, optimumBatteryChargeLevel}` — exactly two
* fields. `chargingTime === -1` is the documented error sentinel (zero
* battery capacity, zero connector power, or zero max charge power on
* the vehicle).
*
* Mirrors `bemap_idea/.../service/v1_0_0/model/chargingTime/ChargingTimeResponse.java`.
*
* @public
* @constructor
* @param {Object} options
* @param {Number} options.chargingTime Seconds, or -1 on server-side error.
* @param {Number} options.optimumBatteryChargeLevel Percent — the "knee" of the curve.
*/
bemap.ChargingTimeResponse = function(options) {
var opts = options || {};
this.chargingTime = (typeof opts.chargingTime === 'number') ? opts.chargingTime : null;
this.optimumBatteryChargeLevel = (typeof opts.optimumBatteryChargeLevel === 'number') ? opts.optimumBatteryChargeLevel : null;
};
/**
* Estimated charging time in seconds. Returns `-1` when the server
* could not compute (zero battery capacity, zero connector power, etc.).
* Use `isError()` to test for this case ergonomically.
* @public
* @return {Number}
*/
bemap.ChargingTimeResponse.prototype.getChargingTime = function() {
return this.chargingTime;
};
/**
* Battery level (%) above which the charging power starts to taper — the
* "knee" of the charging curve. Customers plotting a curve typically
* draw a steep line from `remainingBatteryLevel` to this value, then a
* flatter line from here to `chargingBatteryLevel`.
* @public
* @return {Number}
*/
bemap.ChargingTimeResponse.prototype.getOptimumBatteryChargeLevel = function() {
return this.optimumBatteryChargeLevel;
};
/**
* `true` when the server returned the documented -1 error sentinel.
* @public
* @return {Boolean}
*/
bemap.ChargingTimeResponse.prototype.isError = function() {
return this.chargingTime === -1;
};
bemap.ChargingTimeResponse.fromJson = function(json) {
return new bemap.ChargingTimeResponse(json || {});
};