Skip to content

Commit 6aa6fa1

Browse files
committed
grouped formatting functions into a single 'formatPayload' function
1 parent 7f0c906 commit 6aa6fa1

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/SparkPost/Transmission.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,25 @@ public function __construct(SparkPost $sparkpost)
1414
*
1515
* @return SparkPostPromise or SparkPostResponse depending on sync or async request
1616
*/
17-
public function post($payload, $headers = [])
17+
public function post($payload = [], $headers = [])
1818
{
19+
$payload = $this->formatPayload($payload);
20+
return parent::post($payload, $headers);
21+
}
22+
23+
/**
24+
* Runs the given payload through the formatting methods
25+
*
26+
* @param array $payload - the request body
27+
*
28+
* @return array - the modified request body
29+
*/
30+
public function formatPayload($payload) {
1931
$payload = $this->formatBlindCarbonCopy($payload); //Fixes BCCs into payload
2032
$payload = $this->formatCarbonCopy($payload); //Fixes CCs into payload
2133
$payload = $this->formatShorthandRecipients($payload); //Fixes shorthand recipients format
22-
return parent::post($payload, $headers);
34+
35+
return $payload;
2336
}
2437

2538
/**

0 commit comments

Comments
 (0)