'use strict';
var LocalServiceRegistry = require('dw/svc/LocalServiceRegistry');

var recaptchaService = LocalServiceRegistry.createService('recaptcha.http.post', {
  createRequest: function(svc, params) {
    svc.setRequestMethod('POST');
    // You can perform other operations, such as adding request headers
    svc.addHeader('Content-Type', 'application/json');
    // Add properties to the request body
    svc.addParam('secret', params.secret);
    svc.addParam('response', params.response);
  },
  parseResponse: function(svc, responseObject) {
    return JSON.parse(response.text);
  },
  // mockCall: function(svc, requestObject) {
  //   // Return a mocked response
  //   // If configuration set to MOCK mode
  //   return {
  //     success: true,
  //     'challenge_ts': Date.now(),
  //     hostname: 'MOCK EXAMPLE'
  //   };
  // }
  // If dealing with any sensitive information
  // You should filter it out before it hits the logs
  // filterLogMessage: function() {}
});

module.exports = {
  recaptchaService: recaptchaService
};
