22 private $restBasePath =
'/rest/';
28 private $jsonSerializer;
41 $this->curlClient = $curlClient ? :
$objectManager->get(CurlClient::class);
42 $this->jsonSerializer = $jsonSerializer ? :
$objectManager->get(JsonSerializer::class);
53 public function get($resourcePath,
$data = [], $headers = [])
60 $responseBody = $this->curlClient->get(
$url,
$data, $headers);
61 return $this->jsonSerializer->jsonDecode($responseBody);
72 public function post($resourcePath,
$data, $headers = [])
75 if (in_array(
"Content-Type: application/json", $headers)) {
77 if (
$data != self::EMPTY_REQUEST_BODY) {
78 $data = $this->jsonSerializer->jsonEncode(
$data);
83 $responseBody = $this->curlClient->post(
$url,
$data, $headers);
84 return $this->jsonSerializer->jsonDecode($responseBody);
95 public function put($resourcePath,
$data, $headers = [])
98 if (in_array(
"Content-Type: application/json", $headers)) {
100 if (
$data != self::EMPTY_REQUEST_BODY) {
101 $data = $this->jsonSerializer->jsonEncode(
$data);
106 $responseBody = $this->curlClient->put(
$url,
$data, $headers);
107 return $this->jsonSerializer->jsonDecode($responseBody);
117 public function delete($resourcePath, $headers = [])
120 $responseBody = $this->curlClient->delete(
$url, $headers);
121 return $this->jsonSerializer->jsonDecode($responseBody);
131 return rtrim(TESTS_BASE_URL,
'/') . $this->restBasePath . ltrim($resourcePath,
'/');
constructResourceUrl($resourcePath)
__construct(\Magento\TestFramework\TestCase\HttpClient\CurlClient $curlClient=null, \Magento\TestFramework\Helper\JsonSerializer $jsonSerializer=null)
put($resourcePath, $data, $headers=[])
post($resourcePath, $data, $headers=[])
static getObjectManager()