Doofinder_Feed - Version 1.7.1

Version Notes

WARNING: Updated Doofinder PHP API Library. This is a big update. Remember to clear Magento Cache!!!

Download this release

Release Info

Developer Carlos Escribano Rey
Extension Doofinder_Feed
Version 1.7.1
Comparing to
See all releases


Code changes from version 1.7.0 to 1.7.1

Files changed (74) hide show
  1. app/code/community/Doofinder/Feed/Block/Adminhtml/Log/View.php +1 -1
  2. app/code/community/Doofinder/Feed/Block/Adminhtml/Map/Additional.php +1 -1
  3. app/code/community/Doofinder/Feed/Block/Integration.php +1 -1
  4. app/code/community/Doofinder/Feed/Block/Settings/Buttons/Generate.php +1 -1
  5. app/code/community/Doofinder/Feed/Block/Settings/Buttons/ViewLog.php +1 -1
  6. app/code/community/Doofinder/Feed/Block/Settings/Panel/Crondescription.php +1 -1
  7. app/code/community/Doofinder/Feed/Block/Settings/Panel/Datetime.php +1 -1
  8. app/code/community/Doofinder/Feed/Block/Settings/Panel/Description.php +1 -1
  9. app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php +1 -1
  10. app/code/community/Doofinder/Feed/Block/Settings/Panel/Layerdescription.php +1 -1
  11. app/code/community/Doofinder/Feed/Block/Settings/Panel/Message.php +1 -1
  12. app/code/community/Doofinder/Feed/Helper/Data.php +2 -2
  13. app/code/community/Doofinder/Feed/Helper/Log.php +2 -2
  14. app/code/community/Doofinder/Feed/Helper/Tax.php +2 -2
  15. app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Backend/Cron.php +1 -1
  16. app/code/community/Doofinder/Feed/Model/Config.php +2 -2
  17. app/code/community/Doofinder/Feed/Model/Cron.php +1 -1
  18. app/code/community/Doofinder/Feed/Model/Generator.php +2 -2
  19. app/code/community/Doofinder/Feed/Model/Log.php +1 -1
  20. app/code/community/Doofinder/Feed/Model/Map/Product/Abstract.php +2 -2
  21. app/code/community/Doofinder/Feed/Model/Map/Product/Associated.php +2 -2
  22. app/code/community/Doofinder/Feed/Model/Map/Product/Bundle.php +2 -2
  23. app/code/community/Doofinder/Feed/Model/Map/Product/Configurable.php +2 -2
  24. app/code/community/Doofinder/Feed/Model/Map/Product/Downloadable.php +2 -2
  25. app/code/community/Doofinder/Feed/Model/Map/Product/Grouped.php +2 -2
  26. app/code/community/Doofinder/Feed/Model/Map/Product/Simple.php +2 -2
  27. app/code/community/Doofinder/Feed/Model/Map/Product/Virtual.php +2 -2
  28. app/code/community/Doofinder/Feed/Model/Mysql4/Cron.php +1 -1
  29. app/code/community/Doofinder/Feed/Model/Mysql4/Cron/Collection.php +1 -1
  30. app/code/community/Doofinder/Feed/Model/Mysql4/Log.php +1 -1
  31. app/code/community/Doofinder/Feed/Model/Mysql4/Log/Collection.php +1 -1
  32. app/code/community/Doofinder/Feed/Model/Observers/Feed.php +1 -1
  33. app/code/community/Doofinder/Feed/Model/Observers/Logs.php +1 -1
  34. app/code/community/Doofinder/Feed/Model/Observers/Schedule.php +1 -1
  35. app/code/community/Doofinder/Feed/Model/Resource/Mysql4/Setup.php +1 -1
  36. app/code/community/Doofinder/Feed/Model/System/Config/Backend/Map/Additional.php +1 -1
  37. app/code/community/Doofinder/Feed/Model/System/Config/Reset.php +1 -1
  38. app/code/community/Doofinder/Feed/Model/System/Config/Source/Product/Attributes.php +1 -1
  39. app/code/community/Doofinder/Feed/Model/Tools.php +2 -2
  40. app/code/community/Doofinder/Feed/controllers/DoofinderFeedFeedController.php +1 -1
  41. app/code/community/Doofinder/Feed/controllers/DoofinderFeedLogController.php +1 -1
  42. app/code/community/Doofinder/Feed/controllers/FeedController.php +2 -2
  43. app/code/community/Doofinder/Feed/controllers/IndexController.php +2 -2
  44. app/code/community/Doofinder/Feed/etc/config.xml +1 -1
  45. lib/php-doofinder/CHANGELOG.txt +38 -0
  46. lib/php-doofinder/README.md +599 -0
  47. lib/php-doofinder/autoload.php +21 -0
  48. lib/php-doofinder/composer.json +27 -0
  49. lib/php-doofinder/phpunit.xml +8 -0
  50. lib/php-doofinder/src/Management/AggregatesIterator.php +59 -0
  51. lib/php-doofinder/src/Management/Client.php +144 -0
  52. lib/php-doofinder/src/Management/Errors/BadRequest.php +5 -0
  53. lib/php-doofinder/src/Management/Errors/NotAllowed.php +5 -0
  54. lib/php-doofinder/src/Management/Errors/NotFound.php +4 -0
  55. lib/php-doofinder/src/Management/Errors/NotProcessedResponse.php +5 -0
  56. lib/php-doofinder/src/Management/Errors/QuotaExhausted.php +5 -0
  57. lib/php-doofinder/src/Management/Errors/ThrottledResponse.php +5 -0
  58. lib/php-doofinder/src/Management/Errors/Utils.php +53 -0
  59. lib/php-doofinder/src/Management/Errors/WrongResponse.php +5 -0
  60. lib/php-doofinder/src/Management/ItemsResultSet.php +60 -0
  61. lib/php-doofinder/src/Management/ScrollIterator.php +49 -0
  62. lib/php-doofinder/src/Management/SearchEngine.php +269 -0
  63. lib/php-doofinder/src/Management/TopTermsIterator.php +54 -0
  64. lib/php-doofinder/src/Search/Client.php +581 -0
  65. lib/php-doofinder/src/Search/Error.php +10 -0
  66. lib/php-doofinder/src/Search/Results.php +220 -0
  67. lib/php-doofinder/src/Test/Management/AggregatesIteratorTest.php +77 -0
  68. lib/php-doofinder/src/Test/Management/ClientTest.php +94 -0
  69. lib/php-doofinder/src/Test/Management/ScrollIteratorTest.php +67 -0
  70. lib/php-doofinder/src/Test/Management/SearchEngineTest.php +355 -0
  71. lib/php-doofinder/src/Test/Management/TopTermsIteratorTest.php +96 -0
  72. lib/php-doofinder/src/Test/Search/ClientTest.php +381 -0
  73. lib/php-doofinder/src/Test/Search/ResultsTests.php +94 -0
  74. package.xml +4 -4
