-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f42aeb8
commit cf9b5ab
Showing
6 changed files
with
277 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Theposeidonas\LaravelParasutApi\Models\Other; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
|
||
/** | ||
* API HOME | ||
* https://apidocs.parasut.com/#tag/ApiHome | ||
*/ | ||
class ApiHome | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private string $token; | ||
/** | ||
* @var array | ||
*/ | ||
private array $config; | ||
/** | ||
* @var string | ||
*/ | ||
private string $baseUrl; | ||
|
||
/** | ||
* @param $token | ||
* @param $config | ||
*/ | ||
public function __construct($token, $config) | ||
{ | ||
$this->token = $token; | ||
$this->config = $config; | ||
$this->baseUrl = 'https://api.parasut.com/v4/me'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function index(): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->get($this->baseUrl); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $response | ||
* @return array | ||
*/ | ||
public function handleResponse($response): array | ||
{ | ||
if ($response->successful()) { | ||
return [ | ||
'success' => true, | ||
'error' => false, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status() | ||
]; | ||
} else { | ||
return [ | ||
'success' => false, | ||
'error' => true, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status(), | ||
]; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Theposeidonas\LaravelParasutApi\Models\Other; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
|
||
/** | ||
* API HOME | ||
* https://apidocs.parasut.com/#tag/showTrackableJob | ||
*/ | ||
class TrackableJob | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private string $token; | ||
/** | ||
* @var array | ||
*/ | ||
private array $config; | ||
/** | ||
* @var string | ||
*/ | ||
private string $baseUrl; | ||
|
||
/** | ||
* @param $token | ||
* @param $config | ||
*/ | ||
public function __construct($token, $config) | ||
{ | ||
$this->token = $token; | ||
$this->config = $config; | ||
$this->baseUrl = 'https://api.parasut.com/v4/'.$this->config['company_id'].'/trackable_jobs'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function show($id): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->get($this->baseUrl.'/'.$id); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $response | ||
* @return array | ||
*/ | ||
public function handleResponse($response): array | ||
{ | ||
if ($response->successful()) { | ||
return [ | ||
'success' => true, | ||
'error' => false, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status() | ||
]; | ||
} else { | ||
return [ | ||
'success' => false, | ||
'error' => true, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status(), | ||
]; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
|
||
namespace Theposeidonas\LaravelParasutApi\Models\Other; | ||
|
||
use Illuminate\Support\Facades\Http; | ||
|
||
/** | ||
* Vergi | ||
* https://apidocs.parasut.com/#tag/Webhooks | ||
*/ | ||
class Webhook | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private string $token; | ||
/** | ||
* @var array | ||
*/ | ||
private array $config; | ||
/** | ||
* @var string | ||
*/ | ||
private string $baseUrl; | ||
|
||
/** | ||
* @param $token | ||
* @param $config | ||
*/ | ||
public function __construct($token, $config) | ||
{ | ||
$this->token = $token; | ||
$this->config = $config; | ||
$this->baseUrl = 'https://api.parasut.com/v4/'.$this->config['company_id'].'/webhooks'; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function index(): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->get($this->baseUrl); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $data | ||
* @return array | ||
*/ | ||
public function create($data): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->post($this->baseUrl, $data); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $id | ||
* @param $data | ||
* @return array | ||
*/ | ||
public function edit($id, $data): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->put($this->baseUrl.'/'.$id, $data); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $id | ||
* @return array | ||
*/ | ||
public function delete($id): array | ||
{ | ||
$response = Http::withHeaders([ | ||
'Authorization' => 'Bearer '.$this->token, | ||
'Content-Type' => 'application/json', | ||
])->delete($this->baseUrl.'/'.$id); | ||
return $this->handleResponse($response); | ||
} | ||
|
||
/** | ||
* @param $response | ||
* @return array | ||
*/ | ||
public function handleResponse($response): array | ||
{ | ||
if ($response->successful()) { | ||
return [ | ||
'success' => true, | ||
'error' => false, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status() | ||
]; | ||
} else { | ||
return [ | ||
'success' => false, | ||
'error' => true, | ||
'body' => json_decode($response->body()), | ||
'status' => $response->status(), | ||
]; | ||
} | ||
|
||
} | ||
} |