@@ -131,7 +131,7 @@ public function delete( $resourcePath=null, Array $query=[] ) {
131
131
* assembles a URL for a request
132
132
* @param string $resourcePath path after the initial endpoint
133
133
* @param array $options array with an optional value of query with values to build a querystring from. Any
134
- * query elements that are themselves arrays will be imploded into a comma separated list.
134
+ * query elements that are themselves arrays will be imploded into a comma separated list.
135
135
* @return string the assembled URL
136
136
*/
137
137
private function buildUrl ($ resourcePath , $ options ) {
@@ -202,7 +202,14 @@ private function callResource( $action, $resourcePath=null, $options=[] ) {
202
202
return json_decode ($ response ->getBody ()->getContents (), true );
203
203
}
204
204
elseif ($ statusCode === 403 ) {
205
- throw new APIResponseException ('Request forbidden. Does this API Key have the correct SparkPost permissions? ' );
205
+ $ response = json_decode ($ response ->getBody (), true );
206
+ throw new APIResponseException (
207
+ 'Request forbidden ' ,
208
+ $ statusCode ,
209
+ isset ($ response ['errors ' ][0 ]['message ' ]) ? $ response ['errors ' ][0 ]['message ' ] : "Request forbidden " ,
210
+ isset ($ response ['errors ' ][0 ]['code ' ]) ? $ response ['errors ' ][0 ]['code ' ] : 1100 ,
211
+ isset ($ response ['errors ' ][0 ]['description ' ]) ? $ response ['errors ' ][0 ]['description ' ] : "Does this API Key have the correct permissions? "
212
+ );
206
213
}
207
214
elseif ($ statusCode === 404 ) {
208
215
throw new APIResponseException ('The specified resource does not exist ' , 404 );
0 commit comments