<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class SteadfastService
{
protected $apiKey;
protected $apiSecret;
protected $baseUrl;
public function __construct()
{
$this->apiKey = env('ST_API_KEY');
$this->apiSecret = env('ST_SECRET_KEY');
$this->baseUrl = env('ST_BASE_URL');
}
protected function getHeaders()
{
return [
'Api-Key' => $this->apiKey,
'Secret-Key' => $this->apiSecret,
'Content-Type' => 'application/json',
];
}
public function createShipment(array $data)
{
$response = Http::withHeaders($this->getHeaders())
->post("{$this->baseUrl}/create_order", $data);
// dd($response);
return $response->json();
}
public function getShipmentStatus($shipmentId)
{
$response = Http::withHeaders($this->getHeaders())
->get("{$this->baseUrl}/shipments/{$shipmentId}");
return $response->json();
}
// Add more methods if needed for other API endpoints
}