Version Notes
last stable release
Download this release
Release Info
Developer | JM Goemaere |
Extension | luckycycle |
Version | 1.6.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.6.1
- app/code/community/Luckycycle/.DS_Store +0 -0
- app/code/community/Luckycycle/Snippetsdk/Helper/Data.php +0 -4
- app/code/community/Luckycycle/Snippetsdk/Model/Bannerdefault.php +0 -13
- app/code/community/Luckycycle/Snippetsdk/Model/Luckycycle.php +0 -15
- app/code/community/Luckycycle/Snippetsdk/Model/Mysql4/Luckycycle.php +0 -13
- app/code/community/Luckycycle/Snippetsdk/Model/Mysql4/Luckycycle/Collection.php +0 -8
- app/code/community/Luckycycle/Snippetsdk/Model/Paymentmethod.php +0 -24
- app/code/community/Luckycycle/Snippetsdk/Model/Posinformation.php +0 -9
- app/code/community/Luckycycle/Snippetsdk/Model/Resource/Setup.php +0 -10
- app/code/community/Luckycycle/Snippetsdk/Model/Usemode.php +0 -9
- app/code/community/Luckycycle/Snippetsdk/etc/adminhtml.xml +0 -24
- app/code/community/Luckycycle/Snippetsdk/etc/config.xml +0 -66
- app/code/community/Luckycycle/Snippetsdk/etc/system.xml +0 -126
- app/code/community/Luckycycle/Snippetsdk/sql/luckycycle_snippetsdk_setup/mysql4-install-1.0.0.php +0 -76
- app/code/community/Luckycycle/Snippetsdk/sql/luckycycle_snippetsdk_setup/mysql4-install-1.0.0.php.bak +0 -76
- app/design/frontend/base/default/layout/Luckycycle/snippetsdk.xml +0 -20
- app/design/frontend/base/default/template/Luckycycle/multishipping/snippetsdk.phtml +0 -214
- app/design/frontend/base/default/template/Luckycycle/multishipping/success.phtml +0 -60
- app/design/frontend/base/default/template/Luckycycle/snippetsdk.phtml +0 -220
- app/design/frontend/base/default/template/Luckycycle/success.phtml +0 -66
- app/etc/modules/Luckycycle_Snippetsdk.xml +0 -8
- lib/luckysdk/.gitignore +0 -2
- lib/luckysdk/Pest.php +0 -564
- lib/luckysdk/PestJSON.php +0 -196
- lib/luckysdk/PestXML.php +0 -81
- lib/luckysdk/README.markdown +0 -131
- lib/luckysdk/composer.json +0 -23
- lib/luckysdk/draw.php +0 -5
- lib/luckysdk/get.php +0 -55
- lib/luckysdk/lucky.php +0 -64
- lib/luckysdk/poke.php +0 -79
- package.xml +13 -15
app/code/community/Luckycycle/.DS_Store
DELETED
Binary file
|
app/code/community/Luckycycle/Snippetsdk/Helper/Data.php
DELETED
@@ -1,4 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Luckycycle_Snippetsdk_Helper_Data extends Mage_Core_Helper_Abstract {
|
3 |
-
|
4 |
-
}
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Bannerdefault.php
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PhpStorm.
|
4 |
-
* User: admin
|
5 |
-
* Date: 12/29/2014
|
6 |
-
* Time: 10:43 AM
|
7 |
-
*/
|
8 |
-
class Luckycycle_Snippetsdk_Model_Bannerdefault extends Mage_Adminhtml_Model_System_Config_Backend_Image {
|
9 |
-
protected function _getAllowedExtensions()
|
10 |
-
{
|
11 |
-
return array('jpg','png','jpeg','gif');
|
12 |
-
}
|
13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Luckycycle.php
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PhpStorm.
|
4 |
-
* User: admin
|
5 |
-
* Date: 12/25/2014
|
6 |
-
* Time: 3:33 PM
|
7 |
-
*/
|
8 |
-
class Luckycycle_Snippetsdk_Model_Luckycycle extends Mage_Core_Model_Abstract
|
9 |
-
{
|
10 |
-
public function __construct()
|
11 |
-
{
|
12 |
-
$this->_init('snippetsdk/luckycycle');
|
13 |
-
parent::_construct();
|
14 |
-
}
|
15 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Mysql4/Luckycycle.php
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PhpStorm.
|
4 |
-
* User: admin
|
5 |
-
* Date: 12/25/2014
|
6 |
-
* Time: 3:35 PM
|
7 |
-
*/
|
8 |
-
class Luckycycle_Snippetsdk_Model_Mysql4_Luckycycle extends Mage_Core_Model_Mysql4_Abstract {
|
9 |
-
public function _construct() {
|
10 |
-
|
11 |
-
$this->_init('snippetsdk/luckycycle', 'id_poke');
|
12 |
-
}
|
13 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Mysql4/Luckycycle/Collection.php
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Luckycycle_Snippetsdk_Model_Mysql4_Luckycycle_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
|
3 |
-
public function _construct() {
|
4 |
-
|
5 |
-
$this->_init('snippetsdk/luckycycle');
|
6 |
-
parent::_construct();
|
7 |
-
}
|
8 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Paymentmethod.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Luckycycle_Snippetsdk_Model_Paymentmethod
|
3 |
-
{
|
4 |
-
|
5 |
-
|
6 |
-
public function toOptionArray()
|
7 |
-
{
|
8 |
-
$payments = Mage::getSingleton('payment/config')->getActiveMethods();
|
9 |
-
|
10 |
-
$methods = array(array('value'=>'', 'label'=>Mage::helper('adminhtml')->__('--Please Select--')));
|
11 |
-
|
12 |
-
foreach ($payments as $paymentCode=>$paymentModel) {
|
13 |
-
$paymentTitle = Mage::getStoreConfig('payment/'.$paymentCode.'/title');
|
14 |
-
$methods[$paymentCode] = array(
|
15 |
-
'label' => $paymentTitle,
|
16 |
-
'value' => $paymentCode,
|
17 |
-
);
|
18 |
-
}
|
19 |
-
|
20 |
-
return $methods;
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Posinformation.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Luckycycle_Snippetsdk_Model_Posinformation {
|
3 |
-
public function toOptionArray() {
|
4 |
-
return array(
|
5 |
-
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Before Banner/ Iframe')),
|
6 |
-
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('After Banner/ Iframe')),
|
7 |
-
);
|
8 |
-
}
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Resource/Setup.php
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Created by PhpStorm.
|
4 |
-
* User: admin
|
5 |
-
* Date: 12/25/2014
|
6 |
-
* Time: 2:37 PM
|
7 |
-
*/
|
8 |
-
class Luckycycle_Snippetsdk_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup {
|
9 |
-
|
10 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/Model/Usemode.php
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Luckycycle_Snippetsdk_Model_Usemode {
|
3 |
-
public function toOptionArray() {
|
4 |
-
return array(
|
5 |
-
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Use Iframe')),
|
6 |
-
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Use Banner')),
|
7 |
-
);
|
8 |
-
}
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/etc/adminhtml.xml
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<config>
|
2 |
-
<acl>
|
3 |
-
<resources>
|
4 |
-
<all>
|
5 |
-
<title>Allow Everything</title>
|
6 |
-
</all>
|
7 |
-
<admin>
|
8 |
-
<children>
|
9 |
-
<system>
|
10 |
-
<children>
|
11 |
-
<config>
|
12 |
-
<children>
|
13 |
-
<snippetsdk>
|
14 |
-
<title>Luckycycle - Snippetsdk</title>
|
15 |
-
</snippetsdk>
|
16 |
-
</children>
|
17 |
-
</config>
|
18 |
-
</children>
|
19 |
-
</system>
|
20 |
-
</children>
|
21 |
-
</admin>
|
22 |
-
</resources>
|
23 |
-
</acl>
|
24 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/etc/config.xml
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<config>
|
2 |
-
<modules>
|
3 |
-
<Luckycycle_Snippetsdk>
|
4 |
-
<version>1.0.0</version>
|
5 |
-
</Luckycycle_Snippetsdk>
|
6 |
-
</modules>
|
7 |
-
<frontend>
|
8 |
-
<layout>
|
9 |
-
<updates>
|
10 |
-
<snippetsdk>
|
11 |
-
<file>Luckycycle/snippetsdk.xml</file>
|
12 |
-
</snippetsdk>
|
13 |
-
</updates>
|
14 |
-
</layout>
|
15 |
-
</frontend>
|
16 |
-
<global>
|
17 |
-
<helpers>
|
18 |
-
<snippetsdk>
|
19 |
-
<class>Luckycycle_Snippetsdk_Helper</class>
|
20 |
-
</snippetsdk>
|
21 |
-
</helpers>
|
22 |
-
<models>
|
23 |
-
<snippetsdk>
|
24 |
-
<class>Luckycycle_Snippetsdk_Model</class>
|
25 |
-
<resourceModel>luckycycle_snippetsdk_mysql4</resourceModel>
|
26 |
-
</snippetsdk>
|
27 |
-
<luckycycle_snippetsdk_mysql4>
|
28 |
-
<class>Luckycycle_Snippetsdk_Model_Mysql4</class>
|
29 |
-
<entities>
|
30 |
-
<luckycycle>
|
31 |
-
<table>luckycycle_snippetsdk</table>
|
32 |
-
</luckycycle>
|
33 |
-
</entities>
|
34 |
-
</luckycycle_snippetsdk_mysql4>
|
35 |
-
</models>
|
36 |
-
<resources>
|
37 |
-
<luckycycle_snippetsdk_setup>
|
38 |
-
<setup>
|
39 |
-
<module>Luckycycle_Snippetsdk</module>
|
40 |
-
<class>Luckycycle_Snippetsdk_Model_Resource_Setup</class>
|
41 |
-
</setup>
|
42 |
-
<connection>
|
43 |
-
<use>core_setup</use>
|
44 |
-
</connection>
|
45 |
-
</luckycycle_snippetsdk_setup>
|
46 |
-
<luckycycle_snippetsdk_write>
|
47 |
-
<connection>
|
48 |
-
<use>core_write</use>
|
49 |
-
</connection>
|
50 |
-
</luckycycle_snippetsdk_write>
|
51 |
-
<luckycycle_snippetsdk_read>
|
52 |
-
<connection>
|
53 |
-
<use>core_read</use>
|
54 |
-
</connection>
|
55 |
-
</luckycycle_snippetsdk_read>
|
56 |
-
</resources>
|
57 |
-
</global>
|
58 |
-
<default>
|
59 |
-
<snippetsdk>
|
60 |
-
<params>
|
61 |
-
<enabled>0</enabled>
|
62 |
-
<use_iframe>1</use_iframe>
|
63 |
-
</params>
|
64 |
-
</snippetsdk>
|
65 |
-
</default>
|
66 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/etc/system.xml
DELETED
@@ -1,126 +0,0 @@
|
|
1 |
-
<config>
|
2 |
-
<tabs>
|
3 |
-
<luckycyclesdk module="snippetsdk">
|
4 |
-
<label>LUCKYCYCLE PLUGINS</label>
|
5 |
-
<sort_order>100</sort_order>
|
6 |
-
</luckycyclesdk>
|
7 |
-
</tabs>
|
8 |
-
<sections>
|
9 |
-
<snippetsdk translate="label" module="snippetsdk">
|
10 |
-
<label>Luckycycle API integration</label>
|
11 |
-
<tab>luckycyclesdk</tab>
|
12 |
-
<frontend_type>text</frontend_type>
|
13 |
-
<sort_order>1000</sort_order>
|
14 |
-
<show_in_default>1</show_in_default>
|
15 |
-
<show_in_website>1</show_in_website>
|
16 |
-
<show_in_store>1</show_in_store>
|
17 |
-
<groups>
|
18 |
-
<params translate="label">
|
19 |
-
<label>Luckycycle Setting</label>
|
20 |
-
<frontend_type>text</frontend_type>
|
21 |
-
<sort_order>12</sort_order>
|
22 |
-
<show_in_default>1</show_in_default>
|
23 |
-
<show_in_website>1</show_in_website>
|
24 |
-
<show_in_store>1</show_in_store>
|
25 |
-
<fields>
|
26 |
-
<enabled translate="label">
|
27 |
-
<label>Enabled</label>
|
28 |
-
<frontend_type>select</frontend_type>
|
29 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
30 |
-
<sort_order>1</sort_order>
|
31 |
-
<show_in_default>1</show_in_default>
|
32 |
-
<show_in_website>1</show_in_website>
|
33 |
-
<show_in_store>1</show_in_store>
|
34 |
-
</enabled>
|
35 |
-
<api_id>
|
36 |
-
<label translate="label">API key</label>
|
37 |
-
<frontend_type>text</frontend_type>
|
38 |
-
<sort_order>2</sort_order>
|
39 |
-
<show_in_default>1</show_in_default>
|
40 |
-
<show_in_website>1</show_in_website>
|
41 |
-
<show_in_store>1</show_in_store>
|
42 |
-
</api_id>
|
43 |
-
<operation_id>
|
44 |
-
<label translate="label">Operation Id</label>
|
45 |
-
<frontend_type>text</frontend_type>
|
46 |
-
<sort_order>3</sort_order>
|
47 |
-
<show_in_default>1</show_in_default>
|
48 |
-
<show_in_website>1</show_in_website>
|
49 |
-
<show_in_store>1</show_in_store>
|
50 |
-
</operation_id>
|
51 |
-
<use_iframe>
|
52 |
-
<label translate="label">Method</label>
|
53 |
-
<frontend_type>select</frontend_type>
|
54 |
-
<sort_order>4</sort_order>
|
55 |
-
<source_model>Luckycycle_Snippetsdk_Model_Usemode</source_model>
|
56 |
-
<show_in_default>1</show_in_default>
|
57 |
-
<show_in_website>1</show_in_website>
|
58 |
-
<show_in_store>1</show_in_store>
|
59 |
-
</use_iframe>
|
60 |
-
<iframe_width>
|
61 |
-
<label translate="label">Width of Banner/ Iframe</label>
|
62 |
-
<frontend_type>text</frontend_type>
|
63 |
-
<sort_order>7</sort_order>
|
64 |
-
<show_in_default>1</show_in_default>
|
65 |
-
<show_in_website>1</show_in_website>
|
66 |
-
<show_in_store>1</show_in_store>
|
67 |
-
</iframe_width>
|
68 |
-
<iframe_height>
|
69 |
-
<label translate="label">Height of Banner/ Iframe</label>
|
70 |
-
<frontend_type>text</frontend_type>
|
71 |
-
<sort_order>8</sort_order>
|
72 |
-
<show_in_default>1</show_in_default>
|
73 |
-
<show_in_website>1</show_in_website>
|
74 |
-
<show_in_store>1</show_in_store>
|
75 |
-
</iframe_height>
|
76 |
-
<!--<iframe_tagcss>-->
|
77 |
-
<!--<label translate="label">Specify iframe tag css </label>-->
|
78 |
-
<!--<frontend_type>text</frontend_type>-->
|
79 |
-
<!--<sort_order>7</sort_order>-->
|
80 |
-
<!--<show_in_default>1</show_in_default>-->
|
81 |
-
<!--<show_in_website>1</show_in_website>-->
|
82 |
-
<!--<show_in_store>1</show_in_store>-->
|
83 |
-
<!--</iframe_tagcss>-->
|
84 |
-
<upload_defaultbanner translate="label">
|
85 |
-
<label>Upload Banner</label>
|
86 |
-
<comment><![CDATA[Allow image type: jpg,png,jpeg,gif. <br/>In case does not setup banner on Luckycycle]]></comment>
|
87 |
-
<frontend_type>image</frontend_type>
|
88 |
-
<backend_model>snippetsdk/bannerdefault</backend_model>
|
89 |
-
<upload_dir config="system/filesystem/media" scope_info="1">upload</upload_dir>
|
90 |
-
<base_url type="media" scope_info="1">upload</base_url>
|
91 |
-
<sort_order>9</sort_order>
|
92 |
-
<show_in_default>1</show_in_default>
|
93 |
-
<show_in_website>0</show_in_website>
|
94 |
-
<show_in_store>0</show_in_store>
|
95 |
-
</upload_defaultbanner>
|
96 |
-
<before_information>
|
97 |
-
<label translate="label">Before Banner/ Iframe:</label>
|
98 |
-
<frontend_type>textarea</frontend_type>
|
99 |
-
<sort_order>10</sort_order>
|
100 |
-
<show_in_default>1</show_in_default>
|
101 |
-
<show_in_website>1</show_in_website>
|
102 |
-
<show_in_store>1</show_in_store>
|
103 |
-
</before_information>
|
104 |
-
<after_information>
|
105 |
-
<label translate="label">After Banner/ Iframe:</label>
|
106 |
-
<frontend_type>textarea</frontend_type>
|
107 |
-
<sort_order>11</sort_order>
|
108 |
-
<show_in_default>1</show_in_default>
|
109 |
-
<show_in_website>1</show_in_website>
|
110 |
-
<show_in_store>1</show_in_store>
|
111 |
-
</after_information>
|
112 |
-
<payment_method_luckycyclesdk>
|
113 |
-
<label translate="label">Selection payment</label>
|
114 |
-
<frontend_type>multiselect</frontend_type>
|
115 |
-
<sort_order>12</sort_order>
|
116 |
-
<source_model>Luckycycle_Snippetsdk_Model_Paymentmethod</source_model>
|
117 |
-
<show_in_default>1</show_in_default>
|
118 |
-
<show_in_website>1</show_in_website>
|
119 |
-
<show_in_store>1</show_in_store>
|
120 |
-
</payment_method_luckycyclesdk>
|
121 |
-
</fields>
|
122 |
-
</params>
|
123 |
-
</groups>
|
124 |
-
</snippetsdk>
|
125 |
-
</sections>
|
126 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/sql/luckycycle_snippetsdk_setup/mysql4-install-1.0.0.php
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$installer = $this;
|
3 |
-
$installer->startSetup();
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Create Luckycyle_snippetsdk Table
|
7 |
-
*/
|
8 |
-
/*$tableName = $installer->getTable('snippetsdk/luckycycle');
|
9 |
-
// Check if the table already exists
|
10 |
-
//if ($installer->getConnection()->isTableExists($tableName) != true) {
|
11 |
-
$table = $installer->getConnection()
|
12 |
-
->newTable($installer->getTable('snippetsdk/luckycycle'))
|
13 |
-
->addColumn('id_poke', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
14 |
-
'identity' => true,
|
15 |
-
'unsigned' => true,
|
16 |
-
'nullable' => false,
|
17 |
-
'primary' => true,
|
18 |
-
|
19 |
-
), 'Poke Id')
|
20 |
-
->addColumn('hash', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
21 |
-
'nullable' => true
|
22 |
-
), 'Hash')
|
23 |
-
->addColumn('banner_url', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
24 |
-
'nullable' => true
|
25 |
-
), 'Banner Url')
|
26 |
-
->addColumn('type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255,
|
27 |
-
array(
|
28 |
-
'nullable' => true,
|
29 |
-
),
|
30 |
-
'Type')
|
31 |
-
->addColumn('id_customer', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
32 |
-
array(
|
33 |
-
'nullable' => true,
|
34 |
-
),
|
35 |
-
'Customer Id')
|
36 |
-
->addColumn('id_order', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
37 |
-
array(
|
38 |
-
'nullable' => true,
|
39 |
-
),
|
40 |
-
'Order Id')
|
41 |
-
->addColumn('create_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
42 |
-
array(
|
43 |
-
'nullable' => true,
|
44 |
-
),
|
45 |
-
'Create At')
|
46 |
-
->addColumn('operation_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255,
|
47 |
-
array(
|
48 |
-
'nullable' => true,
|
49 |
-
),
|
50 |
-
'Operation Id')
|
51 |
-
->addColumn('total_played', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
52 |
-
array(
|
53 |
-
'nullable' => true,
|
54 |
-
),
|
55 |
-
'Total Played');
|
56 |
-
|
57 |
-
$installer->getConnection()->createTable($table);
|
58 |
-
//}*/
|
59 |
-
|
60 |
-
$installer->run("
|
61 |
-
CREATE TABLE `{$installer->getTable('snippetsdk/luckycycle')}` (
|
62 |
-
`id_poke` int(11) NOT NULL auto_increment,
|
63 |
-
`hash` varchar(255),
|
64 |
-
`banner_url` varchar(255) ,
|
65 |
-
`type` varchar(255) ,
|
66 |
-
`id_customer` varchar(255),
|
67 |
-
`id_order` varchar(255),
|
68 |
-
`create_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
69 |
-
`operation_id` varchar(255),
|
70 |
-
`total_played` float,
|
71 |
-
PRIMARY KEY (`id_poke`)
|
72 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
73 |
-
");
|
74 |
-
|
75 |
-
|
76 |
-
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Luckycycle/Snippetsdk/sql/luckycycle_snippetsdk_setup/mysql4-install-1.0.0.php.bak
DELETED
@@ -1,76 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$installer = $this;
|
3 |
-
$installer->startSetup();
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Create Luckycyle_snippetsdk Table
|
7 |
-
*/
|
8 |
-
/*$tableName = $installer->getTable('snippetsdk/luckycycle');
|
9 |
-
// Check if the table already exists
|
10 |
-
//if ($installer->getConnection()->isTableExists($tableName) != true) {
|
11 |
-
$table = $installer->getConnection()
|
12 |
-
->newTable($installer->getTable('snippetsdk/luckycycle'))
|
13 |
-
->addColumn('id_poke', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
14 |
-
'identity' => true,
|
15 |
-
'unsigned' => true,
|
16 |
-
'nullable' => false,
|
17 |
-
'primary' => true,
|
18 |
-
|
19 |
-
), 'Poke Id')
|
20 |
-
->addColumn('hash', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
21 |
-
'nullable' => true
|
22 |
-
), 'Hash')
|
23 |
-
->addColumn('banner_url', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
|
24 |
-
'nullable' => true
|
25 |
-
), 'Banner Url')
|
26 |
-
->addColumn('type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255,
|
27 |
-
array(
|
28 |
-
'nullable' => true,
|
29 |
-
),
|
30 |
-
'Type')
|
31 |
-
->addColumn('id_customer', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
32 |
-
array(
|
33 |
-
'nullable' => true,
|
34 |
-
),
|
35 |
-
'Customer Id')
|
36 |
-
->addColumn('id_order', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
37 |
-
array(
|
38 |
-
'nullable' => true,
|
39 |
-
),
|
40 |
-
'Order Id')
|
41 |
-
->addColumn('create_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null,
|
42 |
-
array(
|
43 |
-
'nullable' => true,
|
44 |
-
),
|
45 |
-
'Create At')
|
46 |
-
->addColumn('operation_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255,
|
47 |
-
array(
|
48 |
-
'nullable' => true,
|
49 |
-
),
|
50 |
-
'Operation Id')
|
51 |
-
->addColumn('total_played', Varien_Db_Ddl_Table::TYPE_INTEGER, null,
|
52 |
-
array(
|
53 |
-
'nullable' => true,
|
54 |
-
),
|
55 |
-
'Total Played');
|
56 |
-
|
57 |
-
$installer->getConnection()->createTable($table);
|
58 |
-
//}*/
|
59 |
-
|
60 |
-
$installer->run("
|
61 |
-
CREATE TABLE `{$installer->getTable('snippetsdk/luckycycle')}` (
|
62 |
-
`id_poke` int(11) NOT NULL auto_increment,
|
63 |
-
`hash` varchar(255),
|
64 |
-
`banner_url` varchar(255) ,
|
65 |
-
`type` varchar(255) ,
|
66 |
-
`id_customer` int(11),
|
67 |
-
`id_order` int(11),
|
68 |
-
`create_at` timestamp NOT NULL default CURRENT_TIMESTAMP,
|
69 |
-
`operation_id` varchar(255),
|
70 |
-
`total_played` int(11),
|
71 |
-
PRIMARY KEY (`id_poke`)
|
72 |
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
73 |
-
");
|
74 |
-
|
75 |
-
|
76 |
-
$installer->endSetup();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/layout/Luckycycle/snippetsdk.xml
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<layout version="0.1.0">
|
3 |
-
<checkout_onepage_success translate="label">
|
4 |
-
<label>One Page Checkout Success</label>
|
5 |
-
<reference name="content">
|
6 |
-
<reference name="checkout.success">
|
7 |
-
<action method="setTemplate"><template>Luckycycle/success.phtml</template></action>
|
8 |
-
</reference>
|
9 |
-
<block type="checkout/onepage_success" name="checkout.snippetsdk" template="Luckycycle/snippetsdk.phtml"/>
|
10 |
-
</reference>
|
11 |
-
</checkout_onepage_success>
|
12 |
-
<checkout_multishipping_success>
|
13 |
-
<reference name="content">
|
14 |
-
<reference name="checkout_success">
|
15 |
-
<action method="setTemplate"><template>Luckycycle/multishipping/success.phtml</template></action>
|
16 |
-
</reference>
|
17 |
-
<block before="-" type="checkout/multishipping_success" name="checkout.snippetsdk" template="Luckycycle/multishipping/snippetsdk.phtml"/>
|
18 |
-
</reference>
|
19 |
-
</checkout_multishipping_success>
|
20 |
-
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/Luckycycle/multishipping/snippetsdk.phtml
DELETED
@@ -1,214 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$banner_default = Mage::getStoreConfig('snippetsdk/params/upload_defaultbanner');
|
4 |
-
$before_information = Mage::getStoreConfig('snippetsdk/params/before_information');
|
5 |
-
$after_information = Mage::getStoreConfig('snippetsdk/params/after_information');
|
6 |
-
$iframe_width = Mage::getStoreConfig('snippetsdk/params/iframe_width');
|
7 |
-
$iframe_height = Mage::getStoreConfig('snippetsdk/params/iframe_height');
|
8 |
-
require_once(Mage::getBaseDir('lib') . '/luckysdk/lucky.php');
|
9 |
-
$enabledSnippet = Mage::getStoreConfig('snippetsdk/params/enabled');
|
10 |
-
$apiKey = Mage::getStoreConfig('snippetsdk/params/api_id');
|
11 |
-
$operationKey = Mage::getStoreConfig('snippetsdk/params/operation_id');
|
12 |
-
$useImage = Mage::getStoreConfig('snippetsdk/params/use_iframe');
|
13 |
-
|
14 |
-
if ( $enabledSnippet && $operationKey && $apiKey) {
|
15 |
-
$_orderIds = Mage::getSingleton('core/session')->getData('order_ids');
|
16 |
-
$amount = 0;
|
17 |
-
$orderMultiAddressId = "";
|
18 |
-
$i = 0;
|
19 |
-
$orderIdFirst = 0;
|
20 |
-
$multiAddressItems = array();
|
21 |
-
foreach ($_orderIds as $orderId => $incrementId) {
|
22 |
-
if ($i == 0) {
|
23 |
-
$orderMultiAddressId .= $incrementId;
|
24 |
-
} else {
|
25 |
-
$orderMultiAddressId .= "_" . $incrementId;
|
26 |
-
}
|
27 |
-
$i++;
|
28 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
|
29 |
-
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
30 |
-
$amount += $order->getGrandTotal() - $order->getShippingAmount();
|
31 |
-
}
|
32 |
-
|
33 |
-
$paymentMethodCode = $order->getPayment()->getMethodInstance()->getCode();
|
34 |
-
$paymentMethodLuckyCycle = explode(",", Mage::getStoreConfig('snippetsdk/params/payment_method_luckycyclesdk'));
|
35 |
-
|
36 |
-
if (in_array($paymentMethodCode, $paymentMethodLuckyCycle)) {
|
37 |
-
//first need customer_id
|
38 |
-
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
39 |
-
if ($customerId) {
|
40 |
-
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
41 |
-
$firstName = $customer->getFirstname();
|
42 |
-
$lastName = $customer->getLastname();
|
43 |
-
$emailCustomer = $customer->getEmail();
|
44 |
-
} else {
|
45 |
-
$customerId = "guest_" . md5("guest");
|
46 |
-
$firstName = $quote->getBillingAddress()->getFirstname();
|
47 |
-
$lastName = $quote->getBillingAddress()->getLastname();
|
48 |
-
$emailCustomer = $quote->getBillingAddress()->getEmail();
|
49 |
-
}
|
50 |
-
|
51 |
-
|
52 |
-
//Mage::log("PS order_id/customer_id:" . $orderId . " / " . $customerId);
|
53 |
-
|
54 |
-
//get currency symbol and language
|
55 |
-
$currency = $order->getOrderCurrency();
|
56 |
-
if (is_object($currency)) {
|
57 |
-
$currencyCode = $currency->getCurrencyCode();
|
58 |
-
}
|
59 |
-
$currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
|
60 |
-
$language = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
|
61 |
-
$language = explode('_',$language);
|
62 |
-
$language = $language[0];
|
63 |
-
//get all product in order
|
64 |
-
|
65 |
-
|
66 |
-
$amount = $order->getGrandTotal() - $order->getShippingAmount();
|
67 |
-
$real_paid = $quote['grand_total'];
|
68 |
-
$the_cart = array(); // container product
|
69 |
-
|
70 |
-
|
71 |
-
foreach ($quote->getAllItems() as $order_item) {
|
72 |
-
|
73 |
-
$price = $order_item->getPrice();
|
74 |
-
if ($price > 0) {
|
75 |
-
|
76 |
-
|
77 |
-
$item['price'] = $order_item->getPrice();
|
78 |
-
$item['quantity'] = $order_item->getQty();
|
79 |
-
$item['product_id'] = $order_item->getProduct()->getId();
|
80 |
-
|
81 |
-
//get top categoryId
|
82 |
-
$topCategory = Mage::getResourceModel('catalog/category_collection')
|
83 |
-
->addIdFilter($order_item->getProduct()->getCategoryIds())
|
84 |
-
->setOrder('level', 'ASC')
|
85 |
-
->setPage(1,1)
|
86 |
-
->getFirstItem();
|
87 |
-
$topCategoryId = $topCategory->getId();
|
88 |
-
$item['category_id'] = $topCategoryId;
|
89 |
-
//model product and load product with product id
|
90 |
-
$model_product = Mage::getModel('catalog/product');
|
91 |
-
$_productObject = $model_product->load($order_item->getProduct()->getId());
|
92 |
-
//end model product and load product with product id
|
93 |
-
if ($_productObject->getAttributeText('manufacturer')) {
|
94 |
-
$item['manufacturer_id'] = $_productObject->getAttributeText('manufacturer');
|
95 |
-
} else {
|
96 |
-
$item['manufacturer_id'] = 1;
|
97 |
-
}
|
98 |
-
//end get category id
|
99 |
-
$item['product_name'] = $_productObject->getName();
|
100 |
-
|
101 |
-
//$_productObject->getAttributeText(‘manufacturer’)
|
102 |
-
|
103 |
-
|
104 |
-
$item['reference'] = 'reference';
|
105 |
-
//$item['reference'] = $value['reference'];
|
106 |
-
array_push($the_cart,$item);
|
107 |
-
}
|
108 |
-
}
|
109 |
-
|
110 |
-
//config sdk
|
111 |
-
$req = new LuckyCycleApi('https://www.luckycycle.com');
|
112 |
-
$req->setApiKey($apiKey);
|
113 |
-
$req->setOperationId($operationKey);
|
114 |
-
//Mage::log("language : (string)$language"." / " ."currency: ".$currencyCode);
|
115 |
-
//Mage::log("Item value".$amount);
|
116 |
-
$pokedata = array(
|
117 |
-
'user_uid' => (string)$customerId,
|
118 |
-
'item_uid' => (string)$orderMultiAddressId,
|
119 |
-
'item_value' => (string)$amount,
|
120 |
-
'item_currency' => (string)$currencyCode,
|
121 |
-
'language' => (string)$language,
|
122 |
-
'firstname' => (string)$firstName,
|
123 |
-
'lastname' => (string)$lastName,
|
124 |
-
'email' => (string)$emailCustomer,
|
125 |
-
'cart'=>$the_cart
|
126 |
-
);
|
127 |
-
//end sdk
|
128 |
-
try {
|
129 |
-
$poke = $req->poke($pokedata);
|
130 |
-
//Mage::log($poke);
|
131 |
-
if ($poke && $poke['can_play']== true) {
|
132 |
-
$model_luckycycle = Mage::getModel('snippetsdk/luckycycle')->getCollection()
|
133 |
-
->addFieldToFilter('hash',$poke['computed_hash']);
|
134 |
-
$flagCheckHashExits = count($model_luckycycle);
|
135 |
-
if ($flagCheckHashExits == 0) {
|
136 |
-
$insertLuckycycle = Mage::getModel('snippetsdk/luckycycle');
|
137 |
-
$insertLuckycycle->setHash($poke['computed_hash']);
|
138 |
-
$insertLuckycycle->setBannerUrl($poke['banner_url']);
|
139 |
-
$insertLuckycycle->setIdOrder($orderMultiAddressId);
|
140 |
-
$insertLuckycycle->setOperationId($operationKey);
|
141 |
-
$insertLuckycycle->setType('basket');
|
142 |
-
$insertLuckycycle->setIdCustomer($customerId);
|
143 |
-
$insertLuckycycle->setCreateAt(date('Y-m-d H:i:s'));
|
144 |
-
$insertLuckycycle->setTotalPlayed($real_paid);
|
145 |
-
$insertLuckycycle->save();
|
146 |
-
?>
|
147 |
-
<div id="content-api-luckycycle">
|
148 |
-
<?php
|
149 |
-
if (isset($before_information)) {
|
150 |
-
echo "<div>" . $before_information . "</div>";
|
151 |
-
}
|
152 |
-
if ($useImage) {
|
153 |
-
if ($poke['banner_url'] == null) {
|
154 |
-
if ($banner_default != null) {
|
155 |
-
?>
|
156 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank" id="lc_banner_url">
|
157 |
-
<img src="<?php echo 'http://'.$_SERVER['HTTP_HOST'].'/media'.'/upload/'.$banner_default; ?>"
|
158 |
-
<?php if ($iframe_width) { ?> width="<?php echo $iframe_width.'px' ?>" <?php } ?>
|
159 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height.'px' ?>" <?php } ?> style="margin: auto; max-width: 98%" />
|
160 |
-
</a>
|
161 |
-
<?php } else {
|
162 |
-
$urlNoImage = Mage::helper('catalog/image')->init(Mage::getModel('catalog/product'),'image');
|
163 |
-
?>
|
164 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank" id="lc_banner_url">
|
165 |
-
<img src="<?php echo $urlNoImage?>" <?php if ($iframe_width) { ?> width="<?php echo $iframe_width.'px' ?>" <?php } ?>
|
166 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height.'px' ?>" <?php } ?> style="margin: auto; max-width: 98%" />
|
167 |
-
</a>
|
168 |
-
<?php
|
169 |
-
}
|
170 |
-
} else {
|
171 |
-
?>
|
172 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank" id="lc_banner_url">
|
173 |
-
<img src="<?php echo $poke['banner_url'] ?>" <?php if ($iframe_width) { ?> width="<?php echo $iframe_width.'px' ?>" <?php } ?>
|
174 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height.'px' ?>" <?php } ?> style="margin: auto; max-width: 98%" />
|
175 |
-
</a>
|
176 |
-
<?php
|
177 |
-
}
|
178 |
-
} else {
|
179 |
-
?>
|
180 |
-
<div style="text-align: center">
|
181 |
-
<iframe frameborder="0"
|
182 |
-
src="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>"
|
183 |
-
target="_blank"
|
184 |
-
align="center"
|
185 |
-
scrolling="no"
|
186 |
-
style="margin: auto; max-width: 98%"
|
187 |
-
<?php if ($iframe_width) { ?> width="<?php echo $iframe_width.'px' ?>" <?php } ?>
|
188 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height.'px' ?>" <?php } ?>
|
189 |
-
id="luckycycle_iframe"></iframe>
|
190 |
-
</div>
|
191 |
-
<?php
|
192 |
-
}
|
193 |
-
if (isset($after_information)) {
|
194 |
-
echo "<div>" . $after_information . "</div>";
|
195 |
-
}
|
196 |
-
?>
|
197 |
-
</div>
|
198 |
-
<?php
|
199 |
-
} else {
|
200 |
-
Mage::log('Poke added in DB');
|
201 |
-
}
|
202 |
-
} else {
|
203 |
-
Mage::log("we didn't get a poke back, user cannot play on this order or an error happened");
|
204 |
-
}
|
205 |
-
} catch (Exception $e) {
|
206 |
-
Mage::log($e->getMessage());
|
207 |
-
|
208 |
-
}
|
209 |
-
} else {
|
210 |
-
Mage::log("Api key,operation key or payment method null ");
|
211 |
-
}
|
212 |
-
} else {
|
213 |
-
Mage::log("Luckycycle module is not enable");
|
214 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/Luckycycle/multishipping/success.phtml
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<div class="multiple-checkout">
|
28 |
-
<div class="page-title">
|
29 |
-
<h1 data-role="page-title"><?php echo $this->__('Order Success') ?></h1>
|
30 |
-
</div>
|
31 |
-
<h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
|
32 |
-
<p><?php echo $this->__('We are processing your order and you will soon receive an email with details of the order. Once the order has shipped you will receive another email with a link to track its progress.') ?></p>
|
33 |
-
<?php if($_orderIds = $this->getOrderIds()): ?>
|
34 |
-
<p data-role="order-numbers">
|
35 |
-
<?php $flag = false ?>
|
36 |
-
<?php echo $this->__('Your order number is ') ?>
|
37 |
-
<?php foreach ($_orderIds as $orderId=>$incrementId): ?>
|
38 |
-
<?php if ($flag): ?>
|
39 |
-
<?php echo ', ' ?>
|
40 |
-
<?php endif; ?>
|
41 |
-
<?php $flag = true ?>
|
42 |
-
<a href="<?php echo $this->getViewOrderUrl($orderId) ?>"><?php echo $incrementId ?></a>
|
43 |
-
<?php endforeach; ?>
|
44 |
-
</p>
|
45 |
-
<?php endif; ?>
|
46 |
-
<?php echo $this->getChildHtml() ?>
|
47 |
-
<!--Frame LuckyCycle-->
|
48 |
-
<div id="api-frame-luckycycle" style="text-align: center"></div>
|
49 |
-
<script type="text/javascript">
|
50 |
-
var luckyCycleHtml = document.getElementById('content-api-luckycycle')
|
51 |
-
var luckyCycleApi = document.getElementById('api-frame-luckycycle')
|
52 |
-
if (luckyCycleApi) {
|
53 |
-
luckyCycleApi.innerHTML = luckyCycleHtml.innerHTML;
|
54 |
-
luckyCycleHtml.remove();
|
55 |
-
}
|
56 |
-
</script>
|
57 |
-
<div class="buttons-set">
|
58 |
-
<button type="button" title="<?php echo $this->__('Continue Shopping') ?>" class="button" onclick="setLocation('<?php echo $this->getContinueUrl() ?>')"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
59 |
-
</div>
|
60 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/Luckycycle/snippetsdk.phtml
DELETED
@@ -1,220 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$banner_default = Mage::getStoreConfig('snippetsdk/params/upload_defaultbanner');
|
4 |
-
$before_information = Mage::getStoreConfig('snippetsdk/params/before_information');
|
5 |
-
$after_information = Mage::getStoreConfig('snippetsdk/params/after_information');
|
6 |
-
$iframe_width = Mage::getStoreConfig('snippetsdk/params/iframe_width');
|
7 |
-
$iframe_height = Mage::getStoreConfig('snippetsdk/params/iframe_height');
|
8 |
-
|
9 |
-
require_once(Mage::getBaseDir('lib') . '/luckysdk/lucky.php');
|
10 |
-
$enabledSnippet = Mage::getStoreConfig('snippetsdk/params/enabled');
|
11 |
-
$apiKey = Mage::getStoreConfig('snippetsdk/params/api_id');
|
12 |
-
$operationKey = Mage::getStoreConfig('snippetsdk/params/operation_id');
|
13 |
-
$useImage = Mage::getStoreConfig('snippetsdk/params/use_iframe');
|
14 |
-
$orderId = $this->getOrderId();
|
15 |
-
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
16 |
-
$paymentMethodCode = $order->getPayment()->getMethodInstance()->getCode();
|
17 |
-
$paymentMethodLuckyCycle = explode(",", Mage::getStoreConfig('snippetsdk/params/payment_method_luckycyclesdk'));
|
18 |
-
$quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
19 |
-
|
20 |
-
|
21 |
-
if ($enabledSnippet) {
|
22 |
-
if ($operationKey && $apiKey && in_array($paymentMethodCode, $paymentMethodLuckyCycle)) {
|
23 |
-
//first need customer_id
|
24 |
-
|
25 |
-
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
26 |
-
if ($customerId) {
|
27 |
-
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
28 |
-
$firstName = $customer->getFirstname();
|
29 |
-
$lastName = $customer->getLastname();
|
30 |
-
$emailCustomer = $customer->getEmail();
|
31 |
-
} else {
|
32 |
-
$customerId = "guest_" . md5("guest");
|
33 |
-
$firstName = $quote->getBillingAddress()->getFirstname();
|
34 |
-
$lastName = $quote->getBillingAddress()->getLastname();
|
35 |
-
$emailCustomer = $quote->getBillingAddress()->getEmail();
|
36 |
-
}
|
37 |
-
|
38 |
-
|
39 |
-
//Mage::log("PS order_id/customer_id:" . $orderId . " / " . $customerId);
|
40 |
-
|
41 |
-
//get currency symbol and language
|
42 |
-
$currency = $order->getOrderCurrency();
|
43 |
-
if (is_object($currency)) {
|
44 |
-
$currencyCode = $currency->getCurrencyCode();
|
45 |
-
}
|
46 |
-
$currencySymbol = Mage::app()->getLocale()->currency($currencyCode)->getSymbol();
|
47 |
-
$language = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
|
48 |
-
$language = explode('_', $language);
|
49 |
-
$language = $language[0];
|
50 |
-
//get all product in order
|
51 |
-
|
52 |
-
|
53 |
-
$amount = $order->getGrandTotal() - $order->getShippingAmount();
|
54 |
-
$real_paid = $quote['grand_total'];
|
55 |
-
$the_cart = array(); // container product
|
56 |
-
|
57 |
-
|
58 |
-
foreach ($quote->getAllItems() as $order_item) {
|
59 |
-
|
60 |
-
$price = $order_item->getPrice();
|
61 |
-
if ($price > 0) {
|
62 |
-
|
63 |
-
|
64 |
-
$item['price'] = $order_item->getPrice();
|
65 |
-
$item['quantity'] = $order_item->getQty();
|
66 |
-
$item['product_id'] = $order_item->getProduct()->getId();
|
67 |
-
|
68 |
-
//get top categoryId
|
69 |
-
$topCategory = Mage::getResourceModel('catalog/category_collection')
|
70 |
-
->addIdFilter($order_item->getProduct()->getCategoryIds())
|
71 |
-
->setOrder('level', 'ASC')
|
72 |
-
->setPage(1, 1)
|
73 |
-
->getFirstItem();
|
74 |
-
$topCategoryId = $topCategory->getId();
|
75 |
-
$item['category_id'] = $topCategoryId;
|
76 |
-
//model product and load product with product id
|
77 |
-
$model_product = Mage::getModel('catalog/product');
|
78 |
-
$_productObject = $model_product->load($order_item->getProduct()->getId());
|
79 |
-
//end model product and load product with product id
|
80 |
-
if ($_productObject->getAttributeText('manufacturer')) {
|
81 |
-
$item['manufacturer_id'] = $_productObject->getAttributeText('manufacturer');
|
82 |
-
} else {
|
83 |
-
$item['manufacturer_id'] = 1;
|
84 |
-
}
|
85 |
-
//end get category id
|
86 |
-
$item['product_name'] = $_productObject->getName();
|
87 |
-
|
88 |
-
//$_productObject->getAttributeText(‘manufacturer’)
|
89 |
-
|
90 |
-
|
91 |
-
$item['reference'] = 'reference';
|
92 |
-
//$item['reference'] = $value['reference'];
|
93 |
-
array_push($the_cart, $item);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
//config sdk
|
98 |
-
$req = new LuckyCycleApi('https://www.luckycycle.com');
|
99 |
-
$req->setApiKey($apiKey);
|
100 |
-
$req->setOperationId($operationKey);
|
101 |
-
//Mage::log("language : (string)$language"." / " ."currency: ".$currencyCode);
|
102 |
-
//Mage::log("Item value".$amount);
|
103 |
-
$pokedata = array(
|
104 |
-
'user_uid' => (string)$customerId,
|
105 |
-
'item_uid' => (string)$orderId,
|
106 |
-
'item_value' => (string)$amount,
|
107 |
-
'item_currency' => (string)$currencyCode,
|
108 |
-
'language' => (string)$language,
|
109 |
-
'firstname' => (string)$firstName,
|
110 |
-
'lastname' => (string)$lastName,
|
111 |
-
'email' => (string)$emailCustomer,
|
112 |
-
'cart' => $the_cart
|
113 |
-
);
|
114 |
-
//end sdk
|
115 |
-
//Mage::log($pokedata);
|
116 |
-
try {
|
117 |
-
$poke = $req->poke($pokedata);
|
118 |
-
//Mage::log($poke);
|
119 |
-
if ($poke && $poke['can_play'] == true) {
|
120 |
-
$model_luckycycle = Mage::getModel('snippetsdk/luckycycle')->getCollection()
|
121 |
-
->addFieldToFilter('hash', $poke['computed_hash']);
|
122 |
-
$flagCheckHashExits = count($model_luckycycle);
|
123 |
-
if ($flagCheckHashExits == 0) {
|
124 |
-
$insertLuckycycle = Mage::getModel('snippetsdk/luckycycle');
|
125 |
-
$insertLuckycycle->setHash($poke['computed_hash']);
|
126 |
-
$insertLuckycycle->setBannerUrl($poke['banner_url']);
|
127 |
-
$insertLuckycycle->setIdOrder($orderId);
|
128 |
-
$insertLuckycycle->setOperationId($operationKey);
|
129 |
-
$insertLuckycycle->setType('basket');
|
130 |
-
$insertLuckycycle->setIdCustomer($customerId);
|
131 |
-
$insertLuckycycle->setCreateAt(date('Y-m-d H:i:s'));
|
132 |
-
$insertLuckycycle->setTotalPlayed($real_paid);
|
133 |
-
$insertLuckycycle->save();
|
134 |
-
?>
|
135 |
-
<div id="content-api-luckycycle">
|
136 |
-
<?php
|
137 |
-
if (isset($before_information)) {
|
138 |
-
echo "<div>" . $before_information . "</div>";
|
139 |
-
}
|
140 |
-
if ($useImage) {
|
141 |
-
if ($poke['banner_url'] == null) {
|
142 |
-
if ($banner_default != null) {
|
143 |
-
?>
|
144 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank"
|
145 |
-
id="lc_banner_url">
|
146 |
-
<img
|
147 |
-
src="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . '/media' . '/upload/' . $banner_default; ?>"
|
148 |
-
<?php if ($iframe_width) { ?> width="<?php echo $iframe_width . 'px' ?>" <?php } ?>
|
149 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height . 'px' ?>" <?php } ?>
|
150 |
-
style="margin: auto; max-width: 98%"/>
|
151 |
-
</a>
|
152 |
-
<?php
|
153 |
-
} else {
|
154 |
-
$urlNoImage = Mage::helper('catalog/image')->init(Mage::getModel('catalog/product'), 'image');
|
155 |
-
?>
|
156 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank"
|
157 |
-
id="lc_banner_url">
|
158 |
-
<img
|
159 |
-
src="<?php echo $urlNoImage ?>" <?php if ($iframe_width) { ?> width="<?php echo $iframe_width . 'px' ?>" <?php } ?>
|
160 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height . 'px' ?>" <?php } ?>
|
161 |
-
style="margin: auto; max-width: 98%"/>
|
162 |
-
</a>
|
163 |
-
<?php
|
164 |
-
}
|
165 |
-
} else {
|
166 |
-
?>
|
167 |
-
<a href="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>" target="_blank"
|
168 |
-
id="lc_banner_url">
|
169 |
-
<img
|
170 |
-
src="<?php echo $poke['banner_url'] ?>" <?php if ($iframe_width) { ?> width="<?php echo $iframe_width . 'px' ?>" <?php } ?>
|
171 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height . 'px' ?>" <?php } ?>
|
172 |
-
style="margin: auto; max-width: 98%"/>
|
173 |
-
</a>
|
174 |
-
<?php
|
175 |
-
}
|
176 |
-
} else {
|
177 |
-
?>
|
178 |
-
<div style="text-align: center">
|
179 |
-
<iframe frameborder="0"
|
180 |
-
src="http://www.luckycycle.com/play/<?php echo $poke['computed_hash'] ?>"
|
181 |
-
target="_blank"
|
182 |
-
align="center"
|
183 |
-
scrolling="no"
|
184 |
-
style="margin: auto; max-width: 98%"
|
185 |
-
<?php if ($iframe_width) { ?> width="<?php echo $iframe_width . 'px' ?>" <?php } ?>
|
186 |
-
<?php if ($iframe_height) { ?> height="<?php echo $iframe_height . 'px' ?>" <?php } ?>
|
187 |
-
id="luckycycle_iframe"></iframe>
|
188 |
-
</div>
|
189 |
-
<?php
|
190 |
-
}
|
191 |
-
if (isset($after_information)) {
|
192 |
-
echo "<div>" . $after_information . "</div>";
|
193 |
-
}
|
194 |
-
?>
|
195 |
-
</div>
|
196 |
-
<script type="text/javascript">
|
197 |
-
var luckyCycleHtml = document.getElementById('content-api-luckycycle')
|
198 |
-
var luckyCycleApi = document.getElementById('api-frame-luckycycle')
|
199 |
-
if (luckyCycleApi) {
|
200 |
-
luckyCycleApi.innerHTML = luckyCycleHtml.innerHTML;
|
201 |
-
luckyCycleHtml.remove();
|
202 |
-
}
|
203 |
-
</script>
|
204 |
-
<?php
|
205 |
-
} else {
|
206 |
-
Mage::log('Poke added in DB');
|
207 |
-
}
|
208 |
-
} else {
|
209 |
-
Mage::log("we didn't get a poke back, user cannot play on this order or an error happened");
|
210 |
-
}
|
211 |
-
} catch (Exception $e) {
|
212 |
-
Mage::log($e->getMessage());
|
213 |
-
|
214 |
-
}
|
215 |
-
} else {
|
216 |
-
Mage::log("Api key,operation key or payment method null ");
|
217 |
-
}
|
218 |
-
} else {
|
219 |
-
Mage::log("Luckycycle module is not enable");
|
220 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/Luckycycle/success.phtml
DELETED
@@ -1,66 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Magento
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/afl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* DISCLAIMER
|
16 |
-
*
|
17 |
-
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
-
* versions in the future. If you wish to customize Magento for your
|
19 |
-
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
-
*
|
21 |
-
* @category design
|
22 |
-
* @package base_default
|
23 |
-
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
|
24 |
-
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
-
*/
|
26 |
-
?>
|
27 |
-
<div class="page-title">
|
28 |
-
<h1><?php echo $this->__('Your order has been received.') ?></h1>
|
29 |
-
</div>
|
30 |
-
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
|
31 |
-
<h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
|
32 |
-
|
33 |
-
<?php if ($this->getOrderId()):?>
|
34 |
-
<?php if ($this->getCanViewOrder()) :?>
|
35 |
-
<p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
|
36 |
-
<?php else :?>
|
37 |
-
<p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
|
38 |
-
<?php endif;?>
|
39 |
-
<p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
|
40 |
-
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
|
41 |
-
<p>
|
42 |
-
<?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
|
43 |
-
<?php echo $this->getChildHtml() ?>
|
44 |
-
</p>
|
45 |
-
<?php endif;?>
|
46 |
-
<?php endif;?>
|
47 |
-
|
48 |
-
<?php if ($this->getAgreementRefId()): ?>
|
49 |
-
<p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
|
50 |
-
<?php endif;?>
|
51 |
-
|
52 |
-
<?php if ($profiles = $this->getRecurringProfiles()):?>
|
53 |
-
<p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
|
54 |
-
<ul class="disc">
|
55 |
-
<?php foreach($profiles as $profile):?>
|
56 |
-
<?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
|
57 |
-
<li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
|
58 |
-
<?php endforeach;?>
|
59 |
-
</ul>
|
60 |
-
<?php endif;?>
|
61 |
-
<!--Frame LuckyCycle-->
|
62 |
-
<div id="api-frame-luckycycle" style="text-align: center"></div>
|
63 |
-
|
64 |
-
<div class="buttons-set">
|
65 |
-
<button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
|
66 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/Luckycycle_Snippetsdk.xml
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
<config>
|
2 |
-
<modules>
|
3 |
-
<Luckycycle_Snippetsdk>
|
4 |
-
<active>true</active>
|
5 |
-
<codePool>community</codePool>
|
6 |
-
</Luckycycle_Snippetsdk>
|
7 |
-
</modules>
|
8 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/.gitignore
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
/vendor/
|
2 |
-
.idea
|
|
|
|
lib/luckysdk/Pest.php
DELETED
@@ -1,564 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Pest is a REST client for PHP.
|
4 |
-
*
|
5 |
-
* See http://github.com/educoder/pest for details.
|
6 |
-
*
|
7 |
-
* This code is licensed for use, modification, and distribution
|
8 |
-
* under the terms of the MIT License (see http://en.wikipedia.org/wiki/MIT_License)
|
9 |
-
*/
|
10 |
-
class Pest
|
11 |
-
{
|
12 |
-
/**
|
13 |
-
* @var array Default CURL options
|
14 |
-
*/
|
15 |
-
public $curl_opts = array(
|
16 |
-
CURLOPT_RETURNTRANSFER => true, // return result instead of echoing
|
17 |
-
CURLOPT_SSL_VERIFYPEER => false, // stop cURL from verifying the peer's certificate
|
18 |
-
CURLOPT_FOLLOWLOCATION => false, // follow redirects, Location: headers
|
19 |
-
CURLOPT_MAXREDIRS => 10, // but dont redirect more than 10 times
|
20 |
-
CURLOPT_HTTPHEADER => array()
|
21 |
-
);
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @var string Base URL
|
25 |
-
*/
|
26 |
-
public $base_url;
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var array Last response
|
30 |
-
*/
|
31 |
-
public $last_response;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var array Last request
|
35 |
-
*/
|
36 |
-
public $last_request;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var array Last headers
|
40 |
-
*/
|
41 |
-
public $last_headers;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var bool Throw exceptions on HTTP error codes
|
45 |
-
*/
|
46 |
-
public $throw_exceptions = true;
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Class constructor
|
51 |
-
* @param string $base_url
|
52 |
-
* @throws Exception
|
53 |
-
*/
|
54 |
-
public function __construct($base_url)
|
55 |
-
{
|
56 |
-
if (!function_exists('curl_init')) {
|
57 |
-
throw new Exception('CURL module not available! Pest requires CURL. See http://php.net/manual/en/book.curl.php');
|
58 |
-
}
|
59 |
-
|
60 |
-
/*
|
61 |
-
* Only enable CURLOPT_FOLLOWLOCATION if safe_mode and open_base_dir are
|
62 |
-
* not in use
|
63 |
-
*/
|
64 |
-
if (ini_get('open_basedir') == '' && strtolower(ini_get('safe_mode')) == 'off') {
|
65 |
-
$this->curl_opts['CURLOPT_FOLLOWLOCATION'] = true;
|
66 |
-
}
|
67 |
-
|
68 |
-
$this->base_url = $base_url;
|
69 |
-
|
70 |
-
// The callback to handle return headers
|
71 |
-
// Using PHP 5.2, it cannot be initialised in the static context
|
72 |
-
$this->curl_opts[CURLOPT_HEADERFUNCTION] = array($this, 'handle_header');
|
73 |
-
}
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Setup authentication
|
77 |
-
*
|
78 |
-
* @param string $user
|
79 |
-
* @param string $pass
|
80 |
-
* @param string $auth Can be 'basic' or 'digest'
|
81 |
-
*/
|
82 |
-
public function setupAuth($user, $pass, $auth = 'basic')
|
83 |
-
{
|
84 |
-
$this->curl_opts[CURLOPT_HTTPAUTH] = constant('CURLAUTH_' . strtoupper($auth));
|
85 |
-
$this->curl_opts[CURLOPT_USERPWD] = $user . ":" . $pass;
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Setup proxy
|
90 |
-
* @param string $host
|
91 |
-
* @param int $port
|
92 |
-
* @param string $user Optional.
|
93 |
-
* @param string $pass Optional.
|
94 |
-
*/
|
95 |
-
public function setupProxy($host, $port, $user = NULL, $pass = NULL)
|
96 |
-
{
|
97 |
-
$this->curl_opts[CURLOPT_PROXYTYPE] = 'HTTP';
|
98 |
-
$this->curl_opts[CURLOPT_PROXY] = $host;
|
99 |
-
$this->curl_opts[CURLOPT_PROXYPORT] = $port;
|
100 |
-
if ($user && $pass) {
|
101 |
-
$this->curl_opts[CURLOPT_PROXYUSERPWD] = $user . ":" . $pass;
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Perform HTTP GET request
|
107 |
-
*
|
108 |
-
* @param string $url
|
109 |
-
* @param array $data
|
110 |
-
* @param array $headers
|
111 |
-
* @return string
|
112 |
-
*/
|
113 |
-
public function get($url, $data = array(), $headers=array())
|
114 |
-
{
|
115 |
-
if (!empty($data)) {
|
116 |
-
$pos = strpos($url, '?');
|
117 |
-
if ($pos !== false) {
|
118 |
-
$url = substr($url, 0, $pos);
|
119 |
-
}
|
120 |
-
$url .= '?' . http_build_query($data);
|
121 |
-
}
|
122 |
-
|
123 |
-
$curl_opts = $this->curl_opts;
|
124 |
-
|
125 |
-
$curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers);
|
126 |
-
|
127 |
-
$curl = $this->prepRequest($curl_opts, $url);
|
128 |
-
$body = $this->doRequest($curl);
|
129 |
-
$body = $this->processBody($body);
|
130 |
-
|
131 |
-
return $body;
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* Prepare request
|
136 |
-
*
|
137 |
-
* @param array $opts
|
138 |
-
* @param string $url
|
139 |
-
* @return resource
|
140 |
-
* @throws Pest_Curl_Init
|
141 |
-
*/
|
142 |
-
protected function prepRequest($opts, $url)
|
143 |
-
{
|
144 |
-
if (strncmp($url, $this->base_url, strlen($this->base_url)) != 0) {
|
145 |
-
$url = rtrim($this->base_url, '/') . '/' . ltrim($url, '/');
|
146 |
-
}
|
147 |
-
|
148 |
-
$curl = curl_init($url);
|
149 |
-
if ($curl === false) {
|
150 |
-
throw new Pest_Curl_Init($this->processError(curl_error($curl), 'curl'));
|
151 |
-
}
|
152 |
-
|
153 |
-
foreach ($opts as $opt => $val)
|
154 |
-
curl_setopt($curl, $opt, $val);
|
155 |
-
|
156 |
-
$this->last_request = array(
|
157 |
-
'url' => $url
|
158 |
-
);
|
159 |
-
|
160 |
-
if (isset($opts[CURLOPT_CUSTOMREQUEST]))
|
161 |
-
$this->last_request['method'] = $opts[CURLOPT_CUSTOMREQUEST];
|
162 |
-
else
|
163 |
-
$this->last_request['method'] = 'GET';
|
164 |
-
|
165 |
-
if (isset($opts[CURLOPT_POSTFIELDS]))
|
166 |
-
$this->last_request['data'] = $opts[CURLOPT_POSTFIELDS];
|
167 |
-
|
168 |
-
return $curl;
|
169 |
-
}
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Determines if a given array is numerically indexed or not
|
173 |
-
*
|
174 |
-
* @param array $array
|
175 |
-
* @return boolean
|
176 |
-
*/
|
177 |
-
protected function _isNumericallyIndexedArray($array)
|
178 |
-
{
|
179 |
-
return !(bool)count(array_filter(array_keys($array), 'is_string'));
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* Flatten headers from an associative array to a numerically indexed array of "Name: Value"
|
184 |
-
* style entries like CURLOPT_HTTPHEADER expects. Numerically indexed arrays are not modified.
|
185 |
-
*
|
186 |
-
* @param array $headers
|
187 |
-
* @return array
|
188 |
-
*/
|
189 |
-
protected function prepHeaders($headers)
|
190 |
-
{
|
191 |
-
if ($this->_isNumericallyIndexedArray($headers)) {
|
192 |
-
return $headers;
|
193 |
-
}
|
194 |
-
|
195 |
-
$flattened = array();
|
196 |
-
foreach ($headers as $name => $value) {
|
197 |
-
$flattened[] = $name . ': ' . $value;
|
198 |
-
}
|
199 |
-
|
200 |
-
return $flattened;
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Process error
|
205 |
-
* @param string $body
|
206 |
-
* @return string
|
207 |
-
*/
|
208 |
-
protected function processError($body)
|
209 |
-
{
|
210 |
-
// Override this in classes that extend Pest.
|
211 |
-
// The body of every erroneous (non-2xx/3xx) GET/POST/PUT/DELETE
|
212 |
-
// response goes through here prior to being used as the 'message'
|
213 |
-
// of the resulting Pest_Exception
|
214 |
-
return $body;
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Do CURL request
|
219 |
-
* @param resource $curl
|
220 |
-
* @return mixed
|
221 |
-
* @throws Pest_Curl_Exec
|
222 |
-
* @throws Pest_Curl_Meta
|
223 |
-
*/
|
224 |
-
private function doRequest($curl)
|
225 |
-
{
|
226 |
-
$this->last_headers = array();
|
227 |
-
$this->last_response = array();
|
228 |
-
|
229 |
-
// curl_error() needs to be tested right after function failure
|
230 |
-
$this->last_response["body"] = curl_exec($curl);
|
231 |
-
if ($this->last_response["body"] === false && $this->throw_exceptions) {
|
232 |
-
throw new Pest_Curl_Exec(curl_error($curl));
|
233 |
-
}
|
234 |
-
|
235 |
-
$this->last_response["meta"] = curl_getinfo($curl);
|
236 |
-
if ($this->last_response["meta"] === false && $this->throw_exceptions) {
|
237 |
-
throw new Pest_Curl_Meta(curl_error($curl));
|
238 |
-
}
|
239 |
-
|
240 |
-
curl_close($curl);
|
241 |
-
|
242 |
-
$this->checkLastResponseForError();
|
243 |
-
|
244 |
-
return $this->last_response["body"];
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Check last response for error
|
249 |
-
*
|
250 |
-
* @throws Pest_Conflict
|
251 |
-
* @throws Pest_Gone
|
252 |
-
* @throws Pest_Unauthorized
|
253 |
-
* @throws Pest_ClientError
|
254 |
-
* @throws Pest_MethodNotAllowed
|
255 |
-
* @throws Pest_NotFound
|
256 |
-
* @throws Pest_BadRequest
|
257 |
-
* @throws Pest_UnknownResponse
|
258 |
-
* @throws Pest_InvalidRecord
|
259 |
-
* @throws Pest_ServerError
|
260 |
-
* @throws Pest_Forbidden
|
261 |
-
*/
|
262 |
-
protected function checkLastResponseForError()
|
263 |
-
{
|
264 |
-
if (!$this->throw_exceptions)
|
265 |
-
return;
|
266 |
-
|
267 |
-
$meta = $this->last_response['meta'];
|
268 |
-
$body = $this->last_response['body'];
|
269 |
-
//var_dump($body);exit();
|
270 |
-
if ($meta === false)
|
271 |
-
return;
|
272 |
-
|
273 |
-
$err = null;
|
274 |
-
switch ($meta['http_code']) {
|
275 |
-
case 400:
|
276 |
-
throw new Pest_BadRequest($this->processError($body));
|
277 |
-
break;
|
278 |
-
case 401:
|
279 |
-
throw new Pest_Unauthorized($this->processError($body));
|
280 |
-
break;
|
281 |
-
case 403:
|
282 |
-
throw new Pest_Forbidden($this->processError($body));
|
283 |
-
break;
|
284 |
-
case 404:
|
285 |
-
throw new Pest_NotFound($this->processError($body));
|
286 |
-
break;
|
287 |
-
case 405:
|
288 |
-
throw new Pest_MethodNotAllowed($this->processError($body));
|
289 |
-
break;
|
290 |
-
case 409:
|
291 |
-
throw new Pest_Conflict($this->processError($body));
|
292 |
-
break;
|
293 |
-
case 410:
|
294 |
-
throw new Pest_Gone($this->processError($body));
|
295 |
-
break;
|
296 |
-
case 422:
|
297 |
-
// Unprocessable Entity -- see http://www.iana.org/assignments/http-status-codes
|
298 |
-
// This is now commonly used (in Rails, at least) to indicate
|
299 |
-
// a response to a request that is syntactically correct,
|
300 |
-
// but semantically invalid (for example, when trying to
|
301 |
-
// create a resource with some required fields missing)
|
302 |
-
throw new Pest_InvalidRecord($this->processError($body));
|
303 |
-
break;
|
304 |
-
default:
|
305 |
-
if ($meta['http_code'] >= 400 && $meta['http_code'] <= 499)
|
306 |
-
throw new Pest_ClientError($this->processError($body));
|
307 |
-
elseif ($meta['http_code'] >= 500 && $meta['http_code'] <= 599)
|
308 |
-
throw new Pest_ServerError($this->processError($body)); elseif (!isset($meta['http_code']) || $meta['http_code'] >= 600) {
|
309 |
-
throw new Pest_UnknownResponse($this->processError($body));
|
310 |
-
}
|
311 |
-
}
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Process body
|
316 |
-
* @param string $body
|
317 |
-
* @return string
|
318 |
-
*/
|
319 |
-
protected function processBody($body)
|
320 |
-
{
|
321 |
-
// Override this in classes that extend Pest.
|
322 |
-
// The body of every GET/POST/PUT/DELETE response goes through
|
323 |
-
// here prior to being returned.
|
324 |
-
return $body;
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Perform HTTP HEAD request
|
329 |
-
* @param string $url
|
330 |
-
* @return string
|
331 |
-
*/
|
332 |
-
public function head($url)
|
333 |
-
{
|
334 |
-
$curl_opts = $this->curl_opts;
|
335 |
-
$curl_opts[CURLOPT_NOBODY] = true;
|
336 |
-
|
337 |
-
$curl = $this->prepRequest($this->curl_opts, $url);
|
338 |
-
$body = $this->doRequest($curl);
|
339 |
-
|
340 |
-
$body = $this->processBody($body);
|
341 |
-
|
342 |
-
return $body;
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Perform HTTP POST request
|
347 |
-
*
|
348 |
-
* @param string $url
|
349 |
-
* @param array $data
|
350 |
-
* @param array $headers
|
351 |
-
* @return string
|
352 |
-
*/
|
353 |
-
public function post($url, $data, $headers = array())
|
354 |
-
{
|
355 |
-
$data = $this->prepData($data);
|
356 |
-
|
357 |
-
$curl_opts = $this->curl_opts;
|
358 |
-
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'POST';
|
359 |
-
if (!is_array($data)) $headers[] = 'Content-Length: ' . strlen($data);
|
360 |
-
$curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers);
|
361 |
-
$curl_opts[CURLOPT_POSTFIELDS] = $data;
|
362 |
-
|
363 |
-
$curl = $this->prepRequest($curl_opts, $url);
|
364 |
-
$body = $this->doRequest($curl);
|
365 |
-
|
366 |
-
$body = $this->processBody($body);
|
367 |
-
|
368 |
-
return $body;
|
369 |
-
}
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Prepare data
|
373 |
-
* @param array $data
|
374 |
-
* @return array|string
|
375 |
-
*/
|
376 |
-
public function prepData($data)
|
377 |
-
{
|
378 |
-
if (is_array($data)) {
|
379 |
-
$multipart = false;
|
380 |
-
|
381 |
-
foreach ($data as $item) {
|
382 |
-
if (is_string($item) && strncmp($item, "@", 1) == 0 && is_file(substr($item, 1))) {
|
383 |
-
$multipart = true;
|
384 |
-
break;
|
385 |
-
}
|
386 |
-
}
|
387 |
-
|
388 |
-
return ($multipart) ? $data : http_build_query($data);
|
389 |
-
} else {
|
390 |
-
return $data;
|
391 |
-
}
|
392 |
-
}
|
393 |
-
|
394 |
-
/**
|
395 |
-
* Perform HTTP PUT request
|
396 |
-
*
|
397 |
-
* @param string $url
|
398 |
-
* @param array $data
|
399 |
-
* @param array $headers
|
400 |
-
* @return string
|
401 |
-
*/
|
402 |
-
public function put($url, $data, $headers = array())
|
403 |
-
{
|
404 |
-
$data = $this->prepData($data);
|
405 |
-
|
406 |
-
$curl_opts = $this->curl_opts;
|
407 |
-
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'PUT';
|
408 |
-
if (!is_array($data)) $headers[] = 'Content-Length: ' . strlen($data);
|
409 |
-
$curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers);
|
410 |
-
$curl_opts[CURLOPT_POSTFIELDS] = $data;
|
411 |
-
|
412 |
-
$curl = $this->prepRequest($curl_opts, $url);
|
413 |
-
$body = $this->doRequest($curl);
|
414 |
-
|
415 |
-
$body = $this->processBody($body);
|
416 |
-
|
417 |
-
return $body;
|
418 |
-
}
|
419 |
-
|
420 |
-
/**
|
421 |
-
* Perform HTTP PATCH request
|
422 |
-
*
|
423 |
-
* @param string $url
|
424 |
-
* @param array $data
|
425 |
-
* @param array $headers
|
426 |
-
* @return string
|
427 |
-
*/
|
428 |
-
public function patch($url, $data, $headers = array())
|
429 |
-
{
|
430 |
-
$data = (is_array($data)) ? http_build_query($data) : $data;
|
431 |
-
|
432 |
-
$curl_opts = $this->curl_opts;
|
433 |
-
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'PATCH';
|
434 |
-
$headers[] = 'Content-Length: ' . strlen($data);
|
435 |
-
$curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers);
|
436 |
-
$curl_opts[CURLOPT_POSTFIELDS] = $data;
|
437 |
-
|
438 |
-
$curl = $this->prepRequest($curl_opts, $url);
|
439 |
-
$body = $this->doRequest($curl);
|
440 |
-
|
441 |
-
$body = $this->processBody($body);
|
442 |
-
|
443 |
-
return $body;
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Perform HTTP DELETE request
|
448 |
-
*
|
449 |
-
* @param string $url
|
450 |
-
* @param array $headers
|
451 |
-
* @return string
|
452 |
-
*/
|
453 |
-
public function delete($url, $headers=array())
|
454 |
-
{
|
455 |
-
$curl_opts = $this->curl_opts;
|
456 |
-
$curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE';
|
457 |
-
$curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers);
|
458 |
-
|
459 |
-
$curl = $this->prepRequest($curl_opts, $url);
|
460 |
-
$body = $this->doRequest($curl);
|
461 |
-
|
462 |
-
$body = $this->processBody($body);
|
463 |
-
|
464 |
-
return $body;
|
465 |
-
}
|
466 |
-
|
467 |
-
/**
|
468 |
-
* Get last response body
|
469 |
-
*
|
470 |
-
* @return string
|
471 |
-
*/
|
472 |
-
public function lastBody()
|
473 |
-
{
|
474 |
-
return $this->last_response['body'];
|
475 |
-
}
|
476 |
-
|
477 |
-
/**
|
478 |
-
* Get last response status
|
479 |
-
*
|
480 |
-
* @return int
|
481 |
-
*/
|
482 |
-
public function lastStatus()
|
483 |
-
{
|
484 |
-
return $this->last_response['meta']['http_code'];
|
485 |
-
}
|
486 |
-
|
487 |
-
/**
|
488 |
-
* Return the last response header (case insensitive) or NULL if not present.
|
489 |
-
* HTTP allows empty headers (e.g. RFC 2616, Section 14.23), thus is_null()
|
490 |
-
* and not negation or empty() should be used.
|
491 |
-
*
|
492 |
-
* @param string $header
|
493 |
-
* @return string
|
494 |
-
*/
|
495 |
-
public function lastHeader($header)
|
496 |
-
{
|
497 |
-
if (empty($this->last_headers[strtolower($header)])) {
|
498 |
-
return NULL;
|
499 |
-
}
|
500 |
-
return $this->last_headers[strtolower($header)];
|
501 |
-
}
|
502 |
-
|
503 |
-
/**
|
504 |
-
* Handle header
|
505 |
-
* @param $ch
|
506 |
-
* @param $str
|
507 |
-
* @return int
|
508 |
-
*/
|
509 |
-
private function handle_header($ch, $str)
|
510 |
-
{
|
511 |
-
if (preg_match('/([^:]+):\s(.+)/m', $str, $match)) {
|
512 |
-
$this->last_headers[strtolower($match[1])] = trim($match[2]);
|
513 |
-
}
|
514 |
-
return strlen($str);
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
class Pest_Exception extends Exception
|
519 |
-
{}
|
520 |
-
class Pest_UnknownResponse extends Pest_Exception
|
521 |
-
{}
|
522 |
-
|
523 |
-
// HTTP Errors
|
524 |
-
/* 401-499 */
|
525 |
-
class Pest_ClientError extends Pest_Exception
|
526 |
-
{}
|
527 |
-
/* 400 */
|
528 |
-
class Pest_BadRequest extends Pest_ClientError
|
529 |
-
{}
|
530 |
-
/* 401 */
|
531 |
-
class Pest_Unauthorized extends Pest_ClientError
|
532 |
-
{}
|
533 |
-
/* 403 */
|
534 |
-
class Pest_Forbidden extends Pest_ClientError
|
535 |
-
{}
|
536 |
-
/* 404 */
|
537 |
-
class Pest_NotFound extends Pest_ClientError
|
538 |
-
{}
|
539 |
-
/* 405 */
|
540 |
-
class Pest_MethodNotAllowed extends Pest_ClientError
|
541 |
-
{}
|
542 |
-
/* 409 */
|
543 |
-
class Pest_Conflict extends Pest_ClientError
|
544 |
-
{}
|
545 |
-
/* 410 */
|
546 |
-
class Pest_Gone extends Pest_ClientError
|
547 |
-
{}
|
548 |
-
/* 422 */
|
549 |
-
class Pest_InvalidRecord extends Pest_ClientError
|
550 |
-
{}
|
551 |
-
/* 500-599 */
|
552 |
-
class Pest_ServerError extends Pest_ClientError
|
553 |
-
{}
|
554 |
-
|
555 |
-
// CURL Errors
|
556 |
-
/* init */
|
557 |
-
class Pest_Curl_Init extends Pest_Exception
|
558 |
-
{}
|
559 |
-
/* meta */
|
560 |
-
class Pest_Curl_Meta extends Pest_Exception
|
561 |
-
{}
|
562 |
-
/* exec */
|
563 |
-
class Pest_Curl_Exec extends Pest_Exception
|
564 |
-
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/PestJSON.php
DELETED
@@ -1,196 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Pest is a REST client for PHP.
|
4 |
-
*
|
5 |
-
* PestJSON adds JSON-specific functionality to Pest, automatically converting
|
6 |
-
* JSON data resturned from REST services into PHP arrays and vice versa.
|
7 |
-
*
|
8 |
-
* In other words, while Pest's get/post/put/delete calls return raw strings,
|
9 |
-
* PestJSON return (associative) arrays.
|
10 |
-
*
|
11 |
-
* In case of >= 400 status codes, an exception is thrown with $e->getMessage()
|
12 |
-
* containing the error message that the server produced. User code will have to
|
13 |
-
* json_decode() that manually, if applicable, because the PHP Exception base
|
14 |
-
* class does not accept arrays for the exception message and some JSON/REST servers
|
15 |
-
* do not produce nice JSON
|
16 |
-
*
|
17 |
-
* If you don't want to have exceptions thrown when there are errors encoding or
|
18 |
-
* decoding JSON set the `throwEncodingExceptions` property to FALSE.
|
19 |
-
*
|
20 |
-
* See http://github.com/educoder/pest for details.
|
21 |
-
*
|
22 |
-
* This code is licensed for use, modification, and distribution
|
23 |
-
* under the terms of the MIT License (see http://en.wikipedia.org/wiki/MIT_License)
|
24 |
-
*/
|
25 |
-
|
26 |
-
require_once 'Pest.php';
|
27 |
-
|
28 |
-
class PestJSON extends Pest
|
29 |
-
{
|
30 |
-
const JSON_ERROR_UNKNOWN = 1000;
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var bool Throw exceptions on JSON encoding errors?
|
34 |
-
*/
|
35 |
-
public $throwJsonExceptions = true;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Perform an HTTP POST
|
39 |
-
*
|
40 |
-
* @param string $url
|
41 |
-
* @param array $data
|
42 |
-
* @param array $headers
|
43 |
-
* @return string
|
44 |
-
*/
|
45 |
-
public function post($url, $data, $headers = array())
|
46 |
-
{
|
47 |
-
return parent::post($url, $this->jsonEncode($data), $headers);
|
48 |
-
}
|
49 |
-
|
50 |
-
/**
|
51 |
-
* Perform HTTP PUT
|
52 |
-
*
|
53 |
-
* @param string $url
|
54 |
-
* @param array $data
|
55 |
-
* @param array $headers
|
56 |
-
* @return string
|
57 |
-
*/
|
58 |
-
public function put($url, $data, $headers = array())
|
59 |
-
{
|
60 |
-
return parent::put($url, $this->jsonEncode($data), $headers);
|
61 |
-
}
|
62 |
-
|
63 |
-
/**
|
64 |
-
* JSON encode with error checking
|
65 |
-
*
|
66 |
-
* @param mixed $data
|
67 |
-
* @return string
|
68 |
-
* @throws Pest_Json_Encode
|
69 |
-
*/
|
70 |
-
public function jsonEncode($data)
|
71 |
-
{
|
72 |
-
$ret = json_encode($data);
|
73 |
-
|
74 |
-
if ($ret === false && $this->throwJsonExceptions) {
|
75 |
-
throw new Pest_Json_Encode(
|
76 |
-
'Encoding error: ' . $this->getLastJsonErrorMessage(),
|
77 |
-
$this->getLastJsonErrorCode()
|
78 |
-
);
|
79 |
-
}
|
80 |
-
|
81 |
-
return $ret;
|
82 |
-
}
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Decode a JSON string with error checking
|
86 |
-
*
|
87 |
-
* @param string $data
|
88 |
-
* @param bool $asArray
|
89 |
-
* @throws Pest_Json_Decode
|
90 |
-
* @return mixed
|
91 |
-
*/
|
92 |
-
public function jsonDecode($data, $asArray=true)
|
93 |
-
{
|
94 |
-
$ret = json_decode($data, $asArray);
|
95 |
-
|
96 |
-
if ($ret === false && $this->throwJsonExceptions) {
|
97 |
-
throw new Pest_Json_Decode(
|
98 |
-
'Decoding error: ' . $this->getLastJsonErrorMessage(),
|
99 |
-
$this->getLastJsonErrorCode()
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
return $ret;
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Get last JSON error message
|
108 |
-
*
|
109 |
-
* @return string
|
110 |
-
*/
|
111 |
-
public function getLastJsonErrorMessage()
|
112 |
-
{
|
113 |
-
// For PHP < 5.3, just return "Unknown"
|
114 |
-
if (!function_exists('json_last_error')) {
|
115 |
-
return "Unknown";
|
116 |
-
}
|
117 |
-
|
118 |
-
// Use the newer JSON error message function if it exists
|
119 |
-
if (function_exists('json_last_error_msg')) {
|
120 |
-
return(json_last_error_msg());
|
121 |
-
}
|
122 |
-
|
123 |
-
$lastError = json_last_error();
|
124 |
-
|
125 |
-
// PHP 5.3+ only
|
126 |
-
if (defined('JSON_ERROR_UTF8') && $lastError === JSON_ERROR_UTF8) {
|
127 |
-
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
|
128 |
-
}
|
129 |
-
|
130 |
-
switch ($lastError) {
|
131 |
-
case JSON_ERROR_DEPTH:
|
132 |
-
return 'Maximum stack depth exceeded';
|
133 |
-
break;
|
134 |
-
case JSON_ERROR_STATE_MISMATCH:
|
135 |
-
return 'Underflow or the modes mismatch';
|
136 |
-
break;
|
137 |
-
case JSON_ERROR_CTRL_CHAR:
|
138 |
-
return 'Unexpected control character found';
|
139 |
-
break;
|
140 |
-
case JSON_ERROR_SYNTAX:
|
141 |
-
return 'Syntax error, malformed JSON';
|
142 |
-
break;
|
143 |
-
default:
|
144 |
-
return 'Unknown';
|
145 |
-
break;
|
146 |
-
}
|
147 |
-
}
|
148 |
-
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Get last JSON error code
|
152 |
-
* @return int|null
|
153 |
-
*/
|
154 |
-
public function getLastJsonErrorCode()
|
155 |
-
{
|
156 |
-
// For PHP < 5.3, just return the PEST code for unknown errors
|
157 |
-
if (!function_exists('json_last_error')) {
|
158 |
-
return self::JSON_ERROR_UNKNOWN;
|
159 |
-
}
|
160 |
-
|
161 |
-
return json_last_error();
|
162 |
-
}
|
163 |
-
|
164 |
-
/**
|
165 |
-
* Process body
|
166 |
-
* @param string $body
|
167 |
-
* @return mixed|string
|
168 |
-
*/
|
169 |
-
public function processBody($body)
|
170 |
-
{
|
171 |
-
return $this->jsonDecode($body);
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* Prepare request
|
176 |
-
*
|
177 |
-
* @param array $opts
|
178 |
-
* @param string $url
|
179 |
-
* @return resource
|
180 |
-
*/
|
181 |
-
protected function prepRequest($opts, $url)
|
182 |
-
{
|
183 |
-
$opts[CURLOPT_HTTPHEADER][] = 'Accept: application/json';
|
184 |
-
$opts[CURLOPT_HTTPHEADER][] = 'Content-Type: application/json';
|
185 |
-
return parent::prepRequest($opts, $url);
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
// JSON Errors
|
190 |
-
/* decode */
|
191 |
-
class Pest_Json_Decode extends Pest_ClientError
|
192 |
-
{}
|
193 |
-
|
194 |
-
/* encode */
|
195 |
-
class Pest_Json_Encode extends Pest_ClientError
|
196 |
-
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/PestXML.php
DELETED
@@ -1,81 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Pest is a REST client for PHP.
|
4 |
-
* PestXML adds XML-specific functionality to Pest, automatically converting
|
5 |
-
* XML data resturned from REST services into SimpleXML objects.
|
6 |
-
*
|
7 |
-
* In other words, while Pest's get/post/put/delete calls return raw strings,
|
8 |
-
* PestXML's return SimpleXML objects.
|
9 |
-
*
|
10 |
-
* PestXML also attempts to derive error messages from the body of erroneous
|
11 |
-
* responses, expecting that these too are in XML (i.e. the contents of
|
12 |
-
* the first <error></error> tag in the response is assumed to be the error mssage)
|
13 |
-
*
|
14 |
-
* See http://github.com/educoder/pest for details.
|
15 |
-
*
|
16 |
-
* This code is licensed for use, modification, and distribution
|
17 |
-
* under the terms of the MIT License (see http://en.wikipedia.org/wiki/MIT_License)
|
18 |
-
*/
|
19 |
-
|
20 |
-
require_once 'Pest.php';
|
21 |
-
|
22 |
-
class PestXML extends Pest
|
23 |
-
{
|
24 |
-
/**
|
25 |
-
* Process error
|
26 |
-
* @param string $body
|
27 |
-
* @return string
|
28 |
-
*/
|
29 |
-
public function processError($body)
|
30 |
-
{
|
31 |
-
try {
|
32 |
-
$xml = $this->processBody($body);
|
33 |
-
if (!$xml)
|
34 |
-
return $body;
|
35 |
-
|
36 |
-
$error = $xml->xpath('//error');
|
37 |
-
|
38 |
-
if ($error && $error[0])
|
39 |
-
return strval($error[0]);
|
40 |
-
else
|
41 |
-
return $body;
|
42 |
-
} catch (PestXML_Exception $e) {
|
43 |
-
return $body;
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Process body
|
49 |
-
*
|
50 |
-
* @todo This should always return a SimpleXMLElement
|
51 |
-
* @param string $body
|
52 |
-
* @return null|SimpleXMLElement|string
|
53 |
-
* @throws PestXML_Exception
|
54 |
-
*/
|
55 |
-
public function processBody($body)
|
56 |
-
{
|
57 |
-
libxml_use_internal_errors(true);
|
58 |
-
if (empty($body) || preg_match('/^\s+$/', $body))
|
59 |
-
return null;
|
60 |
-
|
61 |
-
$xml = simplexml_load_string($body);
|
62 |
-
|
63 |
-
if (!$xml) {
|
64 |
-
$err = "Couldn't parse XML response because:\n";
|
65 |
-
$xml_errors = libxml_get_errors();
|
66 |
-
libxml_clear_errors();
|
67 |
-
if (!empty($xml_errors)) {
|
68 |
-
foreach ($xml_errors as $xml_err)
|
69 |
-
$err .= "\n - " . $xml_err->message;
|
70 |
-
$err .= "\nThe response was:\n";
|
71 |
-
$err .= $body;
|
72 |
-
throw new PestXML_Exception($err);
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
return $xml;
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
class PestXML_Exception extends Pest_Exception
|
81 |
-
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/README.markdown
DELETED
@@ -1,131 +0,0 @@
|
|
1 |
-
Pest
|
2 |
-
====
|
3 |
-
|
4 |
-
**Pest** is a PHP client library for [RESTful](http://en.wikipedia.org/wiki/Representational_State_Transfer)
|
5 |
-
web services.
|
6 |
-
|
7 |
-
Unlike [Zend_Rest_Client](http://framework.zend.com/manual/en/zend.rest.client.html), which is not
|
8 |
-
really a "REST" client at all (more like RPC-over-HTTP), Pest supports the four REST verbs
|
9 |
-
(GET/POST/PUT/DELETE) and pays attention to HTTP response status codes.
|
10 |
-
|
11 |
-
Composer Installation
|
12 |
-
------------
|
13 |
-
|
14 |
-
To install Pest, use the following composer `require` statement:
|
15 |
-
```
|
16 |
-
{
|
17 |
-
"require": {
|
18 |
-
"educoder/pest": "1.0.0"
|
19 |
-
}
|
20 |
-
}
|
21 |
-
|
22 |
-
```
|
23 |
-
|
24 |
-
|
25 |
-
Basic Example
|
26 |
-
-------------
|
27 |
-
|
28 |
-
Pest's get/post/put/delete() return the raw response body as a string.
|
29 |
-
See the info on PestXML (below) if you're working with XML-based REST services and
|
30 |
-
PestJSON if you're working with JSON.
|
31 |
-
|
32 |
-
<?php
|
33 |
-
|
34 |
-
$pest = new Pest('http://example.com');
|
35 |
-
|
36 |
-
$thing = $pest->get('/things');
|
37 |
-
|
38 |
-
$thing = $pest->post('/things',
|
39 |
-
array(
|
40 |
-
'name' => "Foo",
|
41 |
-
'colour' => "Red"
|
42 |
-
)
|
43 |
-
);
|
44 |
-
|
45 |
-
$thing = $pest->put('/things/15',
|
46 |
-
array(
|
47 |
-
'colour' => "Blue"
|
48 |
-
)
|
49 |
-
);
|
50 |
-
|
51 |
-
$pest->delete('/things/15');
|
52 |
-
|
53 |
-
?>
|
54 |
-
|
55 |
-
Responses with error status codes (4xx and 5xx) raise exceptions.
|
56 |
-
|
57 |
-
<?php
|
58 |
-
|
59 |
-
try {
|
60 |
-
$thing = $pest->get('/things/18');
|
61 |
-
} catch (Pest_NotFound $e) {
|
62 |
-
// 404
|
63 |
-
echo "Thing with ID 18 doesn't exist!";
|
64 |
-
}
|
65 |
-
|
66 |
-
try {
|
67 |
-
$thing = $pest->post('/things', array('colour' => "Red"));
|
68 |
-
} catch (Pest_InvalidRecord $e) {
|
69 |
-
// 422
|
70 |
-
echo "Data for Thing is invalid because: ".$e->getMessage();
|
71 |
-
}
|
72 |
-
|
73 |
-
?>
|
74 |
-
|
75 |
-
PestXML
|
76 |
-
-------
|
77 |
-
|
78 |
-
**PestXML** is an XML-centric version of Pest, specifically targeted at REST services that
|
79 |
-
return XML data. Rather than returning the raw response body as a string, PestXML will
|
80 |
-
try to parse the service's response into a [SimpleXML](http://php.net/manual/en/book.simplexml.php) object.
|
81 |
-
|
82 |
-
<?php
|
83 |
-
|
84 |
-
$pest = new Pest('http://example.com');
|
85 |
-
|
86 |
-
$things = $pest->get('/things.xml');
|
87 |
-
|
88 |
-
$colours = $things->xpath('//colour');
|
89 |
-
foreach($colours as $colour) {
|
90 |
-
echo $colour."\n";
|
91 |
-
}
|
92 |
-
|
93 |
-
?>
|
94 |
-
|
95 |
-
Similarly, **PestJSON** is a JSON-centric version of Pest.
|
96 |
-
|
97 |
-
Much more detailed examples are available in the `examples` directory:
|
98 |
-
|
99 |
-
* [Rollcall Example](http://github.com/educoder/pest/blob/master/examples/rollcall_example.php)
|
100 |
-
* [OpenStreetMap Example](http://github.com/educoder/pest/blob/master/examples/open_street_map_example.php)
|
101 |
-
|
102 |
-
|
103 |
-
TODO
|
104 |
-
----
|
105 |
-
|
106 |
-
* Authentication
|
107 |
-
* Follow Redirects
|
108 |
-
|
109 |
-
|
110 |
-
License
|
111 |
-
-------
|
112 |
-
|
113 |
-
Copyright (C) 2011 by University of Toronto
|
114 |
-
|
115 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
116 |
-
of this software and associated documentation files (the "Software"), to deal
|
117 |
-
in the Software without restriction, including without limitation the rights
|
118 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
119 |
-
copies of the Software, and to permit persons to whom the Software is
|
120 |
-
furnished to do so, subject to the following conditions:
|
121 |
-
|
122 |
-
The above copyright notice and this permission notice shall be included in
|
123 |
-
all copies or substantial portions of the Software.
|
124 |
-
|
125 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
126 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
127 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
128 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
129 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
130 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
131 |
-
THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/composer.json
DELETED
@@ -1,23 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "educoder/pest",
|
3 |
-
"description": "A proper REST client for PHP.",
|
4 |
-
"homepage": "https://github.com/educoder/pest",
|
5 |
-
"license": "MIT",
|
6 |
-
"authors": [
|
7 |
-
{
|
8 |
-
"name": "Matt Zukowski",
|
9 |
-
"email": "matt@zukowski.ca"
|
10 |
-
},
|
11 |
-
{
|
12 |
-
"name": "Donald Sipe",
|
13 |
-
"email": "donald.sipe@gmail.com"
|
14 |
-
}
|
15 |
-
],
|
16 |
-
"require": {
|
17 |
-
"lib-curl": "*",
|
18 |
-
"php": ">=5.2"
|
19 |
-
},
|
20 |
-
"autoload": {
|
21 |
-
"classmap": [""]
|
22 |
-
}
|
23 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/draw.php
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
<a href="get.php">SHOW</a> | <a href="poke.php">POKE</a> | <a href="draw.php">DRAW</a>
|
2 |
-
<hr />
|
3 |
-
|
4 |
-
|
5 |
-
Todo
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/get.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<a href="get.php">SHOW</a> | <a href="poke.php">POKE</a> | <a href="draw.php">DRAW</a>
|
2 |
-
<hr />
|
3 |
-
|
4 |
-
<?php
|
5 |
-
|
6 |
-
require_once './lucky.php';
|
7 |
-
|
8 |
-
$api_key = '90efb718602b07e9fa52fbbc0ad9e578';
|
9 |
-
|
10 |
-
if (isset($_GET['operation_id'])) {
|
11 |
-
|
12 |
-
$op = $_GET['operation_id'];
|
13 |
-
$api_key = $_GET['api_key'];
|
14 |
-
|
15 |
-
if ($op) {
|
16 |
-
|
17 |
-
// $req = new LuckyCycleApi('http://localhost:3000);
|
18 |
-
$req = new LuckyCycleApi('https://www.luckycycle.com'); // use PRODUCTION URL to test
|
19 |
-
$req->setApiKey($api_key);
|
20 |
-
$req->setOperationId($op);
|
21 |
-
|
22 |
-
//$data = array();
|
23 |
-
//$headers = array( 'X-LuckyApiKey' => $api_key );
|
24 |
-
//$path = '/api/v1/operations/' . $op . '/show';
|
25 |
-
//$poke = $req->get( $path , $data, $headers );
|
26 |
-
// email
|
27 |
-
// I have run the sample code from the SDK of lucky.
|
28 |
-
// I need additional info to get it running.
|
29 |
-
// Can you provide me the API KEY and the Operation_id to have the sample working?
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$poke = $req->show();
|
34 |
-
|
35 |
-
}
|
36 |
-
} else {
|
37 |
-
echo("Enter an operation id");
|
38 |
-
}
|
39 |
-
|
40 |
-
?>
|
41 |
-
|
42 |
-
|
43 |
-
Enter an operation id:
|
44 |
-
|
45 |
-
<form action="get.php">
|
46 |
-
<input type="text" name="api_key" placeholder="Api Key">
|
47 |
-
<input type="text" name="operation_id" placeholder="Operation id">
|
48 |
-
<input type="submit">
|
49 |
-
</form>
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
<pre>
|
54 |
-
<? print_r($poke) ?>
|
55 |
-
</pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/lucky.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
require_once 'PestJSON.php';
|
4 |
-
|
5 |
-
class LuckyCycleApi extends PestJSON
|
6 |
-
{
|
7 |
-
const DEV_URL = 'http://localhost:3000';
|
8 |
-
const PROD_URL = 'https://www.luckycycle.com';
|
9 |
-
|
10 |
-
public function __construct($base_url=DEV_URL)
|
11 |
-
{
|
12 |
-
parent::__construct($base_url);
|
13 |
-
//$this->mode =
|
14 |
-
//die("base url of webservice: " . $base_url);
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var string api key
|
19 |
-
*/
|
20 |
-
public $api_key;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @var string operation id
|
24 |
-
*/
|
25 |
-
public $operation_id;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* @var boolean mode
|
29 |
-
*/
|
30 |
-
public $mode;
|
31 |
-
|
32 |
-
public function setApiKey($api_key) {
|
33 |
-
$this->api_key = $api_key;
|
34 |
-
}
|
35 |
-
|
36 |
-
public function setOperationId($operation_id) {
|
37 |
-
$this->operation_id = $operation_id;
|
38 |
-
}
|
39 |
-
|
40 |
-
public function show() {
|
41 |
-
$path = '/api/v1/operations/' . $this->operation_id . '/show';
|
42 |
-
$data = array();
|
43 |
-
$headers = array( 'X-LuckyApiKey' => $this->api_key );
|
44 |
-
|
45 |
-
return $this->get($path, $data, $headers);
|
46 |
-
}
|
47 |
-
|
48 |
-
public function poke($data) {
|
49 |
-
$path = '/api/v1/operations/' . $this->operation_id . '/poke';
|
50 |
-
$headers = array( 'X-LuckyApiKey' => $this->api_key );
|
51 |
-
|
52 |
-
return $this->post($path, $data, $headers);
|
53 |
-
}
|
54 |
-
|
55 |
-
public function draw($data) {
|
56 |
-
$path = '/api/v1/operations/' . $this->operation_id . '/draw';
|
57 |
-
$headers = array( 'X-LuckyApiKey' => $this->api_key );
|
58 |
-
|
59 |
-
return $this->post($path, $data, $headers);
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/luckysdk/poke.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<a href="get.php">SHOW</a> | <a href="poke.php">POKE</a> | <a href="draw.php">DRAW</a>
|
2 |
-
<hr />
|
3 |
-
|
4 |
-
<?php
|
5 |
-
|
6 |
-
require_once './lucky.php';
|
7 |
-
|
8 |
-
$api_key = '9c936dbf1cfa00bc11a8961238d34fb1';
|
9 |
-
|
10 |
-
if (isset($_GET['operation_id'])) {
|
11 |
-
|
12 |
-
$op = $_GET['operation_id'];
|
13 |
-
$uid = $_GET['user_id'];
|
14 |
-
$item_id = $_GET['item_id'];
|
15 |
-
$item_value = $_GET['item_value'];
|
16 |
-
$item_currency = $_GET['item_currency'];
|
17 |
-
$email = $_GET['email'];
|
18 |
-
$firstname = $_GET['firstname'];
|
19 |
-
$lastname = $_GET['lastname'];
|
20 |
-
$random_data = $_GET['random_data'];
|
21 |
-
|
22 |
-
if ($op) {
|
23 |
-
|
24 |
-
$req = new LuckyCycleApi('https://www.luckycycle.com');
|
25 |
-
$req->setApiKey($api_key);
|
26 |
-
$req->setOperationId($op);
|
27 |
-
|
28 |
-
//$data = array();
|
29 |
-
//$headers = array( 'X-LuckyApiKey' => $api_key );
|
30 |
-
//$path = '/api/v1/operations/' . $op . '/show';
|
31 |
-
//$poke = $req->get( $path , $data, $headers );
|
32 |
-
|
33 |
-
$pokedata = array(
|
34 |
-
'operation_id' => $op,
|
35 |
-
'user_uid' => $uid,
|
36 |
-
'item_uid' => $item_id,
|
37 |
-
'item_value' => $item_value,
|
38 |
-
'item_currency' => $item_currency,
|
39 |
-
'email' => $email,
|
40 |
-
'firstname' => $firstname,
|
41 |
-
'lastname' => $lastname,
|
42 |
-
|
43 |
-
//, 'random_data' => 1
|
44 |
-
);
|
45 |
-
if($random_data) {
|
46 |
-
$pokedata['random_data'] = 1;
|
47 |
-
}
|
48 |
-
|
49 |
-
$poke = $req->poke($pokedata);
|
50 |
-
|
51 |
-
}
|
52 |
-
} else {
|
53 |
-
echo("Enter an operation id");
|
54 |
-
}
|
55 |
-
|
56 |
-
?>
|
57 |
-
|
58 |
-
|
59 |
-
Enter an operation id to make a poke:
|
60 |
-
|
61 |
-
<form action="poke.php" method="">
|
62 |
-
<input type="text" name="operation_id" placeholder="Operation id">
|
63 |
-
<input type="text" name="user_id" placeholder="User id">
|
64 |
-
<input type="text" name="item_id" placeholder="Item id">
|
65 |
-
<input type="text" name="item_value" placeholder="Amount" value="100">
|
66 |
-
<input type="text" name="item_currency" placeholder="Currency" value="EUR">
|
67 |
-
<input type="text" name="email" placeholder="Email" value="email@email.be">
|
68 |
-
<input type="text" name="firstname" placeholder="Firstname" value="firstname">
|
69 |
-
<input type="text" name="lastname" placeholder="Lastname" value="lastname">
|
70 |
-
<input type="checkbox" name="random_data" value="1">
|
71 |
-
|
72 |
-
<input type="submit">
|
73 |
-
</form>
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
<pre>
|
78 |
-
<? print_r($poke) ?>
|
79 |
-
</pre>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,22 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
-
<name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>Luckycycle
|
11 |
-

|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
<
|
16 |
-
<
|
17 |
-
<
|
18 |
-
<time>10:39:33</time>
|
19 |
-
<contents><target name="magecommunity"><dir name="Luckycycle"><dir name="Snippetsdk"><dir name="Helper"><file name="Data.php" hash="00cd3b339a743f60ba9f781e1741f5c6"/></dir><dir name="Model"><file name="Bannerdefault.php" hash="7b82281124ab9ecd8d6d5e97448c0018"/><file name="Luckycycle.php" hash="0f1e514c97231f3d855fbcba9d2b39aa"/><dir name="Mysql4"><dir name="Luckycycle"><file name="Collection.php" hash="ecd953b3bc37e1ce9ed48b2e5d6466e2"/></dir><file name="Luckycycle.php" hash="7f7701e670205d2f36a1aac638200416"/></dir><file name="Paymentmethod.php" hash="875b65e444b7c0fc05b5f3aad4e29405"/><file name="Posinformation.php" hash="a2c2896a9786073994ef815405fcccd3"/><dir name="Resource"><file name="Setup.php" hash="ae57d1935d370d2322408a886bfa1d87"/></dir><file name="Usemode.php" hash="270b05a079ae7e623c028e176f1a1bee"/></dir><dir name="etc"><file name="adminhtml.xml" hash="0e8ed401660ff82c4745f61070d31112"/><file name="config.xml" hash="873c4c4b374bbc77b32b6d53f9372b6b"/><file name="system.xml" hash="eb9af6e367eada02ea2aa44fb5e1b42d"/></dir><dir name="sql"><dir name="luckycycle_snippetsdk_setup"><file name="mysql4-install-1.0.0.php" hash="0886f787f7107771d3c307b11377f6bf"/><file name="mysql4-install-1.0.0.php.bak" hash="744a19f3573ec85b6072ba6cfa7a1850"/></dir></dir></dir><file name=".DS_Store" hash="a708356ae60e99b183a3354a5e1c1632"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="Luckycycle"><file name="snippetsdk.xml" hash="121ec1d1c392c19d2eda7ecd3a4f0599"/></dir></dir><dir name="template"><dir name="Luckycycle"><dir name="multishipping"><file name="snippetsdk.phtml" hash="5aba1afa065530f359498b11937f4dc9"/><file name="success.phtml" hash="ff1086fab2e76aa08ac8abc33f2a742a"/></dir><file name="snippetsdk.phtml" hash="a9159e1153e4ccc5f603c059929498ad"/><file name="success.phtml" hash="ac6c218c64e42392cfaa74e936a3745e"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Luckycycle_Snippetsdk.xml" hash="31d8da4d548231ffd5fb958db21e5873"/></dir></target><target name="magelib"><dir name="luckysdk"><file name="Pest.php" hash="8ec7c28da2611e5250ebde66b08a726b"/><file name="PestJSON.php" hash="c11bd95a37ed6b59b295aeb31c634746"/><file name="PestXML.php" hash="2b1e28a69908051e8477ed2666b938bd"/><file name="README.markdown" hash="f67a352fe5189051212f4ee6ed9230a1"/><file name="composer.json" hash="2ba49c7d970ffa3e811deac225f24e0c"/><file name="draw.php" hash="3e26dfa7fd9249a38f2a35377161146c"/><file name="get.php" hash="acbe4dc1e76fdf235835050ab822db60"/><file name="lucky.php" hash="a8c49f3e5c3c689714b488cd40598584"/><file name="poke.php" hash="6a7d6da9b1da06104f5a4bb1182f595e"/><file name=".gitignore" hash="519ab8ba66c7113563fcdbb909d274de"/></dir></target></contents>
|
20 |
<compatible/>
|
21 |
-
<dependencies><required><php><min>5.
|
22 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
+
<name>Luckycycle</name>
|
4 |
+
<version>1.6.1</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/MIT">MIT</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Luckycycle modules that add the gamebox in the confirmation page</summary>
|
10 |
+
<description>Luckycycle modules sends some data to the Luckycycle servers and show a gamebox in the confirmation page of some conditions are met.
|
11 |
+
More info : https://www.luckycycle.com
|
12 |
+
</description>
|
13 |
+
<notes>last stable release</notes>
|
14 |
+
<authors><author><name>JM Goemaere</name><user>sucrenoir</user><email>jm@luckycycle.com</email></author></authors>
|
15 |
+
<date>2015-12-14</date>
|
16 |
+
<time>14:11:52</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="."><dir name="app"><dir name="code"><dir name="community"><dir name="Luckycycle"><dir name="Snippetsdk"><dir name="Block"><file name="Index.php" hash=""/></dir><dir name="controllers"><file name="IndexController.php" hash=""/></dir><dir name="etc"><file name="adminhtml.xml" hash=""/><file name="config.xml" hash=""/><file name="system.xml" hash=""/></dir><dir name="Helper"><file name="Data.php" hash=""/></dir><dir name="Model"><file name="Luckycycle.php" hash=""/><file name="Paymentmethod.php" hash=""/><file name="Posinformation.php" hash=""/></dir></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="."><dir name="app"><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="Luckycycle"><file name="snippetsdk.xml" hash=""/></dir></dir><dir name="template"><dir name="Luckycycle"><file name="index.phtml" hash=""/><dir name="multishipping"><file name="snippetsdk.phtml" hash=""/><file name="success.phtml" hash=""/></dir><file name="snippetsdk.phtml" hash=""/><file name="success.phtml" hash=""/></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="."><dir name="app"><dir name="etc"><dir name="modules"><file name="Luckycycle_Snippetsdk.xml" hash=""/></dir></dir></dir></dir></target><target name="magelib"><dir name="."><dir name="lib"><dir name="luckysdk"><file name="lucky.php" hash=""/><dir name="pest"><file name="Pest.php" hash=""/><file name="PestJSON.php" hash=""/><file name="PestXML.php" hash=""/></dir></dir></dir></dir></target></contents>
|
|
|
|
|
18 |
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.3.0</min><max>7.0.0</max></php><extension><name>curl</name><min/><max/></extension></required></dependencies>
|
20 |
</package>
|