| @@ 7-42 (lines=36) @@ | ||
| 4 | ||
| 5 | use TestMonitor\ActiveCampaign\Resources\AccountCustomField; |
|
| 6 | ||
| 7 | trait ManagesAccountCustomFields |
|
| 8 | { |
|
| 9 | use ImplementsActions; |
|
| 10 | ||
| 11 | /** |
|
| 12 | * Get all custom fields. |
|
| 13 | * |
|
| 14 | * @return array |
|
| 15 | */ |
|
| 16 | public function customAccountFields() |
|
| 17 | { |
|
| 18 | return $this->transformCollection( |
|
| 19 | $this->get('accountCustomFieldMeta'), |
|
| 20 | AccountCustomField::class, |
|
| 21 | 'accountCustomFieldMeta' |
|
| 22 | ); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Find custom field by name. |
|
| 27 | * |
|
| 28 | * @param string $name |
|
| 29 | * |
|
| 30 | * @return AccountCustomField|null |
|
| 31 | */ |
|
| 32 | public function findCustomAccountField($name) |
|
| 33 | { |
|
| 34 | $customFields = $this->transformCollection( |
|
| 35 | $this->get('accountCustomFieldMeta', ['query' => ['filters[fieldLabel]' => $name]]), |
|
| 36 | AccountCustomField::class, |
|
| 37 | 'accountCustomFieldMeta' |
|
| 38 | ); |
|
| 39 | ||
| 40 | return array_shift($customFields); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||
| @@ 7-42 (lines=36) @@ | ||
| 4 | ||
| 5 | use TestMonitor\ActiveCampaign\Resources\Automation; |
|
| 6 | ||
| 7 | trait ManagesAutomations |
|
| 8 | { |
|
| 9 | use ImplementsActions; |
|
| 10 | ||
| 11 | /** |
|
| 12 | * Get all automations. |
|
| 13 | * |
|
| 14 | * @return array |
|
| 15 | */ |
|
| 16 | public function automations() |
|
| 17 | { |
|
| 18 | return $this->transformCollection( |
|
| 19 | $this->get('automations'), |
|
| 20 | Automation::class, |
|
| 21 | 'automations' |
|
| 22 | ); |
|
| 23 | } |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Find automation by name. |
|
| 27 | * |
|
| 28 | * @param string $name |
|
| 29 | * |
|
| 30 | * @return Automation|null |
|
| 31 | */ |
|
| 32 | public function findAutomation($name) |
|
| 33 | { |
|
| 34 | $automations = $this->transformCollection( |
|
| 35 | $this->get('automations', ['query' => ['search' => $name]]), |
|
| 36 | Automation::class, |
|
| 37 | 'automations' |
|
| 38 | ); |
|
| 39 | ||
| 40 | return array_shift($automations); |
|
| 41 | } |
|
| 42 | } |
|
| 43 | ||