-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if the update on save is apt (#233)
* Check if the update on save is apt * fix translations
- Loading branch information
1 parent
3fe1b03
commit 90ce933
Showing
5 changed files
with
153 additions
and
55 deletions.
There are no files selected for viewing
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,62 @@ | ||
<?php | ||
/** | ||
* NOTICE OF LICENSE | ||
* | ||
* This file is licenced under the Software License Agreement. | ||
* With the purchase or the installation of the software in your application | ||
* you accept the licence agreement. | ||
* | ||
* You must not modify, adapt or create derivative works of this source code | ||
* | ||
* @author Doofinder | ||
* @copyright Doofinder | ||
* @license GPLv3 | ||
*/ | ||
require_once _PS_MODULE_DIR_ . 'doofinder/lib/EasyREST.php'; | ||
|
||
if (!defined('_PS_VERSION_')) { | ||
exit; | ||
} | ||
|
||
const API_URL = 'https://{region}-plugins.doofinder.com'; | ||
|
||
class DoofinderInstallation | ||
{ | ||
private $api_key; | ||
private $api_url; | ||
|
||
public function __construct($api_key, $region) | ||
{ | ||
$this->api_key = $api_key; | ||
$this->api_url = str_replace('{region}', $region, API_URL); | ||
} | ||
|
||
/** | ||
* Make a request to the plugins API to to check that the update on save is valid | ||
* | ||
* @param string $installation_id | ||
* @param string $callback_url | ||
*/ | ||
public function is_valid_update_on_save($installation_id) | ||
{ | ||
$api_endpoint = $this->api_url . '/' . $installation_id . '/validate-update-on-save'; | ||
|
||
return $this->get($api_endpoint); | ||
} | ||
|
||
private function get($url) | ||
{ | ||
$client = new EasyREST(); | ||
|
||
$response = $client->get( | ||
$url, | ||
null, | ||
false, | ||
false, | ||
'application/json', | ||
['Authorization: Token ' . $this->api_key] | ||
); | ||
|
||
return json_decode($response->response, true); | ||
} | ||
} |
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
Oops, something went wrong.