plazbot-cli 0.2.19 → 0.2.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ // Utilidades para llamadas directas al API de Plazbot
2
+ // Usado por comandos que no tienen clase SDK (ej: workers)
3
+
4
+ import axios, { AxiosInstance } from 'axios';
5
+
6
+ interface ApiClientOptions {
7
+ apiKey: string;
8
+ workspace: string;
9
+ zone: 'LA' | 'EU';
10
+ dev?: boolean;
11
+ }
12
+
13
+ function getBaseUrl(zone: string, dev?: boolean): string {
14
+ if (dev) return 'http://localhost:5090';
15
+ return zone === 'EU' ? 'https://apieu.plazbot.com' : 'https://api.plazbot.com';
16
+ }
17
+
18
+ export function createApiClient(options: ApiClientOptions): AxiosInstance {
19
+ const baseURL = getBaseUrl(options.zone, options.dev);
20
+
21
+ return axios.create({
22
+ baseURL,
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ 'x-api-key': options.apiKey,
26
+ 'x-workspace-id': options.workspace,
27
+ },
28
+ });
29
+ }