Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move createService to AbstractApi #41

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Move createService to AbstractApi
  • Loading branch information
robertwittman committed Oct 21, 2019
commit 44163ff6470d738b11721f4199dd3aaa0348abb9
12 changes: 12 additions & 0 deletions src/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GuzzleHttp\Client;
use Psr\Log\LoggerInterface;
use Shopify\Service\AbstractService;

abstract class AbstractApi implements ApiInterface
{
Expand Down Expand Up @@ -146,6 +147,17 @@ public function getApiVersion()
return $this->api_version;
}

/**
* Helper function to create new service instances
*
* @param $serviceClass Fully Qualified Service className
* @return AbstractService
*/
public function createService($serviceClass)
{
return new $serviceClass($this);
}

/**
* Initialize our Client, using settings based on the app type
*
Expand Down
13 changes: 0 additions & 13 deletions src/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

namespace Shopify;

use Shopify\Service\AbstractService;
use Shopify\Storage\PersistentStorageInterface;
use Shopify\Storage\SessionStorage;
use Shopify\Helper\OAuthHelper;
use GuzzleHttp\Client;
use Psr\Log\LoggerInterface;

class Api extends AbstractApi
{
Expand Down Expand Up @@ -146,17 +144,6 @@ public function getOAuthHelper()
return new OAuthHelper($this, $this->getStorageInterface());
}

/**
* Helper function to create new service instances
*
* @param $serviceClass Fully Qualified Service className
* @return AbstractService
*/
public function createService($serviceClass)
{
return new $serviceClass($this);
}

public function loadApiKeyFromEnv()
{
$this->api_key = getenv(self::SHOPIFY_API_KEY_NAME);
Expand Down