Intelipost - Version 0.8.4

Version Notes

. Added quote examples
. Check for api_url / api_key right combination
. Added intelipost.log

Download this release

Release Info

Developer Intelipost
Extension Intelipost
Version 0.8.4
Comparing to
See all releases


Code changes from version 0.8.3 to 0.8.4

app/code/local/Intelipost/Shipping/Model/Carrier/Intelipost.php CHANGED
@@ -12,11 +12,16 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
12
 
13
  private $_zipCodeRegex = '/[0-9]{2}\.?[0-9]{3}-?[0-9]{3}/';
14
 
15
- public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
 
 
 
 
 
16
  $this->_helper = Mage::helper('intelipost');
17
 
18
  if (!$this->getConfigFlag('active')) {
19
- Mage::log('Intelipost is inactive', null, 'intelipost.log');
20
  return false;
21
  }
22
 
@@ -24,7 +29,7 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
24
  $destinationZipCode = $request->getDestPostcode();
25
 
26
  if (!preg_match($this->_zipCodeRegex, $originZipCode) || !preg_match($this->_zipCodeRegex, $destinationZipCode)) {
27
- Mage::log('Invalid zip code ' . $originZipCode . ' or ' . $destinationZipCode, null, 'intelipost.log');
28
  return false;
29
  }
30
 
@@ -33,6 +38,7 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
33
  $destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
34
 
35
  $weight = $request->getPackageWeight();
 
36
  if ($weight <= 0) {
37
  $this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
38
  }
@@ -40,26 +46,18 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
40
  // weight must be in Kg
41
  if($this->getConfigData('weight_type') == 'gr') {
42
  $weight = number_format($weight/1000, 2, '.', '');
43
- }else{
44
- // TODO: do the weight defaults to Kg if it is not gr?
45
  $weight = number_format($weight, 2, '.', '');
46
  }
47
 
48
- $price = $request->getPackageValue();
49
 
50
  $encryption = Mage::getSingleton('core/encryption');
51
- $account = $encryption->decrypt($this->getConfigData('account'));
52
- $password = $encryption->decrypt($this->getConfigData('password'));
53
  $api_key = $encryption->decrypt($this->getConfigData('apikey'));
54
- // $token = $encryption->decrypt($this->getConfigData('token'));
55
-
56
- if(!isset($api_key)/* || !isset($token) ||*/
57
- || !is_string($api_key)/* || !is_string($token)*/
58
- ){
59
- Mage::log('Intelipost not configured', null, 'intelipost.log');
60
- Mage::log('account: ' . $account, null, 'intelipost.log');
61
- // take care to not log the password
62
- Mage::log('password length: ' . strlen($password) , null, 'intelipost.log');
63
  return false;
64
  }
65
 
@@ -71,7 +69,7 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
71
  $quote->destination_zip_code = $destinationZipCode;
72
 
73
  if (!$request->getAllItems()) {
74
- Mage::log('Cart is empty', null, 'intelipost.log');
75
  return false;
76
  }
77
 
@@ -86,13 +84,13 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
86
  $volume->volume_type = 'BOX';
87
 
88
  if (!$this->isDimensionSet($product)) {
89
- Mage::log('Product does not have dimensions set', null, 'intelipost.log');
90
 
91
  if ($dimension_check) {
92
  $this->notifyProductsDimension($item_list);
93
  return false;
94
  }
95
- }else{
96
  $volume->width = $product->getVolumeLargura();
97
  $volume->height = $product->getVolumeAltura();
98
  $volume->length = $product->getVolumeComprimento();
@@ -104,24 +102,10 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
104
  array_push($quote->volumes, $volume);
105
  }
106
 
107
- $body = json_encode($quote);
108
-
109
- $s = curl_init();
110
- curl_setopt($s, CURLOPT_TIMEOUT, 5000);
111
- curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
112
- if ($username != null && $password != null) {
113
- curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
114
- }
115
- curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: $token"*/));
116
- curl_setopt($s, CURLOPT_POST, true);
117
- curl_setopt($s, CURLOPT_ENCODING , "");
118
- curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
119
- curl_setopt($s, CURLOPT_POSTFIELDS, $body);
120
- $responseBody = curl_exec($s);
121
 
122
- $response = json_decode($responseBody);
123
- // echo $responseBody;
124
- curl_close($s);
125
 
126
  $result = Mage::getModel('shipping/rate_result');
127
 
@@ -141,11 +125,20 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
141
  return $result;
