Snippets

OICP 2.1 Pull EVSE Status by ID | Java

You are viewing an old version of this snippet. View the current version.
Revised by Gregor Schermuly 99443ba
/**
 * Create a new OICP v2.0 PullEVSEStatusById request.
 *
 * @param ProviderId the unique identification of the EV service provider for this request.
 * @param EVSEIds an array of EVSE Ids to query their status.
 * @return a new PullEVSEStatusById request builder object.
 */
public PullEVSEStatusByIdRequest PullEVSEStatusById(final EVSP_Id     ProviderId,
                                                    final EVSE_Id...  EVSEIds)
{ ... }

/**
 * Create a new OICP v2.0 PullEVSEStatusById request.
 *
 * @param ProviderId the unique identification of the EV service provider for this request.
 * @param EVSEIds a stream of EVSE Ids to query their status.
 * @return a new PullEVSEStatusById request builder object.
 */
public PullEVSEStatusByIdRequest PullEVSEStatusById(final EVSP_Id          ProviderId,
                                                    final Stream<EVSE_Id>  EVSEIds)
{ ... }
CompletableFuture req = new EMPClient("api.playground.hubject.com").

    PullEVSEStatusById(EVSP_Id.Parse("DE*GDF"),
                       Stream.of(EVSE_Id.Parse("DE*GEF*E123456789*1"),
                                 EVSE_Id.Parse("+49*822*083431571*1"))).

    Run(EVSEStatus -> {

        if (EVSEStatus.getStatusCode().hasResult())
            System.out.println(
                    EVSEStatus.getEVSEStatusRecords().
                               map(evsedatarecords -> "EVSE '" + evsedatarecords.getId() +
                                                      "' has status '" +
                                                      evsedatarecords.getStatus().toString() +
                                                      "'" ).

                               reduce((a, b) -> a + System.lineSeparator() + b).
                               get());

        else {
            System.out.println(EVSEStatus.getStatusCode().getCode());
            System.out.println(EVSEStatus.getStatusCode().getDescription());
            System.out.println(EVSEStatus.getStatusCode().getAdditionalInfo());
        }

    });

// Wait for the future to complete...
req.get();
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.