app/code/community/Doofinder/Feed/Block/Adminhtml/Log/View.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widget_Grid
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Log_View extends Mage_Adminhtml_Block_Widget_Grid
app/code/community/Doofinder/Feed/Block/Adminhtml/Map/Additional.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Adminhtml_Map_Additional extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Integration.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Integration extends Mage_Core_Block_Abstract
app/code/community/Doofinder/Feed/Block/Settings/Buttons/Generate.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_Generate extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Settings/Buttons/ViewLog.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Buttons_ViewLog extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Settings/Panel/Crondescription.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_CronDescription extends Doofinder_Feed_Block_Settings_Panel_Description
app/code/community/Doofinder/Feed/Block/Settings/Panel/Datetime.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Datetime extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Settings/Panel/Description.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Description extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Settings/Panel/File.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_File extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Block/Settings/Panel/Layerdescription.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_LayerDescription extends Doofinder_Feed_Block_Settings_Panel_Description
app/code/community/Doofinder/Feed/Block/Settings/Panel/Message.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_System_Config_Form_Field
6
  /**
7
  * @category blocks
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Block_Settings_Panel_Message extends Mage_Adminhtml_Block_System_Config_Form_Field
app/code/community/Doofinder/Feed/Helper/Data.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Data helper for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Data helper for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Data extends Mage_Core_Helper_Abstract
app/code/community/Doofinder/Feed/Helper/Log.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Log helper for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Log helper for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Log extends Mage_Core_Helper_Abstract
app/code/community/Doofinder/Feed/Helper/Tax.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Tax helper for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Tax extends Mage_Tax_Helper_Data
6
  /**
7
  * @category Helpers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Tax helper for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Helper_Tax extends Mage_Tax_Helper_Data
app/code/community/Doofinder/Feed/Model/Adminhtml/System/Config/Backend/Cron.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Adminhtml_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Adminhtml_System_Config_Backend_Cron extends Mage_Core_Model_Config_Data {
app/code/community/Doofinder/Feed/Model/Config.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Config model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Config model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Config extends Mage_Core_Model_Config_Data
app/code/community/Doofinder/Feed/Model/Cron.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Cron extends Mage_Core_Model_Abstract {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Cron extends Mage_Core_Model_Abstract {
app/code/community/Doofinder/Feed/Model/Generator.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Generator model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  if (!defined('DS'))
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Generator model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  if (!defined('DS'))
app/code/community/Doofinder/Feed/Model/Log.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Log extends Mage_Core_Model_Abstract {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Log extends Mage_Core_Model_Abstract {
app/code/community/Doofinder/Feed/Model/Map/Product/Abstract.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Abstract Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Abstract Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Abstract extends Varien_Object
app/code/community/Doofinder/Feed/Model/Map/Product/Associated.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Associated Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Associated
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Associated Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Associated
app/code/community/Doofinder/Feed/Model/Map/Product/Bundle.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Bundle Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Bundle
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Bundle Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Bundle
app/code/community/Doofinder/Feed/Model/Map/Product/Configurable.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Configurable Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Configurable
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Configurable Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Configurable
app/code/community/Doofinder/Feed/Model/Map/Product/Downloadable.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Downloadable Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Downloadable
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Downloadable Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Downloadable
app/code/community/Doofinder/Feed/Model/Map/Product/Grouped.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Grouped Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Grouped
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Grouped Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Grouped
app/code/community/Doofinder/Feed/Model/Map/Product/Simple.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Simple Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Simple
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Simple Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Simple
app/code/community/Doofinder/Feed/Model/Map/Product/Virtual.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Virtual Product Map Model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Virtual
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Virtual Product Map Model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Map_Product_Virtual
app/code/community/Doofinder/Feed/Model/Mysql4/Cron.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Cron extends Mage_Core_Model_Mysql4_Abstract {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Cron extends Mage_Core_Model_Mysql4_Abstract {
app/code/community/Doofinder/Feed/Model/Mysql4/Cron/Collection.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Cron_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Cron_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
app/code/community/Doofinder/Feed/Model/Mysql4/Log.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
app/code/community/Doofinder/Feed/Model/Mysql4/Log/Collection.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
app/code/community/Doofinder/Feed/Model/Observers/Feed.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  require_once(Mage::getBaseDir('lib') . DS. 'Doofinder' . DS .'doofinder_management_api.php');
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  require_once(Mage::getBaseDir('lib') . DS. 'Doofinder' . DS .'doofinder_management_api.php');
app/code/community/Doofinder/Feed/Model/Observers/Logs.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Observers_Logs
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Observers_Logs
app/code/community/Doofinder/Feed/Model/Observers/Schedule.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Observers_Schedule
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Observers_Schedule
app/code/community/Doofinder/Feed/Model/Resource/Mysql4/Setup.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_Resource_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
app/code/community/Doofinder/Feed/Model/System/Config/Backend/Map/Additional.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Backend_Map_Additional extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Backend_Map_Additional extends Mage_Adminhtml_Model_System_Config_Backend_Serialized
app/code/community/Doofinder/Feed/Model/System/Config/Reset.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Reset extends Mage_Core_Model_Config_Data
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Reset extends Mage_Core_Model_Config_Data
app/code/community/Doofinder/Feed/Model/System/Config/Source/Product/Attributes.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Source_Product_Attributes
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_Model_System_Config_Source_Product_Attributes
app/code/community/Doofinder/Feed/Model/Tools.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Tools model for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Tools extends Varien_Object
6
  /**
7
  * @category Models
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Tools model for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_Model_Tools extends Varien_Object
app/code/community/Doofinder/Feed/controllers/DoofinderFeedFeedController.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_DoofinderFeedFeedController extends Mage_Adminhtml_Controller_Action
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_DoofinderFeedFeedController extends Mage_Adminhtml_Controller_Action
app/code/community/Doofinder/Feed/controllers/DoofinderFeedLogController.php CHANGED
@@ -6,7 +6,7 @@
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  class Doofinder_Feed_DoofinderFeedLogController extends Mage_Adminhtml_Controller_Action
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  class Doofinder_Feed_DoofinderFeedLogController extends Mage_Adminhtml_Controller_Action
app/code/community/Doofinder/Feed/controllers/FeedController.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Feed controller for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Feed controller for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_FeedController extends Mage_Core_Controller_Front_Action
app/code/community/Doofinder/Feed/controllers/IndexController.php CHANGED
@@ -6,13 +6,13 @@
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
- * @version 1.7.0
10
  */
