for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CodeCloud\Bundle\ShopifyBundle\Api;
use CodeCloud\Bundle\ShopifyBundle\Model\ShopifyStoreManagerInterface;
/**
* Creates ShopifyApi instances.
*/
class ShopifyApiFactory
{
* @var ShopifyStoreManagerInterface
private $storeManager;
* @var HttpClientFactoryInterface
private $httpClientFactory;
* @var string
private $apiVersion;
* @param ShopifyStoreManagerInterface $storeManager
* @param HttpClientFactoryInterface $httpClientFactory
* @param string $apiVersion
public function __construct(
ShopifyStoreManagerInterface $storeManager,
HttpClientFactoryInterface $httpClientFactory,
$apiVersion = null
) {
$this->storeManager = $storeManager;
$this->httpClientFactory = $httpClientFactory;
$this->apiVersion = $apiVersion;
}
* @param string $storeName
* @return ShopifyApi
public function getForStore($storeName)
$accessToken = $this->storeManager->getAccessToken($storeName);
$client = $this->httpClientFactory->createHttpClient($storeName, new PublicAppCredentials($accessToken));
return new ShopifyApi($client, $this->apiVersion);