<commit_before>var Promise = require('bluebird')
var request = require('request')

var OneSignal = module.exports = {

  register: function (platform, deviceToken) {
    var url = 'https://onesignal.com/api/v1/players'
    var appId = process.env.ONESIGNAL_APP_ID
    var deviceType = platform === 'ios_macos' ? 0 : 1
    var params = {app_id: appId, device_type: deviceType, identifier: deviceToken}

    if (process.env.NODE_ENV === 'development') {
      params['test_type'] = 1
    }

    var requestOptions = {
      url: url,
      method: 'POST',
      json: params
    }

    return new Promise((resolve, reject) => {
      request(requestOptions, (error, resp, body) => {
        if (error) return reject(error)

        if (resp.statusCode !== 200) {
          return reject('OneSignal.register for device ' + deviceToken + ' failed with status code: ' + resp.statusCode)
        }

        resolve(resp)
      })
    })
  },

  iosBadgeUpdate: function (deviceToken, badgeNo) {
    return {
      include_ios_tokens: [deviceToken],
      ios_badgeType: 'SetTo',
      ios_badgeCount: badgeNo,
      content_available: true
    }
  },

  iosNotification: function (deviceToken, alert, path, badgeNo) {
    return _.merge(_.omit(OneSignal.iosBadgeUpdate(deviceToken, badgeNo), 'content_available'),
      {
        contents: {en: alert},
        data: {path: path}
      })
  },

  androidNotification: function (deviceToken, alert, path) {
    return {
      include_android_reg_ids: [deviceToken],
      contents: {en: alert},
      data: {alert: alert, path: path}
    }
  },

  notification: function (platform, deviceToken, alert, path, badgeNo) {
    var params

    if (platform === 'ios_macos') {
      if (path === '') {
        params = OneSignal.iosBadgeUpdate(deviceToken, badgeNo)
      } else {
        params = OneSignal.iosNotification(deviceToken, alert, path, badgeNo)
      }
    } else {
      params = OneSignal.androidNotification(deviceToken, alert, path)
    }

    params['app_id'] = OneSignal.appId(platform)
    return params
  },

  notify: function (platform, deviceToken, alert, path, badgeNo) {<commit_msg>use combined app id<commit_after>var Promise = require('bluebird')
var request = require('request')

var OneSignal = module.exports = {

  register: function (platform, deviceToken) {
    var url = 'https://onesignal.com/api/v1/players'
    var appId = process.env.ONESIGNAL_APP_ID
    var deviceType = platform === 'ios_macos' ? 0 : 1
    var params = {app_id: appId, device_type: deviceType, identifier: deviceToken}

    if (process.env.NODE_ENV === 'development') {
      params['test_type'] = 1
    }

    var requestOptions = {
      url: url,
      method: 'POST',
      json: params
    }

    return new Promise((resolve, reject) => {
      request(requestOptions, (error, resp, body) => {
        if (error) return reject(error)

        if (resp.statusCode !== 200) {
          return reject('OneSignal.register for device ' + deviceToken + ' failed with status code: ' + resp.statusCode)
        }

        resolve(resp)
      })
    })
  },

  iosBadgeUpdate: function (deviceToken, badgeNo) {
    return {
      include_ios_tokens: [deviceToken],
      ios_badgeType: 'SetTo',
      ios_badgeCount: badgeNo,
      content_available: true
    }
  },

  iosNotification: function (deviceToken, alert, path, badgeNo) {
    return _.merge(_.omit(OneSignal.iosBadgeUpdate(deviceToken, badgeNo), 'content_available'),
      {
        contents: {en: alert},
        data: {path: path}
      })
  },

  androidNotification: function (deviceToken, alert, path) {
    return {
      include_android_reg_ids: [deviceToken],
      contents: {en: alert},
      data: {alert: alert, path: path}
    }
  },

  notification: function (platform, deviceToken, alert, path, badgeNo) {
    var params

    if (platform === 'ios_macos') {
      if (path === '') {
        params = OneSignal.iosBadgeUpdate(deviceToken, badgeNo)
      } else {
        params = OneSignal.iosNotification(deviceToken, alert, path, badgeNo)
      }
    } else {
      params = OneSignal.androidNotification(deviceToken, alert, path)
    }

    params['app_id'] = process.env.ONESIGNAL_APP_ID
    return params
  },

  notify: function (platform, deviceToken, alert, path, badgeNo) {
{'fraction_non_alphanumeric': 0.12531969309462915, 'fraction_numerical': 0.0032550569634968614, 'mean_word_length': 2.893212669683258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6506678', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1297, 'n_words': 315}