1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 
<?php

namespace Manticoresearch\Endpoints;

use Manticoresearch\Request;

/**
 * Class Bulk
 * @package Manticoresearch\Endpoints
 */
class Bulk extends Request
{
    /**
     * @return mixed|string
     */
    public function getPath()
    {
        return '/json/bulk';
    }

    /**
     * @return mixed|string
     */
    public function getMethod()
    {
        return 'POST';
    }

    /**
     * @return mixed|string
     */
    public function getContentType()
    {
        return 'application/x-ndjson';
    }

    /**
     * @param mixed $body
     */
    public function setBody($body = null)
    {
        if (is_array($body) || $body instanceof \Traversable) {
            $this->_body = '';
            foreach ($body as $b) {
                $this->_body .= json_encode($b, true) . "\n";
            }
        } else {
            $this->_body = $body;
        }
    }
}