Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Run tests

on:
push:
branches: ["*"]
pull_request:

jobs:
phpunit:
runs-on: ubuntu-latest
strategy:
matrix:
php: ["8.1", "8.2"]
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction
- name: Run tests
run: composer test
63 changes: 63 additions & 0 deletions src/Types/AcceptedGiftTypes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\TypeInterface;

class AcceptedGiftTypes extends BaseType implements TypeInterface
{
protected static $requiredParams = ['unlimited_gifts', 'limited_gifts', 'unique_gifts', 'premium_subscription'];

protected static $map = [
'unlimited_gifts' => true,
'limited_gifts' => true,
'unique_gifts' => true,
'premium_subscription' => true,
];

protected $unlimitedGifts;
protected $limitedGifts;
protected $uniqueGifts;
protected $premiumSubscription;

public function getUnlimitedGifts()
{
return $this->unlimitedGifts;
}

public function setUnlimitedGifts($unlimitedGifts)
{
$this->unlimitedGifts = $unlimitedGifts;
}

public function getLimitedGifts()
{
return $this->limitedGifts;
}

public function setLimitedGifts($limitedGifts)
{
$this->limitedGifts = $limitedGifts;
}

public function getUniqueGifts()
{
return $this->uniqueGifts;
}

public function setUniqueGifts($uniqueGifts)
{
$this->uniqueGifts = $uniqueGifts;
}

public function getPremiumSubscription()
{
return $this->premiumSubscription;
}

public function setPremiumSubscription($premiumSubscription)
{
$this->premiumSubscription = $premiumSubscription;
}
}
23 changes: 23 additions & 0 deletions src/Types/ArrayOfGift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TelegramBot\Api\Types;

use TelegramBot\Api\InvalidArgumentException;

abstract class ArrayOfGift
{
/**
* @param array $data
* @return Gift[]
* @throws InvalidArgumentException
*/
public static function fromResponse($data)
{
$array = [];
foreach ($data as $datum) {
$array[] = Gift::fromResponse($datum);
}

return $array;
}
}
23 changes: 23 additions & 0 deletions src/Types/ArrayOfOwnedGift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace TelegramBot\Api\Types;

use TelegramBot\Api\InvalidArgumentException;

abstract class ArrayOfOwnedGift
{
/**
* @param array $data
* @return OwnedGift[]
* @throws InvalidArgumentException
*/
public static function fromResponse($data)
{
$array = [];
foreach ($data as $datum) {
$array[] = OwnedGift::fromResponse($datum);
}

return $array;
}
}
91 changes: 91 additions & 0 deletions src/Types/Gift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\TypeInterface;

/**
* Class Gift
* This object represents a gift that can be sent by the bot.
*/
class Gift extends BaseType implements TypeInterface
{
protected static $requiredParams = ['id', 'sticker', 'star_count'];

protected static $map = [
'id' => true,
'sticker' => Sticker::class,
'star_count' => true,
'upgrade_star_count' => true,
'total_count' => true,
'remaining_count' => true,
];

protected $id;
protected $sticker;
protected $starCount;
protected $upgradeStarCount;
protected $totalCount;
protected $remainingCount;

public function getId()
{
return $this->id;
}

public function setId($id)
{
$this->id = $id;
}

public function getSticker()
{
return $this->sticker;
}

public function setSticker($sticker)
{
$this->sticker = $sticker;
}

public function getStarCount()
{
return $this->starCount;
}

public function setStarCount($starCount)
{
$this->starCount = $starCount;
}

public function getUpgradeStarCount()
{
return $this->upgradeStarCount;
}

public function setUpgradeStarCount($upgradeStarCount)
{
$this->upgradeStarCount = $upgradeStarCount;
}

public function getTotalCount()
{
return $this->totalCount;
}

public function setTotalCount($totalCount)
{
$this->totalCount = $totalCount;
}

public function getRemainingCount()
{
return $this->remainingCount;
}

public function setRemainingCount($remainingCount)
{
$this->remainingCount = $remainingCount;
}
}
111 changes: 111 additions & 0 deletions src/Types/GiftInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\TypeInterface;

class GiftInfo extends BaseType implements TypeInterface
{
protected static $requiredParams = ['gift'];

protected static $map = [
'gift' => Gift::class,
'owned_gift_id' => true,
'convert_star_count' => true,
'prepaid_upgrade_star_count' => true,
'can_be_upgraded' => true,
'text' => true,
'entities' => ArrayOfMessageEntity::class,
'is_private' => true,
];

protected $gift;
protected $ownedGiftId;
protected $convertStarCount;
protected $prepaidUpgradeStarCount;
protected $canBeUpgraded;
protected $text;
protected $entities;
protected $isPrivate;

public function getGift()
{
return $this->gift;
}

public function setGift($gift)
{
$this->gift = $gift;
}

public function getOwnedGiftId()
{
return $this->ownedGiftId;
}

public function setOwnedGiftId($ownedGiftId)
{
$this->ownedGiftId = $ownedGiftId;
}

public function getConvertStarCount()
{
return $this->convertStarCount;
}

public function setConvertStarCount($convertStarCount)
{
$this->convertStarCount = $convertStarCount;
}

public function getPrepaidUpgradeStarCount()
{
return $this->prepaidUpgradeStarCount;
}

public function setPrepaidUpgradeStarCount($prepaidUpgradeStarCount)
{
$this->prepaidUpgradeStarCount = $prepaidUpgradeStarCount;
}

public function getCanBeUpgraded()
{
return $this->canBeUpgraded;
}

public function setCanBeUpgraded($canBeUpgraded)
{
$this->canBeUpgraded = $canBeUpgraded;
}

public function getText()
{
return $this->text;
}

public function setText($text)
{
$this->text = $text;
}

public function getEntities()
{
return $this->entities;
}

public function setEntities($entities)
{
$this->entities = $entities;
}

public function getIsPrivate()
{
return $this->isPrivate;
}

public function setIsPrivate($isPrivate)
{
$this->isPrivate = $isPrivate;
}
}
27 changes: 27 additions & 0 deletions src/Types/Gifts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace TelegramBot\\Api\\Types;

use TelegramBot\\Api\\BaseType;
use TelegramBot\\Api\\TypeInterface;

class Gifts extends BaseType implements TypeInterface
{
protected static $requiredParams = ['gifts'];

protected static $map = [
'gifts' => ArrayOfGift::class,
];

protected $gifts;

public function getGifts()
{
return $this->gifts;
}

public function setGifts($gifts)
{
$this->gifts = $gifts;
}
}
Loading
Loading