mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-16 13:03:13 +03:00
Merge branch 'master' of https://github.com/mailgun/mailgun-php into travis/merging
This commit is contained in:
commit
45ec0c8f3a
@ -117,9 +117,11 @@ class RestClient{
|
||||
public function responseHandler($responseObj){
|
||||
$httpResponseCode = $responseObj->getStatusCode();
|
||||
if($httpResponseCode === 200){
|
||||
$jsonResponseData = json_decode($responseObj->getBody(), false);
|
||||
$data = (string) $responseObj->getBody();
|
||||
$jsonResponseData = json_decode($data, false);
|
||||
$result = new \stdClass();
|
||||
$result->http_response_body = $jsonResponseData;
|
||||
// return response data as json if possible, raw if not
|
||||
$result->http_response_body = $data && $jsonResponseData === null ? $data : $jsonResponseData;
|
||||
}
|
||||
elseif($httpResponseCode == 400){
|
||||
throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
|
||||
|
@ -169,26 +169,22 @@ class MessageBuilder
|
||||
|
||||
public function addAttachment($attachmentPath, $attachmentName = null)
|
||||
{
|
||||
if (preg_match("/^@/", $attachmentPath)) {
|
||||
if (isset($this->files["attachment"])) {
|
||||
$attachment = array(
|
||||
if (isset($this->files["attachment"])) {
|
||||
$attachment = array(
|
||||
'filePath' => $attachmentPath,
|
||||
'remoteName' => $attachmentName
|
||||
);
|
||||
array_push($this->files["attachment"], $attachment);
|
||||
} else {
|
||||
$this->files["attachment"] = array(
|
||||
array(
|
||||
'filePath' => $attachmentPath,
|
||||
'remoteName' => $attachmentName
|
||||
);
|
||||
array_push($this->files["attachment"], $attachment);
|
||||
} else {
|
||||
$this->files["attachment"] = array(
|
||||
array(
|
||||
'filePath' => $attachmentPath,
|
||||
'remoteName' => $attachmentName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
throw new InvalidParameter(INVALID_PARAMETER_ATTACHMENT);
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function addInlineImage($inlineImagePath, $inlineImageName = null)
|
||||
@ -314,15 +310,7 @@ class MessageBuilder
|
||||
|
||||
public function addCustomData($customName, $data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
$jsonArray = json_encode($data);
|
||||
$this->message['v:' . $customName] = $jsonArray;
|
||||
|
||||
return $this->message['v:' . $customName];
|
||||
} else {
|
||||
throw new InvalidParameter(INVALID_PARAMETER_NON_ARRAY);
|
||||
}
|
||||
|
||||
$this->message['v:' . $customName] = json_encode($data);
|
||||
}
|
||||
|
||||
public function addCustomParameter($parameterName, $data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user