The Simpay\SmsTransactionApi class implements the Simpay\SmsTransactionInterface and is used to interact with the Simpay SMS Transaction API.
| Name | Type | Description |
|---|---|---|
$client |
ClientInterface | The HTTP client used to make requests to the API |
public function __construct(HttpClientFactoryInterface $factory)This method is the constructor of the Simpay\SmsTransactionApi class. It takes in one parameter:
$factory- An instance of theSimpay\HttpClientFactoryInterfaceinterface used to create the HTTP client used to make requests to the API.
It sets the $client property to the client created by the factory.
public function smsTransactionsList(ServiceId $serviceId): SmsTransactionCollectionThis method sends a GET request to the Simpay SMS Transaction API to retrieve a list of transactions for a specific SMS service. It takes in one parameter:
$serviceId- An instance of theSimpay\Model\Request\ServiceIdclass representing the ID of the SMS service to retrieve transactions for.
It returns a Simpay\Model\Response\SmsTransactionCollection object.
public function smsTransactionsShow(ServiceId $serviceId, SmsTransactionId $transactionId): SmsTransactionThis method sends a GET request to the Simpay SMS Transaction API to retrieve a specific transaction for a specific SMS service. It takes in two parameters:
$serviceId- An instance of theSimpay\Model\Request\ServiceIdclass representing the ID of the SMS service to retrieve the transaction for.$transactionId- An instance of theSimpay\Model\Request\SmsTransactionIdclass representing the ID of the SMS transaction to retrieve.
It returns a Simpay\Model\Response\SmsTransaction object.
$httpFactory = new HttpClientFactory('https://api.simpay.pl', '123456', 'qwerty');
$smsTransactionApi = new SmsTransactionApi($httpFactory);
$serviceId = new ServiceId('abc123');
$transactions = $smsTransactionApi->smsTransactionsList($serviceId);
foreach ($transactions->data as $transaction) {
echo $transaction->id . PHP_EOL;
}
$transaction = $smsTransactionApi->smsTransactionsShow($serviceId, new SmsTransactionId('def456'));
echo $transaction->id;