Skip to content
This repository has been archived by the owner on Feb 1, 2018. It is now read-only.

Commit

Permalink
Change Permissions
Browse files Browse the repository at this point in the history
Fix merge_vars
Fix get url
  • Loading branch information
gonzaloebiz committed Mar 2, 2016
1 parent ce16975 commit f0054b8
Show file tree
Hide file tree
Showing 28 changed files with 45 additions and 19 deletions.
Empty file modified Block/Adminhtml/System/Config/Account.php
100755 → 100644
Empty file.
Empty file modified Block/Adminhtml/System/Config/Fieldset/Hint.php
100755 → 100644
Empty file.
Empty file modified Block/Adminhtml/System/Config/Form/Field/Customermap.php
100755 → 100644
Empty file.
Empty file modified Block/Adminhtml/System/Config/OauthWizard.php
100755 → 100644
Empty file.
33 changes: 20 additions & 13 deletions Helper/Data.php
100755 → 100644
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ public function getMergeVars($customer,$store = null)
$mergeVars = unserialize($this->scopeConfig->getValue(self::XML_PATH_MAPPING, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store)); $mergeVars = unserialize($this->scopeConfig->getValue(self::XML_PATH_MAPPING, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store));
foreach($mergeVars as $map) foreach($mergeVars as $map)
{ {
$this->_getMergeVarsValue($map, $customer); array_merge($merge_vars,$this->_getMergeVarsValue($map, $customer));
} }
return $merge_vars; return $merge_vars;
} }


