OSCA-Kampala-Chapter / autobot

Autobot is a bot library targetted to build software bots for various platforms with ease of integration in mind
MIT License
14 stars 15 forks source link

replace parameters in api methods with keyword arguments #148

Closed TobiasHT5 closed 1 year ago

TobiasHT5 commented 1 year ago

The different parameters in all classes in api modules should be removed and replaced with **kwargs. This will help us remove the overhead of constructing a dictionary needed to make api requests. The docstrings and return value can remain the same

TobiasHT5 commented 1 year ago

@ushergodwin can you handle this?

ushergodwin commented 1 year ago

Sure, I can. How do you intend to handle required parameters during method implementation?

Check the existence of required parameters in kwargs, then throw an exception if any are missing?

How about having positional required argument, ( can also be *args) and then the optional ones can go in (**kwargs).

Am looking for away that wouldn't involve a lot of processing while validating the method calls.

Let me know what you think.

TobiasHT5 commented 1 year ago

@ushergodwin we shall delegate the task of checking for required arguments off to telegram. We shall pass on the error raised by telegram to the handler if a request fails. for example, this is an error raised by telegram if we send a message using "sendMessage" but without a message text

{"ok":"false",
"error_code":400,
"description":"Bad Request: message text is empty"
}
ushergodwin commented 1 year ago

@ht-thomas Ohh, okay, that's more convenient. Thanks for the clarification.