-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact-api.js
34 lines (31 loc) · 899 Bytes
/
contact-api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import LucioleApi from './../../../../common/core/abstract/luciole-api'
/**
* Class for Contact API
*/
export default class ContactApi extends LucioleApi {
/**
* Send contact message
* @type {Object} endpoint The endpoint to use
* @type {Object} message The message object to send
* @return {Promise} A promise to resolve
*/
sendContactMessage (endpoint, message) {
const body = this.encodeMessage(message)
const uri = `${endpoint}/v1/contact`
return this.requestHelper.post(uri, body)
}
/**
* Encode a message to valid JSON format
* @type {Object} endpoint The endpoint to use
* @type {Object} message The message object to send
* @return {Object} A message encoded
*/
encodeMessage (message) {
return {
mail: message.mail,
subject: message.subject,
content: message.content,
recaptcha: message.captcharesponse
}
}
}