mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-23 22:16:50 +00:00
Added getSubscriptions method
This commit is contained in:
@@ -6,6 +6,7 @@ namespace BushlanovDev\MaxMessengerBot;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
|
||||
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Subscription;
|
||||
|
||||
/**
|
||||
* Creates DTOs from raw associative arrays returned by the API client.
|
||||
@@ -13,6 +14,8 @@ use BushlanovDev\MaxMessengerBot\Models\BotInfo;
|
||||
class ModelFactory
|
||||
{
|
||||
/**
|
||||
* Information about the current bot.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return BotInfo
|
||||
@@ -24,4 +27,30 @@ class ModelFactory
|
||||
|
||||
return BotInfo::fromArray($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about webhook subscription.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return Subscription
|
||||
*/
|
||||
public function createSubscription(array $data): Subscription
|
||||
{
|
||||
return Subscription::fromArray($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* List of all active webhook subscriptions.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return Subscription[]
|
||||
*/
|
||||
public function createSubscriptions(array $data): array
|
||||
{
|
||||
return isset($data['subscriptions']) && is_array($data['subscriptions'])
|
||||
? array_map([$this, 'createSubscription'], $data['subscriptions'])
|
||||
: [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user