# jetformbuilder/3.6.6/modules/active-campaign/methods/contact-modifier.php

JetFormBuilder — Dynamic Blocks Form Builder, version 3.6.6. 95 lines.

- Page: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/modules/active-campaign/methods/contact-modifier.php
- Raw: https://pluginprobe.com/plugins/jetformbuilder/3.6.6/raw/modules/active-campaign/methods/contact-modifier.php
- Modified: 2023-11-20T11:46:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetformbuilder/3.6.6/code/modules/active-campaign/methods/contact-modifier.php#L10-L20`.

```php
<?php


namespace JFB_Modules\Active_Campaign\Methods;

use Jet_Form_Builder\Actions\Methods\Abstract_Modifier;
use Jet_Form_Builder\Actions\Methods\Object_Properties_Collection;
use Jet_Form_Builder\Classes\Arrayable\Collection;
use Jet_Form_Builder\Exceptions\Action_Exception;

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

class Contact_Modifier extends Abstract_Modifier {

	public $token;
	public $url;

	protected function get_actions(): Collection {
		return new Collection(
			array(
				new Sync_Contact_Action(),
			)
		);
	}

	protected function get_properties(): Object_Properties_Collection {
		return new Object_Properties_Collection(
			array(
				new Email_Contact_Property(),
				new First_Name_Contact_Property(),
				new Last_Name_Contact_Property(),
				new Phone_Contact_Property(),
				new List_Contact_Property(),
				new Tags_Contact_Property(),
				new Custom_Contact_Property(),
			)
		);
	}

	/**
	 * @throws Action_Exception
	 */
	public function run() {
		if ( empty( $this->url ) || empty( $this->token ) ) {
			throw new Action_Exception( 'invalid_api_key' );
		}

		parent::run();
	}

	/**
	 * Convert legacy properties.
	 * Custom properties converting in
	 * \JFB_Modules\Active_Campaign\Methods\Custom_Contact_Property
	 *
	 * @param array $fields_map
	 * @param bool $revert
	 *
	 * @return Abstract_Modifier|Contact_Modifier
	 */
	public function set_fields_map( array $fields_map, bool $revert = false ): Abstract_Modifier {
		parent::set_fields_map( $fields_map, $revert );

		$legacy = array(
			'first_name' => 'firstName',
			'last_name'  => 'lastName',
		);

		foreach ( $this->fields_map as $field_name => $property ) {
			if ( ! isset( $legacy[ $property ] ) ) {
				continue;
			}
			$this->fields_map[ $field_name ] = $legacy[ $property ];
		}

		return $this;
	}


	public function set_api_key( string $token ): self {
		$this->token = $token;

		return $this;
	}

	public function set_api_url( string $url ): self {
		$this->url = $url;

		return $this;
	}
}

```
