-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor WebAPI Requests Code #6
base: main
Are you sure you want to change the base?
Conversation
It would be awesome if someone can review it and do some test on it. |
That's really awesome! |
""" | ||
|
||
@wraps(func) | ||
def decorated(*args, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very love your propose to create universal function to interact with webapi. Unfortunately this function not working well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May i know details on the result or error produced by the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below result when call client.view_publication('0000','0') :
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/my-user/Documents/GitHub/stadata/stadata/main.py", line 567, in view_publication res = self.__get_view(domain=domain,model='publication',idx=id,lang='ind') File "/Users/my-user/Documents/GitHub/stadata/stadata/main.py", line 174, in __get_view return requests_model.view(self.TOKEN) File "/Users/my-user/Documents/GitHub/stadata/stadata/main.py", line 22, in decorated if args[0].TOKEN == '': AttributeError: 'RequestModel' object has no attribute 'TOKEN'
I have made significant changes to the web API request to make it more modular, simpler, and easier to read. Although, it might require some tests to make sure everything still running okay. I've used decorator to validate each request instead of writing a repetitive
if(res.status_code != 200): ...
, and make each request url easier to edit by combining it into one class.