diff options
author | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-17 10:57:34 -0400 |
---|---|---|
committer | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-17 10:57:34 -0400 |
commit | 0942bed79ca5e8162213405ea16350ae855d9546 (patch) | |
tree | ab1b97ae22cb105a32e2964b0c8a583a2ede043a | |
parent | 9ef3ac964350190dc77d484e89787d5e80f8c7f9 (diff) | |
download | php-sparkpost-0942bed79ca5e8162213405ea16350ae855d9546.zip php-sparkpost-0942bed79ca5e8162213405ea16350ae855d9546.tar.gz php-sparkpost-0942bed79ca5e8162213405ea16350ae855d9546.tar.bz2 |
added put and delete methods along with request function to handle case with no uri with a payload
-rw-r--r-- | lib/SparkPost/Resource.php | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/SparkPost/Resource.php b/lib/SparkPost/Resource.php index 3a2dd07..59e015d 100644 --- a/lib/SparkPost/Resource.php +++ b/lib/SparkPost/Resource.php @@ -13,13 +13,37 @@ class Resource $this->endpoint = $endpoint; } - public function get($uri, $payload, $header) + public function get($uri, $payload, $headers) { - return $this->sparkpost->request('GET', $this->endpoint.'/'.$uri, $payload, $header); + return $this->request('GET', $uri, $payload, $headers); } - public function post($payload, $header) + public function put($uri, $payload, $headers) { - return $this->sparkpost->request('POST', $this->endpoint, $payload, $header); + return $this->request('PUT', $uri, $payload, $headers); + } + + public function post($payload, $headers) + { + return $this->request('POST', '', $payload, $headers); + } + + public function delete($uri, $payload, $headers) + { + return $this->request('DELETE', $uri, $payload, $headers); + } + + public function request($method = 'GET', $uri = '', $payload = [], $headers = []) + { + + if (is_array($uri)) { + $headers = $payload; + $payload = $uri; + $uri = ''; + } + + $uri = $this->endpoint.'/'.$uri; + + return $this->sparkpost->request($method, $uri, $payload, $headers); } }
\ No newline at end of file |