Skip to content

Commit a83d8b8

Browse files
author
Tyler King
authored
Shop ID interface swap (gnikyt#646)
* Update ShopModel trait to use ShopId interface for value object * Update ShopModel interface to reference new ShopId interface * StyleCI fix * Move all remaining classes using ShopId to use the ShopId interface * StyleCI fixes * Updated Shop query contract to use ShopId interface * StyleCI fixes
1 parent 59545dc commit a83d8b8

File tree

11 files changed

+65
-65
lines changed

11 files changed

+65
-65
lines changed

src/ShopifyApp/Actions/AfterAuthorize.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace Osiset\ShopifyApp\Actions;
44

5+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
56
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
67
use Osiset\ShopifyApp\Contracts\ShopModel as IShopModel;
7-
use Osiset\ShopifyApp\Objects\Values\ShopId;
88
use Osiset\ShopifyApp\Traits\ConfigAccessible;
99

1010
/**
@@ -37,11 +37,11 @@ public function __construct(IShopQuery $shopQuery)
3737
* Execution.
3838
* TODO: Rethrow an API exception.
3939
*
40-
* @param ShopId $shopId The shop ID.
40+
* @param ShopIdValue $shopId The shop ID.
4141
*
4242
* @return bool
4343
*/
44-
public function __invoke(ShopId $shopId): bool
44+
public function __invoke(ShopIdValue $shopId): bool
4545
{
4646
/**
4747
* Fires the job.

src/ShopifyApp/Actions/CreateScripts.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Osiset\ShopifyApp\Actions;
44

55
use Osiset\BasicShopifyAPI\ResponseAccess;
6+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
67
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
7-
use Osiset\ShopifyApp\Objects\Values\ShopId;
88
use Osiset\ShopifyApp\Traits\ConfigAccessible;
99

1010
/**
@@ -37,12 +37,12 @@ public function __construct(IShopQuery $shopQuery)
3737
* Execution.
3838
* TODO: Rethrow an API exception.
3939
*
40-
* @param ShopId $shopId The shop ID.
41-
* @param array $configScripts The scripts to add.
40+
* @param ShopIdValue $shopId The shop ID.
41+
* @param array $configScripts The scripts to add.
4242
*
4343
* @return array
4444
*/
45-
public function __invoke(ShopId $shopId, array $configScripts): array
45+
public function __invoke(ShopIdValue $shopId, array $configScripts): array
4646
{
4747
/**
4848
* Checks if a scripttag exists already in the shop.

src/ShopifyApp/Actions/CreateWebhooks.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Osiset\ShopifyApp\Actions;
44

55
use Osiset\BasicShopifyAPI\ResponseAccess;
6+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
67
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
7-
use Osiset\ShopifyApp\Objects\Values\ShopId;
88
use Osiset\ShopifyApp\Traits\ConfigAccessible;
99

1010
/**
@@ -37,12 +37,12 @@ public function __construct(IShopQuery $shopQuery)
3737
* Execution.
3838
* TODO: Rethrow an API exception.
3939
*
40-
* @param ShopId $shopId The shop ID.
41-
* @param array $configWebhooks The webhooks to add.
40+
* @param ShopIdValue $shopId The shop ID.
41+
* @param array $configWebhooks The webhooks to add.
4242
*
4343
* @return array
4444
*/
45-
public function __invoke(ShopId $shopId, array $configWebhooks): array
45+
public function __invoke(ShopIdValue $shopId, array $configWebhooks): array
4646
{
4747
/**
4848
* Checks if a webhooks exists already in the shop.

src/ShopifyApp/Actions/DispatchScripts.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Osiset\ShopifyApp\Actions;
44

5+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
56
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
6-
use Osiset\ShopifyApp\Objects\Values\ShopId;
77
use Osiset\ShopifyApp\Traits\ConfigAccessible;
88

99
/**
@@ -44,12 +44,12 @@ public function __construct(IShopQuery $shopQuery, string $jobClass)
4444
/**
4545
* Execution.
4646
*
47-
* @param ShopId $shopId The shop ID.
48-
* @param bool $inline Fire the job inline (now) or queue.
47+
* @param ShopIdValue $shopId The shop ID.
48+
* @param bool $inline Fire the job inline (now) or queue.
4949
*
5050
* @return bool
5151
*/
52-
public function __invoke(ShopId $shopId, bool $inline = false): bool
52+
public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
5353
{
5454
// Get the shop
5555
$shop = $this->shopQuery->getById($shopId);

src/ShopifyApp/Actions/DispatchWebhooks.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Osiset\ShopifyApp\Actions;
44

5+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
56
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
6-
use Osiset\ShopifyApp\Objects\Values\ShopId;
77
use Osiset\ShopifyApp\Traits\ConfigAccessible;
88

99
/**
@@ -44,12 +44,12 @@ public function __construct(IShopQuery $shopQuery, string $jobClass)
4444
/**
4545
* Execution.
4646
*
47-
* @param ShopId $shopId The shop ID.
48-
* @param bool $inline Fire the job inlin e (now) or queue.
47+
* @param ShopIdValue $shopId The shop ID.
48+
* @param bool $inline Fire the job inlin e (now) or queue.
4949
*
5050
* @return bool
5151
*/
52-
public function __invoke(ShopId $shopId, bool $inline = false): bool
52+
public function __invoke(ShopIdValue $shopId, bool $inline = false): bool
5353
{
5454
// Get the shop
5555
$shop = $this->shopQuery->getById($shopId);

src/ShopifyApp/Contracts/Commands/Shop.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Osiset\ShopifyApp\Contracts\Objects\Values\AccessToken as AccessTokenValue;
66
use Osiset\ShopifyApp\Contracts\Objects\Values\PlanId as PlanIdValue;
77
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopDomain as ShopDomainValue;
8-
use Osiset\ShopifyApp\Objects\Values\ShopId;
8+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
99

1010
/**
1111
* Reprecents commands for shops.
@@ -17,73 +17,73 @@ interface Shop
1717
*
1818
* @return ShopId
1919
*/
20-
public function make(ShopDomainValue $domain, AccessTokenValue $token): ShopId;
20+
public function make(ShopDomainValue $domain, AccessTokenValue $token): ShopIdValue;
2121

2222
/**
2323
* Sets a plan to a shop, meanwhile cancelling freemium.
2424
*
25-
* @param ShopId $shopId The shop's ID.
25+
* @param ShopIdValue $shopId The shop's ID.
2626
* @param PlanIdValue $planId The plan's ID.
2727
*
2828
* @return bool
2929
*/
30-
public function setToPlan(ShopId $shopId, PlanIdValue $planId): bool;
30+
public function setToPlan(ShopIdValue $shopId, PlanIdValue $planId): bool;
3131

3232
/**
3333
* Sets the access token (offline) from Shopify to the shop.
3434
*
35-
* @param ShopId $shopId The shop's ID.
35+
* @param ShopIdValue $shopId The shop's ID.
3636
* @param AccessTokenValue $token The token from Shopify Oauth.
3737
*
3838
* @return bool
3939
*/
40-
public function setAccessToken(ShopId $shopId, AccessTokenValue $token): bool;
40+
public function setAccessToken(ShopIdValue $shopId, AccessTokenValue $token): bool;
4141

4242
/**
4343
* Cleans the shop's properties (token, plan).
4444
* Used for uninstalls.
4545
*
46-
* @param ShopId $shopId The shop's ID.
46+
* @param ShopIdValue $shopId The shop's ID.
4747
*
4848
* @return bool
4949
*/
50-
public function clean(ShopId $shopId): bool;
50+
public function clean(ShopIdValue $shopId): bool;
5151

5252
/**
5353
* Soft deletes a shop.
5454
* Used for uninstalls.
5555
*
56-
* @param ShopId $shopId The shop's ID.
56+
* @param ShopIdValue $shopId The shop's ID.
5757
*
5858
* @return bool
5959
*/
60-
public function softDelete(ShopId $shopId): bool;
60+
public function softDelete(ShopIdValue $shopId): bool;
6161

6262
/**
6363
* Restore a soft-deleted shop.
6464
*
65-
* @param ShopId $shopId The shop's ID.
65+
* @param ShopIdValue $shopId The shop's ID.
6666
*
6767
* @return bool
6868
*/
69-
public function restore(ShopId $shopId): bool;
69+
public function restore(ShopIdValue $shopId): bool;
7070

7171
/**
7272
* Set a shop as freemium.
7373
*
74-
* @param ShopId $shopId The shop's ID.
74+
* @param ShopIdValue $shopId The shop's ID.
7575
*
7676
* @return bool
7777
*/
78-
public function setAsFreemium(ShopId $shopId): bool;
78+
public function setAsFreemium(ShopIdValue $shopId): bool;
7979

8080
/**
8181
* Set a shop to a namespace.
8282
*
83-
* @param ShopId $shopId The shop's ID.
84-
* @param string $namespace The namespace.
83+
* @param ShopIdValue $shopId The shop's ID.
84+
* @param string $namespace The namespace.
8585
*
8686
* @return bool
8787
*/
88-
public function setNamespace(ShopId $shopId, string $namespace): bool;
88+
public function setNamespace(ShopIdValue $shopId, string $namespace): bool;
8989
}

src/ShopifyApp/Contracts/Queries/Shop.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Illuminate\Support\Collection;
66
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopDomain as ShopDomainValue;
7+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
78
use Osiset\ShopifyApp\Contracts\ShopModel as IShopModel;
8-
use Osiset\ShopifyApp\Objects\Values\ShopId;
99

1010
/**
1111
* Reprecents a queries for shops.
@@ -15,13 +15,13 @@ interface Shop
1515
/**
1616
* Get by ID.
1717
*
18-
* @param ShopId $shopId The shop ID.
19-
* @param array $with The relations to eager load.
20-
* @param bool $withTrashed Include trashed shops?
18+
* @param ShopIdValue $shopId The shop ID.
19+
* @param array $with The relations to eager load.
20+
* @param bool $withTrashed Include trashed shops?
2121
*
2222
* @return IShopModel|null
2323
*/
24-
public function getById(ShopId $shopId, array $with = [], bool $withTrashed = false): ?IShopModel;
24+
public function getById(ShopIdValue $shopId, array $with = [], bool $withTrashed = false): ?IShopModel;
2525

2626
/**
2727
* Get by domain.

src/ShopifyApp/Messaging/Jobs/ScripttagInstaller.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Queue\InteractsWithQueue;
99
use Illuminate\Queue\SerializesModels;
1010
use Osiset\ShopifyApp\Actions\CreateScripts as CreateScriptsAction;
11-
use Osiset\ShopifyApp\Objects\Values\ShopId;
11+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
1212

1313
/**
1414
* Webhook job responsible for handling installing scripttag.
@@ -23,7 +23,7 @@ class ScripttagInstaller implements ShouldQueue
2323
/**
2424
* The shop's ID.
2525
*
26-
* @var ShopId
26+
* @var ShopIdValue
2727
*/
2828
protected $shopId;
2929

@@ -37,12 +37,12 @@ class ScripttagInstaller implements ShouldQueue
3737
/**
3838
* Create a new job instance.
3939
*
40-
* @param ShopId $shopId The shop ID.
41-
* @param array $configScripts The scripts to add.
40+
* @param ShopIdValue $shopId The shop ID.
41+
* @param array $configScripts The scripts to add.
4242
*
4343
* @return void
4444
*/
45-
public function __construct(ShopId $shopId, array $configScripts)
45+
public function __construct(ShopIdValue $shopId, array $configScripts)
4646
{
4747
$this->shopId = $shopId;
4848
$this->configScripts = $configScripts;

src/ShopifyApp/Messaging/Jobs/WebhookInstaller.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Queue\InteractsWithQueue;
99
use Illuminate\Queue\SerializesModels;
1010
use Osiset\ShopifyApp\Actions\CreateWebhooks as CreateWebhooksAction;
11-
use Osiset\ShopifyApp\Objects\Values\ShopId;
11+
use Osiset\ShopifyApp\Contracts\Objects\Values\ShopId as ShopIdValue;
1212

1313
/**
1414
* Webhook job responsible for handling installation of webhook listeners.
@@ -23,7 +23,7 @@ class WebhookInstaller implements ShouldQueue
2323
/**
2424
* The shop's ID.
2525
*
26-
* @var int
26+
* @var ShopIdValue
2727
*/
2828
protected $shopId;
2929

@@ -37,12 +37,12 @@ class WebhookInstaller implements ShouldQueue
3737
/**
3838
* Create a new job instance.
3939
*
40-
* @param ShopId $shopId The shop ID.
41-
* @param array $configWebhooks The webhooks to add.
40+
* @param ShopIdValue $shopId The shop ID.
41+
* @param array $configWebhooks The webhooks to add.
4242
*
4343
* @return void
4444
*/
45-
public function __construct(ShopId $shopId, array $configWebhooks)
45+
public function __construct(ShopIdValue $shopId, array $configWebhooks)
4646
{
4747
$this->shopId = $shopId;
4848
$this->configWebhooks = $configWebhooks;

0 commit comments

Comments
 (0)