protected function _getMergeVarsValue($map, $customer) protected function _getMergeVarsValue($map, $customer)
{ {
$merge_vars = array();
$customAtt = $map['magento']; $customAtt = $map['magento'];
$chimpTag = $map['mailchimp']; $chimpTag = $map['mailchimp'];
if($chimpTag && $customAtt) { if($chimpTag && $customAtt) {
Expand Down Expand Up @@ -120,27 +121,18 @@ protected function _getMergeVarsValue($map, $customer)
case 'billing_address': case 'billing_address':
case 'shipping_address': case 'shipping_address':
$addr = explode('_', $customAtt); $addr = explode('_', $customAtt);
if ($address = $customer->{'getPrimary' . ucfirst($addr[0]) . 'Address'}()) { array_merge($merge_vars,$this->_updateMergeVars($key,ucfirst($addr[0]),$customer));
$merge_vars[$key] = array(
'addr1' => $address->getStreet(1),
'addr2' => $address->getStreet(2),
'city' => $address->getCity(),
'state' => (!$address->getRegion() ? $address->getCity() : $address->getRegion()),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId()
);
}
break; break;
case 'telephone': case 'telephone':
if ($address = $customer->{'getPrimaryBillingAddress'}()) { if ($address = $customer->{'getDefaultBillingAddress'}()) {
$telephone = $address->getTelephone(); $telephone = $address->getTelephone();
if ($telephone) { if ($telephone) {
$merge_vars['TELEPHONE'] = $telephone; $merge_vars['TELEPHONE'] = $telephone;
} }
} }
break; break;
case 'company': case 'company':
if ($address = $customer->{'getPrimaryBillingAddress'}()) { if ($address = $customer->{'getDefaultBillingAddress'}()) {
$company = $address->getCompany(); $company = $address->getCompany();
if ($company) { if ($company) {
$merge_vars['COMPANY'] = $company; $merge_vars['COMPANY'] = $company;
Expand Down Expand Up @@ -168,4 +160,19 @@ protected function _getMergeVarsValue($map, $customer)
return $merge_vars; return $merge_vars;
} }
} }
protected function _updateMergeVars($key,$type,$customer)
{
$merge_vars = array();
if ($address = $customer->{'getDefault' . $type . 'Address'}()) {
$merge_vars[$key] = array(
'addr1' => $address->getStreetLine(1),
'addr2' => $address->getStreetLine(2),
'city' => $address->getCity(),
'state' => (!$address->getRegion() ? $address->getCity() : $address->getRegion()),
'zip' => $address->getPostcode(),
'country' => $address->getCountryId()
);
}
return $merge_vars;
}
} }
Empty file modified Model/Api.php
100755 → 100644
Empty file.
19 changes: 19 additions & 0 deletions Model/Config.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
/**
* magento2magemonkey Magento Component
*
* @category Ebizmarts
* @package magento2magemonkey
* @author Ebizmarts Team <info@ebizmarts.com>
* @copyright Ebizmarts (http://ebizmarts.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @date: 3/2/16 2:44 PM
* @file: ModelConfig.php
*/
namespace Ebizmarts\MageMonkey\Model;

class Config
{
CONST ENDPOINT = 'api.mailchimp.com';
CONST SCHEME = 'https';
}
Empty file modified Model/Config/Source/Details.php
100755 → 100644
Empty file.
Empty file modified Model/Config/Source/Monkeylist.php
100755 → 100644
Empty file.
Empty file modified Model/Logger/Handler/System.php
100755 → 100644
Empty file.
Empty file modified Model/Logger/Magemonkey.php
100755 → 100644
Empty file.
10 changes: 5 additions & 5 deletions Model/MCAPI.php
100755 → 100644
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class MCAPI class MCAPI
{ {
protected $_version = "3.0"; protected $_version = "3.0";
protected $_apiUrl = null; // protected $_apiUrl = null;
protected $_timeout = 300; protected $_timeout = 300;
protected $_chunkSize = 8192; protected $_chunkSize = 8192;
protected $_apiKey = null; protected $_apiKey = null;
Expand All @@ -31,7 +31,7 @@ public function __construct(
) )
{ {
$this->_helper = $helper; $this->_helper = $helper;
$this->_apiUrl = parse_url("http://api.mailchimp.com/" . $this->_version); // $this->_apiUrl = parse_url(\Ebizmarts\MageMonkey\Model\Config::MAILCHIMP_ENDPOINT);
} }


public function load($apiKey, $secure = false){ public function load($apiKey, $secure = false){
Expand Down Expand Up @@ -72,7 +72,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =
$dc = 'us1'; $dc = 'us1';
} }
} }
$host = $dc.'.'.$this->_apiUrl['host'].'/'.$this->_version; $host = $dc.'.'.\Ebizmarts\MageMonkey\Model\Config::ENDPOINT.'/'.$this->_version;
if($method) if($method)
{ {
$host .= "/$method"; $host .= "/$method";
Expand Down Expand Up @@ -120,7 +120,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =


} }


curl_setopt($ch, CURLOPT_URL, $host); curl_setopt($ch, CURLOPT_URL, \Ebizmarts\MageMonkey\Model\Config::SCHEME.'://'.$host);
curl_setopt($ch, CURLOPT_USERAGENT, 'MageMonkey/'); // @todo put the version of MageMonkey curl_setopt($ch, CURLOPT_USERAGENT, 'MageMonkey/'); // @todo put the version of MageMonkey
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: apikey '.$key,'Cache-Control: no-cache')); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Authorization: apikey '.$key,'Cache-Control: no-cache'));
Expand All @@ -136,7 +136,7 @@ public function callServer($use = 'GET',$method = null, $params = null,$fields =
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE); $responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
curl_close($ch); curl_close($ch);
$data = json_decode($body); $data = json_decode($body);
$this->_helper->log(print_r(json_encode($data),1)); $this->_helper->log(var_export(json_encode($data),1));
switch($use) switch($use)
{ {
case 'DELETE': case 'DELETE':
Expand Down
2 changes: 1 addition & 1 deletion Model/Plugin/Subscriber.php
100755 → 100644
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function beforeSubscribeCustomerById(
}else { }else {
$data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status); $data = array('list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status);
} }
$this->_helper->log(print_r(json_encode($data), 1)); $this->_helper->log(var_export(json_encode($data), 1));
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data)); $return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
if (isset($return->id)) { if (isset($return->id)) {
$subscriber->setMagemonkeyId($return->id); $subscriber->setMagemonkeyId($return->id);
Expand Down
Empty file modified Model/Resource/Setup.php
100755 → 100644
Empty file.
Empty file modified Setup/InstallSchema.php
100755 → 100644
Empty file.
Empty file modified Setup/UpgradeSchema.php
100755 → 100644
Empty file.
Empty file modified Test/Unit/Model/Config/Source/DetailsTest.php
100755 → 100644
Empty file.
Empty file modified Test/Unit/Model/Config/Source/MonkeylistTest.php
100755 → 100644
Empty file.
Empty file modified Test/Unit/Model/Plugin/SubscriberTest.php
100755 → 100644
Empty file.
Empty file modified composer.json
100755 → 100644
Empty file.
Empty file modified etc/adminhtml/system.xml
100755 → 100644
Empty file.
Empty file modified etc/config.xml
100755 → 100644
Empty file.
Empty file modified etc/di.xml
100755 → 100644
Empty file.
Empty file modified etc/module.xml
100755 → 100644
Empty file.
Empty file modified i18n/en_US.csv
100755 → 100644
Empty file.
Empty file modified registration.php
100755 → 100644
Empty file.
Empty file modified view/adminhtml/templates/system/config/fieldset/hint.phtml
100755 → 100644
Empty file.
Empty file modified view/adminhtml/templates/system/config/oauth_wizard.phtml
100755 → 100644
Empty file.

0 comments on commit f0054b8

Please sign in to comment.