Skip to content

Commit

Permalink
Lower headers
Browse files Browse the repository at this point in the history
  • Loading branch information
YuriyDurov committed Oct 13, 2023
1 parent a939205 commit 6aceb8e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
14 changes: 7 additions & 7 deletions docs/1.introduction.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Introduction
## Introduction

Welcome to the documentation for the OCPI.Net package! This documentation is organized into several [sections](README.md), each covering a different aspect of the package. In this section, we'll provide an overview of the package and its benefits, as well as a guide to getting started with OCPI.Net.

Expand All @@ -8,25 +8,25 @@ You can refer to the [Architecture](2.architecture.md) section for an overview o

We hope you find this documentation helpful, and we welcome your feedback and contributions to the project!

## Overview of the OCPI.Net package
### 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 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.


## Benefits of using OCPI.Net
### Benefits of using OCPI.Net

- ### Seamless OCPI Protocol Implementation
- **Seamless OCPI Protocol Implementation**
The package provides a comprehensive collection of contract models and validation tools that allow you to implement the OCPI protocol with ease. The package contains all necessary functionality to easily implement OCPI using Asp.Net Core.

- ### Easy to Use
- **Easy to Use**
The package is designed to be easy to use, with a simple and intuitive API that allows you to quickly get up and running with OCPI. The package also contains a collection of examples that demonstrate how to use the package in different scenarios.

- ### Unrestricted Domain Flexibility
- **Unrestricted Domain Flexibility**
The package allows you to integrate your specific requirements without limitations. This adaptable approach ensures your implementation perfectly aligns with your business needs and unique use cases, while still maintaining compliance with the OCPI protocol.

## Getting started with OCPI.Net
### Getting started with OCPI.Net

1. To get started with OCPI.Net, you'll need to install the package using NuGet. You can do this by running the following command:

Expand Down
6 changes: 3 additions & 3 deletions docs/2.architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ Previous topic:

---

# Architecture
## Architecture

The OCPI.Net package is designed to be as flexible as possible, allowing you to implement OCPI modules in any way you see fit. The package uses Asp.Net Core Controllers for handling incoming OCPI requests and returning OCPI responses. The package also contains a number of services which are used to perform various tasks such as validating incoming requests, generating responses, and handling errors.

The package follows a modular design, allowing you to use only the functionality you need. The package also allows you to implement multiple versions of the same module, allowing you to support multiple OCPI versions at the same time.

## How the package works under the hood
### How the package works under the hood

The package uses the default Asp.Net Core dependency injection container to inject services into your controllers. The package also uses the default Asp.Net Core routing system to route incoming requests to the appropriate controllers.

The package uses the `OcpiEndpoint` attribute to determine which controllers are used to handle incoming OCPI requests. The package will perform an automated scan of your controllers and generate a list of supported OCPI versions for each module. See more in [Implementation](3.implementation.md).

The package uses Exceptions as a way to handle errors. The exceptions can be thrown from anywhere in your code, and the package will automatically handle them and generate the appropriate OCPI response. Exception handling is done by the `OcpiExceptionFilter` attribute, which is automatically applied to all controllers that inherit from the `OcpiController` base class. Exceptions can be populated with a custom data payload, which will be included in the OCPI response. See more in [Error Handling](5.error-handling.md).

## Integration with Asp.Net Core
### Integration with Asp.Net Core

The OCPI.Net package is designed to be used with Asp.Net Core. The package contains a `OcpiController` base class which you can use to implement your own OCPI controllers. This class contains a number of methods which you can use to handle incoming OCPI requests and generate OCPI responses.

Expand Down
6 changes: 3 additions & 3 deletions docs/3.implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Previous topic:

---

# Implementation
## Implementation

You can always refer to the [Sample application](/sample/OCPI.Net.Sample) for a working example of how to use the package.

## How to implement OCPI modules using OCPI.Net
### How to implement OCPI modules using OCPI.Net

Apply `OcpiEndpoint` attribute to your module controllers to specify their OCPI versions. The package will perform an automated scan of your controllers and generate a list of supported OCPI versions for each module.

Expand Down Expand Up @@ -42,7 +42,7 @@ public IActionResult Get()

Use `OcpiOk` with a `PageResult<T>` to generate an OCPI-compliant paginated response. See more: [Pagination](6.pagination.md)

## Customizing the package to meet specific business needs
### Customizing the package to meet specific business needs

The package is designed to be as flexible as possible, allowing you to implement OCPI modules in any way you see fit. The package contains a number of services which are used to perform various tasks such as validating incoming requests, generating responses, and handling errors.

Expand Down
4 changes: 2 additions & 2 deletions docs/4.contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ Previous topic:

---

# OCPI Contracts
## 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
### 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.

Expand Down
10 changes: 5 additions & 5 deletions docs/5.error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ Previous topic:

---

# Error Handling
## Error Handling

