خودکارسازیها
`automations->list`، `get`، `create`، `update`، `publish`، `pause`، `resume`، `archive`، `duplicate`، `delete`، `sendTest`، `stats`، `listVersions`، `restoreVersion`، `listStarters`، `listEnrollments`، `getEnrollment`، `enroll` و `exitEnrollment`، همراه با `events->send`، `sendBatch` و `listNames`.
همهٔ متدها
use OpenEmail\Constants\AutomationEnrollmentStatuses;use OpenEmail\Constants\AutomationTriggerKinds; $automation = $client->automations->create([ 'name' => 'Welcome series', 'starter' => 'welcome-series', 'settings' => ['timezone' => 'Europe/London'],]); $definition = $automation['definition'];$definition['trigger'] = ['kind' => AutomationTriggerKinds::EVENT, 'eventName' => 'trial.started', 'filters' => []]; $saved = $client->automations->update($automation['id'], [ 'definition' => $definition, 'expectedUpdatedAt' => $automation['updatedAt'],]); foreach ($saved['problems'] as $problem) { if ($problem['blocking']) { throw new \RuntimeException($problem['message']); }} $client->automations->sendTest($saved['id'], ['stepKey' => $saved['definition']['entry'] ?? '']);$live = $client->automations->publish($saved['id']); $sent = $client->events->send([ 'name' => 'trial.started', 'email' => '[email protected]', 'properties' => ['plan' => 'starter'], 'createContact' => true,], idempotencyKey: 'trial:[email protected]'); foreach ($client->automations->iterateEnrollments($live['id'], status: AutomationEnrollmentStatuses::ACTIVE) as $enrollment) { if ($enrollment['heldFor'] !== null) { echo $enrollment['contact']['email'], ' ', $enrollment['heldFor'], PHP_EOL; }} $stats = $client->automations->stats($live['id']);$history = $client->contacts->listEvents('[email protected]', name: 'trial.started'); $client->automations->pause($live['id']);$client->automations->resume($live['id']); echo count($sent['enrolled']), ' ', $stats['totals']['entered'], ' ', count($history->items), PHP_EOL;هر خودکارسازی یک definition پیشنویس و نسخهٔ published را که اجرا میشود نگه میدارد. update پیشنویس و تنظیمات را تغییر میدهد، و publish پیشنویس را بهعنوان نسخهٔ بعدی ثابت میکند و خودکارسازی را روشن میکند. problems میگوید چه چیزی هنوز جلوی انتشار پیشنویس را میگیرد، و expectedUpdatedAt ذخیرهای را که روی ذخیرهٔ کس دیگری بنویسد با 409 version_conflict رد میکند.
خواندن به automations:read و تغییر دادن به automations:write نیاز دارد. publish، resume و sendTest به emails:send هم نیاز دارند. events->send و events->sendBatch به contacts:write نیاز دارند، و contacts->listEvents به contacts:read. delete از توکن دسترسی OAuth کد تأیید هویت میخواهد، و از کلید API هرگز.
events->sendBatch تا 100 رویداد میپذیرد و هرگز برای یک رویداد نادرست خطا نمیاندازد: پاسخ accepted و failed را فهرست میکند، هر کدام با index رویداد در آرایهای که فرستادید.
attributes در یک مخاطب فیلدهای سفارشی آن را نگه میدارد، و خودکارسازی هر کدام را بهصورت attributes.<key> میخواند.