Skip to content

Commit

Permalink
Fixed several warnings (#286)
Browse files Browse the repository at this point in the history
* Fixed several warnings

* Upgraded version
  • Loading branch information
Aitor-Corrales committed Jul 6, 2023
1 parent f36169a commit 4ceaac1
Show file tree
Hide file tree
Showing 67 changed files with 681 additions and 786 deletions.
4 changes: 4 additions & 0 deletions Api/ChangedItemRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ public function save(ChangedItemInterface $entity): ChangedItemInterface;
public function get($value, ?string $field): ChangedItemInterface;

/**
* Gets entity's list by search criteria
*
* @param SearchCriteriaInterface $searchCriteria
* @return ChangedItemSearchResultsInterface
*/
public function getList(SearchCriteriaInterface $searchCriteria): ChangedItemSearchResultsInterface;

/**
* Determines whether this item exists or not
*
* @param ChangedItemInterface $changedItem
* @return bool
*/
Expand Down
18 changes: 9 additions & 9 deletions Api/Data/ChangedItemInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@ interface ChangedItemInterface
*
* @var string CHANGED_ITEM_ID
*/
const CHANGED_ITEM_ID = 'entity_id';
public const CHANGED_ITEM_ID = 'entity_id';

/**
* Changed item trace row's identity field name.
*
* @var string CHANGED_ITEM_ID
*/
const ITEM_ID = 'item_id';
public const ITEM_ID = 'item_id';

/**
* Store view the change was issued on.
*
* @var string STORE_ID
*/
const STORE_ID = 'store_id';
public const STORE_ID = 'store_id';

/**
* Item type.
* The type of item that represents inside the table.
*
* @var string ITEM_TYPE
*/
const ITEM_TYPE = 'item_type';
public const ITEM_TYPE = 'item_type';

/**
* Operation performed on Changed item field name.
Expand All @@ -41,28 +41,28 @@ interface ChangedItemInterface
*
* @var string OPERATION_TYPE
*/
const OPERATION_TYPE = 'operation_type';
public const OPERATION_TYPE = 'operation_type';

/**
* Tells that the item was updated in regular way.
*
* @var string OPERATION_TYPE_UPDATE
*/
const OPERATION_TYPE_UPDATE = 'update';
public const OPERATION_TYPE_UPDATE = 'update';

/**
* Tells that the item was deleted completely.
*
* @var string OPERATION_TYPE_DELETE
*/
const OPERATION_TYPE_DELETE = 'delete';
public const OPERATION_TYPE_DELETE = 'delete';

/**
* Tells that the item was created.
*
* @var string OPERATION_TYPE_CRATE
*/
const OPERATION_TYPE_CREATE = 'create';
public const OPERATION_TYPE_CREATE = 'create';

/**
* Get item id
Expand Down
4 changes: 4 additions & 0 deletions Api/Data/ChangedItemSearchResultsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
interface ChangedItemSearchResultsInterface extends SearchResultsInterface
{
/**
* Obtains the resulting items from a search
*
* @return ChangedItemInterface[]
*/
public function getItems();

/**
* Sets the items inside the attribute
*
* @param ChangedItemInterface[] $items
* @return void
*/
Expand Down
6 changes: 6 additions & 0 deletions Api/Data/FetcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@
interface FetcherInterface
{
/**
* Processes the item's fetched result
*
* @param array $documents
* @param integer $storeId
* @return void
*/
public function process(array $documents, int $storeId);

/**
* Obtains the fetched result
*
* @param integer $productId
* @return array
*/
public function get(int $productId): array;

/**
* Clears the fetched result
*
* @return void
*/
public function clear();
Expand Down
22 changes: 0 additions & 22 deletions Api/Data/Generator/MapInterface.php

This file was deleted.

15 changes: 0 additions & 15 deletions Api/Data/MapInterface.php

This file was deleted.

1 change: 1 addition & 0 deletions Api/ModuleDataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface ModuleDataInterface
{
/**
* Obtains the data from the Doofinder module. This data contains module's version, M2's version and the store structure.
*
* @return string
*/
public function get();
Expand Down
33 changes: 22 additions & 11 deletions ApiClient/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
class Client
{
/** Management API type */
const MANAGEMENT_API = 'api';
public const MANAGEMENT_API = 'api';

/** Search API type */
const SEARCH_API = 'search';
public const SEARCH_API = 'search';

/** @var StoreConfig */
private $storeConfig;
Expand Down Expand Up @@ -70,8 +70,9 @@ public function __construct(
}

/**
* Request with GET verb
*
* @param string $path
*
* @return string
* @throws BadRequest
* @throws IndexingInProgress
Expand Down Expand Up @@ -103,9 +104,10 @@ public function get(string $path): string
}

/**
* Request with POST verb
*
* @param string $path
* @param array $body
*
* @return string
* @throws BadRequest
* @throws IndexingInProgress
Expand Down Expand Up @@ -138,9 +140,10 @@ public function post(string $path, array $body): string
}

/**
* Request with PATCH verb
*
* @param string $path
* @param array $body
*
* @return string
* @throws BadRequest
* @throws IndexingInProgress
Expand Down Expand Up @@ -173,9 +176,10 @@ public function patch(string $path, array $body): string
}

/**
* Request with DELETE verb
*
* @param string $path
* @param array $body
*
* @return string
* @throws BadRequest
* @throws IndexingInProgress
Expand All @@ -194,7 +198,7 @@ public function delete(string $path, array $body): string
[
RequestOptions::VERIFY => false,
RequestOptions::HEADERS => $this->getHeaders(),
RequestOptions::JSON => $this->flatten_array($body),
RequestOptions::JSON => $this->flattenArray($body),
RequestOptions::EXPECT => '',
]
);
Expand All @@ -208,6 +212,8 @@ public function delete(string $path, array $body): string
}

/**
* Gets results handling errors
*
* @return string
* @throws BadRequest
* @throws IndexingInProgress
Expand All @@ -231,6 +237,8 @@ private function getResult(): string
}

/**
* Gets necessary headers for the requests
*
* @return string[]
*/
private function getHeaders(): array
Expand All @@ -241,6 +249,8 @@ private function getHeaders(): array
}

/**
* Sets API token region in order to match the corresponding one
*
* @param string|null $apiKey
* @throws InvalidApiKey
*/
Expand Down Expand Up @@ -278,10 +288,11 @@ private function parseErrorResponse(string $message): string
* @param array $ids
* @return array
*/
private function flatten_array(array $ids) {
$flattened_ids = array();
array_walk_recursive($ids, function($a) use (&$flattened_ids) {
$flattened_ids[] = $a;
private function flattenArray(array $ids): array
{
$flattened_ids = [];
array_walk_recursive($ids, function($id) use (&$flattened_ids) {
$flattened_ids[] = $id;
});
return $flattened_ids;
}
Expand Down
25 changes: 23 additions & 2 deletions ApiClient/ManagementClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@

class ManagementClient
{
const ENDPOINT_SEARCH_ENGINES = '/api/v2/search_engines';
const ENDPOINT_UPDATE_ON_SAVE = '/plugins/magento2';
private const ENDPOINT_SEARCH_ENGINES = '/api/v2/search_engines';
private const ENDPOINT_UPDATE_ON_SAVE = '/plugins/magento2';

/** @var Client */
private $client;

/**
* ManagementClient constructor.
*
* @param ClientFactory $clientFactory
* @param string $apiKey
* @param string $apiType
*/
public function __construct(
ClientFactory $clientFactory,
string $apiKey = null,
Expand All @@ -31,6 +38,7 @@ public function __construct(

/**
* Request all user's search engines throttled
*
* @see https://docs.doofinder.com/api/management/v2/#operation/search_engine_list
*
* @return array
Expand All @@ -51,6 +59,12 @@ public function listSearchEngines(): array
return json_decode($response, true);
}

/**
* Creates the store structure in Doofinder
*
* @param array $storeData
* @return array
*/
public function createStore(array $storeData): array
{
$response = $this->client->post('/plugins/create-store', $storeData);
Expand All @@ -60,6 +74,7 @@ public function createStore(array $storeData): array

/**
* Creates a new search engine with the provided data
*
* @see https://docs.doofinder.com/api/management/v2/#operation/search_engine_create
*
* @param array $searchEngine
Expand All @@ -83,6 +98,7 @@ public function createSearchEngine(array $searchEngine): array

/**
* Schedules a task for processing all search engine's data sources.
*
* @see https://docs.doofinder.com/api/management/v2/#operation/process
*
* @param string $hashId
Expand All @@ -108,7 +124,9 @@ public function processSearchEngine(string $hashId, string $callbackUrl = null):

/**
* Request a search engine details
*
* @see https://docs.doofinder.com/api/management/v2/#operation/search_engine_show
*
* @param string $hashId
* @return array
* @throws BadRequest
Expand All @@ -130,6 +148,7 @@ public function getSearchEngine(string $hashid): array

/**
* Creates a list of items from the index in a single bulk operation.
*
* @see https://docs.doofinder.com/api/management/v2/#operation/items_bulk_update
*
* @param array $items
Expand All @@ -155,6 +174,7 @@ public function createItemsInBulk(array $items, string $hashId, string $indice)

/**
* Updates a list of items from the index in a single bulk operation.
*
* @see https://docs.doofinder.com/api/management/v2/#operation/items_bulk_update
*
* @param array $items
Expand All @@ -179,6 +199,7 @@ public function updateItemsInBulk(array $items, string $hashId, string $indice)

/**
* Deletes a list of items from the index in a single bulk operation.
*
* @see https://docs.doofinder.com/api/management/v2/#operation/items_bulk_delete
*
* @param array $items
Expand Down
1 change: 0 additions & 1 deletion Block/Adminhtml/Form/Field/CustomAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,4 @@ public function getArrayRows()
}
return $result;
}

}

0 comments on commit 4ceaac1

Please sign in to comment.