From c88a7fd124ba8ab16c4e3ae15420d3a39e940392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnas=20Gec=CC=8Cas?= Date: Mon, 29 Jan 2024 14:39:23 +0200 Subject: [PATCH] Fix comments & readme --- README.md | 30 ++++++++++++++++--- omnisend/includes/Public/Client/V1/a.php | 25 ++++++++++++++++ .../Public/Client/V1/class-client.php | 4 --- .../includes/Public/Client/V1/class-utils.php | 8 ++--- 4 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 omnisend/includes/Public/Client/V1/a.php diff --git a/README.md b/README.md index ff3f74d..b113517 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,33 @@ # Omnisend Core Plugin -[Omnisend](https://wordpress.org/plugins/omnisend/) is WordPress plugin that enables to use different [Omnisend marketing automation tool](https://www.omnisend.com/) features +[Omnisend](https://wordpress.org/plugins/omnisend/) is WordPress plugin that enables to use [Omnisend marketing automation tool](https://www.omnisend.com/) features for WordPress website. ## Plugin features -* Website connection to Omnisend (this enables to use different Omnisend [features](https://www.omnisend.com/features/)) +* Website connection to Omnisend [features](https://www.omnisend.com/features/)) +* SDK Client to connect other plugins to Omnisend. + + +## SDK Client + +The plugin provides an SDK client to easily integrate with Omnisend API. + +> [!IMPORTANT] +> To use this SDK the user must install [wp-omnisend plugin](https://wordpress.org/plugins/wp-omnisend) and connect it to the omnisend. + +You can find function references in the [client folder](https://github.com/omnisend/wp-omnisend/tree/main/omnisend/includes/Public/Client/V1). + +### Examples + +To create a contact: + +```php +TBD check if plugin is activated +TBD create client +TBD create contact +TBD send contact +``` ## PHP Linting @@ -18,7 +40,7 @@ After each push to any branch `PHP Standards` action will run and all the PHP co Tools needed: -- php (7.4 version is recommended because at the time of writing WordPress coding standards supports only up to 7.4 version); +- php (7.4 version is recommended because at the time of writing WordPress coding standards support only up to 7.4 version); - composer (can be installed as described in https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos); After installing those tools one can run in local plugin dir (plugin_woocommerce_api) helper script: @@ -35,7 +57,7 @@ composer update composer install ``` -install linting tool and standards. And then actual linting `phpcs` script can be initiated with +install linting tool and standards. Then actual linting `phpcs` script can be initiated with ```shell ./vendor/squizlabs/php_codesniffer/bin/phpcs --ignore=.js --standard=WordPress omnisend-connect diff --git a/omnisend/includes/Public/Client/V1/a.php b/omnisend/includes/Public/Client/V1/a.php new file mode 100644 index 0000000..c568c07 --- /dev/null +++ b/omnisend/includes/Public/Client/V1/a.php @@ -0,0 +1,25 @@ +setEmail('john.doe@example.com'); +$contact->setFirstName('John'); +$contact->setLastName('Doe'); + +// Send the contact to Omnisend +$apiClient = new Omnisend\ApiClient('YOUR_API_KEY'); +$response = $apiClient->createContact($contact); + +// Check the response +if ($response->isSuccess()) { + echo 'Contact created and sent to Omnisend successfully.'; +} else { + echo 'Failed to create and send contact to Omnisend. Error: ' . $response->getErrorMessage(); +} diff --git a/omnisend/includes/Public/Client/V1/class-client.php b/omnisend/includes/Public/Client/V1/class-client.php index fbde6ba..5c2a604 100644 --- a/omnisend/includes/Public/Client/V1/class-client.php +++ b/omnisend/includes/Public/Client/V1/class-client.php @@ -20,8 +20,6 @@ class Client { /** - * Check if plugin is connected to Omnisend account. - * * Check and return if plugin connected to Omnisend account. If connection does not exist, it will not be possible * to send data to Omnisend. * @@ -32,8 +30,6 @@ public static function is_connected(): bool { } /** - * Create contact in Omnisend - * * Create a contact in Omnisend. For it to succeed ensure that provided contact at least have email or phone number. * * @param Contact $contact diff --git a/omnisend/includes/Public/Client/V1/class-utils.php b/omnisend/includes/Public/Client/V1/class-utils.php index 5d00f31..744c14f 100644 --- a/omnisend/includes/Public/Client/V1/class-utils.php +++ b/omnisend/includes/Public/Client/V1/class-utils.php @@ -23,9 +23,9 @@ public static function is_valid_custom_property_name( $name ): bool { } /** - * Validate custom property tag. + * Validate tag. * - * @param $tags + * @param $tag * * @return bool */ @@ -34,9 +34,9 @@ public static function is_valid_tag( $tag ): bool { } /** - * Clean up custom property name. + * Clean up tag name. * - * @param $tags + * @param $tag * * @return string */