Skip to content

Commit

Permalink
suppress_webhooks mark when marking CustomerInvoice as booked
Browse files Browse the repository at this point in the history
  • Loading branch information
kg-bot committed Feb 22, 2021
1 parent 6edef16 commit cfdee01
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/Models/CustomerInvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,38 @@ class CustomerInvoice extends Model
* [
* "send" => false,
* "body" => "Something",
* "subject" => "YOUR SUBJECT",
* "receivers" => [
* "to" => [ "email@here.com"],
* "cc" => ["cc-email@here.com"],
* "bcc" => ["bcc1-email@here.com", "bcc2@here.com"]
* ]
* ]
* If you set send to false or use ->book(true) email body won't be included
* </p>
* @return mixed
* @throws \Rackbeat\Exceptions\RackbeatClientException
* @throws \Rackbeat\Exceptions\RackbeatRequestException
*/
public function book($send_email = false)
{
return $this->request->handleWithExceptions(function () use ($send_email) {

$query = '';
$body = [];
* "subject" => "YOUR SUBJECT",
* "receivers" => [
* "to" => [ "email@here.com"],
* "cc" => ["cc-email@here.com"],
* "bcc" => ["bcc1-email@here.com", "bcc2@here.com"]
* ]
* ]
* If you set send to false or use ->book(true) email body won't be included
* </p>
* @param bool $suppress_webhooks
*
* @return mixed
* @throws \Rackbeat\Exceptions\RackbeatClientException
* @throws \Rackbeat\Exceptions\RackbeatRequestException
*/
public function book( $send_email = false, bool $suppress_webhooks = false ) {
return $this->request->handleWithExceptions( function () use ( $send_email, $suppress_webhooks ) {

if (is_bool($send_email)) {
$query = '';
$body = [
'suppress_webhooks' => $suppress_webhooks
];

$query = ($send_email === true) ? '?send_mail=true' : '';
} else if (is_array($send_email)) {
if ( is_bool( $send_email ) ) {

$body = [
$query = ( $send_email === true ) ? '?send_mail=true' : '';
} else if ( is_array( $send_email ) ) {

'mail' => $send_email,
];
}
$body['mail'] = $send_email;
}

$response = $this->request->client->post("{$this->entity}/{$this->url_friendly_id}/book" . $query, [
$response = $this->request->client->post( "{$this->entity}/{$this->url_friendly_id}/book" . $query, [
'json' => $body,
]);

Expand Down

0 comments on commit cfdee01

Please sign in to comment.