1 | <?php |
||
17 | class SendGrid |
||
18 | { |
||
19 | /** |
||
20 | * API base URL. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $apiUrl = 'https://api.sendgrid.com'; |
||
25 | |||
26 | /** |
||
27 | * API version. |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $apiVersion = 'v3'; |
||
32 | |||
33 | /** |
||
34 | * Underlying HTTP client. |
||
35 | * |
||
36 | * @var \Http\Client\HttpClient |
||
37 | */ |
||
38 | protected $client; |
||
39 | |||
40 | /** |
||
41 | * Message factory. |
||
42 | * |
||
43 | * @var \Http\Message\MessageFactory |
||
44 | */ |
||
45 | protected $messageFactory; |
||
46 | |||
47 | /** |
||
48 | * Make a new ApiClient instance. |
||
49 | * |
||
50 | * If $client is null, a new HttpClient using $apiKey is instantiated. |
||
51 | * If $apiKey is null, SENDGRID_API_KEY environment variable is used. |
||
52 | * $apiKey is not used when $client is specified. |
||
53 | * |
||
54 | * @param null|string $apiKey |
||
55 | * @param null|\Http\Client\HttpClient $client |
||
56 | */ |
||
57 | public function __construct($apiKey = null, HttpClient $client = null) |
||
69 | |||
70 | /** |
||
71 | * |
||
72 | * @return self |
||
73 | */ |
||
74 | |||
75 | /** |
||
76 | * Get a new SendGrid instance. |
||
77 | * |
||
78 | * @param null|string $apiKey |
||
79 | * @param null|\Http\Client\HttpClient $client |
||
80 | * @return self |
||
81 | */ |
||
82 | public static function newInstance($apiKey = null, HttpClient $client = null): self |
||
88 | |||
89 | /** |
||
90 | * Static constructor to get a ApiClient instance with a given HTTP client. |
||
91 | * |
||
92 | * @param \Http\Client\HttpClient $client |
||
93 | * @return self |
||
94 | */ |
||
95 | public static function newWithClient(HttpClient $client): self |
||
99 | |||
100 | /** |
||
101 | * Get a new SendGrid instance with a mock client pre-loaded with HTTP responses. |
||
102 | * |
||
103 | * @param array $responses |
||
104 | * @return self |
||
105 | */ |
||
106 | public static function mock(array $responses): self |
||
115 | |||
116 | /** |
||
117 | * Set the underlying HTTP client. |
||
118 | * |
||
119 | * @param \Http\Client\HttpClient $client |
||
120 | * @return self |
||
121 | */ |
||
122 | public function withClient(HttpClient $client): self |
||
128 | |||
129 | /** |
||
130 | * Get underlying HTTP client. |
||
131 | * |
||
132 | * @return \Http\Client\HttpClient |
||
133 | */ |
||
134 | public function getClient(): HttpClient |
||
138 | |||
139 | /** |
||
140 | * Make a "raw" HTTP request. |
||
141 | * |
||
142 | * JSON responses are automatically decoded. |
||
143 | * |
||
144 | * @param string $method HTTP method |
||
145 | * @param string $url |
||
146 | * @return string|array |
||
147 | */ |
||
148 | public function requestRaw(string $method, string $url = '') |
||
167 | |||
168 | /** |
||
169 | * Make a request using a Request instance. |
||
170 | * |
||
171 | * @param Request $request |
||
172 | * @return Response|Response[] |
||
173 | */ |
||
174 | public function request(Request $request) |
||
186 | } |
||
187 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: