<?php
require __DIR__ . '/vendor/autoload.php';
class Algolia 
{ 
	private $client;
   	public function __construct($appID,$serverToken){
		
		$this->client = new \AlgoliaSearch\Client($appID,$serverToken);
		
		
	}

	public function addObjects($indexName, $batch){
		if(is_array($batch)){
			$index = $this->client->initIndex($indexName);
			$index->saveObjects($batch);
		}
		else{
			echo 'Invalid array';
		}
	}
	
	public function search($indexName, $searchTerm='',$params=array()){
		$index 	= 	$this->client->initIndex($indexName);
		$result = 	$index->search($searchTerm,$params);
		return $result;
		
	}

}
