Browse Source

chore: open api spec and doc

pull/118/head
Aldino Kemal 2 years ago
parent
commit
0f7101e97d
  1. 57
      docs/openapi.yaml
  2. 17
      readme.md
  3. 2
      src/domains/send/poll.go
  4. 13
      src/views/components/SendPoll.js

57
docs/openapi.yaml

@ -1,7 +1,7 @@
openapi: 3.0.0 openapi: 3.0.0
info: info:
title: WhatsApp API MultiDevice title: WhatsApp API MultiDevice
version: 3.7.0
version: 3.8.0
description: This API is used for sending whatsapp via API description: This API is used for sending whatsapp via API
servers: servers:
- url: http://localhost:3000 - url: http://localhost:3000
@ -548,6 +548,61 @@ paths:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/ErrorInternalServer' $ref: '#/components/schemas/ErrorInternalServer'
/send/poll:
post:
operationId: sendPoll
tags:
- send
summary: Send Poll / Vote
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
phone:
type: string
description: The WhatsApp phone number to send the poll to, including the '@s.whatsapp.net' suffix.
example: '6289685024421@s.whatsapp.net'
question:
type: string
description: The question for the poll.
example: 'Siapa Nama Avatar The Last Air Bender?'
options:
type: array
description: The options for the poll.
items:
type: string
example: [ 'Zuko', 'Aang', 'Katara' ]
max_answer:
type: integer
description: The maximum number of answers allowed for the poll.
example: 2
required:
- phone
- question
- options
- max_answer
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/SendResponse'
'400':
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBadRequest'
'500':
description: Internal Server Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInternalServer'
/message/{message_id}/revoke: /message/{message_id}/revoke:
post: post:
operationId: revokeMessage operationId: revokeMessage

17
readme.md

@ -141,14 +141,15 @@ API using [openapi-generator](https://openapi-generator.tech/#try)
7. Send Contact ![Send Contact](https://i.ibb.co/4810H7N/send-contact.png) 7. Send Contact ![Send Contact](https://i.ibb.co/4810H7N/send-contact.png)
8. Send Location ![Send Location](https://i.ibb.co/TWsy09G/send-location.png) 8. Send Location ![Send Location](https://i.ibb.co/TWsy09G/send-location.png)
9. Send Audio ![Send Location](https://i.ibb.co/p1wL4wh/Send-Audio.png) 9. Send Audio ![Send Location](https://i.ibb.co/p1wL4wh/Send-Audio.png)
10. Revoke Message ![Revoke Message](https://i.ibb.co/yswhvQY/revoke.png?)
11. Reaction Message ![Revoke Message](https://i.ibb.co/BfHgSHG/react-message.png)
12. User Info ![User Info](https://i.ibb.co/3zjX6Cz/user-info.png)
13. User Avatar ![User Avatar](https://i.ibb.co/ZmJZ4ZW/search-avatar.png)
14. My Privacy ![My Privacy](https://i.ibb.co/Cw1sMQz/my-privacy.png)
15. My Group ![My Group](https://i.ibb.co/WB268Xy/list-group.png)
16. Auto Reply ![Auto Reply](https://i.ibb.co/D4rTytX/IMG-20220517-162500.jpg)
17. Basic Auth Prompt ![Basic Auth](https://i.ibb.co/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.png)
10. Send Poll ![Send Poll](https://i.ibb.co/mq2fGHz/send-poll.png)
11. Revoke Message ![Revoke Message](https://i.ibb.co/yswhvQY/revoke.png?)
12. Reaction Message ![Revoke Message](https://i.ibb.co/BfHgSHG/react-message.png)
13. User Info ![User Info](https://i.ibb.co/3zjX6Cz/user-info.png)
14. User Avatar ![User Avatar](https://i.ibb.co/ZmJZ4ZW/search-avatar.png)
15. My Privacy ![My Privacy](https://i.ibb.co/Cw1sMQz/my-privacy.png)
16. My Group ![My Group](https://i.ibb.co/WB268Xy/list-group.png)
17. Auto Reply ![Auto Reply](https://i.ibb.co/D4rTytX/IMG-20220517-162500.jpg)
18. Basic Auth Prompt ![Basic Auth](https://i.ibb.co/PDjQ92W/Screenshot-2022-11-06-at-14-06-29.png)
### Mac OS NOTE ### Mac OS NOTE

2
src/domains/send/poll.go

@ -3,6 +3,6 @@ package send
type PollRequest struct { type PollRequest struct {
Phone string `json:"phone" form:"phone"` Phone string `json:"phone" form:"phone"`
Question string `json:"question" form:"question"` Question string `json:"question" form:"question"`
Options []string `json:"options[]" form:"options[]"`
Options []string `json:"options" form:"options"`
MaxAnswer int `json:"max_answer" form:"max_answer"` MaxAnswer int `json:"max_answer" form:"max_answer"`
} }

13
src/views/components/SendPoll.js

@ -37,13 +37,12 @@ export default {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
this.poll_loading = true; this.poll_loading = true;
let payload = new FormData();
payload.append("phone", this.poll_phone_id)
payload.append("question", this.poll_question)
payload.append("max_answer", this.poll_max_vote)
this.poll_options.forEach((option) => {
payload.append(`options[]`, option)
})
const payload = {
phone: this.poll_phone_id,
question: this.poll_question,
max_answer: this.poll_max_vote,
options: this.poll_options
}
let response = await window.http.post(`/send/poll`, payload) let response = await window.http.post(`/send/poll`, payload)
this.sendPollReset(); this.sendPollReset();
resolve(response.data.message) resolve(response.data.message)

Loading…
Cancel
Save