Skip to content

Commit

Permalink
OcpiLocation object - 2.1.1 properties (validation missing) (#11)
Browse files Browse the repository at this point in the history
* Location object - add 2.1.1 property - LocationType

* OCPI 2.1.1 properties on OcpiCOnnector object

---------

Co-authored-by: Lior Ben Ari <[email protected]>
  • Loading branch information
LiorBenAri and Lior Ben Ari authored Sep 19, 2023
1 parent 4992c13 commit d6e3920
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/OCPI.Net.Contracts/Location/OcpiConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,27 @@ public class OcpiConnector
[JsonPropertyName("power_type")]
public PowerType? PowerType { get; set; }

//OCPI 2.1.1 property
[JsonPropertyName("voltage")]
public int? Voltage { get; set; }

[JsonPropertyName("max_voltage")]
public int? MaxVoltage { get; set; }

//OCPI 2.1.1 property
[JsonPropertyName("amperage")]
public int? Amperage { get; set; }

[JsonPropertyName("max_amperage")]
public int? MaxAmperage { get; set; }

[JsonPropertyName("max_electric_power")]
public int? MaxElectricPower { get; set; }

//OCPI 2.1.1 property
[JsonPropertyName("tariff_id")]
public string? TariffId { get; set; }

[JsonPropertyName("tariff_ids")]
public IEnumerable<string>? TariffIds { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions src/OCPI.Net.Contracts/Location/OcpiLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public class OcpiLocation
[JsonPropertyName("related_locations")]
public IEnumerable<OcpiAdditionalGeolocation>? RelatedLocations { get; set; }

//OCPI 2.1.1 property
[JsonPropertyName("type")]
public LocationType? Type { get; set; }

[JsonPropertyName("parking_type")]
public ParkingType? ParkingType { get; set; }

Expand Down
49 changes: 49 additions & 0 deletions src/OCPI.Net.Core/Enums/Location/LocationType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System.Runtime.Serialization;

namespace OCPI;

public enum LocationType : byte
{
/// <summary>
/// Parking in public space.
/// </summary>
[EnumMember(Value = "UNKNOWN")]
Unknown = 0,

//======================================

/// <summary>
/// Parking in public space.
/// </summary>
[EnumMember(Value = "ON_STREET")]
OnStreet = 11,

//======================================

/// <summary>
/// Multistorey car park
/// </summary>
[EnumMember(Value = "PARKING_GARAGE")]
ParkingGarage = 21,

/// <summary>
/// A cleared area that is intended for parking vehicles,
/// i.e. at super markets, bars, etc.
/// </summary>
[EnumMember(Value = "PARKING_LOT")]
ParkingLot = 22,

/// <summary>
/// Multistorey car park, mainly underground.
/// </summary>
[EnumMember(Value = "UNDERGROUND_GARAGE")]
UndergroundGarage = 23,

//======================================

/// <summary>
/// Parking in public space.
/// </summary>
[EnumMember(Value = "OTHER")]
Other = 255,
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public OcpiLocationValidator(ActionType actionType) : base(actionType)
RuleForEach(x => x.RelatedLocations)
.SetValidator(new OcpiAdditionalGeolocationValidator(actionType));

JsonRuleFor(x => x.Type)
.ValidEnum();

JsonRuleFor(x => x.ParkingType)
.ValidEnum();

Expand Down

0 comments on commit d6e3920

Please sign in to comment.