Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
a.kalin committed Dec 21, 2024
1 parent 6e304a2 commit 370d992
Show file tree
Hide file tree
Showing 28 changed files with 2,677 additions and 77 deletions.
448 changes: 422 additions & 26 deletions src/Client.php

Large diffs are not rendered by default.

209 changes: 209 additions & 0 deletions src/Type/AffiliateInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<?php declare(strict_types=1);

namespace MadmagesTelegram\Types\Type;

use JMS\Serializer\Annotation\ExclusionPolicy;
use JMS\Serializer\Annotation\AccessType;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;

/**
* https://core.telegram.org/bots/api#affiliateinfo
*
* Contains information about the affiliate that received a commission via this transaction.
*
* @ExclusionPolicy("none")
* @AccessType("public_method")
*/
class AffiliateInfo extends AbstractType
{

/**
* Returns raw names of properties of this type
*
* @return string[]
*/
public static function _getPropertyNames(): array
{
return [
'affiliate_user',
'affiliate_chat',
'commission_per_mille',
'amount',
'nanostar_amount',
];
}

/**
* Returns associative array of raw data
*
* @return array
*/
public function _getData(): array
{
$result = [
'affiliate_user' => $this->getAffiliateUser(),
'affiliate_chat' => $this->getAffiliateChat(),
'commission_per_mille' => $this->getCommissionPerMille(),
'amount' => $this->getAmount(),
'nanostar_amount' => $this->getNanostarAmount(),
];

return parent::normalizeData($result);
}

/**
* Optional. The bot or the user that received an affiliate commission if it was received by a bot or a user
*
* @var User|null
* @SkipWhenEmpty
* @SerializedName("affiliate_user")
* @Accessor(getter="getAffiliateUser", setter="setAffiliateUser")
* @Type("MadmagesTelegram\Types\Type\User")
*/
protected $affiliateUser;

/**
* Optional. The chat that received an affiliate commission if it was received by a chat
*
* @var Chat|null
* @SkipWhenEmpty
* @SerializedName("affiliate_chat")
* @Accessor(getter="getAffiliateChat", setter="setAffiliateChat")
* @Type("MadmagesTelegram\Types\Type\Chat")
*/
protected $affiliateChat;

/**
* The number of Telegram Stars received by the affiliate for each 1000 Telegram Stars received by the bot from referred
* users
*
* @var int
* @SerializedName("commission_per_mille")
* @Accessor(getter="getCommissionPerMille", setter="setCommissionPerMille")
* @Type("int")
*/
protected $commissionPerMille;

/**
* Integer amount of Telegram Stars received by the affiliate from the transaction, rounded to 0; can be negative for
* refunds
*
* @var int
* @SerializedName("amount")
* @Accessor(getter="getAmount", setter="setAmount")
* @Type("int")
*/
protected $amount;

/**
* Optional. The number of 1/1000000000 shares of Telegram Stars received by the affiliate; from -999999999 to
* 999999999; can be negative for refunds
*
* @var int|null
* @SkipWhenEmpty
* @SerializedName("nanostar_amount")
* @Accessor(getter="getNanostarAmount", setter="setNanostarAmount")
* @Type("int")
*/
protected $nanostarAmount;


/**
* @param User $affiliateUser
* @return static
*/
public function setAffiliateUser(User $affiliateUser): self
{
$this->affiliateUser = $affiliateUser;

return $this;
}

/**
* @return User|null
*/
public function getAffiliateUser(): ?User
{
return $this->affiliateUser;
}

/**
* @param Chat $affiliateChat
* @return static
*/
public function setAffiliateChat(Chat $affiliateChat): self
{
$this->affiliateChat = $affiliateChat;

return $this;
}

/**
* @return Chat|null
*/
public function getAffiliateChat(): ?Chat
{
return $this->affiliateChat;
}

/**
* @param int $commissionPerMille
* @return static
*/
public function setCommissionPerMille(int $commissionPerMille): self
{
$this->commissionPerMille = $commissionPerMille;

return $this;
}

/**
* @return int
*/
public function getCommissionPerMille(): int
{
return $this->commissionPerMille;
}

/**
* @param int $amount
* @return static
*/
public function setAmount(int $amount): self
{
$this->amount = $amount;

return $this;
}

/**
* @return int
*/
public function getAmount(): int
{
return $this->amount;
}

/**
* @param int $nanostarAmount
* @return static
*/
public function setNanostarAmount(int $nanostarAmount): self
{
$this->nanostarAmount = $nanostarAmount;

return $this;
}

/**
* @return int|null
*/
public function getNanostarAmount(): ?int
{
return $this->nanostarAmount;
}

}
39 changes: 36 additions & 3 deletions src/Type/ChatBoostSourceGiveaway.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
/**
* https://core.telegram.org/bots/api#chatboostsourcegiveaway
*
* The boost was obtained by the creation of a Telegram Premium giveaway. This boosts the chat 4 times for the duration of
* the corresponding Telegram Premium subscription.
* The boost was obtained by the creation of a Telegram Premium or a Telegram Star giveaway. This boosts the chat 4 times
* for the duration of the corresponding Telegram Premium subscription for Telegram Premium giveaways and
* prize_star_count / 500 times for one year for Telegram Star giveaways.
*
* @ExclusionPolicy("none")
* @AccessType("public_method")
Expand All @@ -32,6 +33,7 @@ public static function _getPropertyNames(): array
'source',
'giveaway_message_id',
'user',
'prize_star_count',
'is_unclaimed',
];
}
Expand All @@ -47,6 +49,7 @@ public function _getData(): array
'source' => $this->getSource(),
'giveaway_message_id' => $this->getGiveawayMessageId(),
'user' => $this->getUser(),
'prize_star_count' => $this->getPrizeStarCount(),
'is_unclaimed' => $this->getIsUnclaimed(),
];

Expand Down Expand Up @@ -75,7 +78,7 @@ public function _getData(): array
protected $giveawayMessageId;

/**
* Optional. User that won the prize in the giveaway if any
* Optional. User that won the prize in the giveaway if any; for Telegram Premium giveaways only
*
* @var User|null
* @SkipWhenEmpty
Expand All @@ -85,6 +88,17 @@ public function _getData(): array
*/
protected $user;

