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\HttpClientFactoryInterface
interface 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): SmsTransactionCollection
This 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\ServiceId
class 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): SmsTransaction
This 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\ServiceId
class representing the ID of the SMS service to retrieve the transaction for.$transactionId
- An instance of theSimpay\Model\Request\SmsTransactionId
class 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;