Skip to content

Commit

Permalink
Added CustomRequest call
Browse files Browse the repository at this point in the history
  • Loading branch information
inDeev authored and pionl committed Sep 6, 2022
1 parent 501113e commit c65905e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use SmartEmailing\v3\Request\Send\BulkCustomEmails;
use SmartEmailing\v3\Request\Send\BulkCustomSms;
use SmartEmailing\v3\Request\Send\TransactionalEmails;
use SmartEmailing\v3\Request\CustomRequest\CustomRequest;

/**
* Class Api
Expand Down Expand Up @@ -98,6 +99,11 @@ public function ping(): Ping
return new Ping($this);
}

public function customRequest(string $action, string $method = 'GET', array $postData = []): CustomRequest
{
return new CustomRequest($this, $action, $method, $postData);
}

/**
* @return Credentials
*/
Expand Down
37 changes: 37 additions & 0 deletions src/Request/CustomRequest/CustomRequest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace SmartEmailing\v3\Request\CustomRequest;

use SmartEmailing\v3\Api;
use SmartEmailing\v3\Request\AbstractRequest;

class CustomRequest extends AbstractRequest
{
private string $action;
private string $method;
private array $postData;

public function __construct(Api $api, string $action, string $method = 'GET', array $postData = [])
{
parent::__construct($api);
$this->action = $action;
$this->method = $method;
$this->postData = $postData;
}

protected function method(): string
{
return $this->method;
}

protected function endpoint()
{
return $this->action;
}

protected function options()
{
return [
'json' => $this->postData
];
}
}

0 comments on commit c65905e

Please sign in to comment.