Skip to content

Commit

Permalink
Feature/add shop to api init (gnikyt#631)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gnikyt authored Dec 2, 2020
1 parent f2dd915 commit 5e51672
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/ShopifyApp/Services/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Closure;
use Exception;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\URL;
use Osiset\BasicShopifyAPI\BasicShopifyAPI;
Expand Down Expand Up @@ -43,9 +44,10 @@ public function make(Session $session = null): self
// Create the options
$opts = new Options();

$opts->setApiKey($this->getConfig('api_key'));
$opts->setApiSecret($this->getConfig('api_secret'));
$opts->setVersion($this->getConfig('api_version'));
$shop = $session ? $session->getShop() : Arr::get(Request::all(), 'shop');
$opts->setApiKey($this->getConfig('api_key', $shop));
$opts->setApiSecret($this->getConfig('api_secret', $shop));
$opts->setVersion($this->getConfig('api_version', $shop));

// Create the instance
if ($this->getConfig('api_init')) {
Expand All @@ -58,9 +60,9 @@ public function make(Session $session = null): self
);
} else {
// Default init
$ts = $this->getConfig('api_time_store');
$ls = $this->getConfig('api_limit_store');
$sd = $this->getConfig('api_deferrer');
$ts = $this->getConfig('api_time_store', $shop);
$ls = $this->getConfig('api_limit_store', $shop);
$sd = $this->getConfig('api_deferrer', $shop);

$this->api = new BasicShopifyAPI(
$opts,
Expand Down

0 comments on commit 5e51672

Please sign in to comment.