Cyclr_Webhook - Version 1.0.3

Version Notes

Initial release for Cyclr extension

Download this release

Release Info

Developer Magento Core Team
Extension Cyclr_Webhook
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/community/Cyclr/Webhook/Helper/Data.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
- class Cyclr_Webhook_Helper_Data extends Mage_Core_Helper_Abstract
3
- {
4
  }
1
+ <?php
2
+ class Cyclr_Webhook_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
  }
app/code/community/Cyclr/Webhook/Model/Observer.php CHANGED
@@ -1,72 +1,72 @@
1
- <?php
2
- class Cyclr_Webhook_Model_Observer
3
- {
4
- public function handleCustomerRegister(Varien_Event_Observer $observer)
5
- {
6
- $customer = $observer->getEvent()->getCustomer();
7
- $email = $customer->getEmail();
8
- $url = Mage::getStoreConfig('webhook/newcustomer/url', $customer->getSendemailStoreId());
9
-
10
- // set the customer to be a new object
11
- $customer->isObjectNew(true);
12
-
13
- //$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
14
- //if ($subscriber->getId()) {
15
- //$json = Mage::helper('core')->jsonEncode($customer->getData());
16
- $json = Mage::helper('core')->jsonEncode(array(
17
- 'entity_id' => $customer->getData('entity_id'),
18
- 'email' => $customer->getData('email'),
19
- 'firstname' => $customer->getData('firstname'),
20
- 'lastname' => $customer->getData('lastname'),
21
- 'is_subscribed' => $customer->getData('is_subscribed'),
22
- 'created_at' => $customer->getData('created_at'),
23
- 'updated_at' => $customer->getData('updated_at')
24
- ));
25
-
26
- $client = new Varien_Http_Client();
27
- $client->setUri($url)
28
- ->setMethod('POST');
29
- $client->setHeaders('Content-type','application/json;charset=UTF-8');
30
- $client->setRawData($json); // not pretty
31
- $response = $client->request();
32
-
33
- // if not response 200, then log a message
34
- if(!$response->isSuccessful()) {
35
- Mage::log("POST customer register request failed for {$email} to {$url}", null, "cyclr-webhook.log");
36
- }
37
- //}
38
- }
39
-
40
- public function handleCustomerSave(Varien_Event_Observer $observer)
41
- {
42
- $customer = $observer->getEvent()->getCustomer();
43
- $email = $customer->getEmail();
44
- $url = Mage::getStoreConfig('webhook/existingcustomer/url', $customer->getSendemailStoreId());
45
-
46
- //$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
47
- if (!$customer.isObjectNew()) {
48
- //$json = Mage::helper('core')->jsonEncode($customer->getData());
49
- $json = Mage::helper('core')->jsonEncode(array(
50
- 'entity_id' => $customer->getData('entity_id'),
51
- 'email' => $customer->getData('email'),
52
- 'firstname' => $customer->getData('firstname'),
53
- 'lastname' => $customer->getData('lastname'),
54
- 'is_subscribed' => $customer->getData('is_subscribed'),
55
- 'created_at' => $customer->getData('created_at'),
56
- 'updated_at' => $customer->getData('updated_at')
57
- ));
58
-
59
- $client = new Varien_Http_Client();
60
- $client->setUri($url)
61
- ->setMethod('POST');
62
- $client->setHeaders('Content-type','application/json;charset=UTF-8');
63
- $client->setRawData($json); // not pretty
64
- $response = $client->request();
65
-
66
- // if not response 200, then log a message
67
- if(!$response->isSuccessful()) {
68
- Mage::log("POST customer save request failed for {$email} to {$url}", null, "cyclr-webhook.log");
69
- }
70
- }
71
- }
72
- }
1
+ <?php
2
+ class Cyclr_Webhook_Model_Observer
3
+ {
4
+ public function handleCustomerRegister(Varien_Event_Observer $observer)
5
+ {
6
+ $customer = $observer->getEvent()->getCustomer();
7
+ $email = $customer->getEmail();
8
+ $url = Mage::getStoreConfig('webhook/newcustomer/url', $customer->getSendemailStoreId());
9
+
10
+ // set the customer to be a new object
11
+ $customer->isObjectNew(true);
12
+
13
+ //$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
14
+ //if ($subscriber->getId()) {
15
+ //$json = Mage::helper('core')->jsonEncode($customer->getData());
16
+ $json = Mage::helper('core')->jsonEncode(array(
17
+ 'entity_id' => $customer->getData('entity_id'),
18
+ 'email' => $customer->getData('email'),
19
+ 'firstname' => $customer->getData('firstname'),
20
+ 'lastname' => $customer->getData('lastname'),
21
+ 'is_subscribed' => $customer->getData('is_subscribed'),
22
+ 'created_at' => $customer->getData('created_at'),
23
+ 'updated_at' => $customer->getData('updated_at')
24
+ ));
25
+
26
+ $client = new Varien_Http_Client();
27
+ $client->setUri($url)
28
+ ->setMethod('POST');
29
+ $client->setHeaders('Content-type','application/json;charset=UTF-8');
30
+ $client->setRawData($json); // not pretty
31
+ $response = $client->request();
32
+
33
+ // if not response 200, then log a message
34
+ if(!$response->isSuccessful()) {
35
+ Mage::log("POST customer register request failed for {$email} to {$url}", null, "cyclr-webhook.log");
36
+ }
37
+ //}
38
+ }
39
+
40
+ public function handleCustomerSave(Varien_Event_Observer $observer)
41
+ {
42
+ $customer = $observer->getEvent()->getCustomer();
43
+ $email = $customer->getEmail();
44
+ $url = Mage::getStoreConfig('webhook/existingcustomer/url', $customer->getSendemailStoreId());
45
+
46
+ //$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
47
+ if (!$customer.isObjectNew()) {
48
+ //$json = Mage::helper('core')->jsonEncode($customer->getData());
49
+ $json = Mage::helper('core')->jsonEncode(array(
50
+ 'entity_id' => $customer->getData('entity_id'),
51
+ 'email' => $customer->getData('email'),
52
+ 'firstname' => $customer->getData('firstname'),
53
+ 'lastname' => $customer->getData('lastname'),
54
+ 'is_subscribed' => $customer->getData('is_subscribed'),
55
+ 'created_at' => $customer->getData('created_at'),
56
+ 'updated_at' => $customer->getData('updated_at')
57
+ ));
58
+
59
+ $client = new Varien_Http_Client();
60
+ $client->setUri($url)
61
+ ->setMethod('POST');
62
+ $client->setHeaders('Content-type','application/json;charset=UTF-8');
63
+ $client->setRawData($json); // not pretty
64
+ $response = $client->request();
65
+
66
+ // if not response 200, then log a message
67
+ if(!$response->isSuccessful()) {
68
+ Mage::log("POST customer save request failed for {$email} to {$url}", null, "cyclr-webhook.log");
69
+ }
70
+ }
71
+ }
72
+ }
app/code/community/Cyclr/Webhook/Model/Url.php CHANGED
@@ -1,16 +1,16 @@
1
- <?php
2
- class Cyclr_Webhook_Model_Url extends Mage_Core_Model_Config_Data
3
- {
4
- public function save()
5
- {
6
- $url = $this->getValue();
7
- $cyclrUrl = 'https://my.cyclr.com/';
8
-
9
- // validate the URL
10
- if (!(substr($url, 0, strlen($cyclrUrl)) === $cyclrUrl)) {
11
- Mage::throwException('Invalid webhook URL. You should only use webhooks generated on Cyclr.');
12
- }
13
-
14
- return parent::save();
15
- }
16
  }
