Skip to content

Commit

Permalink
store to shop rename
Browse files Browse the repository at this point in the history
  • Loading branch information
sevastyanovio committed Mar 29, 2017
1 parent a5b26f8 commit 6573396
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $provider = new Pizdata\OAuth2\Client\Provider\Shopify([
'clientId' => '{shopify-client-id}', // The client ID assigned to you by the Shopify
'clientSecret' => '{shopify-client-secret}', // The client password assigned to you by the Shopify
'redirectUri' => 'http://localhost/callback', // The redirect URI assigned to you
'store' => 'my-test-store', // The Store name
'shop' => 'pizdata.myshopify.com', // The Shop name
]);

// If we don't have an authorization code then get one
Expand Down
20 changes: 6 additions & 14 deletions src/Provider/Shopify.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

class Shopify extends AbstractProvider
{
/**
* Production Shopify domain.
*
* @const string
*/
const BASE_SHOPIFY_DOMAIN = 'myshopify.com';

/**
* The store name.
*
Expand All @@ -31,12 +24,12 @@ public function __construct($options = [], array $collaborators = [])
{
parent::__construct($options, $collaborators);

if (empty($options['store'])) {
$message = 'The "store" option not set. Please set a Store name.';
if (empty($options['shop'])) {
$message = 'The "shop" option not set. Please set a Shop name.';
throw new \InvalidArgumentException($message);
}

$this->store = $options['store'];
$this->store = $options['shop'];
}

/**
Expand All @@ -46,7 +39,7 @@ public function __construct($options = [], array $collaborators = [])
*/
public function getBaseAuthorizationUrl()
{
return sprintf('https://%s.%s/admin/oauth/authorize', $this->store, self::BASE_SHOPIFY_DOMAIN);
return sprintf('https://%s/admin/oauth/authorize', $this->store);
}

/**
Expand All @@ -58,7 +51,7 @@ public function getBaseAuthorizationUrl()
*/
public function getBaseAccessTokenUrl(array $params)
{
return sprintf('https://%s.%s/admin/oauth/access_token', $this->store, self::BASE_SHOPIFY_DOMAIN);
return sprintf('https://%s/admin/oauth/access_token', $this->store);
}

/**
Expand All @@ -71,9 +64,8 @@ public function getBaseAccessTokenUrl(array $params)
public function getResourceOwnerDetailsUrl(AccessToken $token)
{
return sprintf(
'https://%s.%s/admin/shop.json?access_token=%s',
'https://%s/admin/shop.json?access_token=%s',
$this->store,
self::BASE_SHOPIFY_DOMAIN,
$token->getToken()
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Provider/ShopifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function setUp()
'clientId' => 'mock_client_id',
'clientSecret' => 'mock_secret',
'redirectUri' => 'none',
'store' => 'mock_domain',
'shop' => 'mock_domain',
]);
}

Expand All @@ -27,7 +27,7 @@ public function tearDown()

/**
* @covers \Pizdata\OAuth2\Client\Provider\Shopify::__construct
* @expectExceptionMessage 'The "store" option not set. Please set a Store name.'
* @expectExceptionMessage 'The "shop" option not set. Please set a Shop name.'
* @expectedException \InvalidArgumentException
*/
public function testNoStoreName()
Expand Down

0 comments on commit 6573396

Please sign in to comment.