|
| 1 | +# cython: language=c++ |
| 2 | +# cython: language_level=3 |
| 3 | +# cython: binding=True |
| 4 | +# cython: cdivision=True |
| 5 | +# cython: boundscheck=False |
| 6 | +# cython: initializedcheck=False |
| 7 | +import re |
| 8 | +from typing import Any, Dict, Optional |
| 9 | + |
| 10 | +from flask_inputfilter.Exception import ValidationError |
| 11 | +from flask_inputfilter.Model import ExternalApiConfig |
| 12 | + |
| 13 | + |
1 | 14 | cdef class ExternalApiMixin: |
2 | 15 |
|
3 | | - @staticmethod |
4 | | - cdef Optional[object] callExternalApi( |
5 | | - config: ExternalApiConfig, fallback: Any, validated_data: Dict[str, Any] |
| 16 | + cpdef Optional[object] callExternalApi( |
| 17 | + self, config: ExternalApiConfig, fallback: Any, validated_data: Dict[str, Any] |
6 | 18 | ): |
7 | 19 | """ |
8 | 20 | Makes a call to an external API using provided configuration and |
@@ -59,11 +71,11 @@ cdef class ExternalApiMixin: |
59 | 71 | requestData["headers"].update(config.headers) |
60 | 72 |
|
61 | 73 | if config.params: |
62 | | - requestData["params"] = InputFilter.replacePlaceholdersInParams( |
| 74 | + requestData["params"] = ExternalApiMixin.replacePlaceholdersInParams( |
63 | 75 | config.params, validated_data |
64 | 76 | ) |
65 | 77 |
|
66 | | - requestData["url"] = InputFilter.replacePlaceholders( |
| 78 | + requestData["url"] = ExternalApiMixin.replacePlaceholders( |
67 | 79 | config.url, validated_data |
68 | 80 | ) |
69 | 81 | requestData["method"] = config.method |
@@ -142,7 +154,7 @@ cdef class ExternalApiMixin: |
142 | 154 | with the corresponding values from validated_data. |
143 | 155 | """ |
144 | 156 | return { |
145 | | - key: InputFilter.replacePlaceholders(value, validated_data) |
| 157 | + key: ExternalApiMixin.replacePlaceholders(value, validated_data) |
146 | 158 | if isinstance(value, str) |
147 | 159 | else value |
148 | 160 | for key, value in params.items() |
|
0 commit comments