Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
<?php
2
/**
3
  * This library allows you to quickly and easily send emails through SendGrid using PHP.
4
  *
5
  * @author    Elmer Thomas <dx@sendgrid.com>
6
  * @copyright 2017 SendGrid
7
  * @license   https://opensource.org/licenses/MIT The MIT License
8
  * @version   GIT: <git_id>
9
  * @link      http://packagist.org/packages/sendgrid/sendgrid
10
  */
11
 
12
/**
13
  * Interface to the SendGrid Web API
14
  */
15
class SendGrid
16
{
17
    const VERSION = '5.4.2';
18
 
19
    /**
20
     *
21
     * @var string
22
     */
23
    protected $namespace = 'SendGrid';
24
 
25
    /**
26
     * @var \SendGrid\Client
27
     */
28
    public $client;
29
 
30
    /**
31
     * @var string
32
     */
33
    public $version = self::VERSION;
34
 
35
    /**
36
      * Setup the HTTP Client
37
      *
38
      * @param string $apiKey  your SendGrid API Key.
39
      * @param array  $options an array of options, currently only "host" and "curl" are implemented.
40
      */
41
    public function __construct($apiKey, $options = array())
42
    {
43
        $headers = array(
44
            'Authorization: Bearer '.$apiKey,
45
            'User-Agent: sendgrid/' . $this->version . ';php',
46
            'Accept: application/json'
47
            );
48
 
49
        $host = isset($options['host']) ? $options['host'] : 'https://api.sendgrid.com';
50
 
51
        $curlOptions = isset($options['curl']) ? $options['curl'] : null;
52
 
53
        $this->client = new \SendGrid\Client($host, $headers, '/v3', null, $curlOptions);
54
    }
55
}