# 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 `anonymizeContact`

<!-- example: action anonymizeContact -->

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

namespace App\CapellExamples\Contacts;

function runAnonymizeContact(\Capell\Contacts\Models\Contact $contact, ?\Illuminate\Contracts\Auth\Authenticatable $actor = null): \Capell\Contacts\Models\Contact
{
    return \Capell\Contacts\Actions\AnonymizeContactAction::run($contact, $actor);
}
```

## Action `anonymizeContactWithAudit`

<!-- example: action anonymizeContactWithAudit -->

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

namespace App\CapellExamples\Contacts;

function runAnonymizeContactWithAudit(\Capell\Contacts\Models\Contact $contact, ?string $requestedBy = null, ?\Illuminate\Contracts\Auth\Authenticatable $actor = null): \Capell\Contacts\Models\Contact
{
    return \Capell\Contacts\Actions\AnonymizeContactWithAuditAction::run($contact, $requestedBy, $actor);
}
```

## Action `auditContactPrivacyExport`

<!-- example: action auditContactPrivacyExport -->

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

namespace App\CapellExamples\Contacts;

function runAuditContactPrivacyExport(\Capell\Contacts\Models\Contact $contact, ?string $requestedBy = null, ?\Illuminate\Contracts\Auth\Authenticatable $actor = null): array
{
    return \Capell\Contacts\Actions\AuditContactPrivacyExportAction::run($contact, $requestedBy, $actor);
}
```

## Action `buildContactPrivacyExport`

<!-- example: action buildContactPrivacyExport -->

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

namespace App\CapellExamples\Contacts;

function runBuildContactPrivacyExport(\Capell\Contacts\Models\Contact $contact, ?\Illuminate\Contracts\Auth\Authenticatable $actor = null): array
{
    return \Capell\Contacts\Actions\BuildContactPrivacyExportAction::run($contact, $actor);
}
```

## Action `buildContactsOverviewStats`

<!-- example: action buildContactsOverviewStats -->

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

namespace App\CapellExamples\Contacts;

function runBuildContactsOverviewStats(?int $siteId = null): array
{
    return \Capell\Contacts\Actions\BuildContactsOverviewStatsAction::run($siteId);
}
```

## Action `findOrCreateContact`

<!-- example: action findOrCreateContact -->

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

namespace App\CapellExamples\Contacts;

function runFindOrCreateContact(\Capell\Contacts\Data\ContactIdentityData $identity, ?\Illuminate\Database\Eloquent\Model $source = null): \Capell\Contacts\Models\Contact
{
    return \Capell\Contacts\Actions\FindOrCreateContactAction::run($identity, $source);
}
```

## Action `recordContactActivity`

<!-- example: action recordContactActivity -->

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

namespace App\CapellExamples\Contacts;

function runRecordContactActivity(\Capell\Contacts\Models\Contact $contact, \Capell\Contacts\Data\ContactActivityData $activityData, ?\Illuminate\Database\Eloquent\Model $subject = null, ?\Capell\Contacts\Models\Lead $lead = null, ?\Capell\Contacts\Models\Organisation $organisation = null): \Capell\Contacts\Models\ContactActivity
{
    return \Capell\Contacts\Actions\RecordContactActivityAction::run($contact, $activityData, $subject, $lead, $organisation);
}
```

## Action `syncAccessGateRegistrationContact`

<!-- example: action syncAccessGateRegistrationContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncAccessGateRegistrationContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncAccessGateRegistrationContactAction::run($event);
}
```

## Action `syncCampaignConversionContact`

<!-- example: action syncCampaignConversionContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncCampaignConversionContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncCampaignConversionContactAction::run($event);
}
```

## Action `syncCommentContact`

<!-- example: action syncCommentContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncCommentContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncCommentContactAction::run($event);
}
```

## Action `syncContactSourceRecord`

<!-- example: action syncContactSourceRecord -->

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

namespace App\CapellExamples\Contacts;

function runSyncContactSourceRecord(\Capell\Contacts\Data\ContactSourceRecordData $record, ?\Illuminate\Database\Eloquent\Model $source = null, ?\Capell\Contacts\Models\Organisation $organisation = null): \Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncContactSourceRecordAction::run($record, $source, $organisation);
}
```

## Action `syncEventRegistrationContact`

<!-- example: action syncEventRegistrationContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncEventRegistrationContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncEventRegistrationContactAction::run($event);
}
```

## Action `syncFormSubmissionContact`

<!-- example: action syncFormSubmissionContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncFormSubmissionContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncFormSubmissionContactAction::run($event);
}
```

## Action `syncShopifyCustomerContact`

<!-- example: action syncShopifyCustomerContact -->

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

namespace App\CapellExamples\Contacts;

function runSyncShopifyCustomerContact(object $event): ?\Capell\Contacts\Data\ContactSourceSyncResultData
{
    return \Capell\Contacts\Actions\SyncShopifyCustomerContactAction::run($event);
}
```

## Action `tagContact`

<!-- example: action tagContact -->

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

namespace App\CapellExamples\Contacts;

function runTagContact(\Capell\Contacts\Models\Contact $contact, array|string $tags): \Capell\Contacts\Models\Contact
{
    return \Capell\Contacts\Actions\TagContactAction::run($contact, $tags);
}
```