142
  }
143
 
144
- public function getAllowedMethods() {
 
 
 
 
145
  return array($this->_code => $this->getConfigData('name'));
146
  }
147
 
148
- private function isDimensionSet($product) {
 
 
 
 
 
149
  $volume_altura = $product->getData('volume_altura');
150
  $volume_largura = $product->getData('volume_largura');
151
  $volume_comprimento = $product->getData('volume_comprimento');
@@ -160,7 +153,11 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
160
  return true;
161
  }
162
 
163
- private function notifyProductsDimension($item_list) {
 
 
 
 
164
  $notification = Mage::getSingleton('adminnotification/inbox');
165
  $message = $this->_helper->__('The following products do not have dimension set:');
166
 
@@ -184,7 +181,7 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
184
  }
185
  $message .= '</ul>';
186
 
187
- $message .= $this->_helper->__('<small>Disable these notifications in System > Settings > Carriers > Intelipost</small>');
188
 
189
  $notification->add(
190
  Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR,
@@ -193,7 +190,12 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
193
  );
194
  }
195
 
196
- private function formatDeadline($days) {
 
 
 
 
 
197
  if ($days == 0) {
198
  return $this->_helper->__('(same day)');
199
  }
@@ -208,5 +210,31 @@ class Intelipost_Shipping_Model_Carrier_Intelipost
208
 
209
  return sprintf($this->_helper->__('(%s days)'), $days);
210
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  }
212
 
12
 
13
  private $_zipCodeRegex = '/[0-9]{2}\.?[0-9]{3}-?[0-9]{3}/';
14
 
15
+ /**
16
+ * @param Mage_Shipping_Model_Rate_Request $request
17
+ * @return bool|false|Mage_Core_Model_Abstract|Mage_Shipping_Model_Rate_Result|null
18
+ */
19
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
20
+ {
21
  $this->_helper = Mage::helper('intelipost');
22
 
23
  if (!$this->getConfigFlag('active')) {
24
+ Mage::log('Intelipost is inactive', null, 'intelipost.log', true);
25
  return false;
26
  }
27
 
29
  $destinationZipCode = $request->getDestPostcode();
30
 
31
  if (!preg_match($this->_zipCodeRegex, $originZipCode) || !preg_match($this->_zipCodeRegex, $destinationZipCode)) {
32
+ Mage::log('Invalid zip code ' . $originZipCode . ' or ' . $destinationZipCode, null, 'intelipost.log', true);
33
  return false;
34
  }
35
 
38
  $destinationZipCode = preg_replace('/[^0-9]/', '', $destinationZipCode);
39
 
40
  $weight = $request->getPackageWeight();
41
+
42
  if ($weight <= 0) {
43
  $this->_throwError('weightzeroerror', 'Weight zero', __LINE__);
44
  }
46
  // weight must be in Kg
47
  if($this->getConfigData('weight_type') == 'gr') {
48
  $weight = number_format($weight/1000, 2, '.', '');
49
+ } else {
 
50
  $weight = number_format($weight, 2, '.', '');
51
  }
52
 
53
+ $price = $request->getPackageValue();
54
 
55
  $encryption = Mage::getSingleton('core/encryption');
 
 
56
  $api_key = $encryption->decrypt($this->getConfigData('apikey'));
57
+ $api_url = $encryption->decrypt($this->getConfigData('apiurl'));
58
+
59
+ if(!isset($api_key) || !is_string($api_key)) {
60
+ Mage::log('Intelipost not configured', null, 'intelipost.log', true);
 
 
 
 
 
61
  return false;
62
  }
63
 
69
  $quote->destination_zip_code = $destinationZipCode;
70
 
71
  if (!$request->getAllItems()) {
72
+ Mage::log('Cart is empty', null, 'intelipost.log, true');
73
  return false;
74
  }
75
 
84
  $volume->volume_type = 'BOX';
85
 
86
  if (!$this->isDimensionSet($product)) {
87
+ Mage::log('Product does not have dimensions set', null, 'intelipost.log', true);
88
 
89
  if ($dimension_check) {
90
  $this->notifyProductsDimension($item_list);
91
  return false;
92
  }
93
+ } else {
94
  $volume->width = $product->getVolumeLargura();
95
  $volume->height = $product->getVolumeAltura();
96
  $volume->length = $product->getVolumeComprimento();
102
  array_push($quote->volumes, $volume);
103
  }
104
 
105
+ $request = json_encode($quote);
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
+ // INTELIPOST QUOTE
108
+ $response = $this->intelipostRequest($api_url, $api_key, "/quote", $request);
 
109
 
110
  $result = Mage::getModel('shipping/rate_result');
111
 
125
  return $result;
126
  }
