adachsoft / model-pricing-automation-action
Automation action for synchronizing model pricing sources.
Package info
gitlab.com/a.adach/model-pricing-automation-action
pkg:composer/adachsoft/model-pricing-automation-action
Requires
- php: ^8.3
- adachsoft/action-contracts: ^0.1.2
- adachsoft/model-pricing-contracts: ^0.4
- adachsoft/model-pricing-lib: ^0.1.0
Requires (Dev)
- adachsoft/php-code-style: ^0.8.0
- adachsoft/reference-contracts: ^0.1
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13
- rector/rector: ^2.9
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
An automation action for synchronizing model pricing sources.
Capabilities
- Synchronizes model prices from one or all registered providers.
- Supports selective synchronization via a
providerparameter. - Preserves partial results when individual sources fail during synchronization.
Installation
Install the package via Composer:
composer require adachsoft/model-pricing-automation-action
The package provides the ModelPricingSyncActionTypeProvider and ModelPricingSyncActionHandler. Register both with your action container to enable automatic discovery of the model_pricing.sync action type.
Integration
The action relies on:
AdachSoft\ActionContracts\Type\ActionTypeProviderInterface— registers the action schema with supported parameters.AdachSoft\ActionContracts\Execution\ActionHandlerInterface— executes the synchronization workflow.AdachSoft\ModelPricingContracts\Sync\PriceSourceInterface— represents a price source provider.AdachSoft\ModelPricingLib\Sync\PriceSyncService— performs the actual sync logic.
After installation, wire the action handler with your PriceSyncService implementation and pass an iterable of PriceSourceInterface instances tagged with your DI container's service identifiers.
The action automatically exposes an optional provider enum parameter listing all registered provider IDs. Omitting the parameter triggers synchronization across every registered source.
Requirements
- PHP ^8.3
adachsoft/action-contracts^0.1.2adachsoft/model-pricing-contracts^0.4adachsoft/model-pricing-lib^0.1.0
Usage
Configure your dependency injection container to resolve the price sources (implementing AdachSoft\ModelPricingContracts\Sync\PriceSourceInterface). The package provides two services:
ModelPricingSyncActionTypeProvider: Registers themodel_pricing.syncaction definition. Inject a tagged iterable of price sources into its constructor.ModelPricingSyncActionHandler: Handles the execution. RequiresAdachSoft\ModelPricingLib\Sync\PriceSyncServiceand the same iterable of price sources.
Wire both instances into your action engine's registry. The system will automatically expose the action. Use the optional provider parameter to trigger a sync for a single provider; omitting it triggers a global synchronization.
Example Integration
use AdachSoft\ModelPricingAutomationAction\ActionType\ModelPricingSyncActionTypeProvider;
use AdachSoft\ModelPricingAutomationAction\Handler\ModelPricingSyncActionHandler;
use AdachSoft\ModelPricingContracts\Sync\PriceSourceInterface;
use AdachSoft\ModelPricingLib\Sync\PriceSyncService;
// ... retrieve $priceSyncService and list of PriceSourceInterface instances ...
$handler = new ModelPricingSyncActionHandler($priceSyncService, $priceSources);
$typeProvider = new ModelPricingSyncActionTypeProvider($priceSources);
$registry->addHandler($handler);
$registry->addTypeProvider($typeProvider);