|
1 | 1 | openapi: 3.0.3 |
2 | 2 | info: |
3 | | - title: Supabase → Z-API (Documentação) |
| 3 | + title: Supabase → Z-API (Docs) |
4 | 4 | version: "1.0.0" |
5 | 5 | description: | |
6 | | - Documentação do fluxo de envio de WhatsApp: |
7 | | - - Busca contatos ativos no Supabase |
| 6 | + Documentação ilustrativa do fluxo: |
| 7 | + - Lê contatos ativos no Supabase |
8 | 8 | - Envia mensagem personalizada via Z-API |
9 | 9 |
|
10 | 10 | servers: |
11 | | - - url: http://localhost # apenas ilustrativo |
| 11 | + - url: http://localhost |
| 12 | + description: "Somente ilustrativo (não há servidor HTTP neste projeto)" |
12 | 13 |
|
13 | 14 | paths: |
14 | 15 | /contacts: |
15 | 16 | get: |
16 | | - summary: Listar contatos ativos (fonte: Supabase) |
17 | | - description: | |
18 | | - Equivalente ao que `fetch_contacts(limit)` faz no código. |
| 17 | + summary: "Listar contatos ativos (Supabase)" |
| 18 | + description: > |
| 19 | + Este endpoint é apenas documentação do que o script faz ao consultar o Supabase. |
| 20 | + Não existe rota HTTP no projeto; isto é uma representação. |
19 | 21 | parameters: |
20 | 22 | - in: query |
21 | 23 | name: limit |
22 | | - schema: { type: integer, minimum: 1, default: 3 } |
23 | | - description: Número máximo de contatos |
| 24 | + required: false |
| 25 | + schema: |
| 26 | + type: integer |
| 27 | + minimum: 1 |
| 28 | + default: 3 |
| 29 | + description: "Número máximo de contatos" |
24 | 30 | responses: |
25 | 31 | "200": |
26 | | - description: Contatos retornados |
| 32 | + description: "Contatos retornados" |
27 | 33 | content: |
28 | 34 | application/json: |
29 | 35 | schema: |
30 | | - type: object |
31 | | - properties: |
32 | | - count: { type: integer } |
33 | | - items: |
34 | | - type: array |
35 | | - items: |
36 | | - $ref: "#/components/schemas/Contact" |
| 36 | + $ref: "#/components/schemas/ContactsResponse" |
37 | 37 | examples: |
38 | | - exemplo: |
| 38 | + demo: |
39 | 39 | value: |
40 | 40 | count: 3 |
41 | 41 | items: |
42 | | - - id: "1206b580-ea..." |
| 42 | + - id: "1206b580-aaaa-bbbb-cccc-111111111111" |
43 | 43 | name: "Breno" |
44 | 44 | phone: "5518996628576" |
45 | 45 | active: true |
46 | | - - id: "a839c618-95e..." |
| 46 | + - id: "a389c618-aaaa-bbbb-cccc-222222222222" |
47 | 47 | name: "Washington" |
48 | 48 | phone: "5511948054059" |
49 | 49 | active: true |
| 50 | + - id: "dba0426c-aaaa-bbbb-cccc-333333333333" |
| 51 | + name: "Carla" |
| 52 | + phone: "5581999999999" |
| 53 | + active: true |
50 | 54 |
|
51 | | - /send: |
| 55 | + /send-message: |
52 | 56 | post: |
53 | | - summary: Disparar envio de mensagens |
54 | | - description: | |
55 | | - Para cada contato retornado do Supabase, envia |
56 | | - **"Olá {nome}, tudo bem com você?"** via Z-API. |
| 57 | + summary: "Enviar mensagem via Z-API" |
| 58 | + description: > |
| 59 | + Documenta a chamada que o script faz para a Z-API usando o header `Client-Token`. |
| 60 | + Representação apenas para fins de documentação. |
57 | 61 | requestBody: |
58 | | - required: false |
| 62 | + required: true |
59 | 63 | content: |
60 | 64 | application/json: |
61 | 65 | schema: |
62 | | - type: object |
63 | | - properties: |
64 | | - limit: |
65 | | - type: integer |
66 | | - description: Número de contatos a enviar |
67 | | - default: 3 |
| 66 | + $ref: "#/components/schemas/SendMessageRequest" |
| 67 | + examples: |
| 68 | + demo: |
| 69 | + value: |
| 70 | + phone: "5511999999999" |
| 71 | + message: "Ola Breno, tudo bem com voce?" |
68 | 72 | responses: |
69 | 73 | "200": |
70 | | - description: Resultado do disparo |
| 74 | + description: "Resposta encaminhada da Z-API" |
71 | 75 | content: |
72 | 76 | application/json: |
73 | 77 | schema: |
74 | | - $ref: "#/components/schemas/SendResponse" |
75 | | - examples: |
76 | | - sucesso: |
77 | | - value: |
78 | | - sent: 3 |
79 | | - failed: 0 |
80 | | - results: |
81 | | - - id: "a839c618-95e..." |
82 | | - name: "Washington" |
83 | | - phone: "5511948054059" |
84 | | - ok: true |
85 | | - status: 200 |
86 | | - - id: "1206b580-ea..." |
87 | | - name: "Breno" |
88 | | - phone: "5518996628576" |
89 | | - ok: true |
90 | | - status: 200 |
| 78 | + $ref: "#/components/schemas/SendMessageResponse" |
| 79 | + "400": |
| 80 | + description: "Payload invalido ou token ausente" |
91 | 81 |
|
92 | 82 | components: |
93 | 83 | schemas: |
94 | 84 | Contact: |
95 | 85 | type: object |
| 86 | + required: [id, name, phone, active] |
96 | 87 | properties: |
97 | | - id: { type: string, format: uuid } |
98 | | - name: { type: string } |
99 | | - phone: { type: string, description: "Somente dígitos (E.164 sem '+')" } |
100 | | - active: { type: boolean } |
101 | | - required: [name, phone] |
| 88 | + id: |
| 89 | + type: string |
| 90 | + format: uuid |
| 91 | + name: |
| 92 | + type: string |
| 93 | + phone: |
| 94 | + type: string |
| 95 | + description: "Numero E.164 apenas digitos (ex.: 5511999999999)" |
| 96 | + active: |
| 97 | + type: boolean |
102 | 98 |
|
103 | | - SendItem: |
| 99 | + ContactsResponse: |
104 | 100 | type: object |
105 | 101 | properties: |
106 | | - id: { type: string, nullable: true } |
107 | | - name: { type: string } |
108 | | - phone: { type: string } |
109 | | - ok: { type: boolean } |
110 | | - status: { type: integer, nullable: true } |
111 | | - error: { type: string, nullable: true } |
| 102 | + count: |
| 103 | + type: integer |
| 104 | + items: |
| 105 | + type: array |
| 106 | + items: |
| 107 | + $ref: "#/components/schemas/Contact" |
112 | 108 |
|
113 | | - SendResponse: |
| 109 | + SendMessageRequest: |
114 | 110 | type: object |
| 111 | + required: [phone, message] |
115 | 112 | properties: |
116 | | - sent: { type: integer } |
117 | | - failed: { type: integer } |
118 | | - results: |
119 | | - type: array |
120 | | - items: { $ref: "#/components/schemas/SendItem" } |
| 113 | + phone: |
| 114 | + type: string |
| 115 | + example: "5511999999999" |
| 116 | + message: |
| 117 | + type: string |
| 118 | + example: "Ola Breno, tudo bem com voce?" |
121 | 119 |
|
122 | | - securitySchemes: |
123 | | - ZapiClientToken: |
124 | | - type: apiKey |
125 | | - in: header |
126 | | - name: Client-Token |
127 | | - description: Token configurado na aba Segurança da Z-API |
128 | | - |
129 | | -security: |
130 | | - - ZapiClientToken: [] |
| 120 | + SendMessageResponse: |
| 121 | + type: object |
| 122 | + properties: |
| 123 | + ok: |
| 124 | + type: boolean |
| 125 | + example: true |
| 126 | + status: |
| 127 | + type: integer |
| 128 | + example: 200 |
| 129 | + data: |
| 130 | + type: object |
| 131 | + nullable: true |
| 132 | + example: |
| 133 | + messageId: "abcd-1234" |
0 commit comments