Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rifkybujana
Copy link

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.

@rifkybujana
Copy link
Author

It would be awesome if someone can review it and do some test on it.

@assulthoni
Copy link

That's really awesome!

@isandyawan isandyawan self-requested a review October 15, 2023 10:23
"""

@wraps(func)
def decorated(*args, **kwargs):
Copy link
Collaborator

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

Copy link
Author

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?

Copy link
Collaborator

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'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants