Make API more Dart-y #99
Labels
challenge accepted
Enhancement or feature request accepted
enhancement
New feature or request
good first issue
Good for newcomers
I like the distinction of
telegram
andteledart
– one is a simple typed wrapper around web requests, the other one a full-fledged powerful API that uses the capabilities of object-oriented programming. Some aspects like the inline mode are really great, but I think other parts could be a bit better.For example, most requests still need to be made through the
teledart
instance with the exception of replies. I'd love it if you could simply send a message to a chat if you got hold of theChat
. Something likechat.send('Some text.')
.Also, most fields currently have the name from the API in
snake_case
instead of using an adaptedcamelCase
version. The typing could also be a bit stronger. For example, we could create aChatId
class to represent a reference to aChat
. Then we could do stuff like this:We could also introduce classes for several other concepts to make them type-safe. Take photos for example. Currently, the
telegram.sendPhoto
function acceptsdynamic
as a photo and developers are forced to go to the Telegram API documentation to find out what they can send, but we could also create aPhoto
class which gets subclassed byPhotoUrl
, andPhotoFile
. Users could then create photos usingPhoto.fromUrl(…)
andPhoto.fromFile(…)
constructors, which makes the API easier to use and explore.Let me know what you think about this. I'd be happy to help implementing these changes.
The text was updated successfully, but these errors were encountered: