# Documentação API HCI Whats Center # Recursos # **Find All Managers** ``` /get api/user/ ``` **Return** ``` { success: true, data: [manegers] } ``` # **Find Manager By number** ``` /post api/user/ ``` **Body Required:** ``` { number: 123456789 } ``` **Return** ``` { success: true, data: { "name": "Name Main User", "email": "Email of the user", "number": 123456789, "controllerPort": "8080", "facebookId": "369258147", "facebookToken": "ajbcucauoincjapso" "contacts" : [] } } ``` # **Find a Manager using a facebook Page Id** ``` /post api/user/facebook ``` **Body Required:** ``` { facebookId: "963852741" } ``` **Return** ``` success: true data: { "name": "Name Main User", "email": "Email of the user", "number": 123456789, "controllerPort": "8080", "facebookId": "369258147", "facebookToken": "ajbcucauoincjapso" "contacts" : [] } ``` # **Add New Manager** ``` /post api/user/save ``` **Body required if facebook and whatsApp Manager** ``` { name: "name Example", controllerPort: "8888", number: 123456789, facebookId: "369258147", facebookToken: "sajboubcoiaucusnoa" } ``` **Return** ``` { success: true, data: { "name": "Name Main User", "number": 123456789, "controllerPort": "8080", "facebookId": "369258147", "facebookToken": "ajbcucauoincjapso" "contacts" : [] } } ``` # **Add a facebook to a whatsapp user** ``` /post /api/user/save/facebook ``` **Body Required** ``` number: 123456789, facebookId: "369258147", facebookToken: "udhuionua9as" ``` **Return** ``` success: true, data: { "name": "Name Main User", "email": "Email of the user", "number": 123456789, "controllerPort": "8080", "facebookId": "369258147", "facebookToken": "ajbcucauoincjapso" "contacts" : [] } ``` # **Add a whatsApp Number to a Facebook Manager** ``` /post /api/user/save/facebook ``` **Body Required** ``` facebookId: "369258147", mumber: 123456789 ``` **Return** ``` success: true, data: { "name": "Name Main User", "email": "Email of the user", "number": 123456789, "controllerPort": "8080", "facebookId": "369258147", "facebookToken": "ajbcucauoincjapso" "contacts" : [] } ``` # **Search for all contacts with a main user have** ``` /post api/user/contact/get ``` **Body Required:** ``` { number: 123456789 } ``` **Return** ``` success: true, data: { contacts: [] } ``` # **Get all contacts in the specific area** ``` /post api/user/contact/area ``` **Body Required:** ``` { number: 123456789, area: "Id of the area" } ``` **Return** ``` success: true, data: [array of contacts] ``` # **Get all contacts the operator have or contacts that in the area** ``` /post api/user/contact/operator ``` **Body Required:** ``` { number: 123456789, operatorId: "operatorId", area: "operator Area" } ``` **Return** ``` success: true, data: { contacts: [] } ``` # **answer the contact** ``` /put api/user/contact/operator/my ``` **Body Required:** ``` { number: 123456879, operatorId: "operatorId", contactId: 987654321 } ``` **Body Required using facebookId:** ``` { facebookId: "123456879", operatorId: "operatorId", contactId: 987654321 } ``` **Return** ``` success: true, data: "Contact Send to the operator" ``` # **Send Contact to the operator** ``` /put api/user/contact/operator ``` **Body Required:** ``` { number: 123456879, operatorId: "operatorId", contactId: 987654321 } ``` **Body Required using facebookId:** ``` { facebookId: "123456879", operatorId: "operatorId", contactId: 987654321 } ``` **Return** ``` success: true, data: "Contact Send to the operator" ``` # **Change Area of the contact** ``` /put api/user/contact/area ``` **Body Required:** ``` { number: 123456879, area: "AreaId" contactNumber: 987654321 } ``` **Return** ``` success: true, data: "Contact changed Area" ``` # **Add a new contact of a main number** ``` /post api/user/contact/save ``` **Body Required:** ``` { number: 123456789, name: "ExampleName", photo: "Not Required", contactNumber: 987654321, area: "Area String", protocol: "protocol Id" } ``` **Return** ``` success: true, data: { id: 123456789, name: "ExampleName", photo: "Not Required", area: "Area String", operatorId: "2", protocol: "BR848a795dsa684d", sa: -100 } ``` # **Add a new facebook contact** ``` /post api/user/contact/save/facebook ``` **Body Required** ``` { name: "ExampleName", photo: "Not Required", area: "Area String", protocol: "BR98465483218", contactId: "facebookId", facebookId: "Id Of the facebook Page" } ``` **Return** ``` success: true, data: { id: "facebookId", name: "ExampleName", photo: "Not Required", area: "Area String", operatorId: "2", protocol: "BR848a795dsa684d", sa: 1 } ``` # **Add a facebook Contact or Return Sa** ``` /post api/user/contact/sa ``` **Body Required** ``` { name: "ExampleName", photo: "Not Required", area: "Area String", protocol: "BR98465483218", contactId: "facebookId", facebookId: "Id Of the facebook Page" } ``` **Return** ``` success: true, data: contact.sa ? contact.sa : 0 ``` # **Increase The Sa of a number** ``` /put /api/user/contact/sa/increase ``` **Body Required** ``` facebookId: "369258147", contactId: "7418252963" ``` **Return** ``` success: true, data: contact.sa ``` # **Decrease The Sa of a number** ``` /put /api/user/contact/sa/decrease ``` **Body Required** ``` facebookId: "369258147", contactId: "7418252963" ``` **Return** ``` success: true, data: contact.sa ``` # **Delete a contact** ``` /delete api/user/contact/ ``` **Body Required:** ``` { number: 123456789, contactNumber: 987654321 } ``` **Return** ``` success: true, data: 'Contact deleted' ``` # ** Create a new Chat using a number** ``` /post api/chat/new ``` **Body Required:** ``` { contactNumber: 987654321 } ``` **Return** ``` success: true, data: { contactId: 987654321, operatorId: 0, messages: [] } ``` # **Create a new Chat using FacebookId** ``` /post api/chat/facebook/new ``` **Body Required** ``` { contactId: 987654321 } ``` **Return** ``` success: true, data: { contactId: 987654321, operatorId: 0, messages: [] } ``` # **Find All messages from a chat** ``` /post api/chat/message ``` **Body Required:** ``` { operatorId: "Id of a operator", contactId: 987654321 } ``` **Return** ``` { success: true, data: [messages] } ``` # **Change operator chat** ``` /put api/chat/operator ``` **Body Required:** ``` { contactId: 987654321, operatorId: "Id operator" } ``` **Return** ``` { success: true, data: { contactNumber: 987654321, operatorId: "Id operator", messages: [] } } ``` # **Delete a Chat** ``` /delete api/chat/ ``` **Body Required:** ``` { contactId: 987654321 } ``` **Return** ``` { success: true, data: 'Chat deleted' } ``` # **Send a message** ``` /post api/chat/message/send ``` **Body if is a facebook Text Message** ``` { contactId: "987654321", content: "text of the message", facebookId: "369258147", type: "text", from: "987654321", } ``` **Body if is not a facebook text message** ``` { supertype: "audio", url: "url.com", from: "987654321", contactId: "987654321", facebookId: "369258147" } ``` **Body Required if is a WhatsApp text message** ``` { contactNumber: 987654321, content: "Text of a message", type: base64 = text, from: 987654321 managerNumber: 123456789 } ``` **Body Required if is WhatsApp not a text message** ``` { operatorId: "Operator Id", contactNumber: 987654321, url: "exampleUrl.com", type: "image or pdf or audio or video", from: 987654321 managerNumber: 123456789 } ``` **Return if is a text** ``` { success: true, data: { content: "Text of a message", type: "text", from: 987654321 status: "wait", } } ``` **Return not a text** ``` { success: true, data: { content: "Arquivo em anexo", type: "image", from: 987654321 status: "wait", url: "url.com" } } ``` # **Send A Text Message By Operator to a WhatsApp Client** ``` post /api/chat/message/send/operator/:ControllerPort ``` **Body Required:** ``` content: "Base64Msg", content2: "textExample" operatorId: "operatorId", contactNumber: 987654321 ``` **Return** ``` success: true, data: {message data} ``` # **Send Text Message For A facebook client by Operator** ``` post /api/chat/message/send/operator/facebook ``` **Body Required** ``` { content: "Base64Msg", content2: "textExample" operatorId: "operatorId", contactId: 987654321, token: "Facebook Page Token" } ``` # **Send message that is not text By Operator** ``` post /api/chat/message/send/operator/file/:controllerPort ``` **Body Required:** ``` contactNumber: 987654321 from: "operatorId", base64: "data:${fileType}/${mimetipe};base64,${base64 string}", type: "type" ``` **Return** ``` success: true, data: {message data} ``` # **Get all areas** ``` /get /api/area/:controllerPort ``` **Return** ``` success: true, data: [areas] ``` # **Get all operators of an specific Area** ``` /post /api/area/operator/:controllerPort ``` **Body Required:** ``` { idarea: "Area Id" } ``` **Return** ``` success: true, data: [operators] ``` # **Conect whit the socket to verify changes on the Database** ``` /post api/socket ```