Unverified Commit 74f788e4 authored by zeynel's avatar zeynel Committed by GitHub

Merge pull request #13 from zeyneloz/feature/remove-initial-body-restrictions

Feature/remove initial body restrictions
parents 136981b6 eabedd78
This diff is collapsed.
'use strict'; 'use strict';
// TODO Deprecate
var ALLOWED_FIELDS = ['contents', 'included_segments', 'excluded_segments', 'filters', 'include_player_ids',
'app_id', 'app_ids', 'headings', 'subtitle', 'template_id', 'content_available', 'mutable_content',
'data', 'url', 'ios_attachments', 'big_picture', 'adm_big_picture', 'chrome_big_picture', 'buttons',
'web_buttons', 'ios_category', 'android_background_layout', 'small_icon', 'large_icon', 'adm_small_icon',
'adm_large_icon', 'chrome_web_icon', 'chrome_web_image', 'firefox_icon', 'chrome_icon', 'ios_sound',
'android_sound', 'android_led_color', 'android_accent_color', 'android_visibility', 'adm_sound', 'ios_badgeType',
'ios_badgeCount', 'collapse_id', 'send_after', 'delayed_option', 'delivery_time_of_day', 'ttl', 'priority',
'android_group', 'android_group_message', 'adm_group', 'adm_group_message', 'isIos', 'isAndroid',
'isAnyWeb', 'isChromeWeb', 'isFirefox', 'isSafari', 'isWP', 'isWP_WNS', 'isAdm', 'isChrome',
'android_channel_id', 'existing_android_channel_id'];
/** /**
* *
* @param initialBody The body must include either one of these: contents, content_available, template_id * @param initialBody The body must include either one of these: contents, content_available, template_id
...@@ -23,22 +10,7 @@ var Notification = function (initialBody) { ...@@ -23,22 +10,7 @@ var Notification = function (initialBody) {
throw 'Body must be a JSON object'; throw 'Body must be a JSON object';
} }
this.postBody = {}; this.postBody = JSON.parse(JSON.stringify(initialBody));
if ('contents' in initialBody) {
this.postBody.contents = initialBody.contents;
return;
}
if ('content_available' in initialBody) {
this.postBody.content_available = initialBody.content_available;
return;
}
if ('template_id' in initialBody) {
this.postBody.template_id = initialBody.template_id;
return;
}
throw 'Body must include one of the following fields: contents, content_available, template_id'
}; };
/** /**
...@@ -46,11 +18,9 @@ var Notification = function (initialBody) { ...@@ -46,11 +18,9 @@ var Notification = function (initialBody) {
* @param name { String } * @param name { String }
* @param value * @param value
*/ */
// TODO Deprecate
Notification.prototype.setParameter = function (name, value) { Notification.prototype.setParameter = function (name, value) {
// TODO Deprecate console.warn("[onesignal-node] setParameter function will be removed in next release, please check documentation.");
if (name && name[0] === '!') {
name = name.substring(1);
}
this.postBody[name] = value; this.postBody[name] = value;
}; };
...@@ -58,7 +28,9 @@ Notification.prototype.setParameter = function (name, value) { ...@@ -58,7 +28,9 @@ Notification.prototype.setParameter = function (name, value) {
* *
* @param contents * @param contents
*/ */
// TODO Deprecate
Notification.prototype.setContent = function (contents) { Notification.prototype.setContent = function (contents) {
console.warn("[onesignal-node] setContent function will be removed in next release, please check documentation.");
this.postBody.contents = contents; this.postBody.contents = contents;
}; };
...@@ -66,32 +38,40 @@ Notification.prototype.setContent = function (contents) { ...@@ -66,32 +38,40 @@ Notification.prototype.setContent = function (contents) {
* *
* @param included_segments The segment names you want to target * @param included_segments The segment names you want to target
*/ */
// TODO Deprecate
Notification.prototype.setIncludedSegments = function (included_segments) { Notification.prototype.setIncludedSegments = function (included_segments) {
this.postBody.included_segments = included_segments; console.warn("[onesignal-node] setIncludedSegments function will be removed in next release, please check documentation.");
this.postBody.included_segments = included_segments;
}; };
/** /**
* *
* @param excluded_segments Segment that will be excluded when sending * @param excluded_segments Segment that will be excluded when sending
*/ */
// TODO Deprecate
Notification.prototype.setExcludedSegments = function (excluded_segments) { Notification.prototype.setExcludedSegments = function (excluded_segments) {
this.postBody.excluded_segments = excluded_segments; console.warn("[onesignal-node] setExcludedSegments function will be removed in next release, please check documentation.");
this.postBody.excluded_segments = excluded_segments;
}; };
/** /**
* *
* @param filters * @param filters
*/ */
// TODO Deprecate
Notification.prototype.setFilters = function (filters) { Notification.prototype.setFilters = function (filters) {
this.postBody.filters = filters; console.warn("[onesignal-node] setFilters function will be removed in next release, please check documentation.");
this.postBody.filters = filters;
}; };
/** /**
* *
* @param include_player_ids Specific players to send your notification to * @param include_player_ids Specific players to send your notification to
*/ */
// TODO Deprecate
Notification.prototype.setTargetDevices = function (include_player_ids) { Notification.prototype.setTargetDevices = function (include_player_ids) {
this.postBody.include_player_ids = include_player_ids; console.warn("[onesignal-node] setTargetDevices function will be removed in next release, please check documentation.");
this.postBody.include_player_ids = include_player_ids;
}; };
module.exports = Notification; module.exports = Notification;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment