From 08d467ff4d766f1692eb81dbad1d0a683e01eedd Mon Sep 17 00:00:00 2001 From: Omer Levy Date: Mon, 9 Oct 2017 23:53:53 +0300 Subject: [PATCH] take out validateParameters from Links class --- lib/modules/links/index.js | 68 +++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/modules/links/index.js b/lib/modules/links/index.js index 8c76c3e9..b39e6d05 100644 --- a/lib/modules/links/index.js +++ b/lib/modules/links/index.js @@ -5,6 +5,38 @@ const EVENT_TYPE = { Link: 'dynamic_link_received', }; +function validateParameters(parameters: Object): boolean { + const suportedParametersObject = { + dynamicLinkInfo: { + dynamicLinkDomain: 'string', + link: 'string', + androidInfo: { + androidPackageName: 'string', + androidFallbackLink: 'string', + androidMinPackageVersionCode: 'string', + androidLink: 'string', + }, + iosInfo: { + iosBundleId: 'string', + iosFallbackLink: 'string', + iosCustomScheme: 'string', + iosIpadFallbackLink: 'string', + iosIpadBundleId: 'string', + iosAppStoreId: 'string', + }, + socialMetaTagInfo: { + socialTitle: 'string', + socialDescription: 'string', + socialImageLink: 'string', + }, + }, + suffix: { + option: 'string', + }, + }; + return areObjectKeysContainedInOther(parameters, suportedParametersObject); +} + /** * @class Links */ @@ -44,7 +76,7 @@ export default class Links extends ModuleBase { * @returns {Promise.} */ createDynamicLink(parameters: Object = {}): Promise { - if (!this._validateParameters(parameters)) { + if (!validateParameters(parameters)) { return Promise.reject(new Error('Invalid Parameters.')); } return this._native.createDynamicLink(parameters); @@ -56,43 +88,11 @@ export default class Links extends ModuleBase { * @returns {Promise.} */ createShortDynamicLink(parameters: Object = {}): Promise { - if (!this._validateParameters(parameters)) { + if (!validateParameters(parameters)) { return Promise.reject(new Error('Invalid Parameters.')); } return this._native.createShortDynamicLink(parameters); } - - _validateParameters(parameters: Object): boolean { - const suportedParametersObject = { - dynamicLinkInfo: { - dynamicLinkDomain: 'string', - link: 'string', - androidInfo: { - androidPackageName: 'string', - androidFallbackLink: 'string', - androidMinPackageVersionCode: 'string', - androidLink: 'string', - }, - iosInfo: { - iosBundleId: 'string', - iosFallbackLink: 'string', - iosCustomScheme: 'string', - iosIpadFallbackLink: 'string', - iosIpadBundleId: 'string', - iosAppStoreId: 'string', - }, - socialMetaTagInfo: { - socialTitle: 'string', - socialDescription: 'string', - socialImageLink: 'string', - }, - }, - suffix: { - option: 'string', - }, - }; - return areObjectKeysContainedInOther(parameters, suportedParametersObject); - } } export const statics = {