uxf / energo-kalkulator-sdk
Requires
- php: ^8.3
- psr/cache: ^2.0 || ^3.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- symfony/service-contracts: ^3.6
- uxf/core: ^3.78
- uxf/graphql: ^3.78
- uxf/storage: ^3.31.1
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main
- 1.42.0
- 1.41.0
- 1.40.2
- 1.40.1
- 1.40.0
- 1.39.1
- 1.39.0
- 1.38.0
- 1.37.0
- 1.36.0
- 1.35.1
- 1.35.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.23.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
This package is auto-updated.
Last update: 2026-11-11 13:46:53 UTC
README
Install
$ composer req uxf/energo-kalkulator-sdk
// bundles.php
return [
UXFCoreBundle::class => ['all' => true];
UXFHydratorBundle::class => ['all' => true];
EnergokalkulatorBundle::class => ['all' => true];
];
Config
// packages/energo_kalkulator.php
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('energo_kalkulator', [
'base_url' => 'https://xxx.com', // optional
'api_key' => env('API_KEY'),
]);
};
Usage
use EnergoKalkulator\EnergoKalkulatorService;
class MagicService
{
public function __construct(private readonly EnergoKalkulatorService $service)
{
}
public function run()
{
$data = $service->getGasEstimateWithPrepaid(
currentPartner: 1,
currentProduct: 1,
distributor: 85,
prepaid: 3333,
);
}
}
Errors
EnergokalkulatorException for every response other than 200. A 404 throws its subclass
EnergokalkulatorNotFoundException (the record does not exist), so an existing catch (EnergokalkulatorException)
keeps working.
GraphQL (uxf/graphql)
src/GraphQL has queries over the public catalog of Energokalkulátor: codebooks, partners, products, previews of the
active products and FAQ. All query names start with energoKalkulator, all types with EnergoKalkulator
(CooperationMethodEnum keeps its name). The types are the response objects of the SDK; only the fields without
#[Ignore] go to the schema, the rest are internal data of Energokalkulátor. A new public property of a response
object needs #[Ignore] unless it is meant to be public.
Nothing changes until the application turns it on:
// packages/uxf.php
$containerConfigurator->extension('uxf_graphql', [
'sources' => [
__DIR__ . '/../../src',
__DIR__ . '/../../vendor/uxf/energo-kalkulator-sdk/src/GraphQL',
],
'modifiers' => [
EnergoKalkulator\GraphQL\EnergoKalkulatorSchemaModifier::class, // FileResponse as EnergoKalkulatorFile
],
]);
// packages/energo_kalkulator.php
$containerConfigurator->extension('energo_kalkulator', [
'api_key' => env('API_KEY'),
'graphql' => [ // optional
'http_client' => 'app.http_client.energo_kalkulator_graphql', // PSR-18 client of the queries only, e.g. a 5 s limit
'cache_pool' => 'cache.user', // results are cached for 180 s, shared between requests
],
]);
- Without the
graphqlconfig the queries use the defaultEnergoKalkulatorServiceand nothing is cached. With any of its keys they get an instance of their own, reset after every request (its memory cache must not outlive a request in a worker), ongraphql.http_clientor on the default PSR-18 client. Withoutgraphql.cache_poolnothing is cached. The default service used by the rest of the application never changes. - Cache keys contain the installed SDK version, objects cached by another version are never read after a deploy.
- Validity of a cached result follows
UXF\Core\SystemProvider\Clock; 404 and errors are not cached. - A 404 of Energokalkulátor is the GraphQL error
NOT_FOUND, any other failure (status, timeout, network)ENERGO_KALKULATOR_UNAVAILABLE. A query never returns an empty list instead of an error. EnergoKalkulatorSchemaModifierimplementsgetPriority()andgetDefaultPriority()(uxf/graphql< 3.80).