/**
  * refresh OAuth token
  * @param ShopInterface $shop
  * @return TokenInterface
  * @throws Exception
  */
 public function refresh(ShopInterface $shop)
 {
     if (!$this->client) {
         throw new Exception('No client specified');
     }
     $token = $shop->getToken();
     $refreshToken = $token->getRefreshToken();
     try {
         $this->client->setRefreshToken($refreshToken);
         $newToken = $this->client->refreshTokens();
         $token->setExpiresAt(new \DateTime('+' . (int) $newToken['expires_in'] . ' seconds'));
         $token->setAccessToken($newToken['access_token']);
         $token->setRefreshToken($newToken['refresh_token']);
         $this->manager->save($token);
     } catch (ClientException $ex) {
         throw new Exception('', 0, $ex);
     }
     return $token;
 }
 /**
  * get ShopAppstoreLib client
  * @param ShopInterface $shop
  * @return ClientInterface
  * @throws \DreamCommerce\ShopAppstoreLib\Exception\ClientException
  */
 public function getClient(ShopInterface $shop)
 {
     $tokens = $shop->getToken();
     /**
      * @var $client Client\OAuth
      */
     $client = Client::factory(Client::ADAPTER_OAUTH, ['entrypoint' => $shop->getShopUrl(), 'client_id' => $this->getAppId(), 'client_secret' => $this->getAppSecret(), 'skip_ssl' => $this->skipSsl, 'user_agent' => $this->getUserAgent()]);
     $client->setAccessToken($tokens->getAccessToken());
     if ($this->logger) {
         $client->setLogger($this->logger);
     }
     return $client;
 }