Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/graphql / dist / endpoints / user / stream / defaultParams.js
Size: Mime:
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
/* eslint-disable max-lines */
// import querystring from 'query-string'
const config_1 = require("../../../bootstrapper/api/config");
const fromPasswordToHashed_1 = require("../../../deps/fromPasswordToHashed");
exports.registerParams = {
    username: 'createuser',
};
exports.registerGuestParams = {
    username: 'createorgetuser',
    userinfo: JSON.stringify({
        customParams: {
            createIfNecessary: ['true'],
            useFP: ['false'],
        },
    }),
};
exports.loginParams = {
// campaignId,
// locale,
// storeId,
// appid,
// userinfo: JSON.stringify({
//   userName: 'xxx@yyy.com',
//   password: 'Xxx@123',
// }),
// customparams: JSON.stringify({
//   type: '0',
//   value: 'skava',
//   messageCampaignId: '',
//   promocode: '',
//   promocampaign: '',
//   locale: '',
//   channel: '',
// }),
};
exports.logoutParams = {
// campaignId,
// storeId,
// appid,
};
exports.addAddressParams = {
// campaignId,
// storeId,
// appid,
// address: JSON.stringify({
//   addresses: [
//     {
//       type: 'shippingAddress',
//       firstName: 'ccc',
//       lastName: 'yyy',
//       phone: '999 - 999 - 9999',
//       addressLine1: '1%20Front%20Street',
//       addressLine2: '',
//       city: 'San Francisco',
//       country: 'US',
//       state: 'CA',
//       postalCode: '94111',
//       customParams: {
//         validated: ['true'],
//         override: ['false'],
//         default: ['false'],
//       },
//     },
//   ],
// }),
// customparams: JSON.stringify({
//   locale: 'en_US',
//   messageCampaignId: '364',
// }),
};
exports.removeAddressParams = {
    // appid,
    // campaignId,
    // storeId,
    // address: JSON.stringify({
    //     addresses: [
    //         {
    //             type: 'shippingAddressToDelete',
    //             firstName: 'xxx',
    //             lastName: 'yyy',
    //             phone: '999 - 999 - 9999',
    //             addressLine1: '1%20Front%20Street',
    //             addressLine2: '',
    //             city: 'San Francisco',
    //             country: 'US',
    //             state: 'CA',
    //             postalCode: '94111',
    //             id: 'fcf8cf28-7f44-4ae0-a392-53a8ccd09867',
    //             customParams: {
    //                 validated: ['true'],
    //                 override: ['false'],
    //                 default: ['false'],
    //             },
    //         },
    //     ],
    // }),
    customparams: JSON.stringify({
        locale: 'en_US',
        messageCampaignId: '365',
    }),
};
exports.updateAddressParams = {
// appid,
// campaignId,
// storeId,
// address: JSON.stringify({
//   addresses: [
//     {
//       type: 'shippingAddress',
//       firstName: 'xxx',
//       lastName: 'yyy',
//       phone: '999 - 999 - 9999',
//       addressLine1: '1%20Front%20Street',
//       addressLine2: '',
//       city: 'San Francisco',
//       country: 'US',
//       state: 'CA',
//       postalCode: '94111',
//       id: 'fcf8cf28-7f44-4ae0-a392-53a8ccd09867',
//       customParams: {
//         validated: ['true'],
//         override: ['false'],
//         default: ['false'],
//       },
//     },
//   ],
// }),
// customparams: JSON.stringify({
//   locale: 'en_US',
//   messageCampaignId: '',
// }),
};
exports.changeDefaultAddressParams = {
// appid,
// campaignId,
// storeId,
// address: JSON.stringify({
//   addresses: [
//     {
//       type: 'shippingAddress',
//       firstName: 'xxx',
//       lastName: 'yyy',
//       phone: '999 - 999 - 9999',
//       addressLine1: '1%20Front%20Street',
//       addressLine2: '',
//       city: 'San Francisco',
//       country: 'US',
//       state: 'CA',
//       postalCode: '94111',
//       id: 'fcf8cf28-7f44-4ae0-a392-53a8ccd09867',
//       customParams: {
//         validated: ['true'],
//         override: ['false'],
//         default: ['true'],
//       },
//     },
//   ],
// }),
// customparams: JSON.stringify({
//   locale: 'en_US',
//   messageCampaignId: '',
// }),
};
exports.addCardParams = {
// appid,
// campaignId,
// storeId,
};
exports.deleteCardParams = {
// appid,
// campaignId,
// storeId,
};
exports.changeDefaultCardParams = {
// appid,
// campaignId,
// storeId,
};
exports.getProfileParams = {
// campaignId,
// locale,
// storeId,
// appid,
};
// interface UpdateProfileParams {
//   firstName: string;
//   lastName: string;
//   userId: string;
// }
exports.defaultUpdateProfileParams = {
    firstName: 'yyy',
    lastName: 'xxx',
    userId: 'xxx@yyy.com',
};
function toUpdateProfileParams(namedParams = exports.defaultUpdateProfileParams) {
    const { firstName, lastName, userId } = namedParams;
    const params = {
        // campaignId,
        // locale,
        // appid,
        // storeId,
        userinfo: JSON.stringify({
            firstName,
            lastName,
        }),
        customparams: JSON.stringify({
            type: '0',
            value: 'skava',
            userId,
        }),
    };
    return params;
}
exports.toUpdateProfileParams = toUpdateProfileParams;
exports.updateProfileParams = toUpdateProfileParams({});
function toUpdatePasswordParams(namedParams) {
    return __awaiter(this, void 0, void 0, function* () {
        const oldPassword = yield fromPasswordToHashed_1.toPassword(namedParams.oldPassword);
        const newPassword = yield fromPasswordToHashed_1.toPassword(namedParams.newPassword);
        const params = {
            // campaignId,
            // locale,
            // storeId,
            // appid,
            userinfo: {
                verificationDetails: { oldPassword, password: newPassword },
            },
            customparams: {
                locale: 'en_US',
                messageCampaignId: '',
            },
        };
        return params;
    });
}
exports.toUpdatePasswordParams = toUpdatePasswordParams;
exports.updatePasswordParams = toUpdatePasswordParams({});
function toUpdateSecurityParams(namedParams) {
    const { userName, challengeQuestion, challengeAnswer } = namedParams;
    const params = {
        // campaignId,
        // locale,
        // appid,
        // storeId,
        userinfo: {
            verificationDetails: { userName: userName },
            addresses: [
                {
                    type: 'securityQuestions',
                    verificationDetails: {
                        challengeQuestion: challengeQuestion,
                        challengeAnswer: challengeAnswer,
                    },
                },
            ],
        },
        customparams: { locale: 'en_US' },
    };
    return params;
}
exports.toUpdateSecurityParams = toUpdateSecurityParams;
exports.addSecurityQuestionParams = toUpdateSecurityParams({});
// export interface resetPasswordEmailParams {
//     email: string;
//     messageCampaignId: string;
// }
// export const defaultResetPasswordEmailParams = {
//     email: 'favtest@skava.com',
//     messageCampaignId: '379',
// }
exports.toResetPasswordByEmailParams = namedParams => {
    const { email, messageCampaignId } = namedParams;
    const params = {
        // campaignId,
        // storeId,
        // appid,
        userinfo: {
            addresses: [
                {
                    type: 'userIdentities',
                    value: 'skava',
                    id: email,
                    customParams: { type: ['0'] },
                },
            ],
        },
        customparams: {
            // messageCampaignId: '379',
            // locale: 'en_US',
            // resetMethod: '1',
            // !!!!!! BAD BAD BAD BAD BAD BAD BAD BAD !!!!!! USE ENV
            messageCampaignId: config_1.createAccountCampaignMessageId,
            locale: 'en_US',
            resetMethod: '2',
            channel: 'WEB',
        },
    };
    return params;
};
// default !?
exports.resetPasswordByEmailParams = exports.toResetPasswordByEmailParams({});
exports.validatePasswordByEmailParams = namedParams => {
    // campaignId,
    // locale,
    // storeId,
    // appid,
    const { password, resetParam } = namedParams;
    const params = {
        userinfo: {
            verificationDetails: { password: password },
            addresses: [
                {
                    type: 'userIdentities',
                    value: 'skava',
                    customParams: { type: ['0'] },
                },
            ],
            customParams: { resetMethod: ['1'] },
        },
        customparams: {
            resetParam: resetParam,
            locale: 'en_US',
            channel: 'web',
            messageCampaignId: '',
            mailerId: '301',
        },
    };
    return params;
};
exports.validateResetPasswordByEmailParams = exports.validatePasswordByEmailParams({});
exports.toResetPasswordBySMSParams = email => {
    const params = {
        // campaignId,
        // storeId,
        // appid,
        userinfo: {
            addresses: [
                {
                    type: 'userIdentities',
                    value: 'skava',
                    id: email,
                    customParams: { type: ['0'] },
                },
            ],
        },
        customparams: {
            // !!! BAD BAD BAD BAD BAD BAD FIXME !!!
            messageCampaignId: '372',
            locale: 'en_US',
            resetMethod: '1',
            channel: 'WEB',
        },
    };
    return params;
};
exports.resetPasswordBySMSParams = exports.toResetPasswordBySMSParams({});
exports.validateResetPasswordBySMSParams = {
    // campaignId,
    // locale,
    // storeId,
    // appid,
    userinfo: JSON.stringify({
        verificationDetails: { password: 'Skava@123' },
        addresses: [
            {
                type: 'userIdentities',
                value: 'skava',
                customParams: { type: ['0'] },
                id: 'gnanaprabhu@skava.com',
            },
        ],
    }),
    customparams: JSON.stringify({
        otp: '12345',
        locale: 'en_US',
        channel: 'WEB',
        messageCampaignId: '376',
        mailerId: '376',
    }),
};
exports.twittertokenParams = {
    // campaignId,
    // appid: 'skreact',
    username: 'twitter',
};
// export interface SecurityParams {
//     emailId: string;
// }
exports.defaultSecurityParams = {
    emailId: 'favtest@skava.com',
};
function toSecurityParams(namedParams = exports.defaultSecurityParams) {
    const { emailId } = namedParams;
    const params = {
        // campaignId,
        // locale,
        // storeId,
        // appid,
        userinfo: {
            addresses: [
                {
                    type: 'userIdentities',
                    id: emailId,
                    value: 'skava',
                    customParams: { type: ['0'], channel: ['WEB'] },
                },
            ],
        },
    };
    return params;
}
exports.toSecurityParams = toSecurityParams;
exports.getSecurityQuestionsParams = toSecurityParams();
exports.resetPasswordSecurityParams = (namedParams) => __awaiter(this, void 0, void 0, function* () {
    const { emailId, challengeQuestion1, challengeAnswer1, password, } = namedParams;
    const hashedPassword = yield fromPasswordToHashed_1.toPassword(password);
    const params = {
        // campaignId,
        // locale,
        // storeId,
        // appid,
        userinfo: {
            addresses: [
                {
                    type: 'userIdentities',
                    value: 'skava',
                    id: emailId,
                    customParams: { type: ['0'] },
                },
                {
                    type: 'securityQuestions',
                    verificationDetails: {
                        challengeQuestion: challengeQuestion1,
                        challengeAnswer: challengeAnswer1,
                    },
                },
            ],
            verificationDetails: { password: hashedPassword },
        },
        customparams: {
            messageCampaignId: '',
            resetMethod: '3',
            channel: 'WEB',
        },
    };
    return params;
});
exports.resetPasswordBySecurityQuestionsParams = exports.resetPasswordSecurityParams({});
// export interface AddPaymentCardParams {
//     messageCampaignId: string;
// }
exports.defaultAddPaymentCardParams = {
    messageCampaignId: '521',
};
function getAddPaymentCardParams(params = exports.defaultAddPaymentCardParams, email) {
    const { cardType, messageCampaignId, cardNumber, expirationmonth, expirationyear, expiryDate, firstName, lastName, makeDefaultCard, securityCode, } = params;
    const details = Object.assign({ payment: {
            creditCard: [
                {
                    type: cardType,
                    number: cardNumber,
                    expirationMonth: expirationmonth,
                    expirationYear: expirationyear,
                    expiryDate,
                    name: firstName,
                    customParams: {
                        cardBrand: cardType,
                        validated: 'false',
                        default: makeDefaultCard,
                    },
                },
            ],
            address: [
                {
                    type: 'billingAddress',
                    addressLine1: '1 Front Street',
                    city: 'San Francisco',
                    state: 'CA',
                    postalCode: '94111',
                    country: 'US',
                    email,
                    firstName,
                    lastName,
                    makeDefaultCard,
                    securityCode,
                    phone: '213 - 123 - 1231',
                    customParams: {
                        validated: ['true'],
                        override: ['false'],
                        default: ['false'],
                    },
                },
            ],
        }, customparams: {
            locale: 'en_US',
            channel: 'web',
            linkBAddrToCard: 'true',
            messageCampaignId,
        } }, exports.addCardParams);
    return details;
}
exports.getAddPaymentCardParams = getAddPaymentCardParams;
function getDeletePaymentCardParams(params) {
    const deletePaymentDetails = Object.assign({ carddetail: {
            cards: [
                {
                    id: params.creditId,
                },
            ],
        }, customparams: {
            type: '0',
            value: 'skava',
            userId: params.email,
            messageCampaignId: '',
        } }, exports.deleteCardParams);
    return deletePaymentDetails;
}
exports.getDeletePaymentCardParams = getDeletePaymentCardParams;
// export interface DefaultCardParams {
//   payment: string;
//   messageCampaignId: string;
// }
exports.changeDefaultPaymentCardParams = {
    payment: '',
    messageCampaignId: '366',
};
function getChangeDefaultCardParams(changeCardParams = exports.changeDefaultPaymentCardParams) {
    const { payment, messageCampaignId } = changeCardParams;
    const changeDefaultPaymentDetails = Object.assign({ payment, customparams: {
            locale: 'en_US',
            channel: 'web',
            linkBAddrToCard: 'true',
        } }, exports.changeDefaultCardParams);
    return changeDefaultPaymentDetails;
}
exports.getChangeDefaultCardParams = getChangeDefaultCardParams;
function getProfileCustomParams(enablePaymentRetrival
/* enableAddressRetrival */
) {
    return {
        customparams: {
            enablePaymentRetrival: [enablePaymentRetrival],
        },
    };
}
exports.getProfileCustomParams = getProfileCustomParams;
// --- export default exports
/**
 * @see toUpdatePasswordParams
 * @todo !!! THIS NEEDS FIXING - SHOULD NOT BE A STRING
 */
