Coverage for src/backend/InvenTree/plugin/samples/integration/api_caller.py: 0%
10 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 17:47 +0000
1"""Sample plugin for calling an external API."""
3from plugin import InvenTreePlugin
4from plugin.mixins import APICallMixin, SettingsMixin
7class SampleApiCallerPlugin(APICallMixin, SettingsMixin, InvenTreePlugin):
8 """A small api call sample."""
10 NAME = 'Sample API Caller'
12 SETTINGS = {
13 'API_TOKEN': {
14 'name': 'API Token',
15 'protected': True,
16 'default': 'reqres-free-v1',
17 },
18 'API_URL': {
19 'name': 'External URL',
20 'description': 'Where is your API located?',
21 'default': 'api.example.com',
22 },
23 }
24 API_URL_SETTING = 'API_URL'
25 API_TOKEN_SETTING = 'API_TOKEN'
26 API_TOKEN = 'x-api-key'
28 def get_external_url(self):
29 """Returns data from the sample endpoint."""
30 return self.api_call('api/users/2')