127
 
128
+ /**
129
+ * @return array
130
+ */
131
+ public function getAllowedMethods()
132
+ {
133
  return array($this->_code => $this->getConfigData('name'));
134
  }
135
 
136
+ /**
137
+ * @param $product
138
+ * @return bool
139
+ */
140
+ private function isDimensionSet($product)
141
+ {
142
  $volume_altura = $product->getData('volume_altura');
143
  $volume_largura = $product->getData('volume_largura');
144
  $volume_comprimento = $product->getData('volume_comprimento');
153
  return true;
154
  }
155
 
156
+ /**
157
+ * @param $item_list
158
+ */
159
+ private function notifyProductsDimension($item_list)
160
+ {
161
  $notification = Mage::getSingleton('adminnotification/inbox');
162
  $message = $this->_helper->__('The following products do not have dimension set:');
163
 
181
  }
182
  $message .= '</ul>';
183
 
184
+ $message .= $this->_helper->__('<small>Disable these notifications in System > Configuration > Shipping Methods > Intelipost</small>');
185
 
186
  $notification->add(
187
  Mage_AdminNotification_Model_Inbox::SEVERITY_MINOR,
190
  );
191
  }
192
 
193
+ /**
194
+ * @param $days
195
+ * @return string
196
+ */
197
+ private function formatDeadline($days)
198
+ {
199
  if ($days == 0) {
200
  return $this->_helper->__('(same day)');
201
  }
210
 
211
  return sprintf($this->_helper->__('(%s days)'), $days);
212
  }
213
+
214
+ /**
215
+ * @param $api_url
216
+ * @param $api_key
217
+ * @param bool $body
218
+ * @return mixed
219
+ */
220
+ private function intelipostRequest($api_url, $api_key, $entity_action, $request=false)
221
+ {
222
+ $s = curl_init();
223
+
224
+ curl_setopt($s, CURLOPT_TIMEOUT, 5000);
225
+ curl_setopt($s, CURLOPT_URL, $api_url.$entity_action);
226
+ curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"));
227
+ curl_setopt($s, CURLOPT_POST, true);
228
+ curl_setopt($s, CURLOPT_ENCODING , "");
229
+ curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
230
+ curl_setopt($s, CURLOPT_POSTFIELDS, $request);
231
+
232
+ $response = curl_exec($s);
233
+
234
+ curl_close($s);
235
+
236
+ return $response;
237
+ }
238
+
239
  }
240
 
app/code/local/Intelipost/Shipping/Model/Config/Apikey.php CHANGED
@@ -7,52 +7,78 @@ class Intelipost_Shipping_Model_Config_Apikey
7
  extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
8
  {
9
 
10
- public function save() {
11
- $api_key = $this->getValue();
12
- $token = $this->getData('groups/intelipost/fields/token/value');
13
- $password = $this->getData('groups/intelipost/fields/password/value');
14
- // $username = $this->getData('groups/intelipost/fields/account/value');
15
- $password = 'mate20mg';
16
- $username = 'projecta';
17
- $helper = Mage::helper('intelipost');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  $volume = new Intelipost_Model_Request_Volume();
20
- $volume->weight = 10;
21
- $volume->volume_type = 'BOX';
22
  $volume->cost_of_goods = "10";
23
- $volume->width = 1;
24
- $volume->height = 1;
25
- $volume->length = 1;
26
 
27
  $quote = new Intelipost_Model_Request_Quote();
28
- $quote->origin_zip_code = "04037-002";
29
- $quote->destination_zip_code = "04037-002";
 
30
  array_push($quote->volumes, $volume);
31
 
32
- $body = json_encode($quote);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  $s = curl_init();
 
34
  curl_setopt($s, CURLOPT_TIMEOUT, 5000);
35
- curl_setopt($s, CURLOPT_URL, "https://api.intelipost.com.br/api/v1/quote");
36
- if ($username != null && $password != null) {
37
- curl_setopt($s, CURLOPT_USERPWD, $username . ":" . $password);
38
- }
39
- curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"/*, "token: testtoken"*/));
40
  curl_setopt($s, CURLOPT_POST, true);
41
  curl_setopt($s, CURLOPT_ENCODING , "");
42
  curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
43
- curl_setopt($s, CURLOPT_POSTFIELDS, $body);
44
 
45
- $responseBody = curl_exec($s);
46
 
47
- $response = json_decode($responseBody);
48
  curl_close($s);
49
 
50
- if (!isset($response->status)) {
51
- // Mage::getSingleton('core/session')->addWarning($helper->__('Could not validate username and password!'));
52
- Mage::throwException($helper->__('Invalid ApiKey!'));
53
- }
54
-
55
- parent::save();
56
  }
57
- }
58
 
 
7
  extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
