4doom4 / python-voipms

Python client for v1 of voip.ms REST API
MIT License
24 stars 12 forks source link

Missing methods #19

Closed JohnMertz closed 6 months ago

JohnMertz commented 7 months ago

While looking for other collisions, I noticed that a few other methods that I'm interested in were not yet implemented. Since I don't know what I might need in the future, I just scraped the whole API docs page, de-duplicated the methods that already exist and imported the rest as closely as possible to the way that all of the existing methods are implemented.

None of the methods are tested, but the library imports correctly and tests pass. I have no doubt that some of the methods will be broken because the API documentation is not great and does not declare types for many parameters. That said, this should not break any existing methods since the only existing methods that I touched were other methods with parameter collisions which would not have worked in the first place.

4doom4 commented 6 months ago

@JohnMertz out of curiosity did you scrap this by hand or did you use a script for it?

JohnMertz commented 6 months ago

A combination. It was very ad hoc.

First, I just used some Bash to filter the names of all of the methods that were already supported to create an ignore list. I then just copy and pasted the description table and usage table into two separate files which I manually cleaned up with substitutions in Vim. Then, since I'm way better with Perl, especially with RegEx, I used that to ingest those files into a hash and output the general format for each method description and argument list (basically only the commented parts, a stub for def method(), setting the method variable and the get request call). I then spent probably 6-7 hours cleaning it up, merging it into the existing files or creating new one, and then actually copying, pasting and modifying the actual argument validation from similar methods that you had already defined. It was pretty mindless work, so I did it while watching YouTube. :)

I wish I could say that there was a beautiful script that handled the whole thing, but in truth it was mostly a bunch of stringed together 1-liners.

4doom4 commented 6 months ago

WOW Thanks for your effort. Will roll it in!

4doom4 commented 6 months ago

@JohnMertz we should also build a new pip package. I will see if I can do this this weekend

4doom4 commented 6 months ago

@JohnMertz I just deployed the package on pypi. hope this will be helpful for others