diff --git a/CHANGELOG.md b/CHANGELOG.md index b8fa3c5..dfe0836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ### Changelog +#### V1.2.2 + +**9 Ekim 2024** + +- Laravel Pint Formatting + #### V1.2.1 **7 Ekim 2024** diff --git a/composer.json b/composer.json index eea7222..b786afe 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Paraşüt v4 API for Laravel Projects", "keywords": ["laravel", "Parasut", "Paraşüt"], "license": "MIT", - "version": "v1.2.1", + "version": "v1.2.2", "authors": [ { "name": "Baran Arda", @@ -28,6 +28,7 @@ "test": "phpunit" }, "require-dev": { + "laravel/pint": "^1.18", "orchestra/testbench": "^6.0", "phpunit/phpunit": "^8.0" }, diff --git a/config/parasut.php b/config/parasut.php index 1d7038f..0ee7ed1 100644 --- a/config/parasut.php +++ b/config/parasut.php @@ -9,7 +9,7 @@ | */ -return [ +return [ 'username' => env('PARASUT_USERNAME'), 'password' => env('PARASUT_PASSWORD'), 'company_id' => env('PARASUT_COMPANY_ID'), @@ -17,4 +17,4 @@ 'client_secret' => env('PARASUT_CLIENT_SECRET'), 'redirect_uri' => env('PARASUT_REDIRECT_URI'), 'api_url' => env('PARASUT_API_URL', 'https://api.parasut.com/v4/'), -]; \ No newline at end of file +]; diff --git a/src/Auth.php b/src/Auth.php index ae96590..27d50b6 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -5,7 +5,6 @@ use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; - /** * Paraşüt OAuth2 işlemleri */ @@ -15,7 +14,6 @@ class Auth /** * Auth constructor. - * @param array $config */ public function __construct(array $config) { @@ -24,14 +22,12 @@ public function __construct(array $config) /** * Get the cached token or fetch a new one. - * - * @return string */ public function getToken(): string { $accessToken = Cache::get('parachute_token'); - if (!$accessToken) { + if (! $accessToken) { return $this->fetchNewToken(); } @@ -40,8 +36,6 @@ public function getToken(): string /** * Fetch a new access token from the OAuth endpoint. - * - * @return string */ private function fetchNewToken(): string { @@ -49,24 +43,24 @@ private function fetchNewToken(): string try { $response = Http::asForm()->post($tokenEndpoint, [ - 'grant_type' => 'password', - 'client_id' => $this->config['client_id'], + 'grant_type' => 'password', + 'client_id' => $this->config['client_id'], 'client_secret' => $this->config['client_secret'], - 'username' => $this->config['username'], - 'password' => $this->config['password'], - 'redirect_uri' => $this->config['redirect_uri'], + 'username' => $this->config['username'], + 'password' => $this->config['password'], + 'redirect_uri' => $this->config['redirect_uri'], ]); if ($response->successful()) { $data = $response->json(); Cache::put('parachute_token', $data['access_token'], now()->addSeconds($data['expires_in'])); + return $data['access_token']; } - throw new \Exception('Token fetch failed: ' . $response->body()); - + throw new \Exception('Token fetch failed: '.$response->body()); } catch (\Exception $e) { - return 'Error: ' . $e->getMessage(); + return 'Error: '.$e->getMessage(); } } } diff --git a/src/Contracts/ParasutV4.php b/src/Contracts/ParasutV4.php index c49900b..7a0da67 100644 --- a/src/Contracts/ParasutV4.php +++ b/src/Contracts/ParasutV4.php @@ -5,23 +5,42 @@ interface ParasutV4 { public function Account(); + public function Transaction(); + public function Bank(); + public function Employee(); + public function Receipt(); + public function Salary(); + public function Supplier(); + public function Tax(); + public function EArchive(); + public function EBill(); + public function ESmm(); + public function Inbox(); + public function Bill(); + public function Customer(); + public function Category(); + public function Tag(); + public function Product(); + public function StockMovement(); + public function Warehouse(); + public function Waybill(); -} \ No newline at end of file +} diff --git a/src/Facades/Parasut.php b/src/Facades/Parasut.php index 174aa5a..d1cecf4 100644 --- a/src/Facades/Parasut.php +++ b/src/Facades/Parasut.php @@ -13,17 +13,13 @@ namespace Theposeidonas\LaravelParasutApi\Facades; -use Theposeidonas\LaravelParasutApi\ParasutV4; use Illuminate\Support\Facades\Facade; +use Theposeidonas\LaravelParasutApi\ParasutV4; class Parasut extends Facade { - - /** - * @return string - */ public static function getFacadeAccessor(): string { return ParasutV4::class; } -} \ No newline at end of file +} diff --git a/src/Models/Cash/Account.php b/src/Models/Cash/Account.php index a373545..4a5a1b3 100644 --- a/src/Models/Cash/Account.php +++ b/src/Models/Cash/Account.php @@ -12,24 +12,14 @@ */ class Account extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/accounts'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ @@ -41,74 +31,57 @@ public function index(array $parameters = []): array 'filter.iban' => 'nullable|string', 'sort' => 'nullable|string|in:id,balance,balance_in_trl,-id,-balance,-balance_in_trl', 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25' + 'page.size' => 'nullable|integer|min:1|max:25', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @return array - */ public function create(array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function show(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @return array - */ public function edit(string $id, array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function transactions(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -116,45 +89,37 @@ public function transactions(string $id, array $parameters = []): array 'sort' => 'nullable|string|in:id,-id', 'page.number' => 'nullable|integer|min:1', 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:debit_account,credit_account' + 'include' => 'nullable|string|in:debit_account,credit_account', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id.'/transactions', $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function debit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:debit_account,credit_account,payments' + 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/debit_transactions?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @return array - */ public function credit(string $id, array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/credit_transactions', $data); + return $this->handleResponse($response); } -} \ No newline at end of file +} diff --git a/src/Models/Cash/Transaction.php b/src/Models/Cash/Transaction.php index 70c84a0..52dc0db 100644 --- a/src/Models/Cash/Transaction.php +++ b/src/Models/Cash/Transaction.php @@ -12,48 +12,35 @@ */ class Transaction extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/transactions'; } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:debit_account,credit_account,payments' + 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Bank.php b/src/Models/Expenses/Bank.php index 0f29962..e976188 100644 --- a/src/Models/Expenses/Bank.php +++ b/src/Models/Expenses/Bank.php @@ -12,139 +12,105 @@ */ class Bank extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ + public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/bank_fees'; } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', - ])->post($this->serviceUrl. '?' . http_build_query($parameters), $data); + ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:payable,transaction' + 'include' => 'nullable|string|in:payable,transaction', ]); - $response = Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/payments?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Employee.php b/src/Models/Expenses/Employee.php index ef60fd7..e8b8948 100644 --- a/src/Models/Expenses/Employee.php +++ b/src/Models/Expenses/Employee.php @@ -12,46 +12,35 @@ */ class Employee extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/employees'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', - 'filter.email' => 'nullable|string|email', - 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:category,managed_by_user,managed_by_user_role', + 'filter.name' => 'nullable|string', + 'filter.email' => 'nullable|string|email', + 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:category,managed_by_user,managed_by_user_role', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } /** - * @param array $data - * @param array $parameters - * @return array + * @param array $data */ public function create($data, array $parameters = []): array { @@ -63,14 +52,10 @@ public function create($data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -81,16 +66,11 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ - public function edit(string $id,array $data, array $parameters = []): array + public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ 'include' => 'nullable|string|in:category,managed_by_user,managed_by_user_role', @@ -100,27 +80,20 @@ public function edit(string $id,array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -131,14 +104,10 @@ public function archive(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -149,6 +118,7 @@ public function unarchive(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Receipt.php b/src/Models/Expenses/Receipt.php index 83bbacf..53dd397 100644 --- a/src/Models/Expenses/Receipt.php +++ b/src/Models/Expenses/Receipt.php @@ -12,24 +12,14 @@ */ class Receipt extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/purchase_bills'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ @@ -45,14 +35,10 @@ public function index(array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function createBasic(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -63,14 +49,10 @@ public function createBasic(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'#basic?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function createDetailed(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -81,14 +63,10 @@ public function createDetailed(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'#detailed?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -99,15 +77,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function editBasic(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -117,15 +90,10 @@ public function editBasic(string $id, array $data, array $parameters = []): arra 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'#basic?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function editDetailed(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -135,110 +103,86 @@ public function editDetailed(string $id, array $data, array $parameters = []): a 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'#detailed?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { - Validator::validate($parameters,[ - 'include'=>'nullable|string|in:payable,transaction', + Validator::validate($parameters, [ + 'include' => 'nullable|string|in:payable,transaction', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/payments?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function cancel(string $id, array $parameters = []): array { - Validator::validate($parameters,[ - 'include'=>'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', + Validator::validate($parameters, [ + 'include' => 'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id.'/cancel?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function recover(string $id, array $parameters = []): array { - Validator::validate($parameters,[ - 'include'=>'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', + Validator::validate($parameters, [ + 'include' => 'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/recover?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { - Validator::validate($parameters,[ - 'include'=>'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', + Validator::validate($parameters, [ + 'include' => 'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { - Validator::validate($parameters,[ - 'include'=>'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', + Validator::validate($parameters, [ + 'include' => 'nullable|string|in:category,spender,details,details.product,details.warehouse,payments,payments.transaction,tags,recurrence_plan,active_e_document,pay_to', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Salary.php b/src/Models/Expenses/Salary.php index fbcc008..aa00cbe 100644 --- a/src/Models/Expenses/Salary.php +++ b/src/Models/Expenses/Salary.php @@ -3,9 +3,8 @@ namespace Theposeidonas\LaravelParasutApi\Models\Expenses; use Illuminate\Support\Facades\Http; -use Theposeidonas\LaravelParasutApi\ParasutV4; use Illuminate\Support\Facades\Validator; - +use Theposeidonas\LaravelParasutApi\ParasutV4; /** * Maaş @@ -13,24 +12,14 @@ */ class Salary extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/salaries'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ @@ -43,135 +32,106 @@ public function index(array $parameters = []): array 'page.size' => 'nullable|integer|min:1|max:25', 'include' => 'nullable|string|in:category,tags,payments,activities,employee', ]); - + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:employee,category,tags' + 'include' => 'nullable|string|in:employee,category,tags', ]); - + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:employee,category,tags' + 'include' => 'nullable|string|in:employee,category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:employee,category,tags' + 'include' => 'nullable|string|in:employee,category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:employee,category,tags' + 'include' => 'nullable|string|in:employee,category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:employee,category,tags' + 'include' => 'nullable|string|in:employee,category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:payable,transaction' + 'include' => 'nullable|string|in:payable,transaction', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/payments?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Supplier.php b/src/Models/Expenses/Supplier.php index f3a2414..a560599 100644 --- a/src/Models/Expenses/Supplier.php +++ b/src/Models/Expenses/Supplier.php @@ -3,9 +3,8 @@ namespace Theposeidonas\LaravelParasutApi\Models\Expenses; use Illuminate\Support\Facades\Http; -use Theposeidonas\LaravelParasutApi\ParasutV4; use Illuminate\Support\Facades\Validator; - +use Theposeidonas\LaravelParasutApi\ParasutV4; /** * Tedarikçi @@ -13,149 +12,113 @@ */ class Supplier extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/contacts'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', - 'filter.email' => 'nullable|string', - 'filter.tax_number' => 'nullable|string', - 'filter.tax_office' => 'nullable|string', - 'filter.city' => 'nullable|string', - 'filter.account_type'=> 'nullable|string|in:customer,supplier', - 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:category,contact_portal,contact_people' + 'filter.name' => 'nullable|string', + 'filter.email' => 'nullable|string', + 'filter.tax_number' => 'nullable|string', + 'filter.tax_office' => 'nullable|string', + 'filter.city' => 'nullable|string', + 'filter.account_type' => 'nullable|string|in:customer,supplier', + 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:category,contact_portal,contact_people', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,contact_portal,contact_people' + 'include' => 'nullable|string|in:category,contact_portal,contact_people', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,contact_portal,contact_people' + 'include' => 'nullable|string|in:category,contact_portal,contact_people', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,contact_portal,contact_people' + 'include' => 'nullable|string|in:category,contact_portal,contact_people', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function collect(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:debit_account,credit_account,payments' + 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); - $response = Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/contact_debit_transactions?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:debit_account,credit_account,payments' + 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); - $response = Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/contact_credit_transactions?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Expenses/Tax.php b/src/Models/Expenses/Tax.php index c079a2d..60b8c4c 100644 --- a/src/Models/Expenses/Tax.php +++ b/src/Models/Expenses/Tax.php @@ -3,9 +3,8 @@ namespace Theposeidonas\LaravelParasutApi\Models\Expenses; use Illuminate\Support\Facades\Http; -use Theposeidonas\LaravelParasutApi\ParasutV4; use Illuminate\Support\Facades\Validator; - +use Theposeidonas\LaravelParasutApi\ParasutV4; /** * Vergi @@ -13,24 +12,14 @@ */ class Tax extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/taxes'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ @@ -41,136 +30,107 @@ public function index(array $parameters = []): array 'sort' => 'nullable|string|in:id,issue_date,due_date,remaining,description,net_total,-id,-issue_date,-due_date,-remaining,-description,-net_total', 'page.number' => 'nullable|integer|min:1', 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:category,tags,payments' + 'include' => 'nullable|string|in:category,tags,payments', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); - + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:category,tags' + 'include' => 'nullable|string|in:category,tags', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:payable,transaction' + 'include' => 'nullable|string|in:payable,transaction', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/payments?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Formalization/EArchive.php b/src/Models/Formalization/EArchive.php index 48ea4a6..bfa49b6 100644 --- a/src/Models/Formalization/EArchive.php +++ b/src/Models/Formalization/EArchive.php @@ -12,55 +12,38 @@ */ class EArchive extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/e_archives'; } - /** - * @param array $data - * @return array - */ public function create(array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:sales_invoice' + 'include' => 'nullable|string|in:sales_invoice', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function showPDF(string $id): array { $response = Http::withHeaders([ @@ -70,5 +53,4 @@ public function showPDF(string $id): array return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Formalization/EBill.php b/src/Models/Formalization/EBill.php index 66f5048..46a937e 100644 --- a/src/Models/Formalization/EBill.php +++ b/src/Models/Formalization/EBill.php @@ -12,55 +12,38 @@ */ class EBill extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/e_invoices'; } - /** - * @param array $data - * @return array - */ public function create(array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:invoice' + 'include' => 'nullable|string|in:invoice', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function showPDF(string $id): array { $response = Http::withHeaders([ @@ -70,6 +53,4 @@ public function showPDF(string $id): array return $this->handleResponse($response); } - - -} \ No newline at end of file +} diff --git a/src/Models/Formalization/ESmm.php b/src/Models/Formalization/ESmm.php index f8166bf..bd0c9ec 100644 --- a/src/Models/Formalization/ESmm.php +++ b/src/Models/Formalization/ESmm.php @@ -12,62 +12,45 @@ */ class ESmm extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/e_smms'; } - /** - * @param array $data - * @return array - */ public function create(array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:sales_invoice' + 'include' => 'nullable|string|in:sales_invoice', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function showPDF(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/pdf', ])->get($this->serviceUrl.'/'.$id.'/pdf'); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Formalization/Inbox.php b/src/Models/Formalization/Inbox.php index 87e4278..2da5cab 100644 --- a/src/Models/Formalization/Inbox.php +++ b/src/Models/Formalization/Inbox.php @@ -12,37 +12,27 @@ */ class Inbox extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/e_invoice_inboxes'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.vkn' => 'nullable|integer', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', + 'filter.vkn' => 'nullable|integer', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Other/ApiHome.php b/src/Models/Other/ApiHome.php index e8899f5..97aad35 100644 --- a/src/Models/Other/ApiHome.php +++ b/src/Models/Other/ApiHome.php @@ -12,34 +12,24 @@ */ class ApiHome extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].'me'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'include' => 'nullable|string|in:user_roles,companies,profile' + 'include' => 'nullable|string|in:user_roles,companies,profile', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Other/TrackableJob.php b/src/Models/Other/TrackableJob.php index 71fb53e..153d634 100644 --- a/src/Models/Other/TrackableJob.php +++ b/src/Models/Other/TrackableJob.php @@ -11,31 +11,21 @@ */ class TrackableJob extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/trackable_jobs'; } - /** - * @param string $id - * @return array - */ public function show(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Other/Webhook.php b/src/Models/Other/Webhook.php index 0eb7a7e..6cf1f04 100644 --- a/src/Models/Other/Webhook.php +++ b/src/Models/Other/Webhook.php @@ -11,35 +11,26 @@ */ class Webhook extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/webhooks'; } - /** - * @return array - */ public function index(): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl); + return $this->handleResponse($response); } /** - * @param array $data - * @return array + * @param array $data */ public function create($data): array { @@ -47,13 +38,12 @@ public function create($data): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } /** - * @param string $id - * @param array $data - * @return array + * @param array $data */ public function edit(string $id, $data): array { @@ -61,20 +51,17 @@ public function edit(string $id, $data): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Sales/Bill.php b/src/Models/Sales/Bill.php index 7227b05..1b1a31b 100644 --- a/src/Models/Sales/Bill.php +++ b/src/Models/Sales/Bill.php @@ -12,53 +12,39 @@ */ class Bill extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/sales_invoices'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.issue_date' => 'nullable|string', - 'filter.due_date' => 'nullable|string', - 'filter.contact_id' => 'nullable|integer', - 'filter.invoice_id' => 'nullable|integer', - 'filter.invoice_series'=> 'nullable|string', - 'filter.item_type' => 'nullable|string|in:invoice,refund,estimate,export', - 'filter.print_status' => 'nullable|string|in:printed,not_printed,invoices_not_sent,e_invoice_sent,e_archive_sent,e_smm_sent', - 'filter.payment_status'=> 'nullable|string|in:overdue,not_due,unscheduled,paid', - 'sort' => 'nullable|string|in:id,issue_date,due_date,remaining,remaining_in_trl,description,net_total,-id,-issue_date,-due_date,-remaining,-remaining_in_trl,-description,-net_total', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:category,contact,details,details.product,details.warehouse,payments,payments.transaction,tags,sharings,recurrence_plan,active_e_document', + 'filter.issue_date' => 'nullable|string', + 'filter.due_date' => 'nullable|string', + 'filter.contact_id' => 'nullable|integer', + 'filter.invoice_id' => 'nullable|integer', + 'filter.invoice_series' => 'nullable|string', + 'filter.item_type' => 'nullable|string|in:invoice,refund,estimate,export', + 'filter.print_status' => 'nullable|string|in:printed,not_printed,invoices_not_sent,e_invoice_sent,e_archive_sent,e_smm_sent', + 'filter.payment_status' => 'nullable|string|in:overdue,not_due,unscheduled,paid', + 'sort' => 'nullable|string|in:id,issue_date,due_date,remaining,remaining_in_trl,description,net_total,-id,-issue_date,-due_date,-remaining,-remaining_in_trl,-description,-net_total', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:category,contact,details,details.product,details.warehouse,payments,payments.transaction,tags,sharings,recurrence_plan,active_e_document', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -69,14 +55,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -87,15 +69,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -106,28 +83,20 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -138,14 +107,10 @@ public function pay(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/payments?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function cancel(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -156,64 +121,47 @@ public function cancel(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id.'/cancel?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function recover(string $id, array $parameters = []): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/recover?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function archive(string $id, array $parameters = []): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/archive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function unarchive(string $id, array $parameters = []): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/unarchive?'.http_build_query($parameters)); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function convert(string $id, array $data, array $parameters = []): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->patch($this->serviceUrl.'/'.$id.'/convert_to_invoice?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Sales/Customer.php b/src/Models/Sales/Customer.php index 21b903e..ca7438c 100644 --- a/src/Models/Sales/Customer.php +++ b/src/Models/Sales/Customer.php @@ -12,50 +12,36 @@ */ class Customer extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/contacts'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', - 'filter.email' => 'nullable|string|email', - 'filter.tax_number' => 'nullable|string', - 'filter.tax_office' => 'nullable|string', - 'filter.city' => 'nullable|string', - 'filter.account_type'=> 'nullable|string|in:customer,supplier', - 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:category,contact_portal,contact_people', + 'filter.name' => 'nullable|string', + 'filter.email' => 'nullable|string|email', + 'filter.tax_number' => 'nullable|string', + 'filter.tax_office' => 'nullable|string', + 'filter.city' => 'nullable|string', + 'filter.account_type' => 'nullable|string|in:customer,supplier', + 'sort' => 'nullable|string|in:id,balance,name,email,-id,-balance,-name,-email', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:category,contact_portal,contact_people', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -65,14 +51,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -83,15 +65,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -102,58 +79,45 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function collect(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); - $response = Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/contact_debit_transactions?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function pay(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ 'include' => 'nullable|string|in:debit_account,credit_account,payments', ]); - $response = Http::withHeaders([ + $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'/'.$id.'/contact_credit_transactions?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Settings/Category.php b/src/Models/Settings/Category.php index 098bd40..a33d657 100644 --- a/src/Models/Settings/Category.php +++ b/src/Models/Settings/Category.php @@ -12,46 +12,33 @@ */ class Category extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ + public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/item_categories'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', - 'filter.category_type'=> 'nullable|string', - 'sort' => 'nullable|string|in:id,name,category_type,-id,-name,-category_type', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:parent_category,subcategories', + 'filter.name' => 'nullable|string', + 'filter.category_type' => 'nullable|string', + 'sort' => 'nullable|string|in:id,name,category_type,-id,-name,-category_type', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:parent_category,subcategories', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -62,14 +49,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -80,15 +63,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -99,20 +77,17 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Settings/Tag.php b/src/Models/Settings/Tag.php index da7f7a4..2f9ddc3 100644 --- a/src/Models/Settings/Tag.php +++ b/src/Models/Settings/Tag.php @@ -12,69 +12,52 @@ */ class Tag extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/tags'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'sort' => 'nullable|string|in:id,name,-id,-name', + 'sort' => 'nullable|string|in:id,name,-id,-name', 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', + 'page.size' => 'nullable|integer|min:1|max:25', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @return array - */ public function create(array $data): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function show(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } /** - * @param string $id - * @param array $data - * @return array + * @param array $data */ public function edit(string $id, $data): array { @@ -82,20 +65,17 @@ public function edit(string $id, $data): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id, $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Stock/Product.php b/src/Models/Stock/Product.php index 04c8c51..80bbaf4 100644 --- a/src/Models/Stock/Product.php +++ b/src/Models/Stock/Product.php @@ -12,47 +12,33 @@ */ class Product extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/products'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', - 'filter.code' => 'nullable|string', - 'sort' => 'nullable|string|in:id,name,-id,-name', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:inventory_levels,category', + 'filter.name' => 'nullable|string', + 'filter.code' => 'nullable|string', + 'sort' => 'nullable|string|in:id,name,-id,-name', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:inventory_levels,category', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -63,14 +49,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -81,15 +63,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -100,47 +77,41 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } /** * https://apidocs.parasut.com/#operation/listInventoryLevels - * - * @param string $id - * @param array $parameters - * @return array */ public function inventory(string $id, array $parameters = []): array { Validator::validate($parameters, [ 'filter.warehouses.name' => 'nullable|string', - 'filter.archived' => 'nullable|boolean', - 'filter.has_stock' => 'nullable|boolean', - 'filter.stock_count' => 'nullable|numeric', - 'sort' => 'nullable|string|in:id,stock_count,-id,-stock_count', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:product,warehouse', + 'filter.archived' => 'nullable|boolean', + 'filter.has_stock' => 'nullable|boolean', + 'filter.stock_count' => 'nullable|numeric', + 'sort' => 'nullable|string|in:id,stock_count,-id,-stock_count', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:product,warehouse', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id.'/inventory_levels', $parameters); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Stock/StockMovement.php b/src/Models/Stock/StockMovement.php index a0bbc46..6c0a100 100644 --- a/src/Models/Stock/StockMovement.php +++ b/src/Models/Stock/StockMovement.php @@ -12,38 +12,28 @@ */ class StockMovement extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/stock_movements'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'sort' => 'nullable|string|in:id,date,-id,-date', + 'sort' => 'nullable|string|in:id,date,-id,-date', 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:product,source,contact,warehouse', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:product,source,contact,warehouse', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/Models/Stock/Warehouse.php b/src/Models/Stock/Warehouse.php index cd76bf0..df2e7d6 100644 --- a/src/Models/Stock/Warehouse.php +++ b/src/Models/Stock/Warehouse.php @@ -12,47 +12,33 @@ */ class Warehouse extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/warehouses'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.name' => 'nullable|string', + 'filter.name' => 'nullable|string', 'filter.archived' => 'nullable|boolean', - 'sort' => 'nullable|string|in:id,name,-id,-name', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:inventory_levels', + 'sort' => 'nullable|string|in:id,name,-id,-name', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:inventory_levels', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -63,14 +49,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -81,15 +63,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -100,19 +77,17 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } -} \ No newline at end of file +} diff --git a/src/Models/Stock/Waybill.php b/src/Models/Stock/Waybill.php index 7582fcb..f6ba287 100644 --- a/src/Models/Stock/Waybill.php +++ b/src/Models/Stock/Waybill.php @@ -12,48 +12,34 @@ */ class Waybill extends ParasutV4 { - /** - * @var string - */ private string $serviceUrl; - /** - * @param $config - */ public function __construct($config) { parent::__construct($config); $this->serviceUrl = $this->config['api_url'].$this->config['company_id'].'/shipment_documents'; } - /** - * @param array $parameters - * @return array - */ public function index(array $parameters = []): array { Validator::validate($parameters, [ - 'filter.flow_type' => 'nullable|string', + 'filter.flow_type' => 'nullable|string', 'filter.invoice_status' => 'nullable|string', - 'filter.archived' => 'nullable|boolean', - 'sort' => 'nullable|string|in:id,issue_date,description,inflow,-id,-issue_date,-description,-inflow', - 'page.number' => 'nullable|integer|min:1', - 'page.size' => 'nullable|integer|min:1|max:25', - 'include' => 'nullable|string|in:contact,stock_movements,stock_movements.product,tags,invoices', + 'filter.archived' => 'nullable|boolean', + 'sort' => 'nullable|string|in:id,issue_date,description,inflow,-id,-issue_date,-description,-inflow', + 'page.number' => 'nullable|integer|min:1', + 'page.size' => 'nullable|integer|min:1|max:25', + 'include' => 'nullable|string|in:contact,stock_movements,stock_movements.product,tags,invoices', ]); $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl, $parameters); + return $this->handleResponse($response); } - /** - * @param array $data - * @param array $parameters - * @return array - */ public function create(array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -64,14 +50,10 @@ public function create(array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->post($this->serviceUrl.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $parameters - * @return array - */ public function show(string $id, array $parameters = []): array { Validator::validate($parameters, [ @@ -82,15 +64,10 @@ public function show(string $id, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->get($this->serviceUrl.'/'.$id, $parameters); + return $this->handleResponse($response); } - /** - * @param string $id - * @param array $data - * @param array $parameters - * @return array - */ public function edit(string $id, array $data, array $parameters = []): array { Validator::validate($parameters, [ @@ -101,20 +78,17 @@ public function edit(string $id, array $data, array $parameters = []): array 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->put($this->serviceUrl.'/'.$id.'?'.http_build_query($parameters), $data); + return $this->handleResponse($response); } - /** - * @param string $id - * @return array - */ public function delete(string $id): array { $response = Http::withHeaders([ 'Authorization' => 'Bearer '.$this->token, 'Content-Type' => 'application/json', ])->delete($this->serviceUrl.'/'.$id); + return $this->handleResponse($response); } - -} \ No newline at end of file +} diff --git a/src/ParasutServiceProvider.php b/src/ParasutServiceProvider.php index b6c65d8..01bbd8b 100644 --- a/src/ParasutServiceProvider.php +++ b/src/ParasutServiceProvider.php @@ -6,7 +6,6 @@ class ParasutServiceProvider extends ServiceProvider { - /** * Bootstrap any package services. * @@ -15,7 +14,7 @@ class ParasutServiceProvider extends ServiceProvider public function boot() { $this->publishes([ - __DIR__ . '/../config/parasut.php' => config_path('parasut.php'), + __DIR__.'/../config/parasut.php' => config_path('parasut.php'), ], 'parasut-config'); } @@ -26,9 +25,9 @@ public function boot() */ public function register() { - $this->mergeConfigFrom(__DIR__ . '/../config/parasut.php', 'parasut'); + $this->mergeConfigFrom(__DIR__.'/../config/parasut.php', 'parasut'); $this->app->singleton(ParasutV4::class, function ($app) { return new ParasutV4($app['config']['parasut']); }); } -} \ No newline at end of file +} diff --git a/src/ParasutV4.php b/src/ParasutV4.php index d5c2e81..3b4c9ad 100644 --- a/src/ParasutV4.php +++ b/src/ParasutV4.php @@ -3,7 +3,6 @@ namespace Theposeidonas\LaravelParasutApi; use Theposeidonas\LaravelParasutApi\Contracts\ParasutV4 as ParasutV4Conract; - use Theposeidonas\LaravelParasutApi\Models\Cash\Account; use Theposeidonas\LaravelParasutApi\Models\Cash\Transaction; use Theposeidonas\LaravelParasutApi\Models\Expenses\Bank; @@ -37,217 +36,141 @@ class ParasutV4 implements ParasutV4Conract /** * @array */ - protected array $config; - + protected array $config; + /** * @string */ protected string $token; - /** - * @param $config - */ public function __construct($config) { $this->config = $config; $this->token = (new Auth($this->config))->getToken(); } - /** - * @return Account - */ public function Account(): Account { return new Account($this->config); } - /** - * @return Transaction - */ public function Transaction(): Transaction { return new Transaction($this->config); } - /** - * @return Bank - */ public function Bank(): Bank { return new Bank($this->config); } - /** - * @return Employee - */ public function Employee(): Employee { return new Employee($this->config); } - /** - * @return Receipt - */ public function Receipt(): Receipt { return new Receipt($this->config); } - /** - * @return Salary - */ public function Salary(): Salary { return new Salary($this->config); } - /** - * @return Supplier - */ public function Supplier(): Supplier { return new Supplier($this->config); } - /** - * @return Tax - */ public function Tax(): Tax { return new Tax($this->config); } - /** - * @return EArchive - */ public function EArchive(): EArchive { return new EArchive($this->config); } - /** - * @return EBill - */ public function EBill(): EBill { return new EBill($this->config); } - /** - * @return ESmm - */ public function ESmm(): ESmm { return new ESmm($this->config); } - /** - * @return Inbox - */ public function Inbox(): Inbox { return new Inbox($this->config); } - /** - * @return Bill - */ public function Bill(): Bill { return new Bill($this->config); } - /** - * @return Customer - */ public function Customer(): Customer { return new Customer($this->config); } - /** - * @return Category - */ public function Category(): Category { return new Category($this->config); } - /** - * @return Tag - */ public function Tag(): Tag { return new Tag($this->config); } - /** - * @return Product - */ public function Product(): Product { return new Product($this->config); } - /** - * @return StockMovement - */ public function StockMovement(): StockMovement { return new StockMovement($this->config); } - /** - * @return Warehouse - */ public function Warehouse(): Warehouse { return new Warehouse($this->config); } - /** - * @return Waybill - */ public function Waybill(): Waybill { return new Waybill($this->config); } - /** - * @return ApiHome - */ public function ApiHome(): ApiHome { return new ApiHome($this->config); } - /** - * @return TrackableJob - */ public function TrackableJob(): TrackableJob { return new TrackableJob($this->config); } - /** - * @return Webhook - */ public function Webhook(): Webhook { return new Webhook($this->config); } - /** - * @param $response - * @return array - */ public function handleResponse($response): array { return [ 'success' => $response->successful(), - 'error' => !$response->successful(), + 'error' => ! $response->successful(), 'body' => json_decode($response->body()), - 'status' => $response->status() + 'status' => $response->status(), ]; } -} \ No newline at end of file +} diff --git a/tests/Feature/BaseTest.php b/tests/Feature/BaseTest.php index b25a19f..5d3f93f 100644 --- a/tests/Feature/BaseTest.php +++ b/tests/Feature/BaseTest.php @@ -10,8 +10,8 @@ protected function setUp(): void { parent::setUp(); - if (file_exists(__DIR__ . '/../../.env')) { - \Dotenv\Dotenv::createImmutable(__DIR__ . '/../../')->load(); + if (file_exists(__DIR__.'/../../.env')) { + \Dotenv\Dotenv::createImmutable(__DIR__.'/../../')->load(); } config()->set('parasut.username', env('PARASUT_USERNAME')); diff --git a/tests/Feature/CashTest/AccountTest.php b/tests/Feature/CashTest/AccountTest.php index b6364a8..d10d999 100644 --- a/tests/Feature/CashTest/AccountTest.php +++ b/tests/Feature/CashTest/AccountTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\CashTest; -use Theposeidonas\LaravelParasutApi\Models\Cash\Account; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Cash\Account; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class AccountTest extends BaseTest @@ -22,9 +22,9 @@ public function test_index() config('parasut.api_url').config('parasut.company_id').'/accounts' => Http::response([ 'data' => [ ['id' => '1', 'name' => 'Test Account'], - ['id' => '2', 'name' => 'Another Account'] - ] - ], 200) + ['id' => '2', 'name' => 'Another Account'], + ], + ], 200), ]); $response = $this->account->index(); @@ -38,8 +38,8 @@ public function test_show() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/accounts/1' => Http::response([ - 'data' => ['id' => '1', 'name' => 'Test Account'] - ], 200) + 'data' => ['id' => '1', 'name' => 'Test Account'], + ], 200), ]); $response = $this->account->show('1'); @@ -52,8 +52,8 @@ public function test_create() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/accounts' => Http::response([ - 'data' => ['id' => '1', 'name' => 'New Account'] - ], 201) + 'data' => ['id' => '1', 'name' => 'New Account'], + ], 201), ]); $response = $this->account->create(['name' => 'New Account']); @@ -66,8 +66,8 @@ public function test_edit() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/accounts/1' => Http::response([ - 'data' => ['id' => '1', 'name' => 'Updated Account'] - ], 200) + 'data' => ['id' => '1', 'name' => 'Updated Account'], + ], 200), ]); $response = $this->account->edit('1', ['name' => 'Updated Account']); @@ -79,7 +79,7 @@ public function test_edit() public function test_delete() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/accounts/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/accounts/1' => Http::response([], 204), ]); $response = $this->account->delete('1'); diff --git a/tests/Feature/CashTest/TransactionTest.php b/tests/Feature/CashTest/TransactionTest.php index 1483a05..37c3670 100644 --- a/tests/Feature/CashTest/TransactionTest.php +++ b/tests/Feature/CashTest/TransactionTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\CashTest; -use Theposeidonas\LaravelParasutApi\Models\Cash\Transaction; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Cash\Transaction; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class TransactionTest extends BaseTest @@ -20,8 +20,8 @@ public function test_show_transaction() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/transactions/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'transaction', 'attributes' => ['amount' => 100]] - ], 200) + 'data' => ['id' => '1', 'type' => 'transaction', 'attributes' => ['amount' => 100]], + ], 200), ]); $response = $this->transaction->show('1'); @@ -34,7 +34,7 @@ public function test_show_transaction() public function test_delete_transaction() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/transactions/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/transactions/1' => Http::response([], 204), ]); $response = $this->transaction->delete('1'); diff --git a/tests/Feature/ExpensesTest/BankTest.php b/tests/Feature/ExpensesTest/BankTest.php index acc36b3..7a4e78c 100644 --- a/tests/Feature/ExpensesTest/BankTest.php +++ b/tests/Feature/ExpensesTest/BankTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Bank; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Bank; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class BankTest extends BaseTest @@ -20,8 +20,8 @@ public function test_create_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees' => Http::response([ - 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 100]] - ], 201) + 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 100]], + ], 201), ]); $response = $this->bank->create(['name' => 'New Bank Fee']); @@ -35,8 +35,8 @@ public function test_show_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 100]] - ], 200) + 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 100]], + ], 200), ]); $response = $this->bank->show('1'); @@ -50,8 +50,8 @@ public function test_edit_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 150]] - ], 200) + 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['amount' => 150]], + ], 200), ]); $response = $this->bank->edit('1', ['amount' => 150]); @@ -63,7 +63,7 @@ public function test_edit_bank_fee() public function test_delete_bank_fee() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/bank_fees/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/bank_fees/1' => Http::response([], 204), ]); $response = $this->bank->delete('1'); @@ -76,8 +76,8 @@ public function test_archive_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees/1/archive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['archived' => true]] - ], 200) + 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['archived' => true]], + ], 200), ]); $response = $this->bank->archive('1'); @@ -90,8 +90,8 @@ public function test_unarchive_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees/1/unarchive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['archived' => false]] - ], 200) + 'data' => ['id' => '1', 'type' => 'bank_fee', 'attributes' => ['archived' => false]], + ], 200), ]); $response = $this->bank->unarchive('1'); @@ -104,8 +104,8 @@ public function test_pay_bank_fee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/bank_fees/1/payments' => Http::response([ - 'data' => ['id' => '1', 'type' => 'payment', 'attributes' => ['amount' => 100]] - ], 200) + 'data' => ['id' => '1', 'type' => 'payment', 'attributes' => ['amount' => 100]], + ], 200), ]); $response = $this->bank->pay('1', ['amount' => 100]); diff --git a/tests/Feature/ExpensesTest/EmployeeTest.php b/tests/Feature/ExpensesTest/EmployeeTest.php index 0c691e7..eb8228d 100644 --- a/tests/Feature/ExpensesTest/EmployeeTest.php +++ b/tests/Feature/ExpensesTest/EmployeeTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Employee; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Employee; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class EmployeeTest extends BaseTest @@ -20,8 +20,8 @@ public function test_create_employee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/employees' => Http::response([ - 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'John Doe']] - ], 201) + 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'John Doe']], + ], 201), ]); $response = $this->employee->create(['name' => 'John Doe']); @@ -35,8 +35,8 @@ public function test_show_employee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/employees/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'John Doe']] - ], 200) + 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'John Doe']], + ], 200), ]); $response = $this->employee->show('1'); @@ -50,8 +50,8 @@ public function test_edit_employee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/employees/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'Jane Doe']] - ], 200) + 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['name' => 'Jane Doe']], + ], 200), ]); $response = $this->employee->edit('1', ['name' => 'Jane Doe']); @@ -63,7 +63,7 @@ public function test_edit_employee() public function test_delete_employee() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/employees/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/employees/1' => Http::response([], 204), ]); $response = $this->employee->delete('1'); @@ -76,8 +76,8 @@ public function test_archive_employee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/employees/1/archive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['archived' => true]] - ], 200) + 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['archived' => true]], + ], 200), ]); $response = $this->employee->archive('1'); @@ -90,8 +90,8 @@ public function test_unarchive_employee() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/employees/1/unarchive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['archived' => false]] - ], 200) + 'data' => ['id' => '1', 'type' => 'employee', 'attributes' => ['archived' => false]], + ], 200), ]); $response = $this->employee->unarchive('1'); diff --git a/tests/Feature/ExpensesTest/ReceiptTest.php b/tests/Feature/ExpensesTest/ReceiptTest.php index 09da388..d551a01 100644 --- a/tests/Feature/ExpensesTest/ReceiptTest.php +++ b/tests/Feature/ExpensesTest/ReceiptTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Receipt; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Receipt; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class ReceiptTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_receipts() 'data' => [ ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 100]], ['id' => '2', 'type' => 'purchase_bill', 'attributes' => ['amount' => 200]], - ] - ], 200) + ], + ], 200), ]); $response = $this->receipt->index(); @@ -33,13 +33,14 @@ public function test_index_receipts() $this->assertCount(2, $response['body']->data); $this->assertEquals(100, $response['body']->data[0]->attributes->amount); } + // Used wildcard '*' in Http::fake() because Http::fake() cannot handle URLs with '#' character properly. public function test_create_basic_receipt() { Http::fake([ '*' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 150]] - ], 201) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 150]], + ], 201), ]); $response = $this->receipt->createBasic(['amount' => 150]); @@ -52,8 +53,8 @@ public function test_create_detailed_receipt() { Http::fake([ '*' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 250]] - ], 201) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 250]], + ], 201), ]); $response = $this->receipt->createDetailed(['amount' => 250]); @@ -66,8 +67,8 @@ public function test_show_receipt() { Http::fake([ '*' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 100]] - ], 200) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 100]], + ], 200), ]); $response = $this->receipt->show('1'); @@ -80,8 +81,8 @@ public function test_edit_basic_receipt() { Http::fake([ '*' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 300]] - ], 200) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 300]], + ], 200), ]); $response = $this->receipt->editBasic('1', ['amount' => 300]); @@ -94,8 +95,8 @@ public function test_edit_detailed_receipt() { Http::fake([ '*' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 300]] - ], 200) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['amount' => 300]], + ], 200), ]); $response = $this->receipt->editDetailed('1', ['amount' => 300]); @@ -103,11 +104,10 @@ public function test_edit_detailed_receipt() $this->assertEquals(300, $response['body']->data->attributes->amount); } - public function test_delete_receipt() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/purchase_bills/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/purchase_bills/1' => Http::response([], 204), ]); $response = $this->receipt->delete('1'); @@ -120,8 +120,8 @@ public function test_archive_receipt() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/purchase_bills/1/archive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['archived' => true]] - ], 200) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['archived' => true]], + ], 200), ]); $response = $this->receipt->archive('1'); @@ -134,8 +134,8 @@ public function test_unarchive_receipt() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/purchase_bills/1/unarchive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['archived' => false]] - ], 200) + 'data' => ['id' => '1', 'type' => 'purchase_bill', 'attributes' => ['archived' => false]], + ], 200), ]); $response = $this->receipt->unarchive('1'); diff --git a/tests/Feature/ExpensesTest/SalaryTest.php b/tests/Feature/ExpensesTest/SalaryTest.php index ac8a993..5333e6d 100644 --- a/tests/Feature/ExpensesTest/SalaryTest.php +++ b/tests/Feature/ExpensesTest/SalaryTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Salary; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Salary; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class SalaryTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_salaries() 'data' => [ ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 1000]], ['id' => '2', 'type' => 'salary', 'attributes' => ['net_total' => 2000]], - ] - ], 200) + ], + ], 200), ]); $response = $this->salary->index(); @@ -38,8 +38,8 @@ public function test_create_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries' => Http::response([ - 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 1500]] - ], 201) + 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 1500]], + ], 201), ]); $response = $this->salary->create(['net_total' => 1500]); @@ -52,8 +52,8 @@ public function test_show_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 1000]] - ], 200) + 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 1000]], + ], 200), ]); $response = $this->salary->show('1'); @@ -66,8 +66,8 @@ public function test_edit_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 2000]] - ], 200) + 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['net_total' => 2000]], + ], 200), ]); $response = $this->salary->edit('1', ['net_total' => 2000]); @@ -79,7 +79,7 @@ public function test_edit_salary() public function test_delete_salary() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/salaries/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/salaries/1' => Http::response([], 204), ]); $response = $this->salary->delete('1'); @@ -92,8 +92,8 @@ public function test_archive_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries/1/archive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['archived' => true]] - ], 200) + 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['archived' => true]], + ], 200), ]); $response = $this->salary->archive('1'); @@ -106,8 +106,8 @@ public function test_unarchive_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries/1/unarchive' => Http::response([ - 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['archived' => false]] - ], 200) + 'data' => ['id' => '1', 'type' => 'salary', 'attributes' => ['archived' => false]], + ], 200), ]); $response = $this->salary->unarchive('1'); @@ -120,8 +120,8 @@ public function test_pay_salary() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/salaries/1/payments' => Http::response([ - 'data' => ['id' => '1', 'type' => 'payment', 'attributes' => ['amount' => 1000]] - ], 200) + 'data' => ['id' => '1', 'type' => 'payment', 'attributes' => ['amount' => 1000]], + ], 200), ]); $response = $this->salary->pay('1', ['amount' => 1000]); diff --git a/tests/Feature/ExpensesTest/SupplierTest.php b/tests/Feature/ExpensesTest/SupplierTest.php index 6943881..e42194e 100644 --- a/tests/Feature/ExpensesTest/SupplierTest.php +++ b/tests/Feature/ExpensesTest/SupplierTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Supplier; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Supplier; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class SupplierTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_suppliers() 'data' => [ ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Supplier 1']], ['id' => '2', 'type' => 'contact', 'attributes' => ['name' => 'Supplier 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->supplier->index(); @@ -38,8 +38,8 @@ public function test_create_supplier() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'New Supplier']] - ], 201) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'New Supplier']], + ], 201), ]); $response = $this->supplier->create(['name' => 'New Supplier'], []); @@ -52,8 +52,8 @@ public function test_show_supplier() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Supplier 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Supplier 1']], + ], 200), ]); $response = $this->supplier->show('1'); @@ -66,8 +66,8 @@ public function test_edit_supplier() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Updated Supplier']] - ], 200) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Updated Supplier']], + ], 200), ]); $response = $this->supplier->edit('1', ['name' => 'Updated Supplier'], []); @@ -79,7 +79,7 @@ public function test_edit_supplier() public function test_delete_supplier() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([], 204), ]); $response = $this->supplier->delete('1'); diff --git a/tests/Feature/ExpensesTest/TaxTest.php b/tests/Feature/ExpensesTest/TaxTest.php index 6347454..8623d9c 100644 --- a/tests/Feature/ExpensesTest/TaxTest.php +++ b/tests/Feature/ExpensesTest/TaxTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\ExpensesTest; -use Theposeidonas\LaravelParasutApi\Models\Expenses\Tax; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Expenses\Tax; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class TaxTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_taxes() 'data' => [ ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 100]], ['id' => '2', 'type' => 'tax', 'attributes' => ['amount' => 200]], - ] - ], 200) + ], + ], 200), ]); $response = $this->tax->index(); @@ -38,8 +38,8 @@ public function test_create_tax() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/taxes' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 150]] - ], 201) + 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 150]], + ], 201), ]); $response = $this->tax->create(['amount' => 150], []); @@ -52,8 +52,8 @@ public function test_show_tax() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/taxes/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 100]] - ], 200) + 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 100]], + ], 200), ]); $response = $this->tax->show('1'); @@ -66,8 +66,8 @@ public function test_edit_tax() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/taxes/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 200]] - ], 200) + 'data' => ['id' => '1', 'type' => 'tax', 'attributes' => ['amount' => 200]], + ], 200), ]); $response = $this->tax->edit('1', ['amount' => 200], []); @@ -79,7 +79,7 @@ public function test_edit_tax() public function test_delete_tax() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/taxes/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/taxes/1' => Http::response([], 204), ]); $response = $this->tax->delete('1'); diff --git a/tests/Feature/FormalizationTest/EArchiveTest.php b/tests/Feature/FormalizationTest/EArchiveTest.php index 83ab05f..b6283e0 100644 --- a/tests/Feature/FormalizationTest/EArchiveTest.php +++ b/tests/Feature/FormalizationTest/EArchiveTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\FormalizationTest; -use Theposeidonas\LaravelParasutApi\Models\Formalization\EArchive; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Formalization\EArchive; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class EArchiveTest extends BaseTest @@ -20,8 +20,8 @@ public function test_create_earchive() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_archives' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_archive', 'attributes' => ['status' => 'sent']] - ], 201) + 'data' => ['id' => '1', 'type' => 'e_archive', 'attributes' => ['status' => 'sent']], + ], 201), ]); $response = $this->eArchive->create(['invoice_data' => 'test_data']); @@ -34,8 +34,8 @@ public function test_show_earchive() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_archives/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_archive', 'attributes' => ['status' => 'approved']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_archive', 'attributes' => ['status' => 'approved']], + ], 200), ]); $response = $this->eArchive->show('1'); @@ -48,8 +48,8 @@ public function test_show_earchive_pdf() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_archives/1/pdf' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at'=>'2024-10-07T09:57:49Z']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at' => '2024-10-07T09:57:49Z']], + ], 200), ]); $response = $this->eArchive->showPDF('1'); diff --git a/tests/Feature/FormalizationTest/EBillTest.php b/tests/Feature/FormalizationTest/EBillTest.php index ccf3c3c..e12f481 100644 --- a/tests/Feature/FormalizationTest/EBillTest.php +++ b/tests/Feature/FormalizationTest/EBillTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\FormalizationTest; -use Theposeidonas\LaravelParasutApi\Models\Formalization\EBill; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Formalization\EBill; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class EBillTest extends BaseTest @@ -20,8 +20,8 @@ public function test_create_ebill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_invoices' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_invoice', 'attributes' => ['status' => 'created']] - ], 201) + 'data' => ['id' => '1', 'type' => 'e_invoice', 'attributes' => ['status' => 'created']], + ], 201), ]); $response = $this->eBill->create(['invoice_data' => 'test_data']); @@ -34,8 +34,8 @@ public function test_show_ebill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_invoices/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_invoice', 'attributes' => ['status' => 'approved']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_invoice', 'attributes' => ['status' => 'approved']], + ], 200), ]); $response = $this->eBill->show('1'); @@ -48,8 +48,8 @@ public function test_show_ebill_pdf() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_invoices/1/pdf' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at'=>'2024-10-07T09:57:49Z']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at' => '2024-10-07T09:57:49Z']], + ], 200), ]); $response = $this->eBill->showPDF('1'); diff --git a/tests/Feature/FormalizationTest/ESmmTest.php b/tests/Feature/FormalizationTest/ESmmTest.php index 2e2337d..3fef7b0 100644 --- a/tests/Feature/FormalizationTest/ESmmTest.php +++ b/tests/Feature/FormalizationTest/ESmmTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\FormalizationTest; -use Theposeidonas\LaravelParasutApi\Models\Formalization\ESmm; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Formalization\ESmm; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class ESmmTest extends BaseTest @@ -20,8 +20,8 @@ public function test_create_esmm() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_smms' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_smm', 'attributes' => ['status' => 'created']] - ], 201) + 'data' => ['id' => '1', 'type' => 'e_smm', 'attributes' => ['status' => 'created']], + ], 201), ]); $response = $this->eSmm->create(['smm_data' => 'test_data']); @@ -34,8 +34,8 @@ public function test_show_esmm() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_smms/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_smm', 'attributes' => ['status' => 'approved']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_smm', 'attributes' => ['status' => 'approved']], + ], 200), ]); $response = $this->eSmm->show('1'); @@ -48,8 +48,8 @@ public function test_show_esmm_pdf() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/e_smms/1/pdf' => Http::response([ - 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at'=>'2024-10-07T09:57:49Z']] - ], 200) + 'data' => ['id' => '1', 'type' => 'e_document_pdfs', 'attributes' => ['url' => 'pdf-url123.pdf', 'expires_at' => '2024-10-07T09:57:49Z']], + ], 200), ]); $response = $this->eSmm->showPDF('1'); diff --git a/tests/Feature/FormalizationTest/InboxTest.php b/tests/Feature/FormalizationTest/InboxTest.php index 18866e4..08a9ae4 100644 --- a/tests/Feature/FormalizationTest/InboxTest.php +++ b/tests/Feature/FormalizationTest/InboxTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\FormalizationTest; -use Theposeidonas\LaravelParasutApi\Models\Formalization\Inbox; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Formalization\Inbox; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class InboxTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_inbox() 'data' => [ ['id' => '1', 'type' => 'e_invoice_inbox', 'attributes' => ['vkn' => 1234567890]], ['id' => '2', 'type' => 'e_invoice_inbox', 'attributes' => ['vkn' => 1257654321]], - ] - ], 200) + ], + ], 200), ]); $response = $this->inbox->index(['filter' => ['vkn' => 1234567890]]); diff --git a/tests/Feature/OtherTest/ApiHomeTest.php b/tests/Feature/OtherTest/ApiHomeTest.php index 1f0b1e1..ad38c17 100644 --- a/tests/Feature/OtherTest/ApiHomeTest.php +++ b/tests/Feature/OtherTest/ApiHomeTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\OtherTest; -use Theposeidonas\LaravelParasutApi\Models\Other\ApiHome; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Other\ApiHome; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class ApiHomeTest extends BaseTest @@ -23,9 +23,9 @@ public function test_index_api_home() 'data' => [ 'id' => '1', 'type' => 'api_home', - 'attributes' => ['user' => 'Test User'] - ] - ], 200) + 'attributes' => ['user' => 'Test User'], + ], + ], 200), ]); $response = $this->apiHome->index(); diff --git a/tests/Feature/OtherTest/TrackableJobTest.php b/tests/Feature/OtherTest/TrackableJobTest.php index f00854d..15dfbab 100644 --- a/tests/Feature/OtherTest/TrackableJobTest.php +++ b/tests/Feature/OtherTest/TrackableJobTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\OtherTest; -use Theposeidonas\LaravelParasutApi\Models\Other\TrackableJob; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Other\TrackableJob; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class TrackableJobTest extends BaseTest @@ -23,9 +23,9 @@ public function test_show_trackable_job() 'data' => [ 'id' => '1', 'type' => 'trackable_job', - 'attributes' => ['status' => 'completed'] - ] - ], 200) + 'attributes' => ['status' => 'completed'], + ], + ], 200), ]); $response = $this->trackableJob->show('1'); diff --git a/tests/Feature/OtherTest/WebhookTest.php b/tests/Feature/OtherTest/WebhookTest.php index 5447164..5fe283e 100644 --- a/tests/Feature/OtherTest/WebhookTest.php +++ b/tests/Feature/OtherTest/WebhookTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\OtherTest; -use Theposeidonas\LaravelParasutApi\Models\Other\Webhook; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Other\Webhook; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class WebhookTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_webhooks() 'data' => [ ['id' => '1', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/webhook1']], ['id' => '2', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/webhook2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->webhook->index(); @@ -38,8 +38,8 @@ public function test_create_webhook() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/webhooks' => Http::response([ - 'data' => ['id' => '1', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/webhook1']] - ], 201) + 'data' => ['id' => '1', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/webhook1']], + ], 201), ]); $response = $this->webhook->create(['url' => 'https://example.com/webhook1']); @@ -52,8 +52,8 @@ public function test_edit_webhook() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/webhooks/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/updated_webhook']] - ], 200) + 'data' => ['id' => '1', 'type' => 'webhook', 'attributes' => ['url' => 'https://example.com/updated_webhook']], + ], 200), ]); $response = $this->webhook->edit('1', ['url' => 'https://example.com/updated_webhook']); @@ -65,7 +65,7 @@ public function test_edit_webhook() public function test_delete_webhook() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/webhooks/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/webhooks/1' => Http::response([], 204), ]); $response = $this->webhook->delete('1'); diff --git a/tests/Feature/SalesTest/BillTest.php b/tests/Feature/SalesTest/BillTest.php index c4d20b2..1e3bc3e 100644 --- a/tests/Feature/SalesTest/BillTest.php +++ b/tests/Feature/SalesTest/BillTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\SalesTest; -use Theposeidonas\LaravelParasutApi\Models\Sales\Bill; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Sales\Bill; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class BillTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_bills() 'data' => [ ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 1000]], ['id' => '2', 'type' => 'sales_invoice', 'attributes' => ['amount' => 2000]], - ] - ], 200) + ], + ], 200), ]); $response = $this->bill->index(); @@ -38,8 +38,8 @@ public function test_create_bill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/sales_invoices' => Http::response([ - 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 1500]] - ], 201) + 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 1500]], + ], 201), ]); $response = $this->bill->create(['amount' => 1500]); @@ -52,8 +52,8 @@ public function test_show_bill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/sales_invoices/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 1000]] - ], 200) + 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 1000]], + ], 200), ]); $response = $this->bill->show('1'); @@ -66,8 +66,8 @@ public function test_edit_bill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/sales_invoices/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 2000]] - ], 200) + 'data' => ['id' => '1', 'type' => 'sales_invoice', 'attributes' => ['amount' => 2000]], + ], 200), ]); $response = $this->bill->edit('1', ['amount' => 2000]); @@ -79,7 +79,7 @@ public function test_edit_bill() public function test_delete_bill() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/sales_invoices/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/sales_invoices/1' => Http::response([], 204), ]); $response = $this->bill->delete('1'); diff --git a/tests/Feature/SalesTest/CustomerTest.php b/tests/Feature/SalesTest/CustomerTest.php index 91e5f5f..6c4178d 100644 --- a/tests/Feature/SalesTest/CustomerTest.php +++ b/tests/Feature/SalesTest/CustomerTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\SalesTest; -use Theposeidonas\LaravelParasutApi\Models\Sales\Customer; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Sales\Customer; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class CustomerTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_customers() 'data' => [ ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Customer 1']], ['id' => '2', 'type' => 'contact', 'attributes' => ['name' => 'Customer 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->customer->index(); @@ -38,8 +38,8 @@ public function test_create_customer() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'New Customer']] - ], 201) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'New Customer']], + ], 201), ]); $response = $this->customer->create(['name' => 'New Customer'], []); @@ -52,8 +52,8 @@ public function test_show_customer() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Customer 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Customer 1']], + ], 200), ]); $response = $this->customer->show('1'); @@ -66,8 +66,8 @@ public function test_edit_customer() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Updated Customer']] - ], 200) + 'data' => ['id' => '1', 'type' => 'contact', 'attributes' => ['name' => 'Updated Customer']], + ], 200), ]); $response = $this->customer->edit('1', ['name' => 'Updated Customer'], []); @@ -79,7 +79,7 @@ public function test_edit_customer() public function test_delete_customer() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/contacts/1' => Http::response([], 204), ]); $response = $this->customer->delete('1'); diff --git a/tests/Feature/SettingsTest/CategoryTest.php b/tests/Feature/SettingsTest/CategoryTest.php index 0893618..0d1c3e2 100644 --- a/tests/Feature/SettingsTest/CategoryTest.php +++ b/tests/Feature/SettingsTest/CategoryTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\SettingsTest; -use Theposeidonas\LaravelParasutApi\Models\Settings\Category; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Settings\Category; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class CategoryTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_categories() 'data' => [ ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'Category 1']], ['id' => '2', 'type' => 'item_category', 'attributes' => ['name' => 'Category 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->category->index(); @@ -38,8 +38,8 @@ public function test_create_category() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/item_categories' => Http::response([ - 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'New Category']] - ], 201) + 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'New Category']], + ], 201), ]); $response = $this->category->create(['name' => 'New Category']); @@ -52,8 +52,8 @@ public function test_show_category() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/item_categories/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'Category 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'Category 1']], + ], 200), ]); $response = $this->category->show('1'); @@ -66,8 +66,8 @@ public function test_edit_category() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/item_categories/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'Updated Category']] - ], 200) + 'data' => ['id' => '1', 'type' => 'item_category', 'attributes' => ['name' => 'Updated Category']], + ], 200), ]); $response = $this->category->edit('1', ['name' => 'Updated Category']); @@ -79,7 +79,7 @@ public function test_edit_category() public function test_delete_category() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/item_categories/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/item_categories/1' => Http::response([], 204), ]); $response = $this->category->delete('1'); diff --git a/tests/Feature/SettingsTest/TagTest.php b/tests/Feature/SettingsTest/TagTest.php index 57cb258..48305b0 100644 --- a/tests/Feature/SettingsTest/TagTest.php +++ b/tests/Feature/SettingsTest/TagTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\SettingsTest; -use Theposeidonas\LaravelParasutApi\Models\Settings\Tag; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Settings\Tag; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class TagTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_tags() 'data' => [ ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'Tag 1']], ['id' => '2', 'type' => 'tag', 'attributes' => ['name' => 'Tag 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->tag->index(); @@ -38,8 +38,8 @@ public function test_create_tag() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/tags' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'New Tag']] - ], 201) + 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'New Tag']], + ], 201), ]); $response = $this->tag->create(['name' => 'New Tag']); @@ -52,8 +52,8 @@ public function test_show_tag() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/tags/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'Tag 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'Tag 1']], + ], 200), ]); $response = $this->tag->show('1'); @@ -66,8 +66,8 @@ public function test_edit_tag() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/tags/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'Updated Tag']] - ], 200) + 'data' => ['id' => '1', 'type' => 'tag', 'attributes' => ['name' => 'Updated Tag']], + ], 200), ]); $response = $this->tag->edit('1', ['name' => 'Updated Tag']); @@ -79,7 +79,7 @@ public function test_edit_tag() public function test_delete_tag() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/tags/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/tags/1' => Http::response([], 204), ]); $response = $this->tag->delete('1'); diff --git a/tests/Feature/StockTest/ProductTest.php b/tests/Feature/StockTest/ProductTest.php index 0464e09..8e506ab 100644 --- a/tests/Feature/StockTest/ProductTest.php +++ b/tests/Feature/StockTest/ProductTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\StockTest; -use Theposeidonas\LaravelParasutApi\Models\Stock\Product; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Stock\Product; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class ProductTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_products() 'data' => [ ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'Product 1']], ['id' => '2', 'type' => 'product', 'attributes' => ['name' => 'Product 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->product->index(); @@ -38,8 +38,8 @@ public function test_create_product() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/products' => Http::response([ - 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'New Product']] - ], 201) + 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'New Product']], + ], 201), ]); $response = $this->product->create(['name' => 'New Product']); @@ -52,8 +52,8 @@ public function test_show_product() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/products/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'Product 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'Product 1']], + ], 200), ]); $response = $this->product->show('1'); @@ -66,8 +66,8 @@ public function test_edit_product() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/products/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'Updated Product']] - ], 200) + 'data' => ['id' => '1', 'type' => 'product', 'attributes' => ['name' => 'Updated Product']], + ], 200), ]); $response = $this->product->edit('1', ['name' => 'Updated Product']); @@ -79,7 +79,7 @@ public function test_edit_product() public function test_delete_product() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/products/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/products/1' => Http::response([], 204), ]); $response = $this->product->delete('1'); @@ -95,8 +95,8 @@ public function test_inventory_product() 'data' => [ ['id' => '1', 'type' => 'inventory_level', 'attributes' => ['stock_count' => 50]], ['id' => '2', 'type' => 'inventory_level', 'attributes' => ['stock_count' => 30]], - ] - ], 200) + ], + ], 200), ]); $response = $this->product->inventory('1'); diff --git a/tests/Feature/StockTest/StockMovementTest.php b/tests/Feature/StockTest/StockMovementTest.php index 53573da..c20357e 100644 --- a/tests/Feature/StockTest/StockMovementTest.php +++ b/tests/Feature/StockTest/StockMovementTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\StockTest; -use Theposeidonas\LaravelParasutApi\Models\Stock\StockMovement; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Stock\StockMovement; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class StockMovementTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_stock_movements() 'data' => [ ['id' => '1', 'type' => 'stock_movement', 'attributes' => ['date' => '2024-01-01']], ['id' => '2', 'type' => 'stock_movement', 'attributes' => ['date' => '2024-01-02']], - ] - ], 200) + ], + ], 200), ]); $response = $this->stockMovement->index(); diff --git a/tests/Feature/StockTest/WarehouseTest.php b/tests/Feature/StockTest/WarehouseTest.php index 4173f58..7d3f114 100644 --- a/tests/Feature/StockTest/WarehouseTest.php +++ b/tests/Feature/StockTest/WarehouseTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\StockTest; -use Theposeidonas\LaravelParasutApi\Models\Stock\Warehouse; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Stock\Warehouse; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class WarehouseTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_warehouses() 'data' => [ ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'Warehouse 1']], ['id' => '2', 'type' => 'warehouse', 'attributes' => ['name' => 'Warehouse 2']], - ] - ], 200) + ], + ], 200), ]); $response = $this->warehouse->index(); @@ -38,8 +38,8 @@ public function test_create_warehouse() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/warehouses' => Http::response([ - 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'New Warehouse']] - ], 201) + 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'New Warehouse']], + ], 201), ]); $response = $this->warehouse->create(['name' => 'New Warehouse']); @@ -52,8 +52,8 @@ public function test_show_warehouse() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/warehouses/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'Warehouse 1']] - ], 200) + 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'Warehouse 1']], + ], 200), ]); $response = $this->warehouse->show('1'); @@ -66,8 +66,8 @@ public function test_edit_warehouse() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/warehouses/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'Updated Warehouse']] - ], 200) + 'data' => ['id' => '1', 'type' => 'warehouse', 'attributes' => ['name' => 'Updated Warehouse']], + ], 200), ]); $response = $this->warehouse->edit('1', ['name' => 'Updated Warehouse']); @@ -79,7 +79,7 @@ public function test_edit_warehouse() public function test_delete_warehouse() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/warehouses/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/warehouses/1' => Http::response([], 204), ]); $response = $this->warehouse->delete('1'); diff --git a/tests/Feature/StockTest/WaybillTest.php b/tests/Feature/StockTest/WaybillTest.php index 389c501..765190b 100644 --- a/tests/Feature/StockTest/WaybillTest.php +++ b/tests/Feature/StockTest/WaybillTest.php @@ -2,8 +2,8 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Feature\StockTest; -use Theposeidonas\LaravelParasutApi\Models\Stock\Waybill; use Illuminate\Support\Facades\Http; +use Theposeidonas\LaravelParasutApi\Models\Stock\Waybill; use Theposeidonas\LaravelParasutApi\Tests\Feature\BaseTest; class WaybillTest extends BaseTest @@ -23,8 +23,8 @@ public function test_index_waybills() 'data' => [ ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-01']], ['id' => '2', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-02']], - ] - ], 200) + ], + ], 200), ]); $response = $this->waybill->index(); @@ -38,8 +38,8 @@ public function test_create_waybill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/shipment_documents' => Http::response([ - 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-01']] - ], 201) + 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-01']], + ], 201), ]); $response = $this->waybill->create(['issue_date' => '2024-01-01']); @@ -52,8 +52,8 @@ public function test_show_waybill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/shipment_documents/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-01']] - ], 200) + 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-01']], + ], 200), ]); $response = $this->waybill->show('1'); @@ -66,8 +66,8 @@ public function test_edit_waybill() { Http::fake([ config('parasut.api_url').config('parasut.company_id').'/shipment_documents/1' => Http::response([ - 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-02']] - ], 200) + 'data' => ['id' => '1', 'type' => 'shipment_document', 'attributes' => ['issue_date' => '2024-01-02']], + ], 200), ]); $response = $this->waybill->edit('1', ['issue_date' => '2024-01-02']); @@ -79,7 +79,7 @@ public function test_edit_waybill() public function test_delete_waybill() { Http::fake([ - config('parasut.api_url').config('parasut.company_id').'/shipment_documents/1' => Http::response([], 204) + config('parasut.api_url').config('parasut.company_id').'/shipment_documents/1' => Http::response([], 204), ]); $response = $this->waybill->delete('1'); diff --git a/tests/Unit/BaseTest.php b/tests/Unit/BaseTest.php index 2fd5c3d..65b14ad 100644 --- a/tests/Unit/BaseTest.php +++ b/tests/Unit/BaseTest.php @@ -10,8 +10,8 @@ protected function setUp(): void { parent::setUp(); - if (file_exists(__DIR__ . '/../../.env')) { - \Dotenv\Dotenv::createImmutable(__DIR__ . '/../../')->load(); + if (file_exists(__DIR__.'/../../.env')) { + \Dotenv\Dotenv::createImmutable(__DIR__.'/../../')->load(); } config()->set('parasut.username', env('PARASUT_USERNAME')); diff --git a/tests/Unit/ParasutAuthenticationTest.php b/tests/Unit/ParasutAuthenticationTest.php index 49c1729..2b86d70 100644 --- a/tests/Unit/ParasutAuthenticationTest.php +++ b/tests/Unit/ParasutAuthenticationTest.php @@ -7,7 +7,6 @@ use Theposeidonas\LaravelParasutApi\Auth; class ParasutAuthenticationTest extends BaseTest - { public function test_get_token_with_cached_token() { @@ -38,7 +37,7 @@ public function test_get_token_without_cached_token() 'https://api.parasut.com/oauth/token' => Http::response([ 'access_token' => 'new_access_token', 'expires_in' => 3600, - ], 200) + ], 200), ]); $auth = new Auth(config('parasut')); @@ -56,7 +55,7 @@ public function test_fetch_new_token_fails() ->andReturn(null); Http::fake([ - 'https://api.parasut.com/oauth/token' => Http::response(null, 400) + 'https://api.parasut.com/oauth/token' => Http::response(null, 400), ]); $auth = new Auth(config('parasut')); diff --git a/tests/Unit/ParasutV4Test.php b/tests/Unit/ParasutV4Test.php index fcce0a3..624f03d 100644 --- a/tests/Unit/ParasutV4Test.php +++ b/tests/Unit/ParasutV4Test.php @@ -2,9 +2,9 @@ namespace Theposeidonas\LaravelParasutApi\Tests\Unit; -use Theposeidonas\LaravelParasutApi\ParasutV4; use Illuminate\Http\Client\Response; use Orchestra\Testbench\TestCase; +use Theposeidonas\LaravelParasutApi\ParasutV4; class ParasutV4Test extends TestCase { @@ -21,7 +21,7 @@ protected function setUp(): void 'client_id' => 'test_client_id', 'client_secret' => 'test_client_secret', 'redirect_uri' => 'test_redirect_uri', - 'api_url' => 'https://api.parasut.com/v4/' + 'api_url' => 'https://api.parasut.com/v4/', ]); }