2
0
mirror of synced 2025-01-23 12:50:05 +00:00

take out validateParameters from Links class

This commit is contained in:
Omer Levy 2017-10-09 23:53:53 +03:00
parent a085733e03
commit 08d467ff4d

View File

@ -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.<String>}
*/
createDynamicLink(parameters: Object = {}): Promise<String> {
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.<String>}
*/
createShortDynamicLink(parameters: Object = {}): Promise<String> {
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 = {