Skip to content

Commit

Permalink
Merge pull request #61 from ebizmarts/Issue-60
Browse files Browse the repository at this point in the history
closes #60
  • Loading branch information
gonzaloebiz authored Dec 9, 2024
2 parents 681e7b9 + a9497dc commit 42840d1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## [3.0.43](https://github.com/ebizmarts/mailchimp-lib/tree/3.0.43) (2024-12-09)

[Full Changelog](https://github.com/ebizmarts/mailchimp-lib/compare/3.0.42...3.0.43)

**Implemented enhancements:**

- Add timestamp and url [\#60](https://github.com/ebizmarts/mailchimp-lib/issues/60)

## [3.0.42](https://github.com/ebizmarts/mailchimp-lib/tree/3.0.42) (2024-12-04)

[Full Changelog](https://github.com/ebizmarts/mailchimp-lib/compare/3.0.41...3.0.42)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ebizmarts/mailchimp-lib",
"type": "library",
"version": "3.0.42",
"version": "3.0.43",
"description": "API client library for the MailChimp",
"keywords": ["email", "api","mailchimp"],
"homepage": "https://github.com/ebizmarts/mailchimp-lib",
Expand Down
15 changes: 12 additions & 3 deletions src/Mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class Mailchimp
protected $_root = 'https://api.mailchimp.com/3.0';
protected $_debug = false;
protected $helper = null;
protected $storeURL = null;


public $root;
public $authorizedApps;
Expand Down Expand Up @@ -210,6 +212,10 @@ public function setHelper($helper)
{
$this->helper = $helper;
}
public function setStoreURL($storeURL)
{
$this->storeURL = $storeURL;
}

public function setUserAgent($userAgent)
{
Expand Down Expand Up @@ -257,7 +263,7 @@ public function call($url,$params,$method=Mailchimp::GET)

$info = curl_getinfo($ch);
if(curl_error($ch)) {
throw new Mailchimp_HttpError($this->_root . $url, $method, $params, '', curl_error($ch),null,null, $this->helper);
throw new Mailchimp_HttpError($this->_root . $url, $method, $params, '', curl_error($ch),null,null, $this->helper, $this->storeURL);
}
$result = json_decode($response_body, true);

Expand All @@ -267,9 +273,9 @@ public function call($url,$params,$method=Mailchimp::GET)
$errors = array_key_exists('errors', $result) ? $result['errors'] : null;
$title = array_key_exists('title', $result) ? $result['title'] : '';
$instance = array_key_exists('title', $result) ? $result['instance'] : null;
throw new Mailchimp_Error($this->_root . $url, $method, $params, $title, $detail, $errors, $instance, $this->helper);
throw new Mailchimp_Error($this->_root . $url, $method, $params, $title, $detail, $errors, $instance, $this->helper, $this->storeURL);
} else {
throw new Mailchimp_Error($this->_root . $url, $method, $params, $result, null, null, null, $this->helper);
throw new Mailchimp_Error($this->_root . $url, $method, $params, $result, null, null, null, $this->helper, $this->storeURL);
}
}
if ($this->helper) {
Expand All @@ -279,6 +285,9 @@ public function call($url,$params,$method=Mailchimp::GET)
} else {
$total_time = 0;
}
if ($this->storeURL) {
$curlinfo['storeURL'] = $this->storeURL;
}
$curlinfo['info']['total_time'] = $total_time;
$curlinfo['info']['time'] = $this->helper->getGmtDate();
$curlinfo['info']['url'] = $this->_root . $url;
Expand Down
10 changes: 9 additions & 1 deletion src/Mailchimp/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ class Mailchimp_Error extends Exception
*/
protected $instance;
protected $helper;
protected $storeURL;

/**
* @var string
*/
protected $params;

public function __construct($url,$method='',$params='',$title='',$detail='',$errors=null, $instance = null, $helper=null)
public function __construct($url,$method='',$params='',$title='',$detail='',$errors=null, $instance = null, $helper=null, $storeURL=null)
{
$titleComplete = $title . " for Api Call: " . $url;
parent::__construct($titleComplete . " - " . $detail);
Expand All @@ -55,6 +56,7 @@ public function __construct($url,$method='',$params='',$title='',$detail='',$err
$this->params = $params;
$this->instance = $instance;
$this->helper = $helper;
$this->storeURL = $storeURL;
}
public function getFriendlyMessage()
{
Expand All @@ -79,6 +81,12 @@ public function getFriendlyMessage()
$error['instance'] = $this->instance;
}
$errors = [];
if ($this->storeURL) {
$errors['storeURL'] = $this->storeURL;
}
if ($this->helper) {
$errors['time'] = $this->helper->getGmtDate();
}
$errors['error'] = $error;
if ($this->helper) {
$this->helper->saveNotification($errors);
Expand Down

0 comments on commit 42840d1

Please sign in to comment.