summaryrefslogtreecommitdiffstats
path: root/lib/SparkPost/Resource.php
blob: 06318b728bb276d38f16faaea46c0060457cf1b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace SparkPost;

class Resource
{
    protected $sparkpost;
    protected $endpoint;

    public function __construct(SparkPost $sparkpost, $endpoint)
    {
        $this->sparkpost = $sparkpost;
        $this->endpoint = $endpoint;
    }

    public function get($uri, $payload, $header)
    {
        return $this->sparkpost->request('GET', $this->endpoint.'/'.$uri, $payload, $header);
    }

    public function post($payload, $header)
    {
        echo "<textarea>" . json_encode($payload) . "</textarea>";
        return $this->sparkpost->request('POST', $this->endpoint, $payload, $header);
    }
}