function toRegisterParams(params) {
    return __awaiter(this, void 0, void 0, function* () {
        const defaultUserIdentity = [
            {
                type: 'userIdentities',
                value: 'skava',
                customParams: {
                    type: ['0'],
                },
            },
        ];
        const defaultUserCustomParams = {
            resetMethod: ['4'],
            status: ['1'],
            contactPreferences: [''],
            additionalPreferences: [''],
            promotions: [''],
            preferences: [''],
        };
        const defaultCustomParams = {
            /**
             * @todo @fixme - messageid is wrong
             */
            // messageCampaignId: process.env.ACCOUNT_CREATE_CAMPAIGN_MESSAGE_ID || '',
            //default message Campaign Id should be empty String
            messageCampaignId: config_1.createAccountCampaignMessageId,
            validationMethod: '4',
            sendWelcomeEmail: 'true',
            skipValidations: '1',
        };
        const { userName, password, telephone, firstName, lastName } = params;
        // Note returning {}
        const hashedPassword = yield fromPasswordToHashed_1.toPassword(password);
        const mergedParams = {
            userinfo: {
                verificationDetails: {
                    userName,
                    password: hashedPassword,
                },
                email: userName,
                phone: telephone,
                firstName,
                lastName,
                addresses: defaultUserIdentity,
                customParams: Object.assign({}, defaultUserCustomParams),
            },
            customparams: Object.assign({}, defaultCustomParams),
        };
        return mergedParams;
    });
}
exports.toRegisterParams = toRegisterParams;
const fromSocialToLoginType = (type) => {
    switch (type) {
        case 'google':
            return 3;
        case 'twitter':
            return 4;
        case 'facebook':
            return 2;
        case 'skava':
            return '0';
        default:
            return '0';
    }
};
function checkIsSocialLogin(provider) {
    return provider !== 'skava';
}
function toLoginParams(params) {
    return __awaiter(this, void 0, void 0, function* () {
        const { userName, password, provider = 'skava', authToken } = params;
        const hashedPassword = yield fromPasswordToHashed_1.toPassword(password);
        const type = fromSocialToLoginType(params.provider);
        const defaultCustomParams = {
            type,
            value: provider,
            /**
             * @todo @fixme - messageid is wrong
             */
            // messageCampaignId: process.env.ACCOUNT_CREATE_CAMPAIGN_MESSAGE_ID || '88',
            messageCampaignId: '',
            promocode: '',
            promocampaign: '',
            locale: 'en_US',
            channel: '',
        };
        const verificationDetails = {
            userName,
            password: hashedPassword,
        };
        if (checkIsSocialLogin(provider)) {
            return {
                customparams: Object.assign({}, defaultCustomParams, { authToken }),
            };
        }
        return {
            userinfo: Object.assign({}, verificationDetails),
            customparams: Object.assign({}, defaultCustomParams),
        };
    });
}
exports.toLoginParams = toLoginParams;
//# sourceMappingURL=defaultParams.js.map