Skip to content

Commit

Permalink
alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
greta-mik committed Jul 2, 2024
1 parent cbe0832 commit 8280f96
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,47 @@ This is done by getting an actual client
Here is how you can create a basic client & submit contact.

```php
$contact = new Contact();

$contact->set_email( $email );
if ( $phone_number != '' ) {
$contact->set_phone( $phone_number );
}
$contact->set_first_name( $first_name );
$contact->set_last_name( $last_name );
$contact->set_birthday( $birthday );
$contact->set_postal_code( $postal_code );
$contact->set_address( $address );
$contact->set_state( $state );
$contact->set_country( $country );
$contact->set_city( $city );
if ( $email_consent ) {
$contact->set_email_consent( 'actual_email_consent_for_gdrp' );
$contact->set_email_opt_in( 'where user opted to become subscriber' );
}

$client = \Omnisend\SDK\V1\Omnisend::get_client( 'integration name', 'integration version' );

$response = $client->create_contact( $contact );
$contact = new Contact();

$contact->set_email( $email );
if ( $phone_number != '' ) {
$contact->set_phone( $phone_number );
}
$contact->set_first_name( $first_name );
$contact->set_last_name( $last_name );
$contact->set_birthday( $birthday );
$contact->set_postal_code( $postal_code );
$contact->set_address( $address );
$contact->set_state( $state );
$contact->set_country( $country );
$contact->set_city( $city );
if ( $email_consent ) {
$contact->set_email_consent( 'actual_email_consent_for_gdrp' );
$contact->set_email_opt_in( 'where user opted to become subscriber' );
}
$client = \Omnisend\SDK\V1\Omnisend::get_client( 'integration name', 'integration version' );

$response = $client->create_contact( $contact );
```

#### Customer events

Here is how you can send customer events.

```php
$contact = new EventContact();
$contact->set_email( $email );
$contact = new EventContact();
$contact->set_email( $email );

$event = new Event();
$event->set_contact($contact);
$event->set_origin('wordpress');
$event->set_event_name('something hapened');
$event->add_properties('importantProperty1', $importantProperty1);
$event->add_properties('importantProperty2', $importantProperty2);
$event = new Event();
$event->set_contact($contact);
$event->set_origin('wordpress');
$event->set_event_name('something hapened');
$event->add_properties('importantProperty1', $importantProperty1);
$event->add_properties('importantProperty2', $importantProperty2);

$client = \Omnisend\SDK\V1\Omnisend::get_client( 'integration name', 'integration version' );
$client = \Omnisend\SDK\V1\Omnisend::get_client( 'integration name', 'integration version' );

$response = $client->send_customer_event($event);
$response = $client->send_customer_event($event);
```

#### Error handling
Expand Down

0 comments on commit 8280f96

Please sign in to comment.