The package uses Exceptions as a way to handle errors. The exceptions can be thrown from anywhere in your code, and the package will automatically handle them and generate the appropriate OCPI response. Exception handling is done by the `OcpiExceptionFilter` attribute, which is automatically applied to all controllers that inherit from the `OcpiController` base class. Exceptions can be populated with a custom data payload, which will be included in the OCPI response.

You can use the `OcpiControllerBase` class if you want to avoid the default exception handling. The only difference between the `OcpiController` and `OcpiControllerBase` classes is that the `OcpiController` class has the `OcpiExceptionFilter` attribute applied to it.

## Overview of the package's error handling capabilities
### Overview of the package's error handling capabilities

When an exception gets thrown within a method that was called by an OCPI controller, this exception will bubble up to the controller and get handled by the `OcpiExceptionFilter` attribute. The attribute will then generate an appropriate OCPI response based on the exception type and the exception data payload. Further request handling will be aborted, and the response will be returned to the client.

The package contains a number of predefined exceptions which you can use to handle common error scenarios. You can also create your own custom exceptions if you need to handle more specific error scenarios.

These exception functionality is based on the [BitzArt.ApiExceptions](https://github.com/BitzArt/ApiExceptions) nuget package. Refer to that package's documentation for more information on how to interact with the exception payloads.

## Predefined OCPI exceptions and how to use them
### Predefined OCPI exceptions and how to use them

The package contains a number of predefined exceptions which you can use to handle common error scenarios. You can create these exceptions using the `OcpiException` static class:

Expand All @@ -32,7 +32,7 @@ throw OcpiException.ClientApiError("Custom error message", innerException);
// will return a ClientApiError OCPI status code, a custom message, and an inner exception.
```

## Returning a custom OCPI status code
### Returning a custom OCPI status code

Return a custom OCPI status code by calling the `Custom` method from the `OcpiException` static class:

Expand All @@ -41,7 +41,7 @@ int customStatusCode = 1;
throw OcpiException.Custom("custom error message", customStatusCode);
```

## Creating custom OCPI exceptions
### Creating custom OCPI exceptions

You can create your own custom exceptions by inheriting from the `OcpiExceptionBase` class:

Expand Down
4 changes: 2 additions & 2 deletions docs/6.pagination.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Previous topic:

---

# Pagination
## Pagination

The OCPI.Net package uses some classes from the [BitzArt.Pagination](https://github.com/BitzArt/Pagination) nuget package to handle paginated endpoints. Refer to it for guidance on how to use the pagination functionality.

There is an [example](/sample/OCPI.Net.Sample/Controllers/OcpiLocationsSenderController.cs) controller with a paginated OCPI method in this reposiory. Refer to it if you are having trouble implementing OCPI paginated requests.

Make sure you call the `SetMaxLimit(pageRequest, maxLimit);` method in your paginated request implementations. This will ensure that the client cannot request more than the maximum allowed number of items per page. This is required by OCPI in order to set the `X-Limit` response header.

## Example implementation
### Example implementation

```csharp
[OcpiEndpoint(OcpiModule.Locations, "Sender", "2.2.1")]
Expand Down
10 changes: 5 additions & 5 deletions docs/7.versioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Previous topic:

---

# Versioning
## Versioning

The OCPI.Net package supports multiple OCPI versions at the same time. The package uses the `OcpiEndpoint` attribute to determine which OCPI versions are supported by a given controller.

Refer to the [Implementation](3.implementation.md) section for more information on how to implement OCPI modules using OCPI.Net.

## How to implement OCPI Versions Module
### How to implement OCPI Versions Module

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.

Expand All @@ -33,7 +33,7 @@ Use the `GetVersionDetails` method to get a list of all supported OCPI endpoints
var details = versionService.GetVersionDetails(request);
```

## Example Versions Module implementation
### Example Versions Module implementation

```csharp
[Route("versions")]
Expand Down Expand Up @@ -64,7 +64,7 @@ public class OcpiVersionsController : OcpiController
}
```

## How to support multiple OCPI versions at the same time
### How to support multiple OCPI versions at the same time

The package allows you to support multiple OCPI versions at the same time. You can do this by marking your controllers with the `OcpiEndpoint` attribute and specifying the OCPI versions supported by each controller.

Expand All @@ -78,7 +78,7 @@ public class OcpiCredentialsController : OcpiController
}
```

## How to handle version-specific differences in OCPI modules
### How to handle version-specific differences in OCPI modules

You can implement version-specific controllers for different versions of the same OCPI Module.

Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## Table of contents

1. [Introduction](1.introduction.md)
- [Overview of the OCPI.Net package](1.introduction.md#overview-of-the-ocpinet-package)
- [Benefits of using OCPI.Net](1.introduction.md#benefits-of-using-ocpinet)
Expand Down

0 comments on commit 6aceb8e

Please sign in to comment.