-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
517 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-element'), 'version' => 'fbe230065258aef97727'); | ||
<?php return array( | ||
'dependencies' => array( 'react', 'wp-components', 'wp-element' ), | ||
'version' => 'fbe230065258aef97727', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-element'), 'version' => '9365906682f82f0695ac'); | ||
<?php return array( | ||
'dependencies' => array( 'react', 'wp-components', 'wp-element' ), | ||
'version' => '9365906682f82f0695ac', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
<?php return array('dependencies' => array('react', 'wp-components', 'wp-element'), 'version' => '259b909fd9e4ab80b67c'); | ||
<?php return array( | ||
'dependencies' => array( 'react', 'wp-components', 'wp-element' ), | ||
'version' => '259b909fd9e4ab80b67c', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
<?php return array('dependencies' => array('react', 'wp-element'), 'version' => 'a0217d8e38bd6f0b7cfa'); | ||
<?php return array( | ||
'dependencies' => array( 'react', 'wp-element' ), | ||
'version' => 'a0217d8e38bd6f0b7cfa', | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
/** | ||
* Omnisend Client | ||
* | ||
* @package OmnisendClient | ||
*/ | ||
|
||
namespace Omnisend\Internal\V1; | ||
|
||
use Omnisend\SDK\V1\Contact; | ||
|
||
class ContactFactory { | ||
|
||
/** | ||
* Create a Contact object from an array of contact data. | ||
* | ||
* @param array $contact_data | ||
* @return Contact | ||
*/ | ||
public static function create_contact( array $contact_data ): Contact { | ||
$contact = new Contact(); | ||
|
||
if ( isset( $contact_data['contactID'] ) ) { | ||
$contact->set_id( $contact_data['contactID'] ); | ||
} | ||
|
||
if ( isset( $contact_data['firstName'] ) ) { | ||
$contact->set_first_name( $contact_data['firstName'] ); | ||
} | ||
|
||
if ( isset( $contact_data['email'] ) ) { | ||
$contact->set_email( $contact_data['email'] ); | ||
$contact->set_email_opt_in( $contact_data['email'] ); | ||
} | ||
|
||
if ( isset( $contact_data['lastName'] ) ) { | ||
$contact->set_last_name( $contact_data['lastName'] ); | ||
} | ||
|
||
if ( isset( $contact_data['country'] ) ) { | ||
$contact->set_country( $contact_data['country'] ); | ||
} | ||
|
||
if ( isset( $contact_data['address'] ) ) { | ||
$contact->set_address( $contact_data['address'] ); | ||
} | ||
|
||
if ( isset( $contact_data['city'] ) ) { | ||
$contact->set_city( $contact_data['city'] ); | ||
} | ||
|
||
if ( isset( $contact_data['state'] ) ) { | ||
$contact->set_state( $contact_data['state'] ); | ||
} | ||
|
||
if ( isset( $contact_data['postalCode'] ) ) { | ||
$contact->set_postal_code( $contact_data['postalCode'] ); | ||
} | ||
|
||
if ( isset( $contact_data['phone'] ) ) { | ||
$contact->set_phone( $contact_data['phone'][0] ); | ||
$contact->set_phone_opt_in( $contact_data['phone'][0] ); | ||
} | ||
|
||
if ( isset( $contact_data['birthdate'] ) ) { | ||
$contact->set_birthday( $contact_data['birthdate'] ); | ||
} | ||
|
||
if ( isset( $contact_data['gender'] ) ) { | ||
$contact->set_gender( $contact_data['gender'] ); | ||
} | ||
|
||
if ( isset( $contact_data['tags'] ) ) { | ||
foreach ( $contact_data['tags'] as $tag ) { | ||
$contact->add_tag( $tag ); | ||
} | ||
} | ||
|
||
if ( isset( $contact_data['customProperties'] ) ) { | ||
foreach ( $contact_data['customProperties'] as $key => $value ) { | ||
$contact->add_custom_property( $key, $value, false ); | ||
} | ||
} | ||
|
||
if ( isset( $contact_data['identifiers'] ) ) { | ||
foreach ( $contact_data['identifiers'] as $single_consent ) { | ||
if ( isset( $single_consent['channels']['sms']['status'] ) ) { | ||
$contact->set_phone_status( $single_consent['channels']['sms']['status'] ); | ||
} | ||
|
||
if ( isset( $single_consent['channels']['email']['status'] ) ) { | ||
$contact->set_email_status( $single_consent['channels']['email']['status'] ); | ||
} | ||
} | ||
} | ||
|
||
return $contact; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.