/**
* BeNomad BeMap JavaScript API - ChargingStationSearchResponse (v1.5)
*
* Strongly-typed response from `POST service/chargingstation/search/1.0`.
* The server payload is `{ pools: [ChargingStationPool] }`.
*
* @public
* @constructor
* @param {Array.<bemap.ChargingStationPool>} pools
*/
bemap.ChargingStationSearchResponse = function(pools) {
/** @type {Array.<bemap.ChargingStationPool>} */
this.pools = Array.isArray(pools) ? pools : [];
};
/**
* @public
* @return {Array.<bemap.ChargingStationPool>}
*/
bemap.ChargingStationSearchResponse.prototype.getPools = function() {
return this.pools;
};
/**
* Parse the raw JSON response from the BeMap server into a strongly-typed
* `ChargingStationSearchResponse`.
*
* @public
* @param {Object} json
* @return {bemap.ChargingStationSearchResponse}
*/
bemap.ChargingStationSearchResponse.fromJson = function(json) {
if (!json || !Array.isArray(json.pools)) {
return new bemap.ChargingStationSearchResponse([]);
}
var pools = json.pools.map(function(p) { return new bemap.ChargingStationPool(p); });
return new bemap.ChargingStationSearchResponse(pools);
};