| 77 | } |
| 78 | |
| 79 | protected async post<T>( |
| 80 | endpoint: string, |
| 81 | data?: Record<string, unknown>, |
| 82 | config?: AxiosRequestConfig, |
| 83 | ttl?: number |
| 84 | ): Promise<T> { |
| 85 | const cacheKey = this.serializeCacheKey(endpoint, { |
| 86 | config: config?.params, |
| 87 | ...(data ? { data } : {}), |
| 88 | }); |
| 89 | |
| 90 | const cachedItem = this.cache?.get<T>(cacheKey); |
| 91 | if (cachedItem) { |
| 92 | return cachedItem; |
| 93 | } |
| 94 | |
| 95 | const response = await this.axios.post<T>(endpoint, data, config); |
| 96 | |
| 97 | if (this.cache && ttl !== 0) { |
| 98 | this.cache.set(cacheKey, response.data, ttl ?? DEFAULT_TTL); |
| 99 | } |
| 100 | |
| 101 | return response.data; |
| 102 | } |
| 103 | |
| 104 | protected async getRolling<T>( |
| 105 | endpoint: string, |