11<?php
22
3- namespace Printful \ PrintfulApi ;
3+ namespace Printful ;
44
5- use Printful \PrintfulApi \ Exceptions \PrintfulApiException ;
6- use Printful \PrintfulApi \ Exceptions \PrintfulException ;
5+ use Printful \Exceptions \PrintfulApiException ;
6+ use Printful \Exceptions \PrintfulException ;
77
88/**
99 * Class PrintfulClient
1010 */
11- class PrintfulClient
11+ class PrintfulApiClient
1212{
1313 /**
1414 * Printful API key
@@ -20,13 +20,13 @@ class PrintfulClient
2020
2121 private $ lastResponse ;
2222
23- const API_URL = 'https://api.theprintful.com/ ' ;
23+ public $ url = 'https://api.theprintful.com/ ' ;
2424
25- const USER_AGENT = 'Printful API PHP Library 1 .0 ' ;
25+ const USER_AGENT = 'Printful PHP API SDK 2 .0 ' ;
2626
2727 /**
2828 * @param string $key Printful Store API key
29- * @throws PrintfulException if the library failed to initialize
29+ * @throws \Printful\Exceptions\ PrintfulException if the library failed to initialize
3030 */
3131 public function __construct ($ key )
3232 {
@@ -52,7 +52,7 @@ public function getItemCount()
5252 * @param string $path Request path (e.g. 'orders' or 'orders/123')
5353 * @param array $params Additional GET parameters as an associative array
5454 * @return mixed API response
55- * @throws PrintfulApiException if the API call status code is not in the 2xx range
55+ * @throws \Printful\Exceptions\ PrintfulApiException if the API call status code is not in the 2xx range
5656 * @throws PrintfulException if the API call has failed or the response is invalid
5757 */
5858 public function get ($ path , $ params = [])
@@ -65,8 +65,8 @@ public function get($path, $params = [])
6565 * @param string $path Request path (e.g. 'orders' or 'orders/123')
6666 * @param array $params Additional GET parameters as an associative array
6767 * @return mixed API response
68- * @throws PrintfulApiException if the API call status code is not in the 2xx range
69- * @throws PrintfulException if the API call has failed or the response is invalid
68+ * @throws \Printful\Exceptions\ PrintfulApiException if the API call status code is not in the 2xx range
69+ * @throws \Printful\Exceptions\ PrintfulException if the API call has failed or the response is invalid
7070 */
7171 public function delete ($ path , $ params = [])
7272 {
@@ -79,7 +79,7 @@ public function delete($path, $params = [])
7979 * @param array $data Request body data as an associative array
8080 * @param array $params Additional GET parameters as an associative array
8181 * @return mixed API response
82- * @throws PrintfulApiException if the API call status code is not in the 2xx range
82+ * @throws \Printful\Exceptions\ PrintfulApiException if the API call status code is not in the 2xx range
8383 * @throws PrintfulException if the API call has failed or the response is invalid
8484 */
8585 public function post ($ path , $ data = [], $ params = [])
@@ -93,8 +93,8 @@ public function post($path, $data = [], $params = [])
9393 * @param array $data Request body data as an associative array
9494 * @param array $params Additional GET parameters as an associative array
9595 * @return mixed API response
96- * @throws PrintfulApiException if the API call status code is not in the 2xx range
97- * @throws PrintfulException if the API call has failed or the response is invalid
96+ * @throws \Printful\Exceptions\ PrintfulApiException if the API call status code is not in the 2xx range
97+ * @throws \Printful\Exceptions\ PrintfulException if the API call has failed or the response is invalid
9898 */
9999 public function put ($ path , $ data = [], $ params = [])
100100 {
@@ -126,8 +126,8 @@ public function getLastResponse()
126126 * @param array $params
127127 * @param mixed $data
128128 * @return
129- * @throws PrintfulApiException
130- * @throws PrintfulException
129+ * @throws \Printful\Exceptions\ PrintfulApiException
130+ * @throws \Printful\Exceptions\ PrintfulException
131131 */
132132 private function request ($ method , $ path , array $ params = [], $ data = null )
133133 {
@@ -140,7 +140,7 @@ private function request($method, $path, array $params = [], $data = null)
140140 $ url .= '? ' . http_build_query ($ params );
141141 }
142142
143- $ curl = curl_init (self :: API_URL . $ url );
143+ $ curl = curl_init ($ this -> url . $ url );
144144
145145 curl_setopt ($ curl , CURLOPT_USERPWD , $ this ->key );
146146 curl_setopt ($ curl , CURLOPT_CUSTOMREQUEST , $ method );
@@ -159,12 +159,12 @@ private function request($method, $path, array $params = [], $data = null)
159159
160160 $ this ->lastResponseRaw = curl_exec ($ curl );
161161
162- $ errno = curl_errno ($ curl );
162+ $ errorNumber = curl_errno ($ curl );
163163 $ error = curl_error ($ curl );
164164 curl_close ($ curl );
165165
166- if ($ errno ) {
167- throw new PrintfulException ('CURL: ' . $ error , $ errno );
166+ if ($ errorNumber ) {
167+ throw new PrintfulException ('CURL: ' . $ error , $ errorNumber );
168168 }
169169
170170 $ this ->lastResponse = $ response = json_decode ($ this ->lastResponseRaw , true );
0 commit comments