/**
* Optional. The number of Telegram Stars to be split between giveaway winners; for Telegram Star giveaways only
*
* @var int|null
* @SkipWhenEmpty
* @SerializedName("prize_star_count")
* @Accessor(getter="getPrizeStarCount", setter="setPrizeStarCount")
* @Type("int")
*/
protected $prizeStarCount;

/**
* Optional. True, if the giveaway was completed, but there was no user to win the prize
*
Expand Down Expand Up @@ -154,6 +168,25 @@ public function getUser(): ?User
return $this->user;
}

/**
* @param int $prizeStarCount
* @return static
*/
public function setPrizeStarCount(int $prizeStarCount): self
{
$this->prizeStarCount = $prizeStarCount;

return $this;
}

/**
* @return int|null
*/
public function getPrizeStarCount(): ?int
{
return $this->prizeStarCount;
}

/**
* @param bool $isUnclaimed
* @return static
Expand Down
65 changes: 65 additions & 0 deletions src/Type/ChatInviteLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public static function _getPropertyNames(): array
'expire_date',
'member_limit',
'pending_join_request_count',
'subscription_period',
'subscription_price',
];
}

Expand All @@ -57,6 +59,8 @@ public function _getData(): array
'expire_date' => $this->getExpireDate(),
'member_limit' => $this->getMemberLimit(),
'pending_join_request_count' => $this->getPendingJoinRequestCount(),
'subscription_period' => $this->getSubscriptionPeriod(),
'subscription_price' => $this->getSubscriptionPrice(),
];

return parent::normalizeData($result);
Expand Down Expand Up @@ -158,6 +162,29 @@ public function _getData(): array
*/
protected $pendingJoinRequestCount;

/**
* Optional. The number of seconds the subscription will be active for before the next payment
*
* @var int|null
* @SkipWhenEmpty
* @SerializedName("subscription_period")
* @Accessor(getter="getSubscriptionPeriod", setter="setSubscriptionPeriod")
* @Type("int")
*/
protected $subscriptionPeriod;

/**
* Optional. The amount of Telegram Stars a user must pay initially and after each subsequent subscription period to be
* a member of the chat using the link
*
* @var int|null
* @SkipWhenEmpty
* @SerializedName("subscription_price")
* @Accessor(getter="getSubscriptionPrice", setter="setSubscriptionPrice")
* @Type("int")
*/
protected $subscriptionPrice;


/**
* @param string $inviteLink
Expand Down Expand Up @@ -330,4 +357,42 @@ public function getPendingJoinRequestCount(): ?int
return $this->pendingJoinRequestCount;
}

/**
* @param int $subscriptionPeriod
* @return static
*/
public function setSubscriptionPeriod(int $subscriptionPeriod): self
{
$this->subscriptionPeriod = $subscriptionPeriod;

return $this;
}

/**
* @return int|null
*/
public function getSubscriptionPeriod(): ?int
{
return $this->subscriptionPeriod;
}

/**
* @param int $subscriptionPrice
* @return static
*/
public function setSubscriptionPrice(int $subscriptionPrice): self
{
$this->subscriptionPrice = $subscriptionPrice;

return $this;
}

/**
* @return int|null
*/
public function getSubscriptionPrice(): ?int
{
return $this->subscriptionPrice;
}

}
Loading

0 comments on commit 370d992

Please sign in to comment.