8
  {
9
 
10
+ /**
11
+ * @return Mage_Core_Model_Abstract|void
12
+ */
13
+ public function save()
14
+ {
15
+ $api_key = $this->getValue();
16
+
17
+ $responseJson = $this->testQuote($api_key);
18
+
19
+ if (!isset($responseJson->status)) {
20
+ $helper = Mage::helper('intelipost');
21
+
22
+ // Mage::getSingleton('core/session')->addWarning($helper->__('Invalid ApiUrl/ApiKey combination'));
23
+ Mage::throwException($helper->__('Invalid ApiUrl/ApiKey combination'));
24
+ }
25
+
26
+ parent::save();
27
+ }
28
+
29
+ private function testQuote($api_key)
30
+ {
31
+ $api_url = $this->getData('groups/intelipost/fields/apiurl/value');
32
+ $zipcode = $this->getData('groups/intelipost/fields/zipcode/value');
33
 
34
  $volume = new Intelipost_Model_Request_Volume();
35
+ $volume->weight = 10.2;
36
+ $volume->volume_type = 'BOX';
37
  $volume->cost_of_goods = "10";
38
+ $volume->width = 20.5;
39
+ $volume->height = 10.25;
40
+ $volume->length = 5.0;
41
 
42
  $quote = new Intelipost_Model_Request_Quote();
43
+ $quote->origin_zip_code = $zipcode;
44
+ $quote->destination_zip_code = $zipcode;
45
+
46
  array_push($quote->volumes, $volume);
47
 
48
+ $request = json_encode($quote);
49
+
50
+ Mage::log("\nREQUEST: ".$request, null, "intelipost.log", true);
51
+
52
+ $response = $this->intelipostRequest($api_url, $api_key, "/quote", $request);
53
+
54
+ Mage::log("\nRESPONSE: ".$response, null, "intelipost.log", true);
55
+
56
+ return json_decode($response);
57
+ }
58
+
59
+ /**
60
+ * @param $api_url
61
+ * @param $api_key
62
+ * @param bool $body
63
+ * @return mixed
64
+ */
65
+ private function intelipostRequest($api_url, $api_key, $entity_action, $request=false)
66
+ {
67
  $s = curl_init();
68
+
69
  curl_setopt($s, CURLOPT_TIMEOUT, 5000);
70
+ curl_setopt($s, CURLOPT_URL, $api_url.$entity_action);
71
+ curl_setopt($s, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json", "api_key: $api_key"));
 
 
 
72
  curl_setopt($s, CURLOPT_POST, true);
73
  curl_setopt($s, CURLOPT_ENCODING , "");
74
  curl_setopt($s, CURLOPT_RETURNTRANSFER, 1);
75
+ curl_setopt($s, CURLOPT_POSTFIELDS, $request);
76
 
77
+ $response = curl_exec($s);
78
 
 
79
  curl_close($s);
80
 
81
+ return $response;
 
 
 
 
 
82
  }
 
83
 
84
+ }
app/code/local/Intelipost/Shipping/Model/Config/{Token.php → Apiurl.php} RENAMED
@@ -1,12 +1,12 @@
1
  <?php
2
 
3
- class Intelipost_Shipping_Model_Config_Token
4
  extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
5
  {
6
 
7
  public function save() {
8
 
9
- $token = $this->getValue();
10
  parent::save();
11
 
12
  }
1
  <?php
2
 
3
+ class Intelipost_Shipping_Model_Config_Apiurl
4
  extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
5
  {
6
 
7
  public function save() {
8
 
9
+ $api_url = $this->getValue();
10
  parent::save();
11
 
12
  }
app/code/local/Intelipost/Shipping/Model/Config/Useraccount.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Intelipost_Shipping_Model_Config_Useraccount
4
- extends Mage_Adminhtml_Model_System_Config_Backend_Encrypted
5
- {
6
-
7
- public function save() {
8
-
9
- $useraccount = $this->getValue();
10
- parent::save();
11
-
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Intelipost/Shipping/Model/Resource/EndCustomer.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author eSprinter (it@e-sprinter.com.br)
5
+ */
6
+ class Intelipost_Model_Request_EndCustomer {
7
+
8
+ /**
9
+ * @var string
10
+ */
11
+ public $first_name;
12
+
13
+ /**
14
+ * @var string
15
+ */
16
+ public $last_name;
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ public $email;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ public $phone;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ public $cellphone;
32
+
33
+ /**
34
+ * @var boolean
35
+ */
36
+ public $is_company;
37
+
38
+ /**
39
+ * @var integer
40
+ */
41
+ public $federal_tax_payer_id;
42
+
43
+ /**
44
+ * @var integer
45
+ */
46
+ public $state_tax_payer_id;
47
+
48
+ /**
49
+ * @var integer
50
+ */
51
+ public $shipping_address;
52
+
53
+ /**
54
+ * @var integer
55
+ */
56
+ public $shipping_number;
57
+
58
+ /**
59
+ * @var integer
60
+ */
61
+ public $shipping_additional;
62
+
63
+ /**
64
+ * @var integer
65
+ */
66
+ public $shipping_reference;
67
+
68
+ /**
69
+ * @var integer
70
+ */
71
+ public $shipping_quarter;
72
+
73
+ /**
74
+ * @var integer
75
+ */
76
+ public $shipping_city;
77
+
78
+ /**
79
+ * @var integer
80
+ */
81
+ public $shipping_state;
82
+
83
+ /**
84
+ * @var integer
85
+ */
86
+ public $shipping_zip_code;
87
+
88
+ /**
89
+ * @var integer
90
+ */
91
+ public $shipping_country;
92
+
93
+ }
app/code/local/Intelipost/Shipping/Model/Resource/Invoice.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author eSprinter (it@e-sprinter.com.br)
4
+ */
5
+
6
+ class Intelipost_Model_Request_Invoice {
7
+
8
+ /**
9
+ * @var string
10
+ */
11
+ public $order_number;
12
+
13
+ /**
14
+ * @var string
15
+ */
16
+ public $shipment_order_volume_number;
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ public $invoice_series;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ public $invoice_number;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ public $invoice_key;
32
+
33
+ /**
34
+ * @var date
35
+ */
36
+ public $invoice_date;
37
+
38
+ /**
39
+ * @var double
40
+ */
41
+ public $invoice_total_value;
42
+
43
+ /**
44
+ * @var double
45
+ */
46
+ public $invoice_products_value;
47
+
48
+ /**
49
+ * @var double
50
+ */
51
+ public $invoice_cfop;
52
+
53
+ }
app/code/local/Intelipost/Shipping/Model/Resource/Quote.php CHANGED
@@ -4,8 +4,17 @@
4
  * @author eSprinter (it@e-sprinter.com.br)
5
  */
6
  class Intelipost_Model_Request_Quote {
 
 
 
 
7
  public $origin_zip_code;
 
 
 
 
8
  public $destination_zip_code;
 
9
  /**
10
  * @var ESprinter_Model_Request_Volume[]
11
  */
4
  * @author eSprinter (it@e-sprinter.com.br)
5
  */
6
  class Intelipost_Model_Request_Quote {
7
+
8
+ /**
9
+ * @var string
10
+ */
11
  public $origin_zip_code;
12
+
13
+ /**
14
+ * @var string
15
+ */
16
  public $destination_zip_code;
17
+
18
  /**
19
  * @var ESprinter_Model_Request_Volume[]
20
  */
app/code/local/Intelipost/Shipping/Model/Resource/ShipmentOrder.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @author eSprinter (it@e-sprinter.com.br)
5
+ */
6
+ class Intelipost_Model_Request_ShipmentOrder {
7
+
8
+ /**
9
+ * @var integer
10
+ */
11
+ public $quote_id;
12
+
13
+ /**
14
+ * @var integer
15
+ */
16
+ public $deliver_method_id;
17
+
18
+ /**
19
+ * @var string
20
+ */
21
+ public $order_number;
22
+
23
+ /**
24
+ * @var datetime
25
+ */
26
+ public $estimated_delivery_date;
27
+
28
+ /**
29
+ * @var Intelipost_Model_Request_EndCustomer[]
30
+ */
31
+ public $end_customer = false;
32
+ }
app/code/local/Intelipost/Shipping/Model/Resource/Volume.php CHANGED
@@ -4,29 +4,55 @@
4
  */
5
 
6
  class Intelipost_Model_Request_Volume {
 
7
  /**
8
  * @var double
9
  */
10
  public $weight;
 
11
  /**
12
  * @var string[BOX|ENVELOPE]
13
  */
14
- public $volume_type;
 
15
  /**
16
  * @var double
17
  */
18
  public $cost_of_goods;
 
19
  /**
20
  * @var double
21
  */
22
  public $width;
 
23
  /**
24
  * @var double
25
  */
26
  public $height;
 
27
  /**
28
  * @var double
29
  */
30
  public $length;
31
 
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  */
5
 
6
  class Intelipost_Model_Request_Volume {
7
+
8
  /**
9
  * @var double
10
  */
11
  public $weight;
12
+
13
  /**
14
  * @var string[BOX|ENVELOPE]
15
  */
16
+ public $volume_type_code;
17
+
18
  /**
19
  * @var double
20
  */
21
  public $cost_of_goods;
22
+
23
  /**
24
  * @var double
25
  */
26
  public $width;
27
+
28
  /**
29
  * @var double
30
  */
31
  public $height;
32
+
33
  /**
34
  * @var double
35
  */
36
  public $length;
37
 
38
+ /**
39
+ * @var integer
40
+ */
41
+ public $shipment_order_volume_number;
42
+
43
+ /**
44
+ * @var string
45
+ */
46
+ public $products_nature;
47
+
48
+ /**
49
+ * @var integer
50
+ */
51
+ public $products_quantity;
52
+
53
+ /**
54
+ * @var boolean
55
+ */
56
+ public $is_icms_exempt;
57
+
58
+ }
app/code/local/Intelipost/Shipping/etc/system.xml CHANGED
@@ -23,7 +23,8 @@
23
  <show_in_store>1</show_in_store>
24
  </active>
25
 
26
- <!-- <account translate="label">
 
27
  <label>User Account</label>
28
  <frontend_type>text</frontend_type>
29
  <backend_model>intelipost_shipping/config_useraccount</backend_model>
@@ -32,10 +33,12 @@
32
  <show_in_default>1</show_in_default>
33
  <show_in_website>1</show_in_website>
34
  <show_in_store>1</show_in_store>
35
- </account> -->
 
36
 
37
  <!-- Model/Config/Password depends on this tag name + hierarchy -->
38
- <!-- <password translate="label">
 
39
  <label>Password</label>
40
  <frontend_type>text</frontend_type>
41
  <backend_model>intelipost_shipping/config_password</backend_model>
@@ -44,20 +47,33 @@
44
  <show_in_default>1</show_in_default>
45
  <show_in_website>1</show_in_website>
46
  <show_in_store>1</show_in_store>
47
- </password> -->
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  <apikey translate="label">
50
  <label>API Key</label>
51
  <frontend_type>text</frontend_type>
52
  <backend_model>intelipost_shipping/config_apikey</backend_model>
53
  <validate>required-entry</validate>
54
- <sort_order>4</sort_order>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
57
  <show_in_store>1</show_in_store>
58
  </apikey>
59
 
60
- <!-- <token translate="label">
 
61
  <label>Token</label>
62
  <frontend_type>text</frontend_type>
63
  <backend_model>intelipost_shipping/config_token</backend_model>
@@ -66,20 +82,22 @@
66
  <show_in_default>1</show_in_default>
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>1</show_in_store>
69
- </token> -->
 
70
 
71
  <zipcode translate="label">
72
  <label>Postal Code</label>
73
  <frontend_type>text</frontend_type>
74
  <!--<validate>validate-zip-international required-entry</validate>-->
75
  <validate>required-entry</validate>
76
- <sort_order>6</sort_order>
77
  <show_in_default>1</show_in_default>
78
  <show_in_website>1</show_in_website>
79
  <show_in_store>1</show_in_store>
80
  </zipcode>
81
 
82
- <!-- <category translate="label">
 
83
  <label>Choose the best fitting category for your products</label>
84
  <frontend_type>select</frontend_type>
85
  <source_model>intelipost_shipping/carrier_category</source_model>
@@ -89,7 +107,8 @@
89
  <show_in_store>1</show_in_store>
90
  </category>-->
91
 
92
- <notification translate="label">
 
93
  <label>Enable dimension check and notifications</label>
94
  <frontend_type>select</frontend_type>
95
  <source_model>adminhtml/system_config_source_yesno</source_model>
@@ -98,15 +117,18 @@
98
  <show_in_website>1</show_in_website>
99
  <show_in_store>1</show_in_store>
100
  </notification>
 
101
 
102
- <!-- <webservice_url translate="label">
 
103
  <label>Axado's webservice url</label>
104
  <frontend_type>text</frontend_type>
105
  <sort_order>10</sort_order>
106
  <show_in_default>1</show_in_default>
107
  <show_in_website>1</show_in_website>
108
  <show_in_store>1</show_in_store>
109
- </webservice_url> -->
 
110
  </fields>
111
 
112
  </intelipost>
23
  <show_in_store>1</show_in_store>
24
  </active>
25
 
26
+ <!--
27
+ <account translate="label">
28
  <label>User Account</label>
29
  <frontend_type>text</frontend_type>
30
  <backend_model>intelipost_shipping/config_useraccount</backend_model>
33
  <show_in_default>1</show_in_default>
34
  <show_in_website>1</show_in_website>
35
  <show_in_store>1</show_in_store>
36
+ </account>
37
+ -->
38
 
39
  <!-- Model/Config/Password depends on this tag name + hierarchy -->
40
+ <!--
41
+ <password translate="label">
42
  <label>Password</label>
43
  <frontend_type>text</frontend_type>
44
  <backend_model>intelipost_shipping/config_password</backend_model>
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
+ </password>
51
+ -->
52
+
53
+ <apiurl translate="label">
54
+ <label>API Url</label>
55
+ <frontend_type>text</frontend_type>
56
+ <backend_model>intelipost_shipping/config_apiurl</backend_model>
57
+ <validate>required-entry</validate>
58
+ <sort_order>2</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </apiurl>
63
 
64
  <apikey translate="label">
65
  <label>API Key</label>
66
  <frontend_type>text</frontend_type>
67
  <backend_model>intelipost_shipping/config_apikey</backend_model>
68
  <validate>required-entry</validate>
69
+ <sort_order>3</sort_order>
70
  <show_in_default>1</show_in_default>
71
  <show_in_website>1</show_in_website>
72
  <show_in_store>1</show_in_store>
73
  </apikey>
74
 
75
+ <!--
76
+ <token translate="label">
77
  <label>Token</label>
78
  <frontend_type>text</frontend_type>
79
  <backend_model>intelipost_shipping/config_token</backend_model>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
84
  <show_in_store>1</show_in_store>
85
+ </token>
86
+ -->
87
 
88
  <zipcode translate="label">
89
  <label>Postal Code</label>
90
  <frontend_type>text</frontend_type>
91
  <!--<validate>validate-zip-international required-entry</validate>-->
92
  <validate>required-entry</validate>
93
+ <sort_order>4</sort_order>
94
  <show_in_default>1</show_in_default>
95
  <show_in_website>1</show_in_website>
96
  <show_in_store>1</show_in_store>
97
  </zipcode>
98
 
99
+ <!--
100
+ <category translate="label">
101
  <label>Choose the best fitting category for your products</label>
102
  <frontend_type>select</frontend_type>
103
  <source_model>intelipost_shipping/carrier_category</source_model>
107
  <show_in_store>1</show_in_store>
108
  </category>-->
109
 
110
+ <!--
111
+ <notification translate="label">
112
  <label>Enable dimension check and notifications</label>
113
  <frontend_type>select</frontend_type>
114
  <source_model>adminhtml/system_config_source_yesno</source_model>
117
  <show_in_website>1</show_in_website>
118
  <show_in_store>1</show_in_store>
119
  </notification>
120
+ -->
121
 
122
+ <!--
123
+ <webservice_url translate="label">
124
  <label>Axado's webservice url</label>
125
  <frontend_type>text</frontend_type>
126
  <sort_order>10</sort_order>
127
  <show_in_default>1</show_in_default>
128
  <show_in_website>1</show_in_website>
129
  <show_in_store>1</show_in_store>
130
+ </webservice_url>
131
+ -->
132
  </fields>
133
 
134
  </intelipost>
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelipost</name>
4
- <version>0.8.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License Version 2 (GPLv2)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Intelipost</summary>
10
  <description>Extens&amp;amp;#xE3;o para utilizar o servi&amp;amp;#xE7;o de cota&amp;amp;#xE7;&amp;amp;#xE3;o do intelipost.com.br</description>
11
- <notes>. Refactor for compatibility</notes>
 
 
12
  <authors><author><name>Intelipost</name><user>Intelipost</user><email>it@intelipost.com.br</email></author></authors>
13
- <date>2014-04-07</date>
14
- <time>12:45:29</time>
15
- <contents><target name="magelocal"><dir name="Intelipost"><dir name="Shipping"><dir name="Helper"><file name="Data.php" hash="7523e254d75d8ec6413164bdfc9484ce"/></dir><dir name="Model"><dir name="Carrier"><file name="Category.php" hash="9e3f8a5013f819dc65c9b84848182c8a"/><file name="Intelipost.php" hash="ed0b097f70db82ca33e0f2107fe2f34d"/></dir><dir name="Config"><file name="Apikey.php" hash="b74ed350e2aad08f58f56caaa2b6f7a4"/><file name="Password.php" hash="a3b0f867850520e637ed6d1561047093"/><file name="Token.php" hash="ae2ef4b4527f06c17061d6c984fa0a28"/><file name="Useraccount.php" hash="89a67edacda5169a4f58590e6ac24006"/></dir><dir name="Resource"><file name="Quote.php" hash="1f02542b8f6c4a16400da34e723c0541"/><file name="Setup.php" hash="8f10c3277be3454dbf61abb1fb0b06f4"/><file name="Volume.php" hash="e1e8de42eeb5d1e02e7ebc4a2dff6dd0"/></dir></dir><dir name="etc"><file name="config.xml" hash="5e5cf688524df28ee306b11424804363"/><file name="system.xml" hash="ff6564d28de2203c67379147d24fdea7"/></dir><dir name="sql"><dir name="intelipost_setup"><file name="mysql4-install-0.0.1.php" hash="7cbddb7bad3e35cba43d14d8e2308900"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelipost_Shipping.xml" hash="285e60144ae15077910cb9200038adb9"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Intelipost_Shipping.csv" hash="ae1e673344d004666d04b254556685c5"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Intelipost</name>
4
+ <version>0.8.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License Version 2 (GPLv2)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Intelipost</summary>
10
  <description>Extens&amp;amp;#xE3;o para utilizar o servi&amp;amp;#xE7;o de cota&amp;amp;#xE7;&amp;amp;#xE3;o do intelipost.com.br</description>
11
+ <notes>. Added quote examples&#xD;
12
+ . Check for api_url / api_key right combination&#xD;
13
+ . Added intelipost.log</notes>
14
  <authors><author><name>Intelipost</name><user>Intelipost</user><email>it@intelipost.com.br</email></author></authors>
15
+ <date>2014-04-08</date>
16
+ <time>17:55:45</time>
17
+ <contents><target name="magelocal"><dir name="Intelipost"><dir name="Shipping"><dir name="Helper"><file name="Data.php" hash="7523e254d75d8ec6413164bdfc9484ce"/></dir><dir name="Model"><dir name="Carrier"><file name="Category.php" hash="9e3f8a5013f819dc65c9b84848182c8a"/><file name="Intelipost.php" hash="ed8c41c207e0a228814f98afb6672311"/></dir><dir name="Config"><file name="Apikey.php" hash="0df659e8eb4cbcc4dbbe634f654b88d6"/><file name="Apiurl.php" hash="4517960e32a1f0a92a84ce96ff40c6dd"/><file name="Password.php" hash="a3b0f867850520e637ed6d1561047093"/></dir><dir name="Resource"><file name="EndCustomer.php" hash="a2109babc9b4fc994ccc8bbc3890efe5"/><file name="Invoice.php" hash="f1f792ed019964038769f4950f8c49e3"/><file name="Quote.php" hash="74f2826810d61c8d584ad02a8c12e82d"/><file name="Setup.php" hash="8f10c3277be3454dbf61abb1fb0b06f4"/><file name="ShipmentOrder.php" hash="83c0a94ecd8c9f913a89b3c81798f653"/><file name="Volume.php" hash="0fc8222182fde7557ac85166855a0c4d"/></dir></dir><dir name="etc"><file name="config.xml" hash="5e5cf688524df28ee306b11424804363"/><file name="system.xml" hash="5e58a7b34773cc5f3264c6fb2d2318be"/></dir><dir name="sql"><dir name="intelipost_setup"><file name="mysql4-install-0.0.1.php" hash="7cbddb7bad3e35cba43d14d8e2308900"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intelipost_Shipping.xml" hash="285e60144ae15077910cb9200038adb9"/></dir></target><target name="magelocale"><dir name="pt_BR"><file name="Intelipost_Shipping.csv" hash="ae1e673344d004666d04b254556685c5"/></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
20
  </package>