Files
microservice-api-gateway/app/Services/ProductService.php
T
2022-01-22 21:30:15 +04:00

83 lines
1.4 KiB
PHP

<?php
declare(strict_types = 1);
namespace App\Services;
use App\Traits\RequestService;
use function config;
class ProductService
{
use RequestService;
/**
* @var string
*/
protected $baseUri;
/**
* @var string
*/
protected $secret;
/**
* ProductService constructor.
*/
public function __construct()
{
$this->baseUri = config('services.products.base_uri');
$this->secret = config('services.products.secret');
}
/**
* @return string
*/
public function fetchProducts() : string
{
return $this->request('GET', '/api/product');
}
/**
* @param $product
*
* @return string
*/
public function fetchProduct($product) : string
{
return $this->request('GET', "/api/product/{$product}");
}
/**
* @param $data
*
* @return string
*/
public function createProduct($data) : string
{
return $this->request('POST', '/api/product', $data);
}
/**
* @param $product
* @param $data
*
* @return string
*/
public function updateProduct($product, $data) : string
{
return $this->request('PATCH', "/api/product/{$product}", $data);
}
/**
* @param $product
*
* @return string
*/
public function deleteProduct($product) : string
{
return $this->request('DELETE', "/api/product/{$product}");
}
}