Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Adding event to notify App Installation on the store #1220

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"ext-json": "*",
"funeralzone/valueobjects": "^0.5",
"jenssegers/agent": "^2.6",
"laravel/framework": "^7.0 || ^8.0 || ^9.0",
"laravel/framework": "^7.0 || ^8.0 || ^9.0 || ^10.0",
"osiset/basic-shopify-api": "^9.0 || <=10.0.5"
},
"require-dev": {
Expand Down
4 changes: 4 additions & 0 deletions src/Actions/InstallShop.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Exception;
use Osiset\ShopifyApp\Contracts\Commands\Shop as IShopCommand;
use Osiset\ShopifyApp\Contracts\Queries\Shop as IShopQuery;
use Osiset\ShopifyApp\Messaging\Events\AppInstalled;
use Osiset\ShopifyApp\Objects\Enums\AuthMode;
use Osiset\ShopifyApp\Objects\Values\AccessToken;
use Osiset\ShopifyApp\Objects\Values\NullAccessToken;
Expand Down Expand Up @@ -88,6 +89,9 @@ public function __invoke(ShopDomain $shopDomain, ?string $code): array
$data = $apiHelper->getAccessData($code);
$this->shopCommand->setAccessToken($shop->getId(), AccessToken::fromNative($data['access_token']));

// Fire the AppInstalled event
AppInstalled::dispatch($shop);

return [
'completed' => true,
'url' => null,
Expand Down
36 changes: 36 additions & 0 deletions src/Messaging/Events/AppInstalled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Osiset\ShopifyApp\Messaging\Events;

use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Osiset\ShopifyApp\Contracts\ShopModel as IShopModel;

class AppInstalled
{
use Dispatchable, SerializesModels;

/**
* Shop's instance.
*
* @var string
*/
protected $shop;

/**
* Create a new event instance.
*
* @param IShopModel $shop The shop.
*
* @return void
*/
public function __construct(IShopModel $shop)
{
$this->shop = $shop;
}

public function getShop()
{
return $this->shop;
}
}