diff --git a/README.md b/README.md index fc0717b..b5e89e6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 + +
(Başa dön)
diff --git a/composer.json b/composer.json index d730eff..1d1afd2 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ }, "prefer-stable": true, "require": { - "guzzlehttp/guzzle": "^7.8" + "guzzlehttp/guzzle": "^7.8", + "ext-json": "*" } } diff --git a/config/parasut.php b/config/parasut.php index 71c6dc7..874a73a 100644 --- a/config/parasut.php +++ b/config/parasut.php @@ -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'), diff --git a/src/Models/Other/ApiHome.php b/src/Models/Other/ApiHome.php new file mode 100644 index 0000000..54f2974 --- /dev/null +++ b/src/Models/Other/ApiHome.php @@ -0,0 +1,72 @@ +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(), + ]; + } + + } +} \ No newline at end of file diff --git a/src/Models/Other/TrackableJob.php b/src/Models/Other/TrackableJob.php new file mode 100644 index 0000000..16eed32 --- /dev/null +++ b/src/Models/Other/TrackableJob.php @@ -0,0 +1,72 @@ +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(), + ]; + } + + } +} \ No newline at end of file diff --git a/src/Models/Other/Webhook.php b/src/Models/Other/Webhook.php new file mode 100644 index 0000000..a8fe9b9 --- /dev/null +++ b/src/Models/Other/Webhook.php @@ -0,0 +1,112 @@ +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(), + ]; + } + + } +} \ No newline at end of file