forked from saleweaver/python-amazon-sp-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.py.jinja2
35 lines (27 loc) · 1.21 KB
/
template.py.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import urllib.parse
from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse
class {{ endpoint }}(Client):
"""
{{ endpoint }} SP-API Client
:link: {{ docs_link }}
{{ description }}
"""
{% for operation in operations %}
@sp_endpoint('{{ operation.uri }}', method='{{ operation.method }}')
def {{ operation.title }}(self, {{ (operation.query_param + ', ') if operation.has_query_params }}**kwargs) -> ApiResponse:
"""
{{ operation.title }}(self, {{ (operation.query_param + ', ') if operation.has_query_params }}**kwargs) -> ApiResponse
{{ operation.description }}
Args:
{% for arg in operation.params %}
{{ 'key ' if arg['in'] == 'query' else ''}}{{ arg.name }}:{{ arg.type }} | {{ '* REQUIRED' if arg.required else '' }} {{ arg.description }}
{% endfor %}
Returns:
ApiResponse:
"""
{% if operation.has_query_params %}
return self._request(fill_query_params(kwargs.pop('path'), {{ operation.query_param }}), {{ operation.params_or_data }}=kwargs)
{% else %}
return self._request(kwargs.pop('path'), {{ operation.params_or_data }}=kwargs)
{% endif %}
{% endfor %}