1
+ <?php
2
+ class Cyclr_Webhook_Model_Url extends Mage_Core_Model_Config_Data
3
+ {
4
+ public function save()
5
+ {
6
+ $url = $this->getValue();
7
+ $cyclrUrl = 'https://my.cyclr.com/';
8
+
9
+ // validate the URL
10
+ if (!(substr($url, 0, strlen($cyclrUrl)) === $cyclrUrl)) {
11
+ Mage::throwException('Invalid webhook URL. You should only use webhooks generated on Cyclr.');
12
+ }
13
+
14
+ return parent::save();
15
+ }
16
  }
app/code/community/Cyclr/Webhook/etc/config.xml CHANGED
@@ -1,61 +1,61 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <modules>
4
- <Cyclr_Webhook>
5
- <version>1.0.2</version>
6
- </Cyclr_Webhook>
7
- </modules>
8
- <global>
9
- <models>
10
- <webhook>
11
- <class>Cyclr_Webhook_Model</class>
12
- </webhook>
13
- </models>
14
- <events>
15
- <customer_register_success>
16
- <observers>
17
- <webhook>
18
- <class>Cyclr_Webhook_Model_Observer</class>
19
- <method>handleCustomerRegister</method>
20
- <type>singleton</type>
21
- </webhook>
22
- </observers>
23
- </customer_register_success>
24
- <customer_save_before>
25
- <observers>
26
- <webhook>
27
- <class>Cyclr_Webhook_Model_Observer</class>
28
- <method>handleCustomerSave</method>
29
- <type>singleton</type>
30
- </webhook>
31
- </observers>
32
- </customer_save_before>
33
- </events>
34
- <helpers>
35
- <webhook>
36
- <class>Cyclr_Webhook_Helper</class>
37
- </webhook>
38
- </helpers>
39
- </global>
40
- <adminhtml>
41
- <acl>
42
- <resources>
43
- <admin>
44
- <children>
45
- <system>
46
- <children>
47
- <config>
48
- <children>
49
- <webhook>
50
- <title>Cylr Extensions to Magento</title>
51
- </webhook>
52
- </children>
53
- </config>
54
- </children>
55
- </system>
56
- </children>
57
- </admin>
58
- </resources>
59
- </acl>
60
- </adminhtml>
61
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cyclr_Webhook>
5
+ <version>1.0.2</version>
6
+ </Cyclr_Webhook>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <webhook>
11
+ <class>Cyclr_Webhook_Model</class>
12
+ </webhook>
13
+ </models>
14
+ <events>
15
+ <customer_register_success>
16
+ <observers>
17
+ <webhook>
18
+ <class>Cyclr_Webhook_Model_Observer</class>
19
+ <method>handleCustomerRegister</method>
20
+ <type>singleton</type>
21
+ </webhook>
22
+ </observers>
23
+ </customer_register_success>
24
+ <customer_save_before>
25
+ <observers>
26
+ <webhook>
27
+ <class>Cyclr_Webhook_Model_Observer</class>
28
+ <method>handleCustomerSave</method>
29
+ <type>singleton</type>
30
+ </webhook>
31
+ </observers>
32
+ </customer_save_before>
33
+ </events>
34
+ <helpers>
35
+ <webhook>
36
+ <class>Cyclr_Webhook_Helper</class>
37
+ </webhook>
38
+ </helpers>
39
+ </global>
40
+ <adminhtml>
41
+ <acl>
42
+ <resources>
43
+ <admin>
44
+ <children>
45
+ <system>
46
+ <children>
47
+ <config>
48
+ <children>
49
+ <webhook>
50
+ <title>Cylr Extensions to Magento</title>
51
+ </webhook>
52
+ </children>
53
+ </config>
54
+ </children>
55
+ </system>
56
+ </children>
57
+ </admin>
58
+ </resources>
59
+ </acl>
60
+ </adminhtml>
61
+ </config>
app/code/community/Cyclr/Webhook/etc/system.xml CHANGED
@@ -1,62 +1,62 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <tabs>
4
- <cyclr_webhook translate="label" module="webhook">
5
- <label>Cyclr</label>
6
- <sort_order>99999</sort_order>
7
- </cyclr_webhook>
8
- </tabs>
9
- <sections>
10
- <webhook translate="label" module="webhook">
11
- <label>Cyclr Settings</label>
12
- <tab>cyclr_webhook</tab>
13
- <frontend_type>text</frontend_type>
14
- <sort_order>1000</sort_order>
15
- <show_in_default>1</show_in_default>
16
- <show_in_website>1</show_in_website>
17
- <show_in_store>1</show_in_store>
18
- <groups>
19
- <newcustomer translate="label">
20
- <label>Customer Create Webhook</label>
21
- <frontend_type>text</frontend_type>
22
- <sort_order>1</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
- <fields>
27
- <url>
28
- <label>URL</label>
29
- <frontend_type>text</frontend_type>
30
- <backend_model>webhook/url</backend_model>
31
- <sort_order>1</sort_order>
32
- <show_in_default>1</show_in_default>
33
- <show_in_website>1</show_in_website>
34
- <show_in_store>1</show_in_store>
35
- <comment><![CDATA[This URL is notified when a customer is created. Customer information, including their newsletter subscription settings, is posted to the URL.]]></comment>
36
- </url>
37
- </fields>
38
- </newcustomer>
39
- <existingcustomer translate="label">
40
- <label>Customer Update Webhook</label>
41
- <frontend_type>text</frontend_type>
42
- <sort_order>2</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>1</show_in_store>
46
- <fields>
47
- <url>
48
- <label>URL</label>
49
- <frontend_type>text</frontend_type>
50
- <backend_model>webhook/url</backend_model>
51
- <sort_order>1</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- <comment><![CDATA[This URL is notified when a customer is updated. Customer information, including their newsletter subscription settings, is posted to the URL.]]></comment>
56
- </url>
57
- </fields>
58
- </existingcustomer>
59
- </groups>
60
- </webhook>
61
- </sections>
62
- </config>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <cyclr_webhook translate="label" module="webhook">
5
+ <label>Cyclr</label>
6
+ <sort_order>99999</sort_order>
7
+ </cyclr_webhook>
8
+ </tabs>
9
+ <sections>
10
+ <webhook translate="label" module="webhook">
11
+ <label>Cyclr Settings</label>
12
+ <tab>cyclr_webhook</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <newcustomer translate="label">
20
+ <label>Customer Create Webhook</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <url>
28
+ <label>URL</label>
29
+ <frontend_type>text</frontend_type>
30
+ <backend_model>webhook/url</backend_model>
31
+ <sort_order>1</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ <comment><![CDATA[This URL is notified when a customer is created. Customer information, including their newsletter subscription settings, is posted to the URL.]]></comment>
36
+ </url>
37
+ </fields>
38
+ </newcustomer>
39
+ <existingcustomer translate="label">
40
+ <label>Customer Update Webhook</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <fields>
47
+ <url>
48
+ <label>URL</label>
49
+ <frontend_type>text</frontend_type>
50
+ <backend_model>webhook/url</backend_model>
51
+ <sort_order>1</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <comment><![CDATA[This URL is notified when a customer is updated. Customer information, including their newsletter subscription settings, is posted to the URL.]]></comment>
56
+ </url>
57
+ </fields>
58
+ </existingcustomer>
59
+ </groups>
60
+ </webhook>
61
+ </sections>
62
+ </config>
app/etc/modules/Cyclr_Webhook.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Cyclr_Webhook>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Cyclr_Webhook>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cyclr_Webhook</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
- <license/>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Cyclr webhook integration</summary>
10
- <description>Provides integration between Magento and Cyclr</description>
11
- <notes>Updated version</notes>
12
  <authors><author><name>CyclrDevs</name><user>auto-converted</user><email>devs@cyclr.com</email></author></authors>
