-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync all the statistincs #2041 for magento 2.4
- Loading branch information
1 parent
23ff13f
commit 3f1bb67
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Ebizmarts\MailChimp\Helper; | ||
|
||
use Magento\Framework\HTTP\Client\Curl; | ||
use Ebizmarts\MailChimp\Helper\Data as MailChimpHelper; | ||
|
||
class Http | ||
{ | ||
/** | ||
* @var Curl | ||
*/ | ||
protected $curl; | ||
protected $url; | ||
public function __construct( | ||
Curl $curl, | ||
MailChimpHelper $helper | ||
) { | ||
$this->curl = $curl; | ||
$this->url = $helper->getConfigValue(MailChimpHelper::SYNC_NOTIFICATION_URL); | ||
$token = $helper->getConfigValue(MailChimpHelper::SYNC_TOKEN); | ||
$headers = ['Authorization' => 'Bearer ' . $token, | ||
'Content-Type' => 'application/json' | ||
]; | ||
$this->curl->setOption(CURLOPT_RETURNTRANSFER, true); | ||
$this->curl->setHeaders($headers); | ||
} | ||
public function post($body) | ||
{ | ||
$this->curl->post($this->url , $body); | ||
$response = $this->curl->getBody(); | ||
return $response; | ||
} | ||
public function extractResponse($response) | ||
{ | ||
$data = json_decode($response, true); | ||
if (key_exists('error', $data) && !$data['error']) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters