Skip to content

Commit

Permalink
V1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
theposeidonas committed Mar 11, 2024
1 parent f42aeb8 commit cf9b5ab
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 5 deletions.
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ Kullanım için projenize eklemeyi yaptıktan sonra, .env dosyası içerisinde
```dotenv
PARASUT_USERNAME="demo@parasut.com" // Username
PARASUT_PASSWORD="XXXXXXXXX" // Password
PARASUT_IS_STAGE="0" // TODO Staging aktif değil şimdilik default olarak 0
PARASUT_COMPANY_ID="123123" // Company ID
PARASUT_CLIENT_ID="XXXXXXXXXXXXXXXXX" // Paraşüt Client ID
PARASUT_CLIENT_SECRET="XXXXXXXXXXXXXXXXX" // Paraşüt Client Secret
Expand Down Expand Up @@ -201,18 +200,35 @@ echo $customer['body']->data->attributes->name; // Oluşturulan müşterinin ism

Eksikleri ve hataları Issues kısmından yazabilirsiniz.
- [x] Fonksiyonlar dahil edildi
- [x] Eksik diğer kısımlar eklendi. (Others)
- [x] Staging fonksiyonları çıkartıldı.
- [ ] Fonksiyonların ekstra filtreleri dahil edilecek (Query Parameters)
- [ ] Staging dahil edilecek (Api test modu)

### Changelog

#### V1.0.2

**11 Mart 2024**

- Others altındaki fonksiyonlar eklendi.
- ApiHome - TrackableJob - Webhook
- Config dosyasından staging çıkartıldı. (Artık kullanılmıyor)
- composer.json'a gereklilikler eklendi.

#### V1.0.1

**22 Ocak 2023**
**22 Ocak 2024**

- Satış Faturasında unutulan pay() fonksiyonu eklendi.


#### V1.0.0

**20 Ocak 2024**

- Initial Release



<p align="right">(<a href="#readme-top">Başa dön</a>)</p>

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
},
"prefer-stable": true,
"require": {
"guzzlehttp/guzzle": "^7.8"
"guzzlehttp/guzzle": "^7.8",
"ext-json": "*"
}
}
1 change: 0 additions & 1 deletion config/parasut.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
return [
'username' => env('PARASUT_USERNAME'),
'password' => env('PARASUT_PASSWORD'),
'is_stage' => env('PARASUT_IS_STAGE', 0),
'company_id' => env('PARASUT_COMPANY_ID'),
'client_id' => env('PARASUT_CLIENT_ID'),
'client_secret' => env('PARASUT_CLIENT_SECRET'),
Expand Down
72 changes: 72 additions & 0 deletions src/Models/Other/ApiHome.php
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(),
];
}

}
}
72 changes: 72 additions & 0 deletions src/Models/Other/TrackableJob.php
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(),
];
}

}
}
112 changes: 112 additions & 0 deletions src/Models/Other/Webhook.php
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(),
];
}

}
}

0 comments on commit cf9b5ab

Please sign in to comment.