diff options
author | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-21 14:15:08 -0400 |
---|---|---|
committer | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-21 14:15:08 -0400 |
commit | 61e1ea7cb8ec1822d80302eecc7ba04165d2f110 (patch) | |
tree | 59764d960e1e89ac5293e28824708e84c2d57830 /lib/SparkPost/Resource.php | |
parent | 7adc129a5fe72f5550db34a0a7f89150b17ca83d (diff) | |
download | php-sparkpost-61e1ea7cb8ec1822d80302eecc7ba04165d2f110.zip php-sparkpost-61e1ea7cb8ec1822d80302eecc7ba04165d2f110.tar.gz php-sparkpost-61e1ea7cb8ec1822d80302eecc7ba04165d2f110.tar.bz2 |
added comments and fixed BCC
Diffstat (limited to 'lib/SparkPost/Resource.php')
-rw-r--r-- | lib/SparkPost/Resource.php | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/SparkPost/Resource.php b/lib/SparkPost/Resource.php index 59e015d..55e87a3 100644 --- a/lib/SparkPost/Resource.php +++ b/lib/SparkPost/Resource.php @@ -4,35 +4,75 @@ namespace SparkPost; class Resource { + /** + * SparkPost object used to make requests + */ protected $sparkpost; + + /** + * The api endpoint that gets prepended to all requests send through this resource + */ protected $endpoint; + /** + * Sets up the Resource + * + * @param SparKPost $sparkpost - the sparkpost instance that this resource is attached to + * @param string $endpoint - the endpoint that this resource wraps + */ public function __construct(SparkPost $sparkpost, $endpoint) { $this->sparkpost = $sparkpost; $this->endpoint = $endpoint; } + /** + * Sends get request to API at the set endpoint + * + * @see SparkPost->request() + */ public function get($uri, $payload, $headers) { return $this->request('GET', $uri, $payload, $headers); } + /** + * Sends put request to API at the set endpoint + * + * @see SparkPost->request() + */ public function put($uri, $payload, $headers) { return $this->request('PUT', $uri, $payload, $headers); } + /** + * Sends post request to API at the set endpoint + * + * @see SparkPost->request() + */ public function post($payload, $headers) { return $this->request('POST', '', $payload, $headers); } + /** + * Sends delete request to API at the set endpoint + * + * @see SparkPost->request() + */ public function delete($uri, $payload, $headers) { return $this->request('DELETE', $uri, $payload, $headers); } + /** + * Sends requests to SparkPost object to the resource endpoint + * + * @see SparkPost->request() + * + * @return SparkPostPromise or SparkPostResponse depending on sync or async request + */ public function request($method = 'GET', $uri = '', $payload = [], $headers = []) { |