# Extension and action examples

<!-- Maintained by scripts/generate-package-readmes.php -->

Use the action functions with records and Data objects supplied by your application.
They pass each argument to the package operation and return its result.

These adapters show container registration. Use the owning package registry when
a contract requires contributor discovery.

Contract adapters wrap an existing implementation. Call their registration function
from your service provider with that implementation; tagged contracts keep their declared tag.
Resolve the backend by its concrete class before registration so the replacement contract
does not resolve itself. Static contract metadata uses one backend class per adapter.

## Action `ingestShopifyWebhook`

<!-- example: action ingestShopifyWebhook -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runIngestShopifyWebhook(\Capell\ShopifyCommerce\Models\ShopifyConnection $connection, string $topic, array $payload): void
{
    \Capell\ShopifyCommerce\Actions\Webhooks\IngestShopifyWebhookAction::run($connection, $topic, $payload);
}
```

## Action `install`

<!-- example: action install -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runInstall(\Capell\Core\Data\PackageData $package, array $arguments = [], ?\Capell\Core\Contracts\ProgressReporter $reporter = null): void
{
    \Capell\ShopifyCommerce\Actions\InstallShopifyCommercePackageAction::run($package, $arguments, $reporter);
}
```

## Action `persistShopifyProduct`

<!-- example: action persistShopifyProduct -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runPersistShopifyProduct(\Capell\ShopifyCommerce\Models\ShopifyConnection $connection, \Capell\ShopifyCommerce\Data\ShopifyProductData $product, \Carbon\CarbonInterface $syncedAt): \Capell\ShopifyCommerce\Models\ShopifyProduct
{
    return \Capell\ShopifyCommerce\Actions\Catalog\PersistShopifyProductAction::run($connection, $product, $syncedAt);
}
```

## Action `pruneExpiredShopifyOAuthStates`

<!-- example: action pruneExpiredShopifyOAuthStates -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runPruneExpiredShopifyOAuthStates(): int
{
    return \Capell\ShopifyCommerce\Actions\OAuth\PruneExpiredShopifyOAuthStatesAction::run();
}
```

## Action `syncShopifyCustomers`

<!-- example: action syncShopifyCustomers -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runSyncShopifyCustomers(\Capell\ShopifyCommerce\Models\ShopifyConnection|int $connection): int
{
    return \Capell\ShopifyCommerce\Actions\Customers\SyncShopifyCustomersAction::run($connection);
}
```

## Action `upsertShopifyCustomer`

<!-- example: action upsertShopifyCustomer -->

```php
<?php
declare(strict_types=1);

namespace App\CapellExamples\ShopifyCommerce;

function runUpsertShopifyCustomer(\Capell\ShopifyCommerce\Models\ShopifyConnection $connection, array $snapshot): \Capell\ShopifyCommerce\Models\ShopifyCustomer
{
    return \Capell\ShopifyCommerce\Actions\Customers\UpsertShopifyCustomerAction::run($connection, $snapshot);
}
```