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

Commit 5e51672

Browse files
authored
Feature/add shop to api init (#631)
* Added shop context to getConfig trait, added callback for API config * Normalize composer file * Fix to AuthProxy middleware shop context for getConfig * Revert Billable middleware shop position * Added shop context to getConfig in API setup
1 parent f2dd915 commit 5e51672

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Diff for: src/ShopifyApp/Services/ApiHelper.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Closure;
66
use Exception;
77
use GuzzleHttp\Exception\RequestException;
8+
use Illuminate\Support\Arr;
89
use Illuminate\Support\Facades\Request;
910
use Illuminate\Support\Facades\URL;
1011
use Osiset\BasicShopifyAPI\BasicShopifyAPI;
@@ -43,9 +44,10 @@ public function make(Session $session = null): self
4344
// Create the options
4445
$opts = new Options();
4546

46-
$opts->setApiKey($this->getConfig('api_key'));
47-
$opts->setApiSecret($this->getConfig('api_secret'));
48-
$opts->setVersion($this->getConfig('api_version'));
47+
$shop = $session ? $session->getShop() : Arr::get(Request::all(), 'shop');
48+
$opts->setApiKey($this->getConfig('api_key', $shop));
49+
$opts->setApiSecret($this->getConfig('api_secret', $shop));
50+
$opts->setVersion($this->getConfig('api_version', $shop));
4951

5052
// Create the instance
5153
if ($this->getConfig('api_init')) {
@@ -58,9 +60,9 @@ public function make(Session $session = null): self
5860
);
5961
} else {
6062
// Default init
61-
$ts = $this->getConfig('api_time_store');
62-
$ls = $this->getConfig('api_limit_store');
63-
$sd = $this->getConfig('api_deferrer');
63+
$ts = $this->getConfig('api_time_store', $shop);
64+
$ls = $this->getConfig('api_limit_store', $shop);
65+
$sd = $this->getConfig('api_deferrer', $shop);
6466

6567
$this->api = new BasicShopifyAPI(
6668
$opts,

0 commit comments

Comments
 (0)