-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
331 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
part of 'models.dart'; | ||
|
||
/// Represents a gift that can be sent by the bot. | ||
class Gift { | ||
/// Unique identifier of the gift. | ||
final String id; | ||
|
||
/// The sticker that represents the gift. | ||
final Sticker sticker; | ||
|
||
/// The number of Telegram Stars that must be paid to send the sticker. | ||
final int starCount; | ||
|
||
/// Optional. The total number of gifts of this type that can be sent; for limited gifts only. | ||
final int? totalCount; | ||
|
||
/// Optional. The number of remaining gifts of this type that can be sent; for limited gifts only. | ||
final int? remainingCount; | ||
|
||
/// Creates a [Gift] object. | ||
const Gift({ | ||
required this.id, | ||
required this.sticker, | ||
required this.starCount, | ||
this.totalCount, | ||
this.remainingCount, | ||
}); | ||
|
||
/// Creates a [Gift] object from a JSON map. | ||
factory Gift.fromJson(Map<String, dynamic> json) { | ||
return Gift( | ||
id: json['id'], | ||
sticker: Sticker.fromJson(json['sticker']), | ||
starCount: json['star_count'], | ||
totalCount: json['total_count'], | ||
remainingCount: json['remaining_count'], | ||
); | ||
} | ||
|
||
/// Converts this object to a JSON map. | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'sticker': sticker.toJson(), | ||
'star_count': starCount, | ||
'total_count': totalCount, | ||
'remaining_count': remainingCount, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
part of 'models.dart'; | ||
|
||
/// Represents a list of gifts. | ||
class Gifts { | ||
/// The list of gifts. | ||
final List<Gift> gifts; | ||
|
||
/// Creates a [Gifts] object. | ||
const Gifts({ | ||
required this.gifts, | ||
}); | ||
|
||
/// Creates a [Gifts] object from a JSON map. | ||
factory Gifts.fromJson(Map<String, dynamic> json) { | ||
return Gifts( | ||
gifts: List<Gift>.from( | ||
(json['gifts'] as List).map((gift) => Gift.fromJson(gift)), | ||
), | ||
); | ||
} | ||
|
||
/// Converts this object to a JSON map. | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'gifts': gifts.map((gift) => gift.toJson()).toList(), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
part of 'models.dart'; | ||
|
||
/// Describes an inline message to be sent by a user of a Mini App. | ||
class PreparedInlineMessage { | ||
/// Unique identifier of the prepared message. | ||
final String id; | ||
|
||
/// Expiration date of the prepared message, in Unix time. | ||
/// Expired prepared messages can no longer be used. | ||
final int expirationDate; | ||
|
||
/// Creates a [PreparedInlineMessage] object. | ||
const PreparedInlineMessage({ | ||
required this.id, | ||
required this.expirationDate, | ||
}); | ||
|
||
/// Creates a [PreparedInlineMessage] object from a JSON map. | ||
factory PreparedInlineMessage.fromJson(Map<String, dynamic> json) { | ||
return PreparedInlineMessage( | ||
id: json['id'], | ||
expirationDate: json['expiration_date'], | ||
); | ||
} | ||
|
||
/// Converts this object to a JSON map. | ||
Map<String, dynamic> toJson() { | ||
return { | ||
'id': id, | ||
'expiration_date': expirationDate, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.