diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 83d1c21..0fb7465 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -58,6 +58,7 @@ public function __construct(array $options = array()) * Set our Client instance * * @param Client $httpHandler + * @return $this */ public function setHttpHandler(Client $httpHandler) { @@ -82,6 +83,7 @@ public function getHttpHandler() * Set our LoggerInterface * * @param LoggerInterface $logger + * @return $this */ public function setLogger(LoggerInterface $logger) { @@ -104,6 +106,7 @@ public function getMyshopifyDomain() * a new client, with new details * * @param string $domain + * @return $this */ public function setMyshopifyDomain($domain) { diff --git a/src/Api.php b/src/Api.php index 3d7165a..29e03c7 100644 --- a/src/Api.php +++ b/src/Api.php @@ -72,6 +72,7 @@ public function getApiSecret() * new client instance * * @param string $accessToken + * @return $this */ public function setAccessToken($accessToken) { @@ -94,6 +95,7 @@ public function getAccessToken() * Set our persistent storage interface * * @param PersistentStorageInterface $storage + * @return $this */ public function setStorageInterface(PersistentStorageInterface $storage) { diff --git a/src/Service/AbandonedCheckoutsService.php b/src/Service/AbandonedCheckoutsService.php index e010a57..1d41815 100644 --- a/src/Service/AbandonedCheckoutsService.php +++ b/src/Service/AbandonedCheckoutsService.php @@ -7,7 +7,7 @@ class AbandonedCheckoutsService extends AbstractService { /** - * List all abandonded checkouts + * List all abandoned checkouts * * @link https://help.shopify.com/api/reference/abandoned_checkouts#index * @param array $params diff --git a/src/Service/AbstractService.php b/src/Service/AbstractService.php index 3db841c..8061e9e 100644 --- a/src/Service/AbstractService.php +++ b/src/Service/AbstractService.php @@ -2,59 +2,93 @@ namespace Shopify\Service; +use GuzzleHttp\Client; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Shopify\ApiInterface; -use Shopify\Object\AbstractObject; -use Shopify\Inflector; abstract class AbstractService { - private $api; - private $mapper; + /** + * Instantiated Guzzle Client for requests + * @var Client + */ + private $client; + + /** + * The last API response from Shopify + * @var Response|null + */ + private $lastResponse; const REQUEST_METHOD_GET = 'GET'; const REQUEST_METHOD_POST = 'POST'; const REQUEST_METHOD_PUT = 'PUT'; const REQUEST_METHOD_DELETE = 'DELETE'; - public static function factory(ApiInterface $api) + public static function factory(ApiInterface $api): AbstractService { return new static($api); } public function __construct(ApiInterface $api) { - $this->api = $api; + $this->client = $api->getHttpHandler(); } - public function getApi() + /** + * Get the client instance + * + * @return Client + */ + public function getClient() { - return $this->api; + return $this->client; } - public function request($endpoint, $method = self::REQUEST_METHOD_GET, array $params = array()) + /** + * @param $endpoint + * @param string $method + * @param array $params + * @return mixed + */ + public function request($endpoint, $method = self::REQUEST_METHOD_GET, array $params = []) { - $request = $this->createRequest($endpoint, $method); - return $this->send($request, $params); + return $this->send(new Request($method, $endpoint), $params); } + /** + * @param $endpoint + * @param string $method + * @return Request + */ public function createRequest($endpoint, $method = self::REQUEST_METHOD_GET) { return new Request($method, $endpoint); } + /** + * Get the last response from Shopify + * @return Response + */ + public function getLastResponse() + { + return $this->lastResponse; + } + public function send(Request $request, array $params = array()) { - $handler = $this->getApi()->getHttpHandler(); $args = array(); if ($request->getMethod() === 'GET') { $args['query'] = $params; } else { $args['json'] = $params; } - $this->lastResponse = $handler->send($request, $args); - return json_decode($this->lastResponse->getBody()->getContents(), true); + $this->lastResponse = $this->client->send($request, $args); + return json_decode( + $this->lastResponse->getBody()->getContents(), + true + ); } public function createObject($className, $data) diff --git a/src/Service/ApplicationChargeService.php b/src/Service/ApplicationChargeService.php index 541207d..02882e0 100644 --- a/src/Service/ApplicationChargeService.php +++ b/src/Service/ApplicationChargeService.php @@ -49,7 +49,7 @@ public function create(ApplicationCharge &$applicationCharge) $data = $applicationCharge->exportData(); $endpoint = '/admin/application_charges.json'; $response = $this->request( - '/admin/application_charges.json', 'POST', array( + $endpoint, 'POST', array( 'application_charge' => $data ) ); diff --git a/src/Service/ArticleService.php b/src/Service/ArticleService.php index cc3e11a..7abed0a 100644 --- a/src/Service/ArticleService.php +++ b/src/Service/ArticleService.php @@ -22,7 +22,7 @@ public function all($blogId, array $params = array()) } /** - * Receive acount of all Articles + * Receive a count of all Articles * * @link https://help.shopify.com/api/reference/article#count * @param integer $blogId @@ -115,7 +115,7 @@ public function delete($blogId, Article &$article) * Get a list of all the authors * * @link https://help.shopify.com/api/reference/article#authors - * @return arrays + * @return array */ public function authors() { diff --git a/src/Service/AssetService.php b/src/Service/AssetService.php index da10a5d..17d62aa 100644 --- a/src/Service/AssetService.php +++ b/src/Service/AssetService.php @@ -13,7 +13,7 @@ class AssetService extends AbstractService * @link https://help.shopify.com/api/reference/asset#index * @param integer $themeId * @param array $params - * @return Asset[] + * @throws ShopifySdkException */ public function all($themeId, array $params = array()) { @@ -26,7 +26,7 @@ public function all($themeId, array $params = array()) * @link https://help.shopify.com/api/reference/asset#show * @param integer $themeId * @param array $params - * @return Article + * @throws ShopifySdkException */ public function get($themeId, array $params = array()) { @@ -39,7 +39,7 @@ public function get($themeId, array $params = array()) * @link https://help.shopify.com/api/reference/asset#update * @param integer $themeId * @param Asset $asset - * @return + * @throws ShopifySdkException */ public function put($themeId, Asset $asset) { @@ -52,7 +52,7 @@ public function put($themeId, Asset $asset) * @link https://help.shopify.com/api/reference/asset#destroy * @param integer $themeId * @param Asset $asset - * @return void + * @throws ShopifySdkException */ public function delete($themeId, Asset $asset) { diff --git a/src/Service/BlogService.php b/src/Service/BlogService.php index 79949db..ecad0e9 100644 --- a/src/Service/BlogService.php +++ b/src/Service/BlogService.php @@ -22,7 +22,7 @@ public function all(array $params = array()) } /** - * Receivea count of all blogs + * Receive a count of all blogs * * @link https://help.shopify.com/api/reference/blog#count * @return integer @@ -77,7 +77,7 @@ public function create(Blog &$blog) * * @link https://help.shopify.com/api/reference/blog#update * @param Blog $blog - * @return void + * @throws ShopifySdkException */ public function update(Blog &$blog) { @@ -85,11 +85,11 @@ public function update(Blog &$blog) } /** - * Removea blog from Database + * Remove a blog from Database * * @link https://help.shopify.com/api/reference/blog#destroy * @param Blog $blog - * @return void + * @throws ShopifySdkException */ public function delete(Blog $blog) { diff --git a/src/Service/CollectService.php b/src/Service/CollectService.php index f66da79..d328ec6 100644 --- a/src/Service/CollectService.php +++ b/src/Service/CollectService.php @@ -30,7 +30,7 @@ public function all(array $params = array()) public function count(array $params = array()) { $endpoint = '/collects/count.json'; - $data = $this->request($endpoint); + $data = $this->request($endpoint, $params); return $data['count']; } diff --git a/src/Service/CommentService.php b/src/Service/CommentService.php index 3a4c17b..0597bc2 100644 --- a/src/Service/CommentService.php +++ b/src/Service/CommentService.php @@ -13,7 +13,7 @@ class CommentService extends AbstractService * @param array $params * @return Comment[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/comments.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,10 +27,10 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/comments/count.json'; - $response = $this->request($endpoint); + $response = $this->request($endpoint, 'GET', $params); return $response['count']; } @@ -42,10 +42,10 @@ public function count(array $params = array()) * @param array $params * @return Comment */ - public function get($commentId, array $params = array()) + public function get($commentId, array $params = []) { $endpoint = '/comments/'.$commentId.'.json'; - $response = $this->request($endpoint); + $response = $this->request($endpoint, 'GET', $params); return $this->createObject(Comment::class, $response['comment']); } @@ -144,7 +144,7 @@ public function remove(Comment &$comment) } /** - * Retore a comment + * Restore a comment * * @link https://help.shopify.com/api/reference/comment#restore * @param Comment $comment diff --git a/src/Service/CountryService.php b/src/Service/CountryService.php index 8b56e4d..5e723da 100644 --- a/src/Service/CountryService.php +++ b/src/Service/CountryService.php @@ -13,7 +13,7 @@ class CountryService extends AbstractService * @param array $params * @return Country[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/countries.json'; $response = $this->request($endpoint, 'GET', $params); @@ -41,7 +41,7 @@ public function count() * @param array $fields * @return Country */ - public function get($countryId, array $fields = array()) + public function get($countryId, array $fields = []) { $params = array(); if (!empty($fields)) { @@ -99,6 +99,7 @@ public function update(Country &$country) */ public function delete(Country $country) { - return $this->request('/countries/'.$country->id.'.json', 'DELETE'); + $this->request('/countries/'.$country->id.'.json', 'DELETE'); + return; } } diff --git a/src/Service/CustomCollectionService.php b/src/Service/CustomCollectionService.php index 8117562..62ba832 100644 --- a/src/Service/CustomCollectionService.php +++ b/src/Service/CustomCollectionService.php @@ -101,8 +101,7 @@ public function update(CustomCollection &$customCollection) public function delete(CustomCollection &$customCollection) { $endpoint = '/custom_collections/'.$customCollection->getId().'.json'; - $request = $this->createRequest($endpoint, static::REQUEST_METHOD_DELETE); - $response = $this->send($request); + $this->request($endpoint, static::REQUEST_METHOD_DELETE); return; } } diff --git a/src/Service/CustomerService.php b/src/Service/CustomerService.php index 06270ca..a94d089 100644 --- a/src/Service/CustomerService.php +++ b/src/Service/CustomerService.php @@ -110,7 +110,7 @@ public function update(Customer &$customer) public function delete(Customer $customer) { $endpoint = '/customers/'.$customer->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); return; } @@ -134,6 +134,7 @@ public function accountActivationUrl($customerId) * @todo Return CustomInvite, instead of raw object * @link https://help.shopify.com/api/reference/customer#send_invite * @param integer $customerId + * @param CustomerInvite $invite * @return CustomerInvite */ public function sendInvite($customerId, CustomerInvite $invite = null) diff --git a/src/Service/DiscountCodeService.php b/src/Service/DiscountCodeService.php index de42ea0..0a1950a 100644 --- a/src/Service/DiscountCodeService.php +++ b/src/Service/DiscountCodeService.php @@ -14,7 +14,7 @@ class DiscountCodeService extends AbstractService * @param array $params * @return DiscountCode[] */ - public function all($priceRuleId, array $params = array()) + public function all($priceRuleId, array $params = []) { $endpoint = '/price_rules/'.$priceRuleId.'/discount_codes.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/EventService.php b/src/Service/EventService.php index b697aad..898b0ae 100644 --- a/src/Service/EventService.php +++ b/src/Service/EventService.php @@ -13,7 +13,7 @@ class EventService extends AbstractService * @param array $params * @return Event[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/events.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/events/count.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/FulfillmentEventService.php b/src/Service/FulfillmentEventService.php index 3fb3064..79cfade 100644 --- a/src/Service/FulfillmentEventService.php +++ b/src/Service/FulfillmentEventService.php @@ -7,7 +7,7 @@ class FulfillmentEventService extends AbstractService { /** - * Receive a list of all fulfillmen events + * Receive a list of all fulfillment events * * @link https://help.shopify.com/api/reference/fulfillmentevent#index * @param integer $orderId @@ -59,7 +59,7 @@ public function create($orderId, $fulfillmentId, FulfillmentEvent &$fulfillmentE } /** - * Delete a fufillment events + * Delete a fulfillment events * * @link https://help.shopify.com/api/reference/fulfillmentevent#destroy * @param integer $orderId @@ -70,7 +70,7 @@ public function create($orderId, $fulfillmentId, FulfillmentEvent &$fulfillmentE public function delete($orderId, $fulfillmentId, FulfillmentEvent $fulfillmentEvent) { $endpoint = '/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'/events/'.$fulfillmentEvent->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); return; } } diff --git a/src/Service/FulfillmentService.php b/src/Service/FulfillmentService.php index f1b1885..4dd5b91 100644 --- a/src/Service/FulfillmentService.php +++ b/src/Service/FulfillmentService.php @@ -6,21 +6,21 @@ class FulfillmentService extends AbstractService { - public function all($orderId, array $params = array()) + public function all($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'/fulfillments.json'; $response = $this->request($endpoint, 'GET', $params); return $this->createCollection(Fulfillment::class, $response['fulfillments']); } - public function count($orderId, array $params = array()) + public function count($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'/fulfillments/count.json'; $response = $this->request($endpoint, 'GET', $params); return $response['count']; } - public function get($orderId, $fulfillmentId, array $params = array()) + public function get($orderId, $fulfillmentId, array $params = []) { $endpoint = '/orders/'.$orderId.'/fulfillments/'.$fulfillmentId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -53,7 +53,6 @@ public function update($orderId, Fulfillment &$fulfillment) public function complete($orderId, Fulfillment &$fulfillment) { - $data = $fulfillment->exportData(); $endpoint = '/orders/'.$orderId.'/fulfillments/'.$fulfillment->getId().'/complete.json'; $response = $this->request($endpoint, 'POST'); $fulfillment->setData($response['fulfillment']); @@ -61,7 +60,6 @@ public function complete($orderId, Fulfillment &$fulfillment) public function cancel($orderId, Fulfillment &$fulfillment) { - $data = $fulfillment->exportData(); $endpoint = '/orders/'.$orderId.'/fulfillments/'.$fulfillment->getId().'/cancel.json'; $response = $this->request($endpoint, 'POST'); $fulfillment->setData($response['fulfillment']); @@ -69,7 +67,6 @@ public function cancel($orderId, Fulfillment &$fulfillment) public function open($orderId, Fulfillment &$fulfillment) { - $data = $fulfillment->exportData(); $endpoint = '/orders/'.$orderId.'/fulfillments/'.$fulfillment->getId().'/open.json'; $response = $this->request($endpoint, 'POST'); $fulfillment->setData($response->fulfillment); diff --git a/src/Service/GiftCardService.php b/src/Service/GiftCardService.php index 4088e34..6b44bcb 100644 --- a/src/Service/GiftCardService.php +++ b/src/Service/GiftCardService.php @@ -13,7 +13,7 @@ class GiftCardService extends AbstractService * @param array $params * @return GiftCard[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/gift_cards.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/gift_cards/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,7 +42,7 @@ public function count(array $params = array()) * @param array $params * @return GiftCard */ - public function get($giftCardId, array $params = array()) + public function get($giftCardId, array $params = []) { $endpoint = '/gift_cards/'.$giftCardId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -96,7 +96,6 @@ public function update(GiftCard &$giftCard) */ public function disable(GiftCard &$giftCard) { - $data = $giftCard->exportData(); $endpoint = '/gift_cards/'.$giftCard->id.'/disable.json'; $response = $this->request($endpoint, 'POST'); $giftCard->setData($response['gift_card']); @@ -109,7 +108,7 @@ public function disable(GiftCard &$giftCard) * @param array $params * @return GiftCard[] */ - public function search(array $params = array()) + public function search(array $params = []) { $endpoint = '/gift_cards/search.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/LocationService.php b/src/Service/LocationService.php index f5b9c65..34dbfff 100644 --- a/src/Service/LocationService.php +++ b/src/Service/LocationService.php @@ -13,7 +13,7 @@ class LocationService extends AbstractService * @param array $params * @return Location[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/locations.json'; $response = $this->request($endpoint, 'GET', $params); @@ -28,7 +28,7 @@ public function all(array $params = array()) * @param array $params * @return Location */ - public function get($locationId, array $params = array()) + public function get($locationId, array $params = []) { $endpoint = '/locations/'.$locationId.'.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/MarketingEventService.php b/src/Service/MarketingEventService.php index 03528bd..66a5cca 100644 --- a/src/Service/MarketingEventService.php +++ b/src/Service/MarketingEventService.php @@ -8,13 +8,13 @@ class MarketingEventService extends AbstractService { /** - * Receieve a list of all Marketing Events + * Receive a list of all Marketing Events * * @link https://help.shopify.com/api/reference/marketing_event#index * @param array $params * @return MarketingEvent[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/marketing_events.json'; $response = $this->request($endpoint, 'GET', $params); @@ -96,7 +96,7 @@ public function update(MarketingEvent &$marketingEvent) public function delete(MarketingEvent &$marketingEvent) { $endpoint = '/marketing_events/'.$marketingEvent->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); return; } @@ -105,7 +105,7 @@ public function delete(MarketingEvent &$marketingEvent) * * @link https://help.shopify.com/api/reference/marketing_event#engagements * @param MarketingEvent $marketingEvent - * @return void + * @throws ShopifySdkException */ public function createEngagements(MarketingEvent $marketingEvent) { diff --git a/src/Service/OrderService.php b/src/Service/OrderService.php index 6c518a0..c3fb7e7 100644 --- a/src/Service/OrderService.php +++ b/src/Service/OrderService.php @@ -13,7 +13,7 @@ class OrderService extends AbstractService * @param array $params * @return Order[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/orders.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/orders/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,7 +42,7 @@ public function count(array $params = array()) * @param array $params * @return Order */ - public function get($orderId, array $params = array()) + public function get($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -77,7 +77,6 @@ public function create(Order &$order) */ public function close(Order &$order) { - $data = $order->exportData(); $endpoint= '/orders/'.$order->id.'/close.json'; $response = $this->request($endpoint, 'POST'); $order->setData($response['order']); @@ -92,7 +91,6 @@ public function close(Order &$order) */ public function open(Order &$order) { - $data = $order->exportData(); $endpoint= '/orders/'.$order->id.'/open.json'; $response = $this->request($endpoint, 'POST'); $order->setData($response['order']); @@ -107,7 +105,6 @@ public function open(Order &$order) */ public function cancel(Order &$order) { - $data = $order->exportData(); $endpoint= '/orders/'.$order->id.'/cancel.json'; $response = $this->request($endpoint, 'POST'); $order->setData($response['order']); diff --git a/src/Service/PageService.php b/src/Service/PageService.php index aa6c7ff..1a93cb6 100644 --- a/src/Service/PageService.php +++ b/src/Service/PageService.php @@ -13,7 +13,7 @@ class PageService extends AbstractService * @param array $params * @return Page[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/pages.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/pages/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,7 +42,7 @@ public function count(array $params = array()) * @param array $params * @return Page */ - public function get($pageId, array $params = array()) + public function get($pageId, array $params = []) { $endpoint = '/pages/'.$pageId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -97,7 +97,7 @@ public function update(Page &$page) public function delete(Page $page) { $endpoint = '/pages/'.$page->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); return; } } diff --git a/src/Service/ProductImageService.php b/src/Service/ProductImageService.php index 8ea9d4c..5c2f9d8 100644 --- a/src/Service/ProductImageService.php +++ b/src/Service/ProductImageService.php @@ -14,7 +14,7 @@ class ProductImageService extends AbstractService * @param array $params * @return ProductImage[] */ - public function all($productId, array $params = array()) + public function all($productId, array $params = []) { $endpoint= '/products/'.$productId.'/images.json'; $response = $this->request($endpoint, 'GET', $params); @@ -29,7 +29,7 @@ public function all($productId, array $params = array()) * @param array $params * @return integer */ - public function count($productId, array $params = array()) + public function count($productId, array $params = []) { $endpoint = '/products/'.$productId.'/images/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -103,6 +103,7 @@ public function update($productId, ProductImage &$productImage) public function delete($productId, ProductImage $productImage) { $endpoint = '/products/'.$productId.'/images/'.$productImage->id.'.json'; - return $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); + return; } } diff --git a/src/Service/ProductService.php b/src/Service/ProductService.php index 878d0df..ac2371f 100644 --- a/src/Service/ProductService.php +++ b/src/Service/ProductService.php @@ -13,7 +13,7 @@ class ProductService extends AbstractService * @param array $params * @return Product[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/products.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/products/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,7 +42,7 @@ public function count(array $params = array()) * @param array $fields * @return Product */ - public function get($productId, array $fields = array()) + public function get($productId, array $fields = []) { $params = array(); if (!empty($fields)) { @@ -102,5 +102,6 @@ public function delete(Product &$product) { $endpoint = '/products/'.$product->id.'.json'; $this->request($endpoint, 'DELETE'); + return; } } diff --git a/src/Service/ProductVariantService.php b/src/Service/ProductVariantService.php index 31e610f..1ff9c02 100644 --- a/src/Service/ProductVariantService.php +++ b/src/Service/ProductVariantService.php @@ -14,7 +14,7 @@ class ProductVariantService extends AbstractService * @param array $params * @return ProductVariant[] */ - public function all($productId, array $params = array()) + public function all($productId, array $params = []) { $endpoint = '/products/'.$productId.'/variants.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,9 +42,9 @@ public function count($productId) * @param array $fields * @return ProductVariant */ - public function get($productVariantId, array $fields = array()) + public function get($productVariantId, array $fields = []) { - $params = array(); + $params = []; if (!empty($fields)) { $params['fields'] = $fields; } @@ -103,6 +103,7 @@ public function update(ProductVariant &$productVariant) public function delete($productId, ProductVariant &$productVariant) { $endpoint = '/products/'.$productId.'/variants/'.$productVariant->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); + return; } } diff --git a/src/Service/ProvinceService.php b/src/Service/ProvinceService.php index 90333ed..50fd5c4 100644 --- a/src/Service/ProvinceService.php +++ b/src/Service/ProvinceService.php @@ -10,6 +10,7 @@ class ProvinceService extends AbstractService * Receive a list of all Provinces * * @link https://help.shopify.com/api/reference/province#index + * @param integer $countryId * @param array $params * @return Province[] */ @@ -53,6 +54,7 @@ public function get($countryId, $provinceId) * Modify an existing province * * @link https://help.shopify.com/api/reference/province#update + * @param integer $countryId * @param Province $province * @return void */ diff --git a/src/Service/RecurringApplicationChargeService.php b/src/Service/RecurringApplicationChargeService.php index 1f4cb35..33cc177 100644 --- a/src/Service/RecurringApplicationChargeService.php +++ b/src/Service/RecurringApplicationChargeService.php @@ -13,7 +13,7 @@ class RecurringApplicationChargeService extends AbstractService * @param array $params * @return RecurringApplicationCharge[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/recurring_application_charges.json'; $response = $this->request($endpoint, 'GET', $params); @@ -28,7 +28,7 @@ public function all(array $params = array()) * @param array $params * @return RecurringApplicationCharge */ - public function get($recurringApplicationChargeId, array $params = array()) + public function get($recurringApplicationChargeId, array $params = []) { $endpoint = '/recurring_application_charges/'.$recurringApplicationChargeId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -64,7 +64,8 @@ public function create(RecurringApplicationCharge &$recurringApplicationCharge) public function delete(RecurringApplicationCharge $recurringApplicationCharge) { $endpoint= '/recurring_application_charges/'.$recurringApplicationCharge->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); + return; } /** @@ -72,7 +73,7 @@ public function delete(RecurringApplicationCharge $recurringApplicationCharge) * * @link https://help.shopify.com/api/reference/recurringapplicationcharge#activate * @param RecurringApplicationCharge $recurringApplicationCharge - * @return boolean + * @return void */ public function activate(RecurringApplicationCharge $recurringApplicationCharge) { diff --git a/src/Service/RedirectService.php b/src/Service/RedirectService.php index 5bf8871..30697ef 100644 --- a/src/Service/RedirectService.php +++ b/src/Service/RedirectService.php @@ -10,10 +10,10 @@ class RedirectService extends AbstractService * Receive a list of all redirects * * @link https://help.shopify.com/api/reference/redirect#index - * @param ListOptions $options + * @param array $params * @return Redirect[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/redirects.json'; $response = $this->request($endpoint, 'GET', $params); @@ -27,7 +27,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $endpoint = '/redirects/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -42,7 +42,7 @@ public function count(array $params = array()) * @param array $params * @return Redirect */ - public function get($redirectId, array $params = array()) + public function get($redirectId, array $params = []) { $endpoint = '/redirects/'.$redirectId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -97,7 +97,7 @@ public function update(Redirect &$redirect) public function delete(Redirect $redirect) { $endpoint = '/redirect/'.$redirect->id.'.json'; - $response = $this->request($endpoint, 'DELETE'); + $this->request($endpoint, 'DELETE'); return; } } diff --git a/src/Service/RefundService.php b/src/Service/RefundService.php index 767fbba..575c0e2 100644 --- a/src/Service/RefundService.php +++ b/src/Service/RefundService.php @@ -15,7 +15,7 @@ class RefundService extends AbstractService * @param array $params * @return Refund[] */ - public function all($orderId, array $params = array()) + public function all($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'/refunds.json'; $response = $this->request($endpoint, 'GET', $params); @@ -31,7 +31,7 @@ public function all($orderId, array $params = array()) * @param array $params * @return Refund */ - public function get($orderId, $refundId, array $params = array()) + public function get($orderId, $refundId, array $params = []) { $endpoint = '/orders/'.$orderId.'/refunds/'.$refundId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -62,7 +62,7 @@ public function create($orderId, Refund &$refund) * Calculate a refund * * @link https://help.shopify.com/api/reference/refund#calculate - * @return mixed + * @throws ShopifySdkException */ public function calculate() { diff --git a/src/Service/ReportService.php b/src/Service/ReportService.php index c5a8d77..7e0e7d3 100644 --- a/src/Service/ReportService.php +++ b/src/Service/ReportService.php @@ -13,7 +13,7 @@ class ReportService extends AbstractService * @param array $params * @return Report[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/reports.json'; $response = $this->request($endpoint, 'GET', $params); @@ -28,7 +28,7 @@ public function all(array $params = array()) * @param array $params * @return Report */ - public function get($reportId, array $params = array()) + public function get($reportId, array $params = []) { $endpoint = '/reports/'.$reportId.'.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/ScriptTagService.php b/src/Service/ScriptTagService.php index e421413..66ce7db 100644 --- a/src/Service/ScriptTagService.php +++ b/src/Service/ScriptTagService.php @@ -13,7 +13,7 @@ class ScriptTagService extends AbstractService * @param array $params * @return ScriptTag[] */ - public function all(array $params = array()) + public function all(array $params = []) { $data = $this->request('/script_tags.json', 'GET', $params); return $this->createCollection(ScriptTag::class, $data['script_tags']); @@ -26,7 +26,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $data = $this->request('/script_tags/count.json', 'GET', $params); return $data['count']; @@ -40,9 +40,9 @@ public function count(array $params = array()) * @param array $fields * @return ScriptTag */ - public function get($scriptTagId, array $fields = array()) + public function get($scriptTagId, array $fields = []) { - $params = array(); + $params = []; if (!empty($fields)) { $params['fields'] = implode(',', $fields); } diff --git a/src/Service/ShippingZoneService.php b/src/Service/ShippingZoneService.php index ac4a977..cfe9745 100644 --- a/src/Service/ShippingZoneService.php +++ b/src/Service/ShippingZoneService.php @@ -11,7 +11,7 @@ class ShippingZoneService extends AbstractService * Return a list of shipping zones * * @link https://help.shopify.com/api/reference/shipping_zone#index - * @return ShippingZone[] + * @throws ShopifySdkException */ public function all() { diff --git a/src/Service/SmartCollectionService.php b/src/Service/SmartCollectionService.php index 3ab1246..ae08df0 100644 --- a/src/Service/SmartCollectionService.php +++ b/src/Service/SmartCollectionService.php @@ -13,7 +13,7 @@ class SmartCollectionService extends AbstractService * @param array $params * @return SmartCollection[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/smart_collections.json'; $response = $this->request($endpoint, 'GET', $params); @@ -41,7 +41,7 @@ public function count() * @param array $params * @return SmartCollection */ - public function get($smartCollectionId, array $params = array()) + public function get($smartCollectionId, array $params = []) { $endpoint = '/smart_collections/'.$smartCollectionId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -105,10 +105,10 @@ public function delete(SmartCollection $smartCollection) * @link https://help.shopify.com/api/reference/smartcollection#order * @param integer $smartCollectionId * @param OrderOptions $options - * @return void + * @throws ShopifySdkException */ public function order($smartCollectionId, OrderOptions $options) { - + throw new ShopifySdkException("SmartCollectionService::order not implemented"); } } diff --git a/src/Service/ThemeService.php b/src/Service/ThemeService.php index 1775db6..7fa9c25 100644 --- a/src/Service/ThemeService.php +++ b/src/Service/ThemeService.php @@ -14,7 +14,7 @@ class ThemeService extends AbstractService * @param array $params * @return Theme */ - public function get($themeId, array $params = array()) + public function get($themeId, array $params = []) { $endpoint = '/themes/'.$themeId.'.json'; $response = $this->request($endpoint, 'GET', $params); @@ -28,7 +28,7 @@ public function get($themeId, array $params = array()) * @param array $params * @return Theme[] */ - public function all(array $params = array()) + public function all(array $params = []) { $endpoint = '/themes.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/TransactionService.php b/src/Service/TransactionService.php index 573b669..cc72668 100644 --- a/src/Service/TransactionService.php +++ b/src/Service/TransactionService.php @@ -7,14 +7,14 @@ class TransactionService extends AbstractService { /** - * Recieve a list of all Transactions + * Receive a list of all Transactions * * @link https://help.shopify.com/api/reference/transaction#index * @param integer $orderId * @param array $params * @return Transaction[] */ - public function all($orderId, array $params = array()) + public function all($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'/transactions.json'; $response = $this->request($endpoint, 'GET', $params); @@ -29,7 +29,7 @@ public function all($orderId, array $params = array()) * @param array $params * @return integer */ - public function count($orderId, array $params = array()) + public function count($orderId, array $params = []) { $endpoint = '/orders/'.$orderId.'/transactions/count.json'; $response = $this->request($endpoint, 'GET', $params); @@ -45,7 +45,7 @@ public function count($orderId, array $params = array()) * @param array $params * @return Transaction */ - public function get($orderId, $transactionId, array $params = array()) + public function get($orderId, $transactionId, array $params = []) { $endpoint = '/orders/'.$orderId.'/transactions/'.$transactionId.'.json'; $response = $this->request($endpoint, 'GET', $params); diff --git a/src/Service/WebhookService.php b/src/Service/WebhookService.php index 131f2e5..4b06b68 100644 --- a/src/Service/WebhookService.php +++ b/src/Service/WebhookService.php @@ -13,7 +13,7 @@ class WebhookService extends AbstractService * @param array $params * @return Webhook[] */ - public function all(array $params = array()) + public function all(array $params = []) { $response = $this->request('/webhooks.json', 'GET', $params); return $this->createCollection(Webhook::class, $response['webhooks']); @@ -26,7 +26,7 @@ public function all(array $params = array()) * @param array $params * @return integer */ - public function count(array $params = array()) + public function count(array $params = []) { $response = $this->request('/webhooks/count.json', $params); return $response['count']; @@ -40,9 +40,9 @@ public function count(array $params = array()) * @param array $fields * @return Webhook */ - public function get($webhookId, array $fields = array()) + public function get($webhookId, array $fields = []) { - $params = array(); + $params = []; if (!empty($fields)) { $params['fields'] = implode(',', $fields); } diff --git a/src/Storage/SessionStorage.php b/src/Storage/SessionStorage.php index 57c9f3a..c694f21 100644 --- a/src/Storage/SessionStorage.php +++ b/src/Storage/SessionStorage.php @@ -8,6 +8,11 @@ class SessionStorage implements PersistentStorageInterface { protected $prefix = 'SHPFY_'; + /** + * @param $key + * @return bool + * @throws ShopifySdkException + */ public function get($key) { $this->assertSession(); @@ -17,12 +22,20 @@ public function get($key) return false; } + /** + * @param $key + * @param $value + * @throws ShopifySdkException + */ public function set($key, $value) { $this->assertSession(); $_SESSION[$this->prefix . $key] = $value; } + /** + * @throws ShopifySdkException + */ public function assertSession() { if (session_status() !== PHP_SESSION_ACTIVE) {