2017 © Pedro Peláez
 

library esios

Access library to Esios API

image

paulogic/esios

Access library to Esios API

  • Friday, February 23, 2018
  • by paulogic
  • Repository
  • 1 Watchers
  • 1 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Esios Access Library

This library offers some utilities to access the information from the Esios platform (Sistema de información del operador del sistema)., (*1)

  • Version 1.0

Set up

  • Installation, (*2)

    composer require paulogic/esios
  • Dependencies, (*3)

    • php >=5.6 with curl

How to use

Using an EsiosHelperFactory

The simplest way to make a call and receive a formatted response (php array of dates-values) is by means of the included Helper Factory class:, (*4)

#!php

    $token = 'AUTHENTICATION TOKEN';

    //Prepare the factory
    $factory = new Esios\EsiosHelperFactory($token);

    //Create a helper to issue calls to obtain the list of prices
    $helper = $factory->getEsiosCaller(Esios\EsiosCallTypes::PVPC_20A_PRICES);
    $params = [
         'start_date' => '2017-04-01T01:00',
         'end_date' => '2017-04-01T05:00'
    ];
    $data = $helper->get($params);

    //Create a helper to issue calls to obtain the list of indicators
    $helper = $factory->getEsiosCaller(Esios\EsiosCallTypes::INDICATORS_LIST);
    $params = [
        'text' => 'facturacion de energia'
    ];
    $data = $helper->get($params);

The list of possible call types is defined inside the abstract class EsiosCallTypes:, (*5)

  • PVPC_20A_PRICES
  • PVPC_20DHA_PRICES
  • PVPC_20DHS_PRICES
  • PVPC_20A_PROFILES
  • PVPC_20DHA_PROFILES
  • PVPC_20DHS_PROFILES
  • PVPC_20A_PEAJESACCESO
  • PVPC_20DHA_PEAJESACCESO
  • PVPC_20DHS_PEAJESACCESO
  • INDICATORS_LIST

New call types can be added to EsiosCallTypes along with the corresponding url paths., (*6)

Direct call to the Esios REST API

You can issue a direct call to the REST API with the utility class EsiosCallService:, (*7)

#!php

    $token = 'AUTHENTICATION TOKEN';
    //optional config, may be empty
    $config = [
        'timeout' => 10,
        'timezone' => 'Atlantic/Canary'    
    ];
    $callService = new Esios\Service\EsiosCallService($token, $config);

    $params = [
        'start_date' => '2017-04-23',
        'end_date' => '2017-04-24',
    ];

    //Direct call to indicator 1013 (prices of rate 20A)
    $data = $callService->getData('/indicators/1013', $params);

Examples

You may find a list of functional examples on how to use the classes separately:, (*8)

  • Creating the accessor to the API and return raw data
  • Creating a formatter to format the raw data
  • Using a custom logger

Check the examples file:, (*9)

    examples/examples.php

Running tests

    vendor/bin/phpunit

Check API response tests

There is a group of tests that check the response format of the actual Esios API calls. They require online connection and a valid authentication token. To activate these tests:, (*10)

  • Modify phpunit.xml :
    • Remove the exclude group 'onlinecheck'
    • Replace TOKEN with the authentication token issued by Esios

The Versions

23/02 2018

dev-master

9999999-dev

Access library to Esios API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Pablo Lorenzo

php esios e.sios

23/02 2018

v1.0.0

1.0.0.0

Access library to Esios API

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Pablo Lorenzo

php esios e.sios