diff --git a/InvenTree/plugin/samples/integration/api_caller.py b/InvenTree/plugin/samples/integration/api_caller.py new file mode 100644 index 0000000000..eaef93a4b6 --- /dev/null +++ b/InvenTree/plugin/samples/integration/api_caller.py @@ -0,0 +1,34 @@ +""" +Sample plugin for calling an external API +""" +from django.utils.translation import ugettext_lazy as _ + +from plugin import IntegrationPluginBase +from plugin.mixins import APICallMixin, SettingsMixin + + +class SampleApiCallerPlugin(APICallMixin, SettingsMixin, IntegrationPluginBase): + """ + A small api call sample + """ + PLUGIN_NAME = "Sample API Caller" + + SETTINGS = { + 'API_TOKEN': { + 'name': 'API Token', + 'protected': True, + }, + 'API_URL': { + 'name': 'External URL', + 'description': 'Where is your API located?', + 'default': 'https://reqres.in', + }, + } + API_URL_SETTING = 'API_URL' + API_TOKEN_SETTING = 'API_TOKEN' + + def get_external_url(self): + """ + returns data from the sample endpoint + """ + return self.api_call('api/users/2')