/**
  * upload all data to recommeder
  * 
  */
 public function upload(DataApi\Client $client)
 {
     if (!is_null($this->filePath)) {
         $batchSize = 25000;
         $csvFile = new CsvFile($this->filePath);
         $csvFile->rewind();
         if (!$csvFile->valid()) {
             break;
         }
         $header = $csvFile->current();
         $csvFile->next();
         $interactionsBatch = new DataApi\Batch\InteractionsBatch();
         $batchRowsCount = 0;
         while ($csvFile->valid()) {
             $attributes = array_combine($header, $csvFile->current());
             $csvFile->next();
             // process row
             try {
                 if (is_numeric($attributes['timestamp'])) {
                     $date = new DateTime('@' . $attributes['timestamp']);
                 } else {
                     $date = new DateTime($attributes['timestamp']);
                 }
             } catch (Exception $e) {
                 throw new Exception('Invalid date format in "' . $this->getName() . '" table');
             }
             $interactionsBatch->addInteraction($attributes['user_id'], $attributes['item_id'], $attributes['interaction_id'], $date);
             $batchRowsCount += 1;
             if ($batchRowsCount == $batchSize || !$csvFile->valid()) {
                 $client->insertInteractions($interactionsBatch);
                 $interactionsBatch = new DataApi\Batch\InteractionsBatch();
                 $batchRowsCount = 0;
             }
         }
     }
     return $this;
 }
 /**
  * @param InteractionsBatch $batch
  * @return NULL
  * @throws RequestFailedException when request failed for some reason
  */
 public function insertInteractions(InteractionsBatch $batch)
 {
     $restriction = new Restriction([], [self::INTERACTIONS_PARAMETER => $batch->getInteractions()]);
     return $this->performPost(self::INSERT_INTERACTION_URL, $restriction);
 }