Skip to content

Commit

Permalink
[Landing Pages] - New endpoint (#236)
Browse files Browse the repository at this point in the history
* [Landing Pages] - New endpoint

* feat: Changed multiline args to single line

---------

Co-authored-by: davidmolinacano <[email protected]>
  • Loading branch information
eduardogomez97 and davidmolinacano authored Sep 4, 2024
1 parent 90ce933 commit 526441b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 55 deletions.
14 changes: 4 additions & 10 deletions doofinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ class Doofinder extends Module
const DOOMANAGER_URL = 'https://admin.doofinder.com';
const GS_SHORT_DESCRIPTION = 1;
const GS_LONG_DESCRIPTION = 2;
const VERSION = '4.8.7';
const VERSION = '4.8.8';
const YES = 1;
const NO = 0;

public function __construct()
{
$this->name = 'doofinder';
$this->tab = 'search_filter';
$this->version = '4.8.7';
$this->version = '4.8.8';
$this->author = 'Doofinder (http://www.doofinder.com)';
$this->ps_versions_compliancy = ['min' => '1.5', 'max' => _PS_VERSION_];
$this->module_key = 'd1504fe6432199c7f56829be4bd16347';
Expand Down Expand Up @@ -1384,14 +1384,8 @@ public function testDoofinderApi($onlyOneLang = false)
*
* @return array
*/
public function searchOnApi(
$string,
$page = 1,
$page_size = 12,
$timeout = 8000,
$filters = null,
$return_facets = false
) {
public function searchOnApi($string, $page = 1, $page_size = 12, $timeout = 8000, $filters = null, $return_facets = false)
{
$page_size = (int) $page_size;
if (!$page_size) {
$page_size = Configuration::get('PS_PRODUCTS_PER_PAGE');
Expand Down
41 changes: 8 additions & 33 deletions lib/EasyREST.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,8 @@ public static function createClient($url = null)
*
* @return EasyREST
*/
public static function post(
$url,
$params = null,
$user = null,
$pwd = null,
$contentType = 'multipart/form-data',
$httpHeaders = null
) {
public static function post($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null)
{
return self::call('POST', $url, $params, $user, $pwd, $contentType, $httpHeaders);
}

Expand Down Expand Up @@ -389,14 +383,8 @@ public static function put($url, $body, $user = null, $pwd = null, $contentType
*
* @return EasyREST
*/
public static function get(
$url,
$params = null,
$user = null,
$pwd = null,
$contentType = 'multipart/form-data',
$httpHeaders = null
) {
public static function get($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null)
{
return self::call('GET', $url, $params, $user, $pwd, $contentType, $httpHeaders);
}

Expand All @@ -410,14 +398,8 @@ public static function get(
*
* @return EasyREST
*/
public static function delete(
$url,
$params = null,
$user = null,
$pwd = null,
$contentType = 'multipart/form-data',
$httpHeaders = null
) {
public static function delete($url, $params = null, $user = null, $pwd = null, $contentType = 'multipart/form-data', $httpHeaders = null)
{
return self::call('DELETE', $url, $params, $user, $pwd, $contentType, $httpHeaders);
}

Expand All @@ -434,15 +416,8 @@ public static function delete(
*
* @return EasyREST
*/
public static function call(
$method,
$url,
$body,
$user = null,
$pwd = null,
$contentType = null,
$httpHeaders = null
) {
public static function call($method, $url, $body, $user = null, $pwd = null, $contentType = null, $httpHeaders = null)
{
return self::createClient($url)
->setParameters($body)
->setMethod($method)
Expand Down
15 changes: 6 additions & 9 deletions lib/dfTools.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,8 @@ public static function getAttributesName($attributes_ids, $id_lang)
*
* @return array of rows (assoc arrays)
*/
public static function getAvailableProductsForLanguage(
$id_lang,
$id_shop,
$limit = false,
$offset = false,
$ids = null
) {
public static function getAvailableProductsForLanguage($id_lang, $id_shop, $limit = false, $offset = false, $ids = null)
{
$Shop = new Shop($id_shop);

$isbn = '';
Expand Down Expand Up @@ -1408,9 +1403,11 @@ public static function get_min_variant_prices($products, $include_taxes)
$min_prices_by_product_id[$product_id]['link'] = self::get_variant_url($product, $context);
}
} else {
$min_prices_by_product_id[$product_id] = ['price' => $variant_price,
$min_prices_by_product_id[$product_id] = [
'price' => $variant_price,
'onsale_price' => $variant_onsale_price,
'link' => self::get_variant_url($product, $context)];
'link' => self::get_variant_url($product, $context),
];
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/doofinder_api_landing.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
exit;
}

const API_URL = 'https://{region}-admin.doofinder.com';
const API_URL = 'https://{region}-plugins.doofinder.com';

class DoofinderApiLanding
{
Expand All @@ -32,11 +32,11 @@ public function __construct($hashid, $api_key, $region)
/**
* Make a request to the API to get landing data
*
* @param array Product data
* @param string Name from Landing
*/
public function getLanding($slug)
{
$endpoint = '/plugins/landing_new/' . $this->hashid . '/' . $slug;
$endpoint = "/landing/{$this->hashid}/$slug";

$url = $this->api_url . $endpoint;

Expand Down

0 comments on commit 526441b

Please sign in to comment.