v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -8,26 +8,26 @@ use GuzzleHttp\Exception\RequestException;
trait SiteApi
{
protected static function getRemote($url, $data = array())
protected static function getRemote($path, $method = 'GET', $data = [])
{
$base = 'https://akaunting.com/api/';
$base = 'https://api.akaunting.com/';
$client = new Client(['verify' => false, 'base_uri' => $base]);
$headers['headers'] = array(
'Authorization' => 'Bearer ' . setting('general.api_token'),
$headers['headers'] = [
'Authorization' => 'Bearer ' . setting('apps.api_key'),
'Accept' => 'application/json',
'Referer' => url('/'),
'Akaunting' => version('short'),
'Language' => language()->getShortCode()
);
];
$data['http_errors'] = false;
$data = array_merge($data, $headers);
try {
$result = $client->get($url, $data);
$result = $client->request($method, $path, $data);
} catch (RequestException $e) {
$result = $e;
}