Skip to content

Client library for Open Charge-Point Protocol eMSP Server from extrawest.com

License

Notifications You must be signed in to change notification settings

extrawest/Extrawest-OCPI-2.2.1-EMSP-Client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Extrawest-OCPI-2.2.1-EMSP-Client

Badges

build release Java CI with Maven contr commits lastcommit OCPI JDK social

Table of Contents

Field of use

Client library for OCPI eMSP Server. Library for OCPI CPO can be found in other repo. Open Charge Point Interface (OCPI) is an open protocol used for connections between charging station operators and service providers. Simply put, this protocol facilitates automated roaming for EV drivers between different EV charging networks.

Automatically generated by the OpenAPI Generator as a client library for OCPI Server Library

Description

With this library, you can easily get started with the Open Charge-Point Interface by making calls to OCPI EMSP Server API. It is a client to OCPI eMSP Server, created using OpenAPI Generator

Please note, this is a library and not an application, so there is no main method.

Currently we support 2.2.1 OCPI version.

Maven

Find the maven repo here: https://mvnrepository.com/artifact/com.extrawest/Extrawest-OCPI-2.2.1-EMSP-Client

Requirements

Building the API client library requires:

  1. Java 1.8+
  2. Maven

Installation

To install the API client library to your local Maven repository, simply execute:

mvn clean install

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>com.extrawest</groupId>
    <artifactId>Extrawest-OCPI-2.2.1-EMSP-Client</artifactId>
</dependency>

Others

At first generate the JAR by executing:

mvn clean package

Then manually install the following JARs:

  • target/extrawest-ocpi-2.2.1-emsp-client-0.0.1.jar
  • target/lib/*.jar

Getting Started

Please follow the installation instruction and execute the following Java code:

public class ClientInfoApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("http://localhost:8080");

        ClientInfoApi apiInstance = new ClientInfoApi(defaultClient);
        String countryCode = "countryCode_example";
        String partyId = "partyId_example";
        try {
            ClientInfoDto result = apiInstance.getHubClientInfo(countryCode, partyId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling ClientInfoApi#getHubClientInfo");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Reason: " + e.getResponseBody());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Using Extrawest-OCPI-2.2.1-EMSP-Client in Spring Boot Application

  1. To access the EMSP API classes, we need to configure them as beans:
@Configuration
public class EmspClientConfig {

    @Bean
    public EmspTariffControllerApi emspTariffApi() {
        return new EmspTariffControllerApi(apiClient());
    }

    @Bean
    public ApiClient apiClient() {
        return new ApiClient();
    }
}
  1. Since we configured our API classes as beans, we can freely inject them in our Spring-managed classes:
@Service
public class EmspTariffServiceImpl implements  EmspTariffService {
    @Autowired
    private EmspTariffControllerApi emspTariffControllerApi;

    @Override
    public TariffDto getTariff() {
        try {
            return emspTariffControllerApi.getTariff("countryCode", "partyId", "tariffId");
        } catch (RestClientException e) {
            throw new RuntimeException();
        }
    }
}

Spring Boot application, where we have tested Extrawest-OCPI-2.2.1-EMSP-Client, has below Spring dependencies. In case of library and your project dependencies versions incompatibility, try to add next spring versions into you projects:

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>5.3.24</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.24</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>5.3.24</version>
        </dependency>

API Endpoints

All URIs are relative to http://localhost:8080

Class Method HTTP request
ClientInfoApi getHubClientInfo GET /api/2.2.1/hubClientInfo/{country_code}/{party_id}
ClientInfoApi putHubClientInfo PUT /api/2.2.1/hubClientInfo/{country_code}/{party_id}
EmspCdrApi getCdr GET /emsp/api/2.2.1/cdr
EmspCdrApi postCdr POST /emsp/api/2.2.1/cdr
EmspChargingProfilesApi postChargingProfile POST /emsp/api/2.2.1/chargingProfiles
EmspChargingProfilesApi putChargingProfile PUT /emsp/api/2.2.1/chargingProfiles/{session_id}
EmspCommandsApi postCommand POST /emsp/api/2.2.1/commands/{command}/{uid}
EmspCredentialsApi deleteCredentials DELETE /emsp/api/2.2.1/credentials
EmspCredentialsApi getCredentials GET /emsp/api/2.2.1/credentials
EmspCredentialsApi postCredentials POST /emsp/api/2.2.1/credentials
EmspCredentialsApi putCredentials PUT /emsp/api/2.2.1/credentials
EmspLocationApi getConnector GET /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}/{connector_id}
EmspLocationApi getEvse GET /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}
EmspLocationApi getLocation GET /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}
EmspLocationApi patchConnector PATCH /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}/{connector_id}
EmspLocationApi patchEvse PATCH /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}
EmspLocationApi patchLocation PATCH /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}
EmspLocationApi pushConnector PUT /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}/{connector_id}
EmspLocationApi pushEvse PUT /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}/{evse_uid}
EmspLocationApi pushLocation PUT /emsp/api/2.2.1/locations/{country_code}/{party_id}/{location_id}
EmspSessionsApi getSession GET /emsp/api/2.2.1/sessions
EmspSessionsApi patchSession PATCH /emsp/api/2.2.1/sessions
EmspSessionsApi putSession PUT /emsp/api/2.2.1/sessions
EmspTariffApi deleteTariff DELETE /emsp/api/2.2.1/tariffs
EmspTariffApi getTariff GET /emsp/api/2.2.1/tariffs
EmspTariffApi saveTariff PUT /emsp/api/2.2.1/tariffs
EmspTokenApi getTokens GET /emsp/api/2.2.1/tokens
EmspTokenApi postToken POST /emsp/api/2.2.1/tokens/{token_uid}/authorize
EmspVersionApi getVersionDetails GET /emsp/api/versions/details
EmspVersionApi getVersions GET /emsp/api/versions

Models

Authentication and Authorization

All endpoints do not require authorization or authentication.

Recommendation

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

License

MIT License

About Extrawest.com

We are devoted to push the marked for vehicles charging forward. There are many standards out there, we intend to implement and share them. Any help is much appreciated!

The market is in its defining state, the practices and standards we come up with now, may very well stick around for decades to come.

See our vision at https://www.extrawest.com/