13
- <date>2015-12-16</date>
14
- <time>13:01:02</time>
15
- <contents><target name="magecommunity"><dir name="Cyclr"><dir name="Webhook"><dir name="Helper"><file name="Data.php" hash="8e2ef78dc0c9bb9a7325459c388121e2"/></dir><dir name="Model"><file name="Observer.php" hash="5792b6624a0f6ac65ebcdf4c1f0234c4"/><file name="Url.php" hash="fb01bf252735a229cba0834ec6ee3191"/></dir><dir name="etc"><file name="config.xml" hash="e031ba25ea8d0ef5c7a4a49f2a35f10b"/><file name="system.xml" hash="8933f8849a1685dba5e08b669429db14"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cyclr_Webhook</name>
4
+ <version>1.0.3</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL-3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Sends notifications to Cyclr when a customer is created or updated.</summary>
10
+ <description>This extension allows the use of webhooks in Cyclr to trigger a new cycle journey when a new customer is created or an existing customer is updated.</description>
11
+ <notes>Initial release for Cyclr extension</notes>
12
  <authors><author><name>CyclrDevs</name><user>auto-converted</user><email>devs@cyclr.com</email></author></authors>
13
+ <date>2015-12-18</date>
14
+ <time>14:04:12</time>
15
+ <contents><target name="magecommunity"><dir name="Cyclr"><dir name="Webhook"><dir name="Helper"><file name="Data.php" hash="31b1683f00d31164e449262334478c26"/></dir><dir name="Model"><file name="Observer.php" hash="1d135646aa23dba6b2a9fa4266a26441"/><file name="Url.php" hash="13fc766f09d096ec6de29a4748e27d52"/></dir><dir name="etc"><file name="config.xml" hash="f2039627b8f18e27ce3ce7dee7ed8f7d"/><file name="system.xml" hash="edec3384d338497d1294ac2c3d72a97a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cyclr_Webhook.xml" hash="55cfbe4b4e0f46691ade441940cb3d3f"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>