pricing - swagger updated + userID optional
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
+ "/api/pricing-definitions": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Get Pricing Definitions",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/EntityID"
+ },
+ {
+ "$ref": "#/components/parameters/EntityType"
+ },
+ {
+ "$ref": "#/components/parameters/Search"
+ },
+ {
+ "$ref": "#/components/parameters/Skip"
+ },
+ {
+ "$ref": "#/components/parameters/Limit"
+ },
+ {
+ "$ref": "#/components/parameters/SortFields"
+ }
+ ],
+ "tags": [
+ "Pricing"
+ ],
+ "responses": {
+ "200": {
+ "description": "Return the pricing definitions",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "count": {
+ "type": "number",
+ "example": 1
+ },
+ "result": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/PricingDefinition"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ }
+ }
+ }
+ },
+ "/api/pricing-definitions/{id}": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Get Pricing Definition by id",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/pricingDefinitionID"
+ }
+ ],
+ "tags": [
+ "Pricing"
+ ],
+ "responses": {
+ "200": {
+ "description": "Returns a pricing definition",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/PricingDefinition"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
+ "/api/pricing-model/resolve": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Resolves the pricing context and returns tariffs",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/ChargingStationID"
+ },
+ {
+ "$ref": "#/components/parameters/ConnectorID"
+ },
+ {
+ "$ref": "#/components/parameters/UserID"
+ },
+ {
+ "$ref": "#/components/parameters/StartDateTime"
+ }
+ ],
+ "tags": [
+ "Pricing"
+ ],
+ "responses": {
+ "200": {
+ "description": "Returns the tariffs matching the pricing context",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "count": {
+ "type": "number",
+ "example": 1
+ },
+ "result": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/PricingDefinition"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
"/api/users/{id}/payment-methods": {
"get": {
"security": [
}
}
},
+ "PricingDefinition": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "type": "string",
+ "readOnly": true
+ },
+ "entityID": {
+ "type": "string"
+ },
+ "entityType": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "description": {
+ "type": "string"
+ },
+ "staticRestrictions": {
+ "$ref": "#/components/schemas/PricingStaticRestrictions"
+ },
+ "restrictions": {
+ "$ref": "#/components/schemas/PricingRestrictions"
+ },
+ "dimensions": {
+ "$ref": "#/components/schemas/PricingDimensions"
+ }
+ }
+ },
+ "PricingDimensions": {
+ "type": "object",
+ "properties": {
+ "flatFee": {
+ "$ref": "#/components/schemas/PricingDimension"
+ },
+ "energy": {
+ "$ref": "#/components/schemas/PricingDimension"
+ },
+ "chargingTime": {
+ "$ref": "#/components/schemas/PricingDimension"
+ },
+ "parkingTime": {
+ "$ref": "#/components/schemas/PricingDimension"
+ }
+ }
+ },
+ "PricingDimension": {
+ "type": "object",
+ "properties": {
+ "active": {
+ "type": "boolean"
+ },
+ "price": {
+ "type": "number"
+ },
+ "stepSize": {
+ "type": "number"
+ }
+ }
+ },
+ "PricingStaticRestrictions": {
+ "type": "object"
+ },
+ "PricingRestrictions": {
+ "type": "object"
+ },
"BillingPaymentMethod": {
"type": "object",
"properties": {
"schema": {
"type": "string"
}
+ },
+ "pricingDefinitionID": {
+ "in": "path",
+ "name": "id",
+ "description": "PricingDefintionID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ },
+ "EntityID": {
+ "in": "query",
+ "name": "Entity ID",
+ "description": "Entity ID",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "EntityType": {
+ "in": "query",
+ "name": "Entity Type",
+ "description": "Entity Type",
+ "schema": {
+ "type": "string"
+ }
+ },
+ "WithEntityInformation": {
+ "in": "query",
+ "name": "WithEntityInformation",
+ "description": "With details about the entity",
+ "schema": {
+ "type": "boolean"
+ }
}
}
}

MODIFY
src/assets/server/rest/v1/schemas/pricing/pricing-model-resolve.json
src/assets/server/rest/v1/schemas/pricing/pricing-model-resolve.json
"UserID": {
"$ref": "common#/definitions/id"
},
- "DateTime": {
+ "StartDateTime": {
"type": "string",
"format": "date-time",
"customType": "date",

MODIFY
src/integration/pricing/PricingHelper.ts
src/integration/pricing/PricingHelper.ts
@@ -46,15 +46,16 @@ export default class PricingHelper {
}
public static checkContextConsistency(pricingContext: PricingContext): boolean {
- if (pricingContext.userID
- && pricingContext.companyID
+ if (pricingContext.companyID
&& pricingContext.siteID
&& pricingContext.siteAreaID
&& pricingContext.chargingStationID
&& !Utils.isNullOrUndefined(pricingContext.connectorId)
&& pricingContext.connectorType
&& !Utils.isNullOrUndefined(pricingContext.connectorPower)
- && pricingContext.timestamp && pricingContext.timezone) {
+ && pricingContext.timestamp && pricingContext.timezone
+ // && pricingContext.userID - not yet used - should we have user groups instead
+ ) {
return true;
}
return false;

MODIFY
src/server/rest/v1/service/PricingService.ts
src/server/rest/v1/service/PricingService.ts
@@ -41,7 +41,7 @@ export default class PricingService {
// Resolve the pricing context
pricingContext = PricingHelper.buildUserPricingContext(req.tenant, filteredRequest.UserID, chargingStation, filteredRequest.ConnectorID, filteredRequest.StartDateTime);
const pricingModel: ResolvedPricingModel = await pricingImpl.resolvePricingContext(pricingContext);
- pricingDefinitions = pricingModel.pricingDefinitions;
+ pricingDefinitions = pricingModel?.pricingDefinitions;
}
}
res.json({

pricing - swagger updated + userID optional