Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriyDurov committed Sep 30, 2023
1 parent b267a37 commit c3ae32f
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/1.introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We hope you find this documentation helpful, and we welcome your feedback and co

## Overview of the OCPI.Net package

The OCPI.Net package is a .NET implementation for the the Open Charge Point Interface (OCPI) protocol, which is used for communication between electric vehicle charging stations and charging station operators.
The OCPI.Net package is a .NET implementation for the the Open Charge Point Interface (OCPI) protocol, which is used for communication between Charge Point Operators and e-Mobility Service Providers.

Make sure to check out this [Sample application](/sample/OCPI.Net.Sample) for a working example of how to use the package.

Expand Down
2 changes: 1 addition & 1 deletion docs/3.implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Refer to the [Architecture](2.architecture.md) section for more information on t
---

Next topic:
[Versioning](4.versioning.md)
[OCPI Contracts](4.contracts.md)
47 changes: 47 additions & 0 deletions docs/4.contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Back to the [Table of Contents](README.md)

Previous topic:
[Implementation](3.implementation.md)

---

# OCPI Contracts

The package contains a number of classes which are used to represent OCPI objects. You can see the full list of contract models [here](https://github.com/BitzArt/OCPI.Net/tree/main/src/OCPI.Net.Contracts).


## Validation

The package contains a collection of validators which you can use to validate incoming OCPI requests. To use a validator, call the `OcpiValidate` method of the `OcpiController` class. The method only allows validating OCPI models from the `OCPI.Contracts` namespace. In case of invalid request, further request handling will be aborted, and the error response will be returned to the client.

```csharp
[OcpiEndpoint(OcpiModule.Locations, "Receiver", "2.2.1")]
[Route("2.2.1/locations")]
[OcpiAuthorize]
public class OcpiLocationsReceiverController : OcpiController
{
[HttpPut("{countryCode}/{partyId}/{locationId}")]
public IActionResult Put(
[FromRoute] string countryCode,
[FromRoute] string partyId,
[FromRoute] string locationId,
[FromBody] OcpiLocation location)
{
// Use a built-in OCPI validator
OcpiValidate(location);

// Your Location PUT logic
Return OcpiOk(result);
}

// Other endpoint methods...
}
```

Validation functionality is built on top of [FluentValidation](https://github.com/FluentValidation/FluentValidation) nuget package.

---

Next topic:
[Error handling](5.error-handling.md)
2 changes: 1 addition & 1 deletion docs/5.error-handling.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Back to the [Table of Contents](README.md)

Previous topic:
[Versioning](4.versioning.md)
[OCPI Contracts](4.contracts.md)

---

Expand Down
7 changes: 6 additions & 1 deletion docs/6.pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ public class OcpiLocationsSenderController : OcpiController
LastUpdated = DateTime.UtcNow
};
}
```
```

---

Next topic:
[Versioning](7.versioning.md)
11 changes: 2 additions & 9 deletions docs/4.versioning.md → docs/7.versioning.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Back to the [Table of Contents](README.md)

Previous topic:
[Implementation](3.implementation.md)
[Pagination](6.pagination.md)

---

Expand All @@ -15,7 +15,7 @@ Refer to the [Implementation](3.implementation.md) section for more information

After you have marked your OCPI controllers with the `OcpiEndpoint` attribute, the package becomes aware of the OCPI versions supported by each controller. The package will automatically generate a list of supported OCPI versions for each module.

An [example](/sample/OCPI.Net.Sample/Controllers/OcpiVersionsController.cs) of how to implement the OCPI Versions module is provided in the [Sample application](sample/OCPI.Net.Sample).
An [example](/sample/OCPI.Net.Sample/Controllers/OcpiVersionsController.cs) of how to implement the OCPI Versions module is provided in the [Sample application](/sample/OCPI.Net.Sample).

In your Versions Module controller, inject the `IOcpiVersionsService` service and use it to retrieve the list of supported OCPI versions for each module:

Expand Down Expand Up @@ -81,10 +81,3 @@ public class OcpiCredentialsV2Controller : OcpiController
// ...
}
```



---

Next topic:
[Error Handling](5.error-handling.md)
12 changes: 7 additions & 5 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@
3. [Implementation](3.implementation.md)
- [How to implement OCPI modules using OCPI.Net](3.implementation.md#how-to-implement-ocpi-modules-using-ocpinet)
- [Customizing the package to meet specific business needs](3.implementation.md#customizing-the-package-to-meet-specific-business-needs)
4. [Versioning](4.versioning.md)
- [How to implement OCPI Versions Module](4.versioning.md#how-to-implement-ocpi-versions-module)
- [How to support multiple OCPI versions at the same time](4.versioning.md#how-to-support-multiple-ocpi-versions-at-the-same-time)
- [How to handle version-specific differences in OCPI modules](4.versioning.md#how-to-handle-version-specific-differences-in-ocpi-modules)
4. [Contracts](4.contracts.md)
- [Validation](4.contracts.md#validation)
5. [Error Handling](5.error-handling.md)
- [Overview of the package's error handling capabilities](5.error-handling.md#overview-of-the-packages-error-handling-capabilities)
- [Predefined OCPI exceptions and how to use them](5.error-handling.md#predefined-ocpi-exceptions-and-how-to-use-them)
- [Returning a custom OCPI status code](5.error-handling.md#returning-a-custom-ocpi-status-code)
- [Creating custom OCPI exceptions](5.error-handling.md#creating-custom-ocpi-exceptions)
6. [Pagination](6.pagination.md)
- [Example implementation](6.pagination.md#example-implementation)
- [Example implementation](6.pagination.md#example-implementation)
7. [Versioning](7.versioning.md)
- [How to implement OCPI Versions Module](7.versioning.md#how-to-implement-ocpi-versions-module)
- [How to support multiple OCPI versions at the same time](7.versioning.md#how-to-support-multiple-ocpi-versions-at-the-same-time)
- [How to handle version-specific differences in OCPI modules](7.versioning.md#how-to-handle-version-specific-differences-in-ocpi-modules)

0 comments on commit c3ae32f

Please sign in to comment.