11
 
12
  /**
13
  * Index controller for Doofinder Feed
14
  *
15
- * @version 1.7.0
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_IndexController extends Mage_Core_Controller_Front_Action
6
  /**
7
  * @category controllers
8
  * @package Doofinder_Feed
9
+ * @version 1.7.1
10
  */
11
 
12
  /**
13
  * Index controller for Doofinder Feed
14
  *
15
+ * @version 1.7.1
16
  * @package Doofinder_Feed
17
  */
18
  class Doofinder_Feed_IndexController extends Mage_Core_Controller_Front_Action
app/code/community/Doofinder/Feed/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
 
4
  <modules>
5
  <Doofinder_Feed>
6
- <version>1.7.0</version>
7
  </Doofinder_Feed>
8
  </modules>
9
  <global>
3
 
4
  <modules>
5
  <Doofinder_Feed>
6
+ <version>1.7.1</version>
7
  </Doofinder_Feed>
8
  </modules>
9
  <global>
lib/php-doofinder/CHANGELOG.txt ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Version 4.
2
+ ----------
3
+
4
+ - CamelCase convention for everything. "has_next(0" is now "hasNext()"
5
+ - And empty query() prompts a "match all" query
6
+ - Facets/Filtering support
7
+
8
+ Version 5.
9
+ ----------
10
+
11
+ - API Key Authorization. API Key required in client constructor
12
+ - Allow unprefixed params
13
+ - Allow custom query parameter name
14
+ - v5.2.1
15
+ - Search Client: getOptions method and https mandatory
16
+ - v5.2.2
17
+ - mainteinance release
18
+ - v5.2.3
19
+ - bugfixes
20
+ - v5.2.4
21
+ - bugfixes
22
+ - v5.2.5
23
+ - stats retrieval
24
+ - v5.2.6
25
+ - added sort parameter.
26
+ - v5.3.1
27
+ - complete rewrite of the file structure: psr4 compliant
28
+ - added to the composer repository
29
+ - v5.4.3
30
+ - bugfixes
31
+ - autoload for those not using composes
32
+ - decent formatting
33
+ - v5.5.0
34
+ - Added phpunit tests
35
+ - Added phpunit tests
36
+ - some small refactoring
37
+ - v5.5.1
38
+ - added deleteItems method
lib/php-doofinder/README.md ADDED
@@ -0,0 +1,599 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![Build Status](https://api.travis-ci.org/doofinder/php-doofinder.svg?branch=master)](https://travis-ci.org/doofinder/php-doofinder)
2
+ # Official PHP Client for doofinder
3
+
4
+ <!-- MarkdownTOC depth=3 -->
5
+
6
+ - [Installation](#installation)
7
+ - [Download Method](#download-method)
8
+ - [Using Composer](#using-composer)
9
+ - [Search Client](#search-client)
10
+ - [Quick & Dirty](#quick--dirty)
11
+ - [Searching from HTML Forms](#searching-from-html-forms)
12
+ - [Tips](#tips)
13
+ - [Extra Search Options](#extra-search-options)
14
+ - [Extra Constructor Options](#extra-constructor-options)
15
+ - [API reference](#api-reference)
16
+ - [One quick example](#one-quick-example)
17
+ - [Management API](#management-api)
18
+ - [Quick & Dirty](#quick--dirty-1)
19
+
20
+ <!-- /MarkdownTOC -->
21
+
22
+ ## Installation
23
+
24
+ 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).
25
+
26
+ Requires PHP 5.3 or later. Not tested in previous versions.
27
+
28
+ ### Download Method
29
+
30
+ Just include the provided `autoload.php` file and use:
31
+
32
+ ```php
33
+ require_once('path/to/php-doofinder/autoload.php');
34
+ $client = new \Doofinder\Api\Search\Client(HASHID, API_KEY);
35
+ ```
36
+
37
+ ### Using Composer
38
+
39
+ Add Doofinder to your `composer.json` file by running:
40
+
41
+ ```bash
42
+ $ composer require doofinder/doofinder
43
+ ```
44
+
45
+ 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:
46
+
47
+ ```php
48
+ <?php
49
+ require_once dirname(__FILE__).'/vendor/autoload.php';
50
+
51
+ use \Doofinder\Api\Search\Client as SearchClient;
52
+ use \Doofinder\Api\Management\Client as ManagementClient;
53
+
54
+ $client = new SearchClient(HASHID, API_KEY);
55
+ ```
56
+
57
+ ## Search Client
58
+
59
+ ### Quick & Dirty
60
+
61
+ ```php
62
+ require_once('path/to/php-doofinder/autoload.php');
63
+
64
+ define('HASHID', '6a9gbc4dcx735x123b1e0198gf92e6e9');
65
+ define('API_KEY', 'eu1-384fdag73c7ff0a59g589xf9f4083bxb9727f9c3')
66
+
67
+ // Set hashid and API Key
68
+ $client = new \Doofinder\Api\Search\Client(HASHID, API_KEY);
69
+
70
+ // You can specify filters
71
+ $client->setFilter('brand', array('nike', 'converse')); // brand must be 'nike' or 'converse' AND ...
72
+ $client->setFilter('color', array('red', 'blue')); // ... color must be 'red' or 'blue' AND ...
73
+ $client->setFilter('price', array('from'=>33.2)); // ... price must be upper than 33.2
74
+
75
+ // You can also use more specific methods for that.
76
+ $client->addTerm('brand', 'adidas'); // add 'adidas' to the 'brand' filter
77
+ $client->removeTerm('brand', 'nike'); // remove 'nike' from the 'brand' filter
78
+ $client->setRange('price', null, 99.9); // add an upper limit to the price
79
+
80
+ // Feeling adventurous? sort!
81
+
82
+ $client->addSort('price', 'desc'); // sort by price (descending)...
83
+ $client->addSort('title', 'asc'); // ... and then by title (ascending)
84
+
85
+ // Do the query, specify the page if you want.
86
+ // 'page' = 1. optional . 'transformer' = 'dflayer'. optional.
87
+ $results = $client->query('test query', 1, array('transformer' => 'dflayer'));
88
+
89
+ // With the results object, fetch specific properties, facets or the results
90
+ // itself as an array.
91
+
92
+ $results->getProperty('results_per_page'); // returns results per page.
93
+ $results->getProperty('page'); // returns the page of the results
94
+ $results->getProperty('total'); // total number of results
95
+ $results->getProperty('query'); // query used
96
+ $results->getProperty('hashid');
97
+ $results->getProperty('max_score'); // maximum score obtained in the search results
98
+ $results->getProperty('doofinder_status'); // special Doofinder status, see below
99
+
100
+ // If you use the 'dflayer' transformer ...
101
+ foreach($results->getResults() as $result){
102
+ echo $result['body']."\n"; // description of the item
103
+ echo $result['dfid']."\n"; // doofinder id. uniquely identifies this item
104
+ echo $result['price']."\n"; // string, may come with currency sign
105
+ echo $result['sale_price']."\n"; // may or may not be present
106
+ echo $result['header']."\n"; // title of the item
107
+ echo $result['href']."\n" ; // url of the item's page
108
+ echo $result['image']."\n" ; // url of the item's image
109
+ echo $result['type']."\n" ; // item's type. "product" at the moment
110
+ echo $result['id']."\n" ; // item's id, as it comes from the xml feed
111
+ }
112
+
113
+ $category_facet = $results->getFacet('category');
114
+
115
+ foreach($category_facet['terms'] as $term) {
116
+ // Category: Trousers : 5 results found
117
+ echo "Category: ".$term['term']." : ".$term['count']." results found\n";
118
+ }
119
+
120
+ $price_facet = $results->getFacet('price');
121
+
122
+ echo "Min price found: ".$price_facet['ranges'][0]['min']."\n";
123
+ // Min price found: 33.6
124
+ echo "Max price found: ".$price_facet['ranges'][0]['max']."\n";
125
+ ```
126
+
127
+ __Notice:__
128
+
129
+ - For non-numeric fields you'll have to set those fields as _sortable_ in Doofinder's control panel before you can sort by them.
130
+ - Every search request is made through secure protocol.
131
+
132
+ ### Searching from HTML Forms
133
+
134
+ #### Be careful with the `query_name` parameter
135
+
136
+ When you issue a query to Doofinder, the search engine tries different types of search in order to provide the best possible results. This "types of search" are controlled by the `query_name` parameter.
137
+
138
+ However, if you're going to apply filters to a query, that means you're going to make the search again with certain added restrictions, therefore you're not interested in let Doofinder find the best _"_type of search_"_ for you again, but you rather do the search exactly the same way you did when first querying, so the results with applied filters are consistent with that.
139
+
140
+ `$results->getProperty('query_name')` gives you the type of query that was used to fetch those results. If you plan to filter on those, you should use the same type of query. You can do that with:
141
+
142
+ ```php
143
+ // make the initial query. no filters and no "query_name" specified
144
+ $results = $client->query("baby gloves");
145
+ // "query_name" is automatically set to be the same it used for the first query
146
+ // add a filter
147
+ $client->addTerm('category', 'More than 6 years');
148
+ // do the same query. this time filtered and with a specific query_name
149
+ $client->query("baby gloves");
150
+ ```
151
+
152
+ or with a form parameter:
153
+
154
+ ```html
155
+ <form>
156
+ <input type="text" name="dfParam_query">
157
+ <input type="hidden" name="dfParam_query_name" value="text_all">
158
+ ...
159
+ </form>
160
+ ```
161
+
162
+ In short:
163
+
164
+ - You make a query to Doofinder either with filters or not. You don't need to specify `query_name`. Doofinder will find the more suitable `query_name`.
165
+ - Once you got the results, you can use `$results->getProperty('query_name')` to know which `query_name` was the one Doofinder chose.
166
+ - If you want to make further filtering on those search results, you should instruct Doofinder to use the same `query_name` you got from the first search results.
167
+ - Each time you do any new query, don't specify `query_name`. Let Doofinder find the best.
168
+ - **Warning:** don't try to figure out a `query_name` on your own. query names may change in the future. You can always count on `$results->getParameter('query_name')` to get the `query_name` that led to those `$results`
169
+
170
+ #### `toQuerystring()`
171
+
172
+ Dumps the complete state of the client (query, page, filters, rpp) into a querystring. Every param has the (configurable) `dfParam_` prefix to avoid conflicts.
173
+
174
+ ```php
175
+ $page = 3; // Results page number. Optional.
176
+ echo $client->toQuerystring($page);
177
+ // query=dfParam_test+query&dfParam_rpp=4&dfParam_timeout=8000&dfParam_page=3
178
+ ```
179
+
180
+ You can use it to build links to search results:
181
+
182
+ ```html
183
+ <a href="results.php?<?php echo $client->toQuerystring(4)?>">Next Page</a>
184
+ ```
185
+
186
+ #### `fromQuerystring()`
187
+
188
+ Gets information from the PHP request globals and initialises the client with search parameters (query, page, filters, rpp).
189
+
190
+ ```php
191
+ $client = new \Doofinder\Api\Search\Client(HASHID, API_KEY);
192
+ $client->fromQuerystring();
193
+ $results = $client->query();
194
+ ```
195
+
196
+ You can do the same in the constructor by passing `true` as the third parameter. This code is equivalent to the code above:
197
+
198
+ ```php
199
+ <?php
200
+ $client = new \Doofinder\Api\Search\Client(HASHID, API_KEY, true);
201
+ $results = $client->query();
202
+ ```
203
+
204
+ #### Filter Parameters
205
+
206
+ When specifying filters in HTML forms, follow this convention:
207
+
208
+ - All the filters are passed in an array called _filter_ prefixed with the _prefix_ specified in `$client` constructor (default: `dfParam_`).
209
+ - Each key is a filter name. Each value is filter definition.
210
+ - Filter definition for terms filter: use an array with terms
211
+ - Filter definition for range filter: use an array with `from` and/or `to` keys.
212
+
213
+ __Example:__ _color_ (terms filter) must be `blue` or `red` and _price_ (range filter) must be greater than `10.2`.
214
+
215
+ ```html
216
+ <input name="dfParam_filter[color][]" value="blue">
217
+ <input name="dfParam_filter[color][]" value="red">
218
+ <input name="dfParam_filter[price][from]" value="10.2">
219
+ ```
220
+
221
+
222
+ This constructs the array:
223
+
224
+ ```php
225
+ dfParam_filter = array(
226
+ 'color' => array('blue', 'red'),
227
+ 'price' => array('from' => 10.2)
228
+ );
229
+ ```
230
+
231
+ #### Sort Parameters
232
+
233
+ As with other params, the parameters must be prefixed with the `prefix` specified in `$client` constructor (default: `dfParam_`).
234
+
235
+ If you sorting for one field in ascending order, you can simply send the `sort` parameter with the name of the field to sort by as value:
236
+
237
+ ```html
238
+ <input name="dfParam_sort" value="price">
239
+ ```
240
+
241
+ If you want to specify the sort direction, you'll have to to send, for the `sort` param, an array, being the key the field to sort on and the value either `asc` or `desc`:
242
+
243
+ ```html
244
+ <input name="dfParam_sort[price]" value="desc".
245
+ ```
246
+
247
+ If you want to sort by several fields, just compound the previous definition in an array.
248
+
249
+ __Example:__ sort in descending order by price and if same price, sort by title in ascending order.
250
+
251
+ ```html
252
+ <input name="dfParam_sort[0][price]" value="desc">
253
+ <input name="dfParam_sort[1][title]" value="asc">
254
+ ```
255
+
256
+ This constructs the array:
257
+
258
+ ```php
259
+ dfParam_sort = array(
260
+ array('price' => 'desc'),
261
+ array('title', 'asc')
262
+ );
263
+ ```
264
+
265
+ Please read carefully the [sort parameters](http://www.doofinder.com/support/developer/api/search-api#sort-parameters) section in our search API documentation.
266
+
267
+ ### Tips
268
+
269
+ #### Empty queries
270
+
271
+ An empty query matches all documents. Of course, if the query is filtered, even if the search term is none, the results are filtered too.
272
+
273
+ #### UTF-8 encoding
274
+
275
+ The results are always in UTF-8 encoding. If you're using it on an ISO-8859-1 encoded page, you can use `utf8_decode`:
276
+
277
+ ```php
278
+ foreach ($results->getResults() as $result) {
279
+ echo utf8_decode($result['body']).PHP_EOL;
280
+ }
281
+ ```
282
+
283
+ ### Extra Search Options
284
+
285
+ ```php
286
+ $query = 'test query';
287
+ $page = 3;
288
+ $results = $client->query($query, $page, array(
289
+ // Results Per Page (default: 10)
290
+ 'rpp' => 4,
291
+ // types of item to search (default: all)
292
+ 'types' => array('product', 'question'),
293
+ // Template used to return items
294
+ 'transformer' => 'dflayer',
295
+ // Filtering options
296
+ 'filter' => array(
297
+ 'brand' => array('nike', 'converse'),
298
+ 'price' => array('from'=> 33.2, 'to'=> 99),
299
+ ),
300
+ // Sorting options
301
+ 'sort' => array(
302
+ array('price' => 'asc'),
303
+ array('title' => 'desc'),
304
+ )
305
+ ));
306
+ ```
307
+
308
+ ### Extra Constructor Options
309
+
310
+ ```php
311
+ $client = new \Doofinder\Api\Search\Client(
312
+ HASHID,
313
+ API_KEY,
314
+ true, // Whether to import request parameters or not (default: false)
315
+ array(
316
+ // Prefix to use with toQuerystring() (default: dfParam_)
317
+ 'prefix' => 'sp_df_df_',
318
+ // Parameter name to use for the query parameter (default: query)
319
+ 'queryParameter' => 'q',
320
+ // API version of the search server (default: 5)
321
+ 'apiVersion' => '5',
322
+ // Use only parameters from $_POST or $_GET methods
323
+ // (default: unset, uses $_REQUEST)
324
+ 'restrictedRequest' => 'post'
325
+ )
326
+ );
327
+ ```
328
+
329
+ ### API reference
330
+
331
+ #### `\Doofinder\Api\Search\Client`
332
+
333
+ ```php
334
+ $client->query($query, $page, $options); // Perform search
335
+ $client->hasNext(); // Boolean, true if there is a next page of results
336
+ $client->hasPrev(); // Boolean, true if there is a prev page of results
337
+ $client->numPages(); // Total number of pages
338
+ $client->getPage(); // Get the actual page number
339
+ $client->setFilter($filterName, $filter); // Set a filter
340
+ $client->getFilter($filterName); // Get a filter by name
341
+ $client->getFilters(); // Get all filters
342
+ $client->addTerm($filterName, $term); // Add a term to a terms type $filterName
343
+ $client->removeTerm($filterName, $term);
344
+ $client->setRange($filterName, $from, $to); // Specify parameters for a range filter
345
+ $client->getFilter($filter_name); // Get filter specifications for $filter_name, if any
346
+ $client->getFilters(); // Get filter specifications for all defined filters
347
+ $client->addSort($sortField, $direction); // Tells doofinder to sort results
348
+ $client->setPrefix($prefix); // Sets prefix for dumping/recovering from querystring
349
+ $client->toQuerystring($page); // Dumps state info to a querystring
350
+ $client->fromQuerystring(); // Recover state from a querystring
351
+ $client->nextPage(); // Obtain results for the nextpage
352
+ $client->prevPage(); // Obtain results for the prev page
353
+ $client->numPages(); // Num of pages
354
+ $client->getRpp(); // Get the number of results per page
355
+ $client->getTimeout();
356
+ $client->setApiVersion($apiVersion); // Sets API version to use (default: 5)
357
+ ```
358
+
359
+ #### `\Doofinder\Api\Search\Results`
360
+
361
+ ```php
362
+ $results->getProperty($propertyName); // Get the property $propertyName
363
+ $results->getResults(); // Get results
364
+ $results->getFacetsNames(); // Array with facet names
365
+ $results->getFacet($facetName); // Obtain search results for facet $facetName
366
+ $results->getFacets(); // All facets
367
+ $results->getAppliedFilters(); // Filters that have been applied to obtain these results
368
+ $results->isOk(); // Checks if all went OK
369
+ $results->status; // Account status info. 'success', 'exhausted', 'notfound'
370
+ ```
371
+
372
+ ### One quick example
373
+
374
+ ```php
375
+ <?php
376
+ require_once('path/to/php-doofinder/autoload.php');
377
+
378
+ define('HASHID', '6a9gbc4dcx735x123b1e0198gf92e6e9');
379
+ define('API_KEY', 'eu1-384fdag73c7ff0a59g589xf9f4083bxb9727f9c3')
380
+
381
+ $client = new \Doofinder\Api\Search\Client(HASHID, API_KEY, true);
382
+ // if no dfParam_query, fetch all the results, to fetch all possible facets
383
+ $results = $client->query(null, null, array('transformer'=>'dflayer'));
384
+ ?>
385
+
386
+ <form method="get" action="">
387
+ <input type="text" name="dfParam_query" onchange="emptyQueryName()" value="<?php echo $results->getProperty('query') ?>">
388
+ <input type="hidden" name="dfParam_rpp" value="3">
389
+ <input type="hidden" name="dfParam_transformer" value="dflayer">
390
+ <!-- this has to be removed via javascript if we want doofinder to find the best search for us. -->
391
+ <input type="hidden" id="query_name" name="dfParam_query_name" value="<?php echo $results->getProperty('query_name') ?>">
392
+ <input type="submit" value="search!">
393
+
394
+ <p>Filter by:</p>
395
+ <ul>
396
+ <?php foreach ($results->getFacets() as $facetName => $facetResults): ?>
397
+ <li>
398
+ <?php echo $facetName ?>
399
+ <ul>
400
+ <?php if ($facetResults['_type'] == 'terms'): ?>
401
+ <?php foreach ($facetResults['terms'] as $term):?>
402
+ <li>
403
+ <input type="checkbox"
404
+ name="dfParam_filter[<?php echo $facetName ?>][]"
405
+ <?php echo $term['selected'] ? 'checked': ''?>
406
+ value="<?php echo $term['term']?>">
407
+ <?php echo $term['term']?>: <?php echo $term['count']?>
408
+ </li>
409
+ <?php endforeach ?>
410
+ <?php endif ?>
411
+ <?php if $facetResults['_type'] == 'range'): $range = $facetResults['ranges'][0]; ?>
412
+ <li>
413
+ Range: <?php echo $range['min']?> -- <?php echo $range['max']?><br/>
414
+ From: <input type="text" name="dfParam_filter[<?php echo $facetName?>][from]" value="<?php echo $range['selected_from']?>">
415
+ To: <input type="text" name="dfParam_filter[<?php echo $facetName?>][to]" value="<?php echo $range['selected_to']?>">
416
+ </li>
417
+ <?php endif?>
418
+ </ul>
419
+ </li>
420
+ <?php endforeach ?>
421
+ </ul>
422
+ </form>
423
+
424
+ <h1>Results</h1>
425
+
426
+ <ul>
427
+ <?php foreach ($results->getResults() as $result): ?>
428
+ <li><?php echo $result['header'] ?></li>
429
+ <?php endforeach ?>
430
+ </ul>
431
+
432
+ <?php if ($client->hasPrev()): ?>
433
+ <a href="?<?php echo $client->toQuerystring($client->getPage() - 1) ?>">Prev</a>
434
+ <?php endif?>
435
+ Number of pages: <?php echo $client->numPages() ?>
436
+ <?php if ($client->hasNext()): ?>
437
+ <a href="?<?php echo $client->toQuerystring($client->getPage() + 1) ?>">Next</a>
438
+ <?php endif?>
439
+
440
+ <script>
441
+ // if the search box changes, a new query is being made
442
+ // don't tell doofinder which search type to use
443
+ function emptyQueryName(){
444
+ document.getElementById('query_name').value = '';
445
+ return true;
446
+ }
447
+ </script>
448
+ ```
449
+
450
+ ## Management API
451
+
452
+ ### Quick & Dirty
453
+
454
+ ```php
455
+ require_once('path/to/php-doofinder/autoload.php');
456
+
457
+ define('API_KEY', 'eu1-384fdag73c7ff0a59g589xf9f4083bxb9727f9c3')
458
+
459
+ // Instantiate the object, use your doofinder's API_KEY.
460
+ $client = new \Doofinder\Api\Management\Client(API_KEY);
461
+
462
+ // Get a list of search engines
463
+ $searchEngines = $client->getSearchEngines();
464
+ // From the list, we will choose the first one
465
+ $mySearchEngine = $searchEngines[0];
466
+ ```
467
+
468
+ The `SearchEngine` object gives you methods to manage a search engine.
469
+
470
+ #### Types Management
471
+
472
+ ```php
473
+ $types = $mySearchEngine->getTypes(); // Obtain search engine's datatypes
474
+ $new_types = $mySearchEngine->addType('product'); // Add new type
475
+ $mySearchEngine->deleteType('product'); // Remove the type and all items within it.
476
+ ```
477
+
478
+ #### Items Management
479
+
480
+ ##### Single Item
481
+
482
+ ```php
483
+ // Obtain item info within 'product' type
484
+ $item = $mySearchEngine->getItem('product', '888493');
485
+ // Add a new item to the 'product' type
486
+ $added_item = $mySearchEngine->addItem('product', array('id'=> 'newid', 'title'=>'a title'));
487
+ // Remove item
488
+ $mySearchEngine->deleteItem('product', 'newid');
489
+ // Update the '888493' item belonging to the 'product' type.
490
+ $mySearchEngine->updateItem('product', '888493', array('title'=>'modifiled title'));
491
+ ```
492
+
493
+ ##### Bulk Add/Update/Delete
494
+
495
+ ```php
496
+ $mySearchEngine->updateItems('product', array(
497
+ array('title' => 'first item', 'id' => 'id1'),
498
+ array('title' => 'second item', 'id' => 'id2'),
499
+ ));
500
+
501
+ $mySearchEngine->addItems('product', array(
502
+ array('title' => 'first item', 'id' => 'newid1'),
503
+ array('title' => 'second item'),
504
+ ));
505
+
506
+ $mySearchEngine->deleteItems('product', array('id1', 'id2'));
507
+ ```
508
+
509
+ ##### Iterating Items
510
+
511
+ If you want to go through **every item in your index** you can only do it forwards. To do that, you'll need to use the *listing/scrolling* method…
512
+
513
+ __WARNING:__ You won't be iterating a standard PHP array. Items will be provided as an iterator object instance.
514
+
515
+ ```php
516
+ $items = $mySearchEngine->items('product');
517
+ foreach ($items as $item) {
518
+ echo $item['title'];
519
+ }
520
+ ```
521
+
522
+ You can't retrieve a specific item by index:
523
+
524
+ ```php
525
+ $items = $mySearchEngine->items('product');
526
+ $item = $items[4]; // WRONG!!!!!
527
+ PHP Fatal error: Cannot use object of type ItemsRS as array…
528
+ ```
529
+
530
+ #### Stats
531
+
532
+ ```php
533
+ // Some PHP versions may need this
534
+ date_default_timezone_set('America/Havana');
535
+
536
+ // If not $from_date or $to_date provided, default is last 15 days
537
+ $from_date = new DateTime("2011-01-07");
538
+ $to_date = new DateTime("2011-02-07");
539
+
540
+ foreach ($mySearchEngine->stats($from_date, $to_date) as $key => $aggregated){
541
+ echo $aggregated['date']; // date of the aggregated data
542
+ echo $aggregated['clicked']; // # clicks in search results
543
+ echo $aggregated['searches']; // # complete searches. i.e.: "mp3 player"
544
+ echo $aggregated['api']; // # requests made through our API
545
+ echo $aggregated['parser']; // # requests used in feeds parsing
546
+ // (1 per each 100 parsed items)
547
+ echo $aggregated['queries']; // # "raw" search requests
548
+ // i.e.: "mp3", "mp3 p", "mp3 pl" ..
549
+ echo $aggregated['requests']; // total # of requests for that day
550
+ }
551
+
552
+ $top_clicked = $mySearchEngine->topTerms('clicked', $from_date, $to_date);
553
+
554
+ foreach ($top_clicked as $key => $clicked) {
555
+ echo $clicked['term']; // title of the clicked item
556
+ echo $clicked['count']; // # of clicks on that item
557
+ }
558
+
559
+ $top_searches = $mySearchEngine->topTerms('searches', $from_date, $to_date);
560
+
561
+ foreach ($top_searches as $key => $search) {
562
+ echo $search['term']; // search terms used
563
+ echo $search['count']; // # of times it's been used
564
+ }
565
+
566
+ $top_opportunities = $mySearchEngine->topTerms('opportunities', $from_date, $to_date);
567
+
568
+ foreach ($top_opportunities as $key => $opportunity) {
569
+ echo $opportunity['term']; // search terms used (that haven't yielded any result)
570
+ echo $opportunity['count']; // # of times it's been used
571
+ }
572
+ ```
573
+
574
+ #### Tasks management
575
+
576
+ ```php
577
+ // Ask our server to process a search engine's feeds
578
+ $taskResult = $mySearchEngine->process();
579
+ // Retrieve info about the last or current process of the search engine
580
+ $taskInfo = $mySearchEngine->processInfo();
581
+ // Retrieve info about a certain task
582
+ $taskInfo = $mySearchEngine->taskInfo($taskResult['task_id']);
583
+ // Get log info about the last processes
584
+ $logs = $mySearchEngine->logs();
585
+ ```
586
+
587
+ ## Run Tests
588
+
589
+ To run tests.
590
+
591
+ - Make sure you have (phpunit) [https://phpunit.de/] (version 4.8) and (php-mock-phpunit)[https://github.com/php-mock/php-mock-phpunit] (version 1.1.*). If you have composer you can run
592
+ ````shell
593
+ $ composer.phar install
594
+ ````
595
+
596
+ - Run the tests!!
597
+ ````shell
598
+ $ phpunit
599
+ ````
lib/php-doofinder/autoload.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ spl_autoload_register('autoload_doofinder_classes');
3
+
4
+ function autoload_doofinder_classes($className) {
5
+ $libraryPrefix = 'Doofinder\\Api\\';
6
+ $libraryDirectory = __DIR__ . '/src/';
7
+
8
+ $len = strlen($libraryPrefix);
9
+
10
+ // Binary safe comparison of $len first characters
11
+ if (strncmp($libraryPrefix, $className, $len) !== 0) {
12
+ return;
13
+ }
14
+
15
+ $classPath = str_replace('\\', '/', substr($className, $len)) . '.php';
16
+ $file = $libraryDirectory . $classPath;
17
+
18
+ if (file_exists($file)) {
19
+ require $file;
20
+ }
21
+ }
lib/php-doofinder/composer.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "doofinder/doofinder",
3
+ "type": "library",
4
+ "description": "Doofinder PHP API Client",
5
+ "keywords": ["search", "api", "doofinder"],
6
+ "homepage": "https://github.com/doofinder/php-doofinder",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "JoeZ99",
11
+ "email": "jzarate@gmail.com",
12
+ "role": "Developer"
13
+ }
14
+ ],
15
+ "require": {
16
+ "php": ">=5.3.0"
17
+ },
18
+ "require-dev": {
19
+ "phpunit/phpunit": "4.8.*",
20
+ "php-mock/php-mock-phpunit": "1.1.*"
21
+ },
22
+ "autoload": {
23
+ "psr-4": {
24
+ "Doofinder\\Api\\": "src/"
25
+ }
26
+ }
27
+ }
lib/php-doofinder/phpunit.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <phpunit colors="true">
3
+ <testsuites>
4
+ <testsuite name="Application Test Suite">
5
+ <directory>./src/Test/</directory>
6
+ </testsuite>
7
+ </testsuites>
8
+ </phpunit>
lib/php-doofinder/src/Management/AggregatesIterator.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace Doofinder\Api\Management;
4
+
5
+ use Doofinder\Api\Management\SearchEngine;
6
+ use Doofinder\Api\Management\ItemsResultSet;
7
+
8
+ class AggregatesIterator extends ItemsResultSet {
9
+
10
+ /**
11
+ * Class to Iterate through SearchEngine's aggregated stats data for a certain period.
12
+ */
13
+ protected $last_page = 0;
14
+ protected $searchParams = array();
15
+
16
+ /**
17
+ * @param SearchEngine $searchEngine
18
+ * @param DateTime $from_date . Starting date of the period. Default: 15 days ago
19
+ * @param DateTime $to_date. Ending date of the period. Default: today.
20
+ */
21
+ public function __construct(SearchEngine $searchEngine, $from_date = null, $to_date = null){
22
+ $this->last_page = 0;
23
+
24
+ if (!is_null($from_date)) {
25
+ $this->searchParams['from'] = $from_date->format("Ymd");
26
+ }
27
+ if (!is_null($to_date)) {
28
+ $this->searchParams['to'] = $to_date->format("Ymd");
29
+ }
30
+
31
+ parent::__construct($searchEngine);
32
+ }
33
+
34
+ protected function fetchResultsAndTotal() {
35
+ $params = $this->last_page > 0 ? array("page" => $this->last_page + 1) : array();
36
+
37
+ try{
38
+ $apiResponse = $this->searchEngine->client->managementApiCall(
39
+ 'GET',
40
+ "{$this->searchEngine->hashid}/stats",
41
+ array_merge($params, $this->searchParams)
42
+ );
43
+
44
+ $this->resultsPage = $apiResponse['response']['aggregates'];
45
+ $this->total = $apiResponse['response']['count'];
46
+ $this->last_page++;
47
+ $this->currentItem = each($this->resultsPage);
48
+ } catch (NotFound $nfe) {
49
+ $this->resultsPage = array();
50
+ }
51
+
52
+ reset($this->resultsPage);
53
+ }
54
+
55
+ public function rewind() {
56
+ $this->last_page = 0;
57
+ parent::rewind();
58
+ }
59
+ }
lib/php-doofinder/src/Management/Client.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author:: JoeZ99 (<jzarate@gmail.com>).
4
+ *
5
+ * License:: Apache License, Version 2.0
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may
8
+ * not use this file except in compliance with the License. You may obtain
9
+ * a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
+ * License for the specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ namespace Doofinder\Api\Management;
21
+
22
+ use Doofinder\Api\Management\SearchEngine;
23
+ use Doofinder\Api\Management\Errors\Utils;
24
+
25
+ /**
26
+ * Class to manage the connection with the API servers.
27
+ *
28
+ * Needs APIKEY in initialization.
29
+ * Example: $dma = new DoofinderManagementApi('eu1-d531af87f10969f90792a4296e2784b089b8a875')
30
+ */
31
+ class Client
32
+ {
33
+ const REMOTE_API_ENDPOINT = "https://%s-api.doofinder.com/v1";
34
+ const LOCAL_API_ENDPOINT = "http://localhost:8000/api/v1";
35
+
36
+ private $apiKey = null;
37
+ private $clusterRegion = 'eu1';
38
+ private $token = null;
39
+ private $baseManagementUrl = null;
40
+
41
+ public function __construct($apiKey, $local = false) {
42
+ $this->apiKey = $apiKey;
43
+ $clusterToken = explode('-', $apiKey);
44
+ $this->clusterRegion = $clusterToken[0];
45
+ $this->token = $clusterToken[1];
46
+
47
+ if ($local === true){
48
+ $this->baseManagementUrl = self::LOCAL_API_ENDPOINT;
49
+ } else {
50
+ $this->baseManagementUrl = sprintf(self::REMOTE_API_ENDPOINT, $this->clusterRegion);
51
+ }
52