<commit_before>/*
 * Some portions extracted from:
 * Parse JavaScript SDK
 * Version: 1.4.2
 */

import Ember from 'ember';
import DS from 'ember-data';

var get = Ember.get,
    forEach = Ember.ArrayPolyfills.forEach;


export default DS.RESTAdapter.extend({
  PARSE_APPLICATION_ID: null,
  PARSE_JAVASCRIPT_KEY: null,

  host: 'https://api.parse.com',
  namespace: '1',
  classesPath: 'classes',
  parseClientVersion: 'js1.4.2',

  init() {
    this._super();

    this.set('parseClientVersion', this.parseVersion);
    this.set('applicationId', this.get('PARSE_APPLICATION_ID'));
    this.set('javascriptKey', this.get('PARSE_JAVASCRIPT_KEY'));
    this.set('installationId', this._getInstallationId());
    this.set('sessionToken', null);
    this.set('userId', null);

    /*
     * avoid pre-flight.
     * Parse._ajax
     */
    this.set('headers', {'Content-Type': 'text/plain'});
  },

  _getInstallationId() {
    /*
     * Parse._getInstallationId
     */
    var hexOctet = function() {
      return (
        Math.floor((1+Math.random())*0x10000).toString(16).substring(1)
      );
    };

    return (
      hexOctet() + hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + hexOctet() + hexOctet());
  },

  ajaxOptions(url, type, options) {
    var hash = options || {};
    hash.url = url;
    hash.type = type;
    hash.dataType = 'json';
    hash.context = this;

    if ((hash.data && type !== 'GET')) {
      hash.contentType = 'application/json; charset=utf-8';

      // Parse auth stuff
      hash.data._ClientVersion = this.get('clientVersion');
      hash.data._ApplicationId = this.get('applicationId');
      hash.data._JavaScriptKey = this.get('javascriptKey');
      hash.data._InstallationId = this.get('installationId');<commit_msg>Make sure client version is reported on requests<commit_after>/*
 * Some portions extracted from:
 * Parse JavaScript SDK
 * Version: 1.4.2
 */

import Ember from 'ember';
import DS from 'ember-data';

var get = Ember.get,
    forEach = Ember.ArrayPolyfills.forEach;


export default DS.RESTAdapter.extend({
  PARSE_APPLICATION_ID: null,
  PARSE_JAVASCRIPT_KEY: null,

  host: 'https://api.parse.com',
  namespace: '1',
  classesPath: 'classes',
  parseClientVersion: 'js1.4.2',

  init() {
    this._super();

    this.set('applicationId', this.get('PARSE_APPLICATION_ID'));
    this.set('javascriptKey', this.get('PARSE_JAVASCRIPT_KEY'));
    this.set('installationId', this._getInstallationId());
    this.set('sessionToken', null);
    this.set('userId', null);

    /*
     * avoid pre-flight.
     * Parse._ajax
     */
    this.set('headers', {'Content-Type': 'text/plain'});
  },

  _getInstallationId() {
    /*
     * Parse._getInstallationId
     */
    var hexOctet = function() {
      return (
        Math.floor((1+Math.random())*0x10000).toString(16).substring(1)
      );
    };

    return (
      hexOctet() + hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + "-" +
      hexOctet() + hexOctet() + hexOctet());
  },

  ajaxOptions(url, type, options) {
    var hash = options || {};
    hash.url = url;
    hash.type = type;
    hash.dataType = 'json';
    hash.context = this;

    if ((hash.data && type !== 'GET')) {
      hash.contentType = 'application/json; charset=utf-8';

      // Parse auth stuff
      hash.data._ClientVersion = this.get('parseClientVersion');
      hash.data._ApplicationId = this.get('applicationId');
      hash.data._JavaScriptKey = this.get('javascriptKey');
      hash.data._InstallationId = this.get('installationId');
{'fraction_non_alphanumeric': 0.16946354883081155, 'fraction_numerical': 0.009903713892709767, 'mean_word_length': 2.96943231441048, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6576348', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1189, 'n_words': 216}