You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.
Yesterday I tried the API, while it works, but every method requires me to specify the url and token is a bit convoluted, please I don't know why the result is a json string but not jsonified into python dictionary:
Without having to rewrite everything, I have created a helper factory to wrap these 2 pain points:
defsnipeit_api_factory(kls):
""" Return an instance of the wrapped snipe-it API class to avoid specifying url and token for every method And jsonify the result """SNIPEIT_URL=''SNIPEIT_TOKEN=''defjsonify(func):
defwrapper(*args, **kwargs):
returnjson.loads(func(*args, **kwargs))
returnwrapperclassCls(kls):
def__getattribute__(self, item):
attr=kls.__getattribute__(self, item)
ifisinstance(attr, types.MethodType):
returnjsonify(partial(attr, settings.SNIPEIT_URL, settings.SNIPEIT_TOKEN))
returnattrreturnCls()
Yesterday I tried the API, while it works, but every method requires me to specify the url and token is a bit convoluted, please I don't know why the result is a json string but not jsonified into python dictionary:
Without having to rewrite everything, I have created a helper factory to wrap these 2 pain points:
Usage:
If you are happy with this helper I will submit a pull request to add this into the repo.
The text was updated successfully, but these errors were encountered: