Skip to content
Snippets Groups Projects
Verified Commit 30837c4a authored by Damien's avatar Damien
Browse files

FEAT #14597 TIME 3:00 WIP maileva v2

parent e24fb226
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ROOT> <ROOT>
<ENABLED>false</ENABLED> <ENABLED>false</ENABLED>
<CONNECTION_URI>https://api.sandbox.aws.maileva.net</CONNECTION_URI> <CONNECTION_URI>https://api.sandbox.maileva.net</CONNECTION_URI>
<URI>https://api.sandbox.aws.maileva.net</URI> <URI>https://api.sandbox.maileva.net</URI>
<CLIENT_ID>ed7637a582ea422d90a8f8753079a386</CLIENT_ID> <CLIENT_ID>ed7637a582ea422d90a8f8753079a386</CLIENT_ID>
<CLIENT_SECRET>abb3ebc779e84291aa4a06e7f36034ec</CLIENT_SECRET> <CLIENT_SECRET>abb3ebc779e84291aa4a06e7f36034ec</CLIENT_SECRET>
</ROOT> </ROOT>
\ No newline at end of file
...@@ -178,7 +178,7 @@ trait ShippingTrait ...@@ -178,7 +178,7 @@ trait ShippingTrait
$resId = $resource['res_id']; $resId = $resource['res_id'];
$createSending = CurlModel::execSimple([ $createSending = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . '/mail/v1/sendings', 'url' => $mailevaConfig['uri'] . '/registered_mail/v2/sendings',
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'headers' => ['Content-Type: application/json'], 'headers' => ['Content-Type: application/json'],
'method' => 'POST', 'method' => 'POST',
...@@ -188,13 +188,14 @@ trait ShippingTrait ...@@ -188,13 +188,14 @@ trait ShippingTrait
$errors[] = "Maileva sending creation failed for attachment {$resId}"; $errors[] = "Maileva sending creation failed for attachment {$resId}";
continue; continue;
} }
foreach ($createSending['headers'] as $header) { $sendingId = $createSending['response']['id'];
if (strpos($header, 'Location:') !== false) { // foreach ($createSending['headers'] as $header) {
$sendingId = strrchr($header, '/'); // if (strpos($header, 'Location:') !== false) {
$sendingId = substr($sendingId, 1); // $sendingId = strrchr($header, '/');
break; // $sendingId = substr($sendingId, 1);
} // break;
} // }
// }
if (empty($sendingId)) { if (empty($sendingId)) {
$errors[] = "Maileva sending id not found for attachment {$resId}"; $errors[] = "Maileva sending id not found for attachment {$resId}";
continue; continue;
...@@ -231,7 +232,7 @@ trait ShippingTrait ...@@ -231,7 +232,7 @@ trait ShippingTrait
} }
$createDocument = CurlModel::execSimple([ $createDocument = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . "/mail/v1/sendings/{$sendingId}/documents", 'url' => $mailevaConfig['uri'] . "/registered_mail/v2/sendings/{$sendingId}/documents",
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'method' => 'POST', 'method' => 'POST',
'multipartBody' => ['document' => file_get_contents($pathToDocument), 'metadata' => json_encode(['priority' => 0, 'name' => $resource['title']])] 'multipartBody' => ['document' => file_get_contents($pathToDocument), 'metadata' => json_encode(['priority' => 0, 'name' => $resource['title']])]
...@@ -244,7 +245,7 @@ trait ShippingTrait ...@@ -244,7 +245,7 @@ trait ShippingTrait
$recipients = []; $recipients = [];
if ($resource['type'] == 'attachment') { if ($resource['type'] == 'attachment') {
$createRecipient = CurlModel::execSimple([ $createRecipient = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . "/mail/v1/sendings/{$sendingId}/recipients", 'url' => $mailevaConfig['uri'] . "/registered_mail/v2/sendings/{$sendingId}/recipients",
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'headers' => ['Content-Type: application/json'], 'headers' => ['Content-Type: application/json'],
'method' => 'POST', 'method' => 'POST',
...@@ -266,7 +267,7 @@ trait ShippingTrait ...@@ -266,7 +267,7 @@ trait ShippingTrait
} else { } else {
foreach ($contacts[$key] as $contact) { foreach ($contacts[$key] as $contact) {
$createRecipient = CurlModel::execSimple([ $createRecipient = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . "/mail/v1/sendings/{$sendingId}/recipients", 'url' => $mailevaConfig['uri'] . "/registered_mail/v2/sendings/{$sendingId}/recipients",
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'headers' => ['Content-Type: application/json'], 'headers' => ['Content-Type: application/json'],
'method' => 'POST', 'method' => 'POST',
...@@ -289,7 +290,7 @@ trait ShippingTrait ...@@ -289,7 +290,7 @@ trait ShippingTrait
} }
$setOptions = CurlModel::execSimple([ $setOptions = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . "/mail/v1/sendings/{$sendingId}/options", 'url' => $mailevaConfig['uri'] . "/registered_mail/v2/sendings/{$sendingId}",
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'headers' => ['Content-Type: application/json'], 'headers' => ['Content-Type: application/json'],
'method' => 'PATCH', 'method' => 'PATCH',
...@@ -306,7 +307,7 @@ trait ShippingTrait ...@@ -306,7 +307,7 @@ trait ShippingTrait
} }
$submit = CurlModel::execSimple([ $submit = CurlModel::execSimple([
'url' => $mailevaConfig['uri'] . "/mail/v1/sendings/{$sendingId}/submit", 'url' => $mailevaConfig['uri'] . "/registered_mail/v2/sendings/{$sendingId}/submit",
'bearerAuth' => ['token' => $token], 'bearerAuth' => ['token' => $token],
'headers' => ['Content-Type: application/json'], 'headers' => ['Content-Type: application/json'],
'method' => 'POST' 'method' => 'POST'
......
...@@ -152,6 +152,9 @@ class ShippingTemplateController ...@@ -152,6 +152,9 @@ class ShippingTemplateController
$body['options'] = json_encode($body['options']); $body['options'] = json_encode($body['options']);
$body['fee'] = json_encode($body['fee']); $body['fee'] = json_encode($body['fee']);
foreach ($body['entities'] as $key => $entity) {
$body['entities'][$key] = (string)$entity;
}
$body['entities'] = json_encode($body['entities']); $body['entities'] = json_encode($body['entities']);
$body['account'] = json_encode($body['account']); $body['account'] = json_encode($body['account']);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment