generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add column is_development_shop to shopify sessions and fill on creation
- Loading branch information
1 parent
964457a
commit 5d557aa
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
database/migrations/add_is_development_shop_to_shopify_sessions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('shopify_sessions', function (Blueprint $table) { | ||
$table->boolean('is_development_shop')->default(false); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('shopify_sessions', function (Blueprint $table) { | ||
$table->dropColumn('is_development_shop'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Codelayer\LaravelShopifyIntegration\Lib; | ||
|
||
use Shopify\Auth\Session; | ||
use Shopify\Clients\Graphql; | ||
|
||
class ShopifyDevelopmentShopHandler | ||
{ | ||
public const DEVELOPMENT_SHOP_GRAPHQL_QUERY = <<<'QUERY' | ||
{ | ||
shop { | ||
plan { | ||
partnerDevelopment | ||
} | ||
} | ||
} | ||
QUERY; | ||
|
||
public function fetchIsDevelopmentShop(Session $session): bool | ||
{ | ||
$client = new Graphql($session->getShop(), $session->getAccessToken()); | ||
|
||
$response = $client->query(self::DEVELOPMENT_SHOP_GRAPHQL_QUERY); | ||
|
||
return data_get($response->getDecodedBody(), 'data.shop.plan.partnerDevelopment'); | ||
} | ||
} |