<commit_before>
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function(request, response) {
  response.success("Hello world!");
});<commit_msg>Validates, formats and saves ticket to Zendesk.<commit_after>var sales = require('cloud/sales.js');

Parse.Cloud.beforeSave("Sales", function(request, response) {

  var ticket = JSON.stringify(request.object);
  ticket = JSON.parse(ticket);

  if(sales.valid(ticket)) {
    sales.save(ticket, function () {
      response.success();
    }, function (error) {
      response.error(error);
    });
  } else {
    response.error('Error!');
  }
});
{'fraction_non_alphanumeric': 0.16084977238239756, 'fraction_numerical': 0.0, 'mean_word_length': 4.15625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3589556', 'n_tokens_mistral': 203, 'n_tokens_neox': 193, 'n_words': 45}