diff --git a/CHANGELOG.md b/CHANGELOG.md
index 61fc7b1..dba21f9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+## [7.0.2] - 2022-11-08
+### Changed
+- Documentation update
+
## [7.0.1] - 2022-10-11
### Changed
- Fixed error in readme files
diff --git a/composer.json b/composer.json
index b2a4450..be35584 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "doofinder/php-doofinder",
- "version": "7.0.1",
+ "version": "7.0.2",
"type": "library",
"description": "Doofinder PHP API Client",
"keywords": [
diff --git a/composer.lock b/composer.lock
index eeeb612..6448f0a 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "6893b44459498c252e2198d20a59f2c5",
+ "content-hash": "e7805bd54f3d1d93de48135f9d7b2330",
"packages": [],
"packages-dev": [
{
@@ -429,25 +429,30 @@
},
{
"name": "phpdocumentor/type-resolver",
- "version": "1.6.1",
+ "version": "1.6.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
- "reference": "77a32518733312af16a44300404e945338981de3"
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3",
- "reference": "77a32518733312af16a44300404e945338981de3",
+ "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
+ "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d",
"shasum": ""
},
"require": {
- "php": "^7.2 || ^8.0",
+ "php": "^7.4 || ^8.0",
"phpdocumentor/reflection-common": "^2.0"
},
"require-dev": {
"ext-tokenizer": "*",
- "psalm/phar": "^4.8"
+ "phpstan/extension-installer": "^1.1",
+ "phpstan/phpstan": "^1.8",
+ "phpstan/phpstan-phpunit": "^1.1",
+ "phpunit/phpunit": "^9.5",
+ "rector/rector": "^0.13.9",
+ "vimeo/psalm": "^4.25"
},
"type": "library",
"extra": {
@@ -473,9 +478,9 @@
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
"support": {
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
- "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1"
+ "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2"
},
- "time": "2022-03-15T21:29:03+00:00"
+ "time": "2022-10-14T12:47:21+00:00"
},
{
"name": "phpspec/prophecy",
diff --git a/doc/classes/Doofinder-Management-Model-Item.html b/doc/classes/Doofinder-Management-Model-Item.html
index 0ef2e48..8774aac 100644
--- a/doc/classes/Doofinder-Management-Model-Item.html
+++ b/doc/classes/Doofinder-Management-Model-Item.html
@@ -152,7 +152,7 @@
SETTED_FIELDS
- = ['id', 'df_grouping_id', 'df_group_leader', 'df_manual_boost', 'categories', 'best_price']
+ = ['title', 'description', 'link', 'image_link', 'availability', 'price', 'sale_price', 'brand', 'gtin', 'mpn']
@@ -303,7 +303,7 @@
public
mixed
SETTED_FIELDS
- = ['id', 'df_grouping_id', 'df_group_leader', 'df_manual_boost', 'categories', 'best_price']
+ = ['title', 'description', 'link', 'image_link', 'availability', 'price', 'sale_price', 'brand', 'gtin', 'mpn']
diff --git a/src/Management/Model/Item.php b/src/Management/Model/Item.php
index b9581cc..4d88835 100644
--- a/src/Management/Model/Item.php
+++ b/src/Management/Model/Item.php
@@ -9,7 +9,7 @@
*/
class Item implements ModelInterface
{
- const SETTED_FIELDS = ['id', 'df_grouping_id', 'df_group_leader', 'df_manual_boost', 'categories', 'best_price'];
+ const SETTED_FIELDS = ['title', 'description', 'link', 'image_link', 'availability', 'price', 'sale_price', 'brand', 'gtin', 'mpn'];
/**
* @var string
diff --git a/src/Management/README_MANAGEMENT.md b/src/Management/README_MANAGEMENT.md
index a584954..a76e128 100644
--- a/src/Management/README_MANAGEMENT.md
+++ b/src/Management/README_MANAGEMENT.md
@@ -1,64 +1,140 @@
-# Doofinder Management API
+# Official PHP client for the Doofinder Management API
Doofinder's management API allows you to perform the same administrative tasks you can do on your search engines using the Doofinder control panel, directly from your code.
- API version: 2.0
-For more information, please visit the documentation: [Management API](https://docs.doofinder.com/#section/Management-API)
+For more information, please visit the documentation: [Management API V2](https://docs.doofinder.com/api/management/v2/)
- [Requirements](#requirements)
- [Installation & Usage](#installation--usage)
- - [Composer](#composer)
+ - [Using Composer](#using-composer)
- [Manual Installation](#manual-installation)
+- [Authorization](#authorization)
+ - [API Token](#api-token)
+ - [JKW](#jkw)
- [Tests](#tests)
-- [Quick & Dirty](#quick--dirty)
-- [Documentation](#documentation-for-clients-methods)
+- [API for Search Engine](#search-engine)
+- [API for Index](#index)
+- [API for Items](#items)
+- [Responses](#responses)
+ - [Search Engine response](#search-engine-response)
+ - [Index response](#index-response)
+ - [Index Options response](#index-options-response)
+ - [Data Source response](#data-source-response)
+ - [Item response](#item-response)
+ - [Status response](#status-response)
## Requirements
-PHP 5.6 and later
+Requires PHP 5.6 or later. Not tested in previous versions.
## Installation & Usage
-### Composer
-To install the bindings via [Composer](http://getcomposer.org/), run the following:
+### Using Composer
-`composer install`
+You can also download the library using [Composer](https://packagist.org/packages/doofinder/doofinder).
+
+Run this command to add the Doofinder library to your `composer.json` file:
+
+```bash
+composer require doofinder/doofinder
+```
+
+If you are already using Composer your `autoload.php` file will be updated. If not, a new one will be generated and you will have to include it:
+
+```php
+getSearchEngineProcessStatus($searchEngine->getHashid());
$managementClient->deleteSearchEngine($searchEngine->getHashid());
```
-### Index
+### Documentation for Search Engine methods
+
+| Method | Description | Return type |
+|-|-|-|
+| **createSearchEngine** | Creates a search engine | [Search Engine response](#search-engine-response) |
+| **updateSearchEngine** | Updates a search engine | [Search Engine response](#search-engine-response) |
+| **getSearchEngine** | Gets a search engine | [Search Engine response](#search-engine-response) |
+| **listSearchEngines** | Gets a list of search engines | Array of [Search Engine response](#search-engine-response) |
+| **deleteSearchEngine** | Deletes a search engine | void |
+| **processSearchEngine** | Schedules a task for processing all search engine's data sources. | Array |
+| **getSearchEngineProcessStatus** | Gets the status of the last process task | Array |
+
+## Index
+
+All indices and temporary indices CRUD operations.
+
```php
reindexIntoTemporary($searchEngine->getHashid(), $index->getN
//// **** Reindex status ****
$managementClient->reindexTaskStatus($searchEngine->getHashid(), $index->getName());
-// **** Reindex status ****
+// **** Replace status ****
$managementClient->replaceIndex($searchEngine->getHashid(), $index->getName());
// **** Deletes temporary index ****
@@ -184,19 +275,37 @@ $managementClient->deleteTemporaryIndex($searchEngine->getHashid(), $index->getN
$managementClient->deleteIndex($searchEngine->getHashid(), $index->getName());
```
-### Items
+### Documentation for Index methods
+
+| Method | Description | Return type |
+|-|-|-|
+| **createIndex** | Creates an index | [Index response](#index-response) |
+| **updateIndex** | Updates an index | [Index response](#index-response) |
+| **getIndex** | Gets an index | [Index response](#index-response) |
+| **listIndexes** | Gets a list of index | Array of [Index response](#index-response) |
+| **deleteIndex** | Deletes an index | void |
+| **createTemporaryIndex** | Creates a temporary index | [Status response](#status-response) |
+| **deleteTemporaryIndex** | Deletes a temporary index | void |
+| **replaceIndex** | Replaces an index with the temporary index | [Status response](#status-response) |
+| **reindexIntoTemporary** | Reindex between from production index to temporary one | [Status response](#status-response) |
+| **reindexTaskStatus** | Gets the status of the last scheduled reindexing tasks | Array |
+
+## Items
+
+Handling content of indices. Allows to retrieve and update the items of an index.
+
```php
countItems($searchEngine->getHashid(), $index->getName());
// **** Find items ****
$idParams = [
- [
- 'id' => 'this_is_my_item_id',
- ]
+ ['id' => 'item_id'],
+ ['id' => 'other_item_id'],
];
$response = $managementClient->findItems($searchEngine->getHashid(), $index->getName(), $idParams);
-/** @var \Doofinder\Management\Model\Item $item */
-$item = $response->getBody()[0]['item'];
+/** @var \Doofinder\Management\Model\Item[] $items */
+$items = $response->getBody();
// **** Scroll index ****
$scrollParams = [
@@ -300,9 +408,8 @@ $items = $response->getBody();
// **** Delete items in bulk ****
$itemParams = [
- [
- 'id' => 'this_is_my_item_id_2',
- ],
+ ['id' => 'this_is_my_item_id_1'],
+ ['id' => 'this_is_my_item_id_2']
];
$managementClient->deleteItemsInBulk($searchEngine->getHashid(), $index->getName(), $itemParams);
@@ -371,50 +478,97 @@ $itemParams = [
];
$managementClient->deleteItemsInBulkInTemporalIndex($searchEngine->getHashid(), $index->getName(), $itemParams);
```
-## Documentation for Client's Methods
-
-| Method | Description | Return type |
-|--------------------------------------|---------------------------------------------------------------------------------|----------------------------------------------------------------------------|
-| **createSearchEngine** | Creates a search engine | [Doofinder\Management\Model\SearchEngine](Model/SearchEngine.php) |
-| **updateSearchEngine** | Updates a search engine | [Doofinder\Management\Model\SearchEngine](Model/SearchEngine.php) |
-| **getSearchEngine** | Gets a search engine | [Doofinder\Management\Model\SearchEngine](Model/SearchEngine.php) |
-| **listSearchEngines** | Gets a list of search engines | Array of [Doofinder\Management\Model\SearchEngine](Model/SearchEngine.php) |
-| **deleteSearchEngine** | Deletes a search engine | void |
-| **processSearchEngine** | Schedules a task for processing all search engine's data sources. | Array |
-| **getSearchEngineProcessStatus** | Gets the status of the last process task | Array |
-| **createIndex** | Creates an index | [Doofinder\Management\Model\Index](Model/Index.php) |
-| **updateIndex** | Updates an index | [Doofinder\Management\Model\Index](Model/Index.php) |
-| **getIndex** | Gets an index | [Doofinder\Management\Model\Index](Model/Index.php) |
-| **listIndexes** | Gets a list of index | Array of [Doofinder\Management\Model\Index](Model/Index.php) |
-| **deleteIndex** | Deletes an index | void |
-| **createItem** | Creates an item | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **updateItem** | Updates an item | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **getItem** | Gets an item | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **scrollIndex** | Scrolls an index and return an item list | Array |
-| **deleteItem** | Deletes an item | void |
-| **createTemporaryIndex** | Creates a temporary index | Array |
-| **deleteTemporaryIndex** | Deletes a temporary index | void |
-| **replaceIndex** | Replaces an index with the temporary index content | Array |
-| **reindexIntoTemporary** | Reindex between from production index to temporary one | Array |
-| **reindexTaskStatus** | Gets the status of the last scheduled reindexing tasks | Array |
-| **createItemInTemporalIndex** | Creates an item with the data provided in the temporal index | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **updateItemInTemporalIndex** | Partially updates an item in the temporal index given its id | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **getItemFromTemporalIndex** | Gets an item from the temporal index by its id | [Doofinder\Management\Model\Item](Model/Item.php) |
-| **deleteItemFromTemporalIndex** | Deletes an item from the temporal index given its id | void |
-| **findItemsFromTemporalIndex** | Finds a list items from a temporal index in a single operation by a list of ids | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **findItems** | Finds a list items in a single operation by a list of ids | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **countItems** | Returns the total number of items in an index | Array |
-| **createItemsInBulkInTemporalIndex** | Creates a list of items in the temporal index in a single bulk operation | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **updateItemsInBulkInTemporalIndex** | Updates a list of items in the temporal index in a single bulk operation | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **deleteItemsInBulkInTemporalIndex** | Deletes a list of items in the temporal index in a single bulk operation | Array |
-| **createItemsInBulk** | Creates a list of items in the index in a single bulk operation | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **updateItemsInBulk** | Updates a list of items from the index in a single bulk operation | Array of [Doofinder\Management\Model\Item](Model/Item.php) |
-| **deleteItemsInBulk** | Deletes a list of items from the index in a single bulk operation | Array |
-## Authorization
-We use [JWT](https://en.wikipedia.org/wiki/JSON_Web_Token) in http header for authenticate requests.
+### Documentation for Item methods
+
+| Method | Description | Return type |
+|-|-|-|
+| **createItem** | Creates an item | [Item response](#item-response) |
+| **updateItem** | Updates an item | [Item response](#item-response) |
+| **getItem** | Gets an item | [Item response](#item-response) |
+| **scrollIndex** | Scrolls an index and return an item list | Array of [Item response](#item-response) |
+| **deleteItem** | Deletes an item | void |
+| **createItemInTemporalIndex** | Creates an item with the data provided in the temporal index | [Item response](#item-response) |
+| **updateItemInTemporalIndex** | Partially updates an item in the temporal index given its id | Array of list of results of each bulk operation |
+| **getItemFromTemporalIndex** | Gets an item from the temporal index by its id | [Item response](#item-response) |
+| **deleteItemFromTemporalIndex** | Deletes an item from the temporal index given its id | void |
+| **findItemsFromTemporalIndex** | Finds a list items from a temporal index in a single operation by a list of ids | Array of [Item response](#item-response) |
+| **findItems** | Finds a list items in a single operation by a list of ids | Array of [Item response](#item-response) |
+| **countItems** | Returns the total number of items in an index | Array |
+| **createItemsInBulkInTemporalIndex** | Creates a list of items in the temporal index in a single bulk operation | Array of list of results of each bulk operation |
+| **updateItemsInBulkInTemporalIndex** | Updates a list of items in the temporal index in a single bulk operation | Array of list of results of each bulk operation |
+| **deleteItemsInBulkInTemporalIndex** | Deletes a list of items in the temporal index in a single bulk operation | Array of list of results of each bulk operation |
+| **createItemsInBulk** | Creates a list of items in the index in a single bulk operation | Array of list of results of each bulk operation |
+| **updateItemsInBulk** | Updates a list of items from the index in a single bulk operation | Array of list of results of each bulk operation |
+| **deleteItemsInBulk** | Deletes a list of items from the index in a single bulk operation | Array of list of results of each bulk operation |
+
+## Responses
+
+#### Search Engine response
+
+```php
+[
+ "currency" => "(string) Currency used in the search engine in ISO 4217 Code",
+ "hashid" => "(string) A unique code that identifies a search engine.",
+ "indices" => "(Array) A list of indices for a search engine.", # Show Index response
+ "inactive" => "(boolean) Indicates if the search engine has been deactivated and therefore it can not receive requests.",
+ "language" => "(string) An ISO 639-1 language code that determines the language of the search engine. The language affects how the words indexed are tokenized and which stopwords to use.",
+ "name" => "(string) A short name that helps identifying the search engine.",
+ "search_url" => "(string) Indicates the search server domain for this search engine. You should use this domain to perform searches to this search engine.",
+ "site_url" => "(string or null) The URL of the site to be integrated with the search engine. It determines the default allowed domains for requests",
+ "stopwords" => "(boolean) Default: false. Ignores high-frequency terms like 'the', 'and', 'is'. These words have a low weight and contribute little to the relevance score.",
+ "platform" => "(string) Indicates which platform the search engine is associated with.",
+ "has_grouping" => "(boolean) When this option is selected, only one of the item variants is returned in the search results. This only works if the indexed item have the group_id field."
+]
```
-{
- "Authorization" : "Bearer {my_jwt_token}"
-}
+
+#### Index response
+
+```php
+[
+ "name" => "(string) Name of the Index. It works as the index identifier.",
+ "preset" => "(string) Enum: ['generic' 'product' 'page' 'category'] Preset of the index. The preset defines a set of configuration parameters for the index like basic fields to be included, and field transformations. For instance, the product preset creates the best_price field.",
+ "options" => "(Array (Index Options)) Options for an index.", # Show Index Options response
+ "datasources" => "(Array (Data Sources)) List of datasources of an index." # Show Data Sources response
+]
+```
+
+#### Index Options response
+
+```php
+[
+ "exclude_out_of_stock_items" => "(boolean) When this option is selected, products without stock are not included in search results. In order to identify which of your products are out of stock you must use the availability field with 'in stock' / 'out of stock' values."
+]
+```
+
+#### Data Source response
+
+```php
+[
+ "type" => "(string) Enum: 'bigcommerce' 'ekm' 'file' 'magento2' 'shopify'. Type of datasource",
+ "options" => "(Array of EKM Source Options or Magento2 Source Options or File Source Options) DataSource general options. They define required parameters for the DataSource to work or options that modify the access to the data feed."
+]
+```
+
+#### Item response
+
+```php
+[
+ "id" => "(string) Item id",
+ "group_id" => "(string or null) This field indicates the group to which this item belongs to. All items with the same group_id will be collapsed into one in search results, returning the most relevant one or the group leader if they all have the same score.",
+ "df_group_leader" => "(boolean or null) This field indicates the item chosen as the default among its group. It will be returned in search results if there is no other item with a higher score.",
+ "df_manual_boost" => "(number or null) A numeric score boosting. It multiplies the natural score of the item for a search. For instance, if boost is greater than 1.0 the item will appear higher in the results. If it is lower than 1.0, it will appear lower. The minimum value is 0.0.",
+ "categories" => "(Array of strings or string) This field has special behaviour when Indice has product preset",
+ "best_price" => "(number or null) Auto created field that gets the min value between price or sale_price fields, if added in the document. It gets null if doesn't find any of these fields.",
+ "price" => "(number or null) A numeric field that indicates the price.",
+ "sale_price" => "(number or null) A numeric field that indicates the actual sale price."
+]
+```
+
+#### Status response
+
+```php
+[
+ "status" => "OK"
+]
```
\ No newline at end of file
diff --git a/src/Search/README_SEARCH.md b/src/Search/README_SEARCH.md
index 3cb68a4..82afb8c 100644
--- a/src/Search/README_SEARCH.md
+++ b/src/Search/README_SEARCH.md
@@ -1,25 +1,23 @@
-# Official PHP Search Client for Doofinder
+# Official PHP client for the Doofinder Search API
-For more information, please visit the documentation: [Search-API](https://docs.doofinder.com/#section/Search-API)
+Search API allows you to perform the search requests you can do on your search engines using the doofinder layer, directly from your code.
+
+- API version: 6.0
+
+For more information, please visit the documentation: [Search-API](https://docs.doofinder.com/api/search/v6/)
- [Requirements](#requirements)
-- [Installation & Usage](#installation-usage)
- - [Download Method](#download-method)
- - [Using Composer](#using-composer)
- - [Authorization](#authorization)
-- [Quick & Dirty](#quick-dirty)
- - [Search](#search)
- - [Documentation for Client's Methods](#documentation-for-clients-methods)
-- [Responses](#responses)
- - [Search](#search)
- - [Banner](#banner)
- - [Term facet](#term-facet)
- - [Items](#items)
- - [Status response](#status)
-- [API Reference](#api-reference)
+- [Installation & Usage](#installation--usage)
+ - [Using Composer](#using-composer)
+ - [Manual Installation](#manual-installation)
+- [Authorization](#authorization)
+ - [API Token](#api-token)
- [Tests](#tests)
+- [API for Search](#search)
+- [API for Stats](#stats)
+
## Requirements
@@ -27,58 +25,83 @@ For more information, please visit the documentation: [Search-API](https://docs.
Requires PHP 5.6 or later. Not tested in previous versions.
## Installation & Usage
-To install the library you can download it from the project's [releases](https://github.com/doofinder/php-doofinder/releases) page or use [Composer](https://packagist.org/packages/doofinder/doofinder).
-
-
-
-### Download Method
-
-Include the provided autoload.php file and use:
-
-```php
- require_once('/path/to/php-doofinder/vendor/autoload.php');
-```
### Using Composer
-Add Doofinder to your `composer.json` file by running:
+You can also download the library using [Composer](https://packagist.org/packages/doofinder/doofinder).
+
+Run this command to add the Doofinder library to your `composer.json` file:
```bash
-$ composer require doofinder/doofinder
+composer require doofinder/doofinder
```
-If you're already using composer your autoload.php file will be updated. If not, a new one will be generated and you will have to include it:
+
+If you are already using Composer your `autoload.php` file will be updated. If not, a new one will be generated and you will have to include it:
```php
"asc"]
],
];
-$response = $searchClient->search($hashId, $searchEngineParams);
+$response = $searchClient->search($hashId, $searchParams);
$search = $response->getBody();
+// **** Suggestions ****
$suggestionParams = [
'indices' => [
'product'
],
'query' => 'cámara',
'session_id' => 'fake_session_id',
- 'stats' => trueº
+ 'stats' => "true"
];
$response = $searchClient->suggest($hashId, $suggestionParams);
$suggestions = $response->getBody();
+```
-// **** Init session ****
-$searchClient->initSession($hashId, $sessionId);
-
-// **** Logs redirection ****
-$searchClient->logRedirection($hashId, $sessionId, $id, $query);
-
-// **** Logs banner ****
-$searchClient->logBanner($hashId, $sessionId, $id, $query);
-
-// **** Logs checkout ****
-$searchClient->logCheckout($hashId, $sessionId);
-
-// **** Logs click ****
-$searchClient->logClick($hashId, $sessionId, $id, $query);
-
-// **** Logs add to cart ****
-$searchClient->logAddToCart($hashId, $sessionId, $amount, $itemId, $indexId, $price, $title);
+### Documentation for Search methods
-// **** Logs remove from cart ****
-$searchClient->logRemoveFromCart($hashId, $sessionId, $amount, $itemId, $indexId);
+| Method | Description | Return type |
+|-|-|-|
+| **search** | Search through indexed items of a search engine | [Search response](#search-response) |
+| **suggest** | Search through indexed suggestions of a search engine | Array of strings |
-// **** Logs clear cart ****
-$searchClient->clearCart($hashId, $sessionId);
-```
+#### Search response
-## Documentation for Client's Methods
-
-| Method | Description | Return type |
-|-----------------------|---------------------------------------------------------------------------------------------|-------------------------------------|
-| **search** | Search through indexed items of a search engine | [Search response](#search-response) |
-| **suggest** | Search through indexed suggestions of a search engine | Array of strings |
-| **initSession** | Starts a session identified by a session_id | [Status response](#status-response) |
-| **logRedirection** | Logs a "redirection triggered" event in stats logs | [Status response](#status-response) |
-| **logBanner** | Logs a "click on banner image" event in stats logs | [Status response](#status-response) |
-| **logCheckout** | Logs a checkout event in stats logs | [Status response](#status-response) |
-| **logClick** | Save click event on doofinder statistics | [Status response](#status-response) |
-| **logAddToCart** | Adds an item to the cart, or creates a new cart for the given session if it does not exists | [Status response](#status-response) |
-| **logRemoveFromCart** | Removes an amount from the given item in the cart | [Status response](#status-response) |
-| **clearCart** | his call will erase completely a cart identified by the pair of hashid and session ID | [Status response](#status-response) |
-
-## Responses
-### Search
```php
[
- 'banner' => 'Banner response for a query search.',
+ 'banner' => 'Banner response for a query search.', # [Show Banner response]
'count' => '(integer) Total number of items found in the search engine for the searched term.',
'custom_results_id' => '(integer) Id of applied custom results. This field will not be included if none of the custom results apply.',
- 'facets' => '(Array of Term Facet Response or Range Facet Response) Information about different groupings that can be made for certain fields in the search results.',
- 'query_name' => '(string) In order to get the best possible results, Doofinder tries several types of querying. This is the type of the query Doofinder made to obtain these results.',
- 'total' => '(integer) Total number of items that can be fetched.'
+ 'facets' => '(Array of Term Facet Response or Range Facet Response) Information about the different groupings that can be made for certain fields in the search results.', # [Show Term facet response]
+ 'query_name' => '(string) To get the best possible results, Doofinder tries several query types. This is the type of query that Doofinder has performed to obtain these results.',
+ 'results' => '(array) List of items found in the search engine for the searched term.', # [Show Items response]
+ 'total' => '(integer) Total number of elements that can be obtained.'
]
```
-### Banner
+#### Banner response
+
```php
[
- 'blank' => '(boolean) Display the banner link in a new window.'
- 'html_code' => '(string) Html code to be used as banner instead of an image.'
+ 'blank' => '(boolean) Display the banner link in a new window.',
+ 'html_code' => '(string) Html code to be used as banner instead of an image.',
'id' => '(integer) Banner identification.',
'image' => '(string) Image URL used as banner.',
- 'link' => '(string) URL to be redirected when click over banner.'
+ 'link' => '(string) URL to be redirected when click over banner.',
'mobile_image' => '(string) Image URL used as banner for mobile devices.'
]
```
-### Term facet
-```php
-[
- 'items' => '(array of Items)',
- 'selected' => '(array of Items)'
-]
-```
+#### Term Facet response
-### Items
```php
[
- 'count' => '(integer) number of elements',
- 'name' => '(string) Name of term'
+
+ 'key' => '(string) Name of the aggregated field.',
+ # Facet terms list
+ 'terms' => [
+ 'items' => [
+ 'count' => '(integer) number of elements',
+ 'name' => '(string) Name of term'
+ ],
+ 'selected' => [
+ 'count' => '(integer) number of elements',
+ 'name' => '(string) Name of term'
+ ]
+ ]
]
```
-### Status
+#### Items response
+
```php
[
- 'status' => 'registered'
+ 'description' => '(string) Item description.',
+ 'dfid' => '(string) Doofinder result doofinder id. It comes in every Doofinder results for every item.',
+ 'id' => '(string) Unique identification of an indexed item.',
+ 'image_url' => '(string) Item image url.',
+ 'title' => '(string) Item title.',
+ 'url' => '(string) Item url.'
]
```
-## API reference
+## Stats
-#### `\Doofinder\Search\Client`
+Functions to perform statistical operations.
```php
-$client->searchParams($params, $options); // Import search params from a request into an array
-$client->dumpParams($options); // Export latest search params in client into an array
-$client->qs(); // Export latest search params in client to a string
+search($params); // Perform search
-$client->getNextPage(); // Perform a search for the next page of results
-$client->getPreviousPage(); // Perform a search for the previous page of results
+require_once(__DIR__ . '/../vendor/autoload.php');
-$client->getSearchParam($paramName, $defaultValue); // Get a search parameter from the client for the latest search done
+const HOST = 'https://eu1-search.doofinder.com';
+const API_KEY = 'your_api_token';
-$client->createSessionId(); // Create a hash to be used as session id
-$client->registerSession($sessionId, $hashid); // Initializes session for the search client
-$client->registerClick($sessionId, $hashid, $id, $options); // Register a click in Doofinder
-$client->registerCheckout($sessionId, $hashid); // Register a checkout in Doofinder
-$client->registerImageClick($sessionId, $hashid, $imageId); // Register a banner click in Doofinder
-$client->registerRedirection($sessionId, $hashid,
- $redirectionId, $link, $options); // Register a redirection in Doofinder
+$searchClient = \Doofinder\Search\SearchClient::create(
+ HOST,
+ API_KEY
+);
-$client->addToCart($sessionId, $hashid, $id, $amount, $options); // Add an amount of item to the cart in the current session
-$client->removeFromCart($sessionId, $hashid, $id, $amount, $options); // Remove an amount of item from the cart in the current session
-$client->clearCart($sessionId, $hashid); // Clear the cart in the current session
+$hashId = 'fake_hash_id';
-$client->setCustomHeaders($headers); // Add custom headers to all requests
-```
+// **** Init session ****
+$response = $searchClient->initSession($hashId, $sessionId);
+$body = $response->getBody();
-#### `\Doofinder\Search\Results`
+// **** Logs redirection ****
+$response = $searchClient->logRedirection($hashId, $sessionId, $id, $query);
+$body = $response->getBody();
-```php
-$results->getProperty($propertyName); // Get the property $propertyName
-$results->getResults(); // Get results
-$results->getFacetsNames(); // Array with facet names
-$results->getFacet($facetName); // Obtain search results for facet $facetName
-$results->getFacets(); // All facets
-$results->getAppliedFilters(); // Filters that have been applied to obtain these results
-$results->isOk(); // Checks if all went OK
-$results->status; // Account status info. 'success', 'exhausted', 'notfound'
-```
+// **** Logs banner ****
+$response = $searchClient->logBanner($hashId, $sessionId, $id, $query);
+$body = $response->getBody();
+// **** Logs checkout ****
+$response = $searchClient->logCheckout($hashId, $sessionId);
+$body = $response->getBody();
-## Tests
+// **** Logs click ****
+$response = $searchClient->logClick($hashId, $sessionId, $id, $query);
+$body = $response->getBody();
-To run the unit tests:
+// **** Logs add to cart ****
+$response = $searchClient->logAddToCart($hashId, $sessionId, $amount, $itemId, $indexId, $price, $title);
+$body = $response->getBody();
+
+// **** Logs remove from cart ****
+$response = $searchClient->logRemoveFromCart($hashId, $sessionId, $amount, $itemId, $indexId);
+$body = $response->getBody();
+// **** Logs clear cart ****
+$response = $searchClient->clearCart($hashId, $sessionId);
+$body = $response->getBody();
```
-composer tests
+
+### Documentation for Stats methods
+
+| Method | Description | Return type |
+|-|-|-|
+| **initSession** | Starts a session identified by a session_id | [Status response](#status-response) |
+| **logRedirection** | Logs a "redirection triggered" event in stats logs | [Status response](#status-response) |
+| **logBanner** | Logs a "click on banner image" event in stats logs | [Status response](#status-response) |
+| **logCheckout** | Logs a checkout event in stats logs | [Status response](#status-response) |
+| **logClick** | Save click event on doofinder statistics | [Status response](#status-response) |
+| **logAddToCart** | Adds an item to the cart, or creates a new cart for the given session if it does not exists | [Status response](#status-response) |
+| **logRemoveFromCart** | Removes an amount from the given item in the cart | [Status response](#status-response) |
+| **clearCart** | his call will erase completely a cart identified by the pair of hashid and session ID | [Status response](#status-response) |
+
+#### Status response
+
+```php
+[
+ 'status' => 'registered'
+]
```
\ No newline at end of file