ucc-sdk
Version:
UnchainedCarrot SDK
883 lines (786 loc) • 28.5 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var axios = require('axios');
var uuid = require('uuid');
var getBrowserFingerprint = require('get-browser-fingerprint');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
var getBrowserFingerprint__default = /*#__PURE__*/_interopDefaultLegacy(getBrowserFingerprint);
/**
* AssociatedAccount Type.
* @typedef {Object} AssociatedAccount
* @property {string} application - ucc application or external system.
* @property {string} userId - ucc application or external system userId.
*/
/**
* NewReferralMember Type.
* @typedef {Object} NewReferralMember
* @property {string} firstName - firstName.
* @property {string} lastName - lastName.
* @property {string} email - email.
* @property {string} phone - phone.
* @property {string} country - country.
* @property {string} password - password.
* @property {AssociatedAccount} associatedAccount - associatedAccount.
* @property {string} referralCode - referralCode.
* @property {string} referralProgramId - referralProgramId.
*/
/**
* MemberSummary Type.
* @typedef {Object} MemberSummary
* @property {string} userProfileId - userProfileId.
* @property {string} auth0Id - auth0Id.
* @property {string} memberId - memberId.
* @property {string} referralLink - referralLink.
*/
/**
* Create A New Referral Member.
* @function
* @memberof rfbm
* @param {NewReferralMember} newReferralMember - New Referral Member.
* @returns {Promise<MemberSummary>} New Referral Result
*/
async function createNewReferralMember(newReferralMember) {
const ENDPOINT = 'https://pmxfwkh2ka.execute-api.eu-central-1.amazonaws.com/default/rfbm-create-member';
const response = await axios__default["default"].post(ENDPOINT, newReferralMember);
return response.data;
}
const _createNewReferralMember = createNewReferralMember;
/**
* Find Referral Program Member.
* @function
* @memberof rfbm
* @param {string} programId - Referral Program Id.
* @param {string} application - Application or External System.
* @param {string} userId - Referral Program User Id.
* @returns {Promise<ReferralProgramMember>} Get Referral Program Member Result
*/
async function findReferralProgramMember(programId, application, userId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/members/programs/${programId}?externalSystem=${application}&userId=${userId}`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _findReferralProgramMember = findReferralProgramMember;
/**
* Confirm Referral.
* @function
* @memberof rfbm
* @param {string} referralId - Referral Id.
* @returns {Promise<any>} Confirm Referral Result
*/
async function confirmReferral(referralId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/referrals/${referralId}/confirm`;
const response = await axios__default["default"].patch(ENDPOINT);
return response.data;
}
const _confirmReferral = confirmReferral;
/**
* Get Member Referral Statistics
* @function
* @memberof rfbm
* @param {string} programId - Referral Program Id.
* @param {string} memberId - Referral Program Member Id.
* @returns {Promise<any>} Get Member Referral Statistics Result
*/
async function getMemberReferralStatistics(programId, memberId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/programs/${programId}/members/${memberId}/statistics`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _getMemberReferralStatistics = getMemberReferralStatistics;
/**
* ReferralProgram Type.
* @typedef {Object} ReferralProgram
* @property {string} title - referral program title
* @property {string} description - referral program description
*/
/**
* ReferralMember Type.
* @typedef {Object} ReferralMember
* @property {string} firstName - referral member firstName
* @property {string} lastName - referral member lastName
*/
/**
* ReferralFriend Type.
* @typedef {Object} ReferralFriend
* @property {string} firstName - referred friend firstName
* @property {string} lastName - referred friend lastName
*/
/**
* Referral Type.
* @typedef {Object} Referral
* @property {ReferralProgram} program - referral program
* @property {ReferralMember} member - referral member
* @property {ReferralFriend} friend- referred friend
*/
/**
* ReferralDetails Type.
* @typedef {Object} ReferralDetails
* @property {string} message - message
* @property {Referral} result - result
*/
/**
* Get Referral Details
* @function
* @memberof rfbm
* @param {string} referralId - Referral Id.
* @returns {Promise<ReferralDetails>} Get Referral Details Result
*/
async function getReferralDetails(referralId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/referrals/${referralId}`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _getReferralDetails = getReferralDetails;
/**
* Associate Friend.
* @function
* @memberof rfbm
* @param {string} referralId - Referral Id.
* @param {string} userId - User Id.
* @returns {Promise<any>} Associate Friend Result
*/
async function associateFriend(referralId, userId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/referrals/${referralId}/friends/${userId}`;
const response = await axios__default["default"].post(ENDPOINT);
return response.data;
}
const _associateFriend = associateFriend;
/**
* PayoutSettings Type.
* @typedef {Object} PayoutSettings
* @property {string} blockchain - blockchain.
* @property {string} address - address.
*/
/**
* SocialMediaProfiles Type.
* @typedef {Object} SocialMediaProfiles
* @property {string} username - username.
* @property {string} provider - provider.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMember
* @property {string} firstName - firstName.
* @property {string} lastName - lastName.
* @property {string} phone - phone.
* @property {string} country - country.
* @property {Array<PayoutSettings>} payoutSettings - payoutSettings.
* @property {Array<SocialMediaProfiles>} socialMediaProfiles - socialMediaProfiles.
* @property {string} email - email.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMemberResult
* @property {ReferralProgramMember} result - referral member.
*/
/**
* Get Member By User Id.
* @function
* @memberof rfbm
* @param {string} programId - Referral Program Id.
* @param {string} userId - auth0 ID.
* @returns {Promise<ReferralProgramMemberResult>} Get Member By User Id Result
*/
async function getMemberByUserId(programId, userId) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/rfbm/members?filter={"$or":[{"auth0.smsId":"${userId}"},{"auth0.emailId":"${userId}"}]}`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _getMemberByUserId = getMemberByUserId;
/**
* PayoutSettings Type.
* @typedef {Object} PayoutSettings
* @property {string} blockchain - blockchain.
* @property {string} address - address.
*/
/**
* SocialMediaProfiles Type.
* @typedef {Object} SocialMediaProfiles
* @property {string} username - username.
* @property {string} provider - provider.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMember
* @property {string} firstName - firstName.
* @property {string} lastName - lastName.
* @property {string} phone - phone.
* @property {string} country - country.
* @property {Array<PayoutSettings>} payoutSettings - payoutSettings.
* @property {Array<SocialMediaProfiles>} socialMediaProfiles - socialMediaProfiles.
* @property {string} email - email.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMemberResult
* @property {ReferralProgramMember} result - referral member.
*/
/**
* Get Member By Associated Account
* @function
* @memberof rfbm
* @param {string} externalSystem - External System.
* @param {string} externalUserId - External User Id.
* @param {string} programId - Referral Program Id.
* @returns {Promise<ReferralProgramMemberResult>} Get Member By Associated Account Result
*/
async function getMemberByAssociatedAccount(externalSystem, externalUserId, programId) {
const filter = {
"associatedAccounts.application": externalSystem,
"associatedAccounts.userId": externalUserId,
};
const ENDPOINT = `https://api.unchainedcarrot.com/v1/users?filter=${JSON.stringify(filter)}`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _getMemberByAssociatedAccount = getMemberByAssociatedAccount;
/**
* PayoutSettings Type.
* @typedef {Object} PayoutSettings
* @property {string} blockchain - blockchain.
* @property {string} address - address.
*/
/**
* SocialMediaProfiles Type.
* @typedef {Object} SocialMediaProfiles
* @property {string} username - username.
* @property {string} provider - provider.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMember
* @property {string} firstName - firstName.
* @property {string} lastName - lastName.
* @property {string} phone - phone.
* @property {string} country - country.
* @property {Array<PayoutSettings>} payoutSettings - payoutSettings.
* @property {Array<SocialMediaProfiles>} socialMediaProfiles - socialMediaProfiles.
* @property {string} email - email.
*/
/**
* ReferralProgramMember Type.
* @typedef {Object} ReferralProgramMemberResult
* @property {ReferralProgramMember} result - referral member.
*/
/**
* Get Member By Friend.
* @function
* @memberof rfbm
* @param {string} userId - user objectId.
* @param {string} programId - Referral Program Id.
* @returns {Promise<ReferralProgramMemberResult>} Get Member By Friend Result
*/
async function getMemberByFriend(userId, programId) {
const referralResponse = await axios__default["default"].get(`https://api.unchainedcarrot.com/v1/rfbm/referrals?filter={"friend":"${userId}","program":"${programId}"}`);
const response = await axios__default["default"].get(`https://api.unchainedcarrot.com/v1/rfbm/members/${referralResponse.data.referrals[0].member}`);
return response.data;
}
const _getMemberByFriend = getMemberByFriend;
/**
* SocialMediaProfiles Type.
* @typedef {Object} SocialMediaProfiles
* @property {string} username - username.
* @property {string} provider - provider.
*/
/**
* PhoneInfo Type.
* @typedef {Object} PhoneInfo
* @property {string} _id - _id
* @property {string} brand - brand
* @property {string} deviceId - deviceId
* @property {string} deviceLocale - deviceLocale
* @property {string} timeZone - timeZone
* @property {string} timeStamp - timeStamp
* @property {boolean} isTablet - isTablet
*/
/**
* BrowserInfo Type.
* @typedef {Object} BrowserInfo
* @property {string} _id - _id
* @property {string} timeStamp - timeStamp
* @property {string} userAgent - userAgent
*/
/**
* PersonalData Type.
* @typedef {Object} PersonalData
* @property {string} firstName - firstName
* @property {string} lastName - lastName
* @property {string} gender - gender
* @property {string} yearOfBirth - yearOfBirth
* @property {string} countryOfResidence - countryOfResidence
* @property {string} nationality - nationality
* @property {Array<SocialMediaProfiles>} socialMedia - socialMedia
*/
/**
* UserProfile Type.
* @typedef {Object} UserProfile
* @property {string} _id - _id
* @property {string} blockchainAddress - blockchainAddress
* @property {PersonalData} personalData - personalData
* @property {Array<PhoneInfo>} phoneInfo - phoneInfo
* @property {Array<BrowserInfo>} browserInfo - browserInfo
*/
/**
* UserProfileResult Type.
* @typedef {Object} UserProfileResult
* @property {number} count - count
* @property {Array<UserProfile>} result - result
*/
/**
* Get User By Associated Account
* @function
* @memberof user
* @param {string} externalSystem - External System.
* @param {string} externalUserId - External User Id.
* @returns {Promise<UserProfileResult>} Get User By Associated Account Result
*/
async function getUserByAssociatedAccount(externalSystem, externalUserId) {
const filter = {
"associatedAccounts.application": externalSystem,
"associatedAccounts.userId": externalUserId,
};
const ENDPOINT = `https://api.unchainedcarrot.com/v1/users?filter=${JSON.stringify(filter)}`;
const response = await axios__default["default"].get(ENDPOINT);
return response.data;
}
const _getUserByAssociatedAccount = getUserByAssociatedAccount;
/**
* NewStoreCard Type.
* @typedef {Object} NewStoreCard
* @property {string} walletProvider - walletProvider.
* @property {string} templateId - templateId.
* @property {string} customerId - customerId.
* @property {string} userId - userId.
*/
/**
* NewStoreCard Result Type.
* @typedef {Object} NewStoreCardResult
* @property {string} passTypeIdentifier - passTypeIdentifier.
* @property {string} serialNumber - serialNumber.
* @property {string} description - description.
*/
/**
* Create Store Card.
* @function
* @memberof user
* @param {NewStoreCard} newStoreCard - New Store Card
* @returns {Promise<NewStoreCardResult>} New Store Card Result
*/
async function createStoreCard(newStoreCard) {
const ENDPOINT = 'https://pmxfwkh2ka.execute-api.eu-central-1.amazonaws.com/default/apple-wallet-create-card';
const response = await axios__default["default"].post(ENDPOINT, newStoreCard);
return response.data;
}
const _createStoreCard = createStoreCard;
/**
* NewUserProfile Type.
* @typedef {Object} NewUserProfile
* @property {string} firstName - firstName.
* @property {string} lastName - lastName.
* @property {string} email - email.
* @property {string} phone - phone.
* @property {string} country - country.
* @property {string} password - password.
* @property {AssociatedAccount} associatedAccount - associatedAccount.
*/
/**
* NewUserProfileResult Type.
* @typedef {Object} NewUserProfileResult
* @property {string} userProfileId - userProfileId.
* @property {string} auth0Id - auth0Id.
*/
/**
* Create A New User Profile.
* @function
* @memberof user
* @param {NewUserProfile} newUserProfile - New User Profile.
* @returns {Promise<NewUserProfileResult>} New User Profile Result
*/
async function create(newUserProfile) {
const ENDPOINT = 'https://pmxfwkh2ka.execute-api.eu-central-1.amazonaws.com/default/ucc-create-user-profile';
const response = await axios__default["default"].post(ENDPOINT, newUserProfile);
return response.data;
}
const _create = create;
/**
* NewEngagement Type.
* @typedef {Object} NewEngagement
* @property {string} customerId - customerId.
* @property {string} firstTimeOn - firstTimeOn.
*/
/**
* Add A New Engagement.
* @function
* @memberof user
* @param {string} userId - User ObjectID
* @param {NewEngagement} newEngagement - New Engagement.
* @returns {Promise<any>} New Engagement Result
*/
async function engagedWith(userId, newEngagement) {
const ENDPOINT = `https://api.unchainedcarrot.com/v1/users/${userId}/engagements`;
const response = await axios__default["default"].post(ENDPOINT, newEngagement);
return response.data;
}
const _engagedWith = engagedWith;
/**
* NewOptIn Type.
* @typedef {Object} NewOptIn
* @property {string} productOrService - productOrService.
* @property {string} optedInOn - optedInOn.
* @property {string} optedInIpAddress - optedInIpAddress.
* @property {string} optedInUserAgent - optedInUserAgent.
* @property {string} optedInFormUrl - optedInFormUrl.
*/
/**
* Add A New Opt In.
* @function
* @memberof user
* @param {string} userId - User ObjectID
* @param {string} customerId - Customer ObjectID
* @param {NewOptIn} newOptIn - New Opt In.
* @returns {Promise<any>} New Opt In Result
*/
async function optIn(userId, customerId, newOptIn) {
const DELETE_ENDPOINT = `https://api.unchainedcarrot.com/v1/users/${userId}/engagements/${customerId}/opt-outs/${newOptIn.productOrService}`;
const POST_ENDPOINT = `https://api.unchainedcarrot.com/v1/users/${userId}/engagements/${customerId}/opt-ins`;
await axios__default["default"].delete(DELETE_ENDPOINT);
const response = await axios__default["default"].post(POST_ENDPOINT, newOptIn);
return response.data;
}
const _optIn = optIn;
/**
* NewOptOut Type.
* @typedef {Object} NewOptOut
* @property {string} productOrService - productOrService.
* @property {string} optedOutOn - optedOutOn.
* @property {string} optedOutIpAddress - optedOutIpAddress.
*/
/**
* Add A New Opt In.
* @function
* @memberof user
* @param {string} userId - User ObjectID
* @param {string} customerId - Customer ObjectID
* @param {NewOptOut} newOptOut - New Opt In.
* @returns {Promise<any>} New Opt In Result
*/
async function optOut(userId, customerId, newOptOut) {
const DELETE_ENDPOINT = `https://api.unchainedcarrot.com/v1/users/${userId}/engagements/${customerId}/opt-ins/${newOptOut.productOrService}`;
const POST_ENDPOINT = `https://api.unchainedcarrot.com/v1/users/${userId}/engagements/${customerId}/opt-outs`;
await axios__default["default"].delete(DELETE_ENDPOINT);
const response = await axios__default["default"].post(POST_ENDPOINT, newOptOut);
return response.data;
}
const _optOut = optOut;
let UCC_CUSTOMER_ID,
UCC_PROJECT_ID,
UCC_LANDING_PAGE_ID,
UCC_SESSION_ID,
UCC_SESSION_TIMESTAMP,
UCC_STAGE = 'dev';
/**
* Initialization Type.
* @typedef {Object} Initialization
* @property {string} customerId - UCC Customer ID.
* @property {string} projectId - UCC Project/Source ID.
* @property {string} apiKey - UCC Customer Api Key.
* @property {string} pageId - UCC Landing Page Object Id.
* @property {string} stage - UCC Stage.
*/
/**
* Initialize UCC Web Tracking.
* @function
* @memberof track
* @param {Initialization} initialization - initialization.
* @returns {boolean} Web Tracking Init Response
*/
function initialize({ customerId, projectId, apiKey = 'live_soon_to_be_deprecated', pageId, stage = 'dev' }) {
if (!customerId) {
throw Error('Please provide a customerId');
}
if (!apiKey) {
throw Error('Please provide an apiKey');
}
if (!stage) {
throw Error('Please provide a stage');
}
// Initialize Global Variables
UCC_CUSTOMER_ID = customerId;
UCC_PROJECT_ID = projectId;
UCC_LANDING_PAGE_ID = pageId;
UCC_STAGE = stage;
UCC_SESSION_ID = uuid.v4();
UCC_SESSION_TIMESTAMP = Date.now();
// Return
return true;
}
/**
* Tracking Event Type.
* @typedef {Object} TrackingEvent
* @property {string} customerId - UCC Customer ID.
* @property {string} projectId - UCC Project/Source ID.
* @property {string} event - Event Name - Find out from Project Manager.
* @property {object} data - Event Data - Find out from Project Manager.
* @property {object} user - User Data If Applicable.
* @property {string} type - Event Type If Applicable. Defaults to track
*/
/**
* Send UCC Web Tracking Event.
* @function
* @memberof track
* @param {TrackingEvent} trackingEvent - trackingEvent.
* @returns {Promise<any>} Web Tracking Response
*/
async function submitEvent({ customerId, projectId, event, data, user = {}, type = 'track' }) {
// Check If Event Name Is Valid
if (!event) throw new Error('Event Name Is Required!');
// Proceed With Event Submission
const URLS = {
"dev": "https://9lsmzfho83.execute-api.eu-central-1.amazonaws.com/dev/web-tracker",
"prod": "https://7ch7pvny4g.execute-api.eu-central-1.amazonaws.com/prod/web-tracker",
};
const ENDPOINT = URLS[UCC_STAGE];
// Get Browser Context
const context = {};
let WINDOW_LOCATION_HOST = null;
if (window) {
WINDOW_LOCATION_HOST = window.location.host;
const url = new URL(window.location.href);
url.searchParams.forEach((value, key) => {
context[key] = value;
});
context.referrer = document.referrer;
context.language = navigator.language;
context.languages = navigator.languages;
context.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
}
if (type === 'page') {
data.pageId = UCC_LANDING_PAGE_ID;
} else {
context.pageId = UCC_LANDING_PAGE_ID;
}
// Returns the ISO week of the date.
Date.prototype.getWeek = function () {
var date = new Date(this.getTime());
date.setHours(0, 0, 0, 0);
// Thursday in current week decides the year.
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
// January 4 is always in week 1.
var week1 = new Date(date.getFullYear(), 0, 4);
// Adjust to Thursday in week 1 and count number of weeks from date to week1.
return 1 + Math.round(((date.getTime() - week1.getTime()) / 86400000 - 3 + (week1.getDay() + 6) % 7) / 7);
};
// Enriched Timestamp
const currentdate = new Date();
const timestamp = {
"iso": currentdate.toISOString(),
"unix": currentdate.valueOf(),
"year": currentdate.getFullYear(),
"month": currentdate.getMonth() + 1,
"day": currentdate.getDate(),
"hour": currentdate.getHours(),
"minute": currentdate.getMinutes(),
"dayOfWeek": currentdate.getDay(),
"weekNumber": currentdate.getWeek()
};
// Get Finger Print
const fingerprint = getBrowserFingerprint__default["default"]();
// Prepare Session
const session = {
"guid": UCC_SESSION_ID,
"timestamp": UCC_SESSION_TIMESTAMP,
"elapsedTime": currentdate.valueOf() - UCC_SESSION_TIMESTAMP
};
// Prepare Request Body
const body = {
"customerId": customerId || UCC_CUSTOMER_ID,
"projectId": projectId || UCC_PROJECT_ID || WINDOW_LOCATION_HOST,
"event": event,
"type": type,
"context": { ...context, session },
"properties": data,
"user": {
fingerprint,
...user
},
"timestamp": timestamp
};
const response = await axios__default["default"].post(ENDPOINT, body);
return response.data;
}
const _submitEvent = submitEvent;
const _initialize = initialize;
// track methods
/**
* Send UCC Web Page Event.
* @function
* @memberof track
* @returns {Promise<any>} Web Tracking Response
*/
function pageEvent() {
return _submitEvent({
event: 'PAGE_VIEWED',
data: {
protocol: (window && window.location) ? window.location.protocol : null,
host: (window && window.location) ? window.location.host : null,
port: (window && window.location) ? window.location.port : null,
origin: (window && window.location) ? window.location.origin : null,
pathname: (window && window.location) ? window.location.pathname : null,
url: (window && window.location) ? window.location.href : null
},
user: {},
type: 'page'
});
}
const _pageEvent = pageEvent;
/**
* Invoke Webhook
* @function
* @memberof track
* @param {string} webhookUrl - webhookUrl
* @param {object} data - data
* @returns {Promise<any>} Web Tracking Response
*/
async function invokeWebhook(webhookUrl, data) {
const response = await axios__default["default"].post(webhookUrl, data);
return response.data;
}
const _invokeWebhook = invokeWebhook;
/**
* Create Crypto Deposit
* @function
* @memberof payments
* @param {string} customerId - customerId
* @param {string} chainName - chainName
* @param {string} userId - userId
* @param {string} currency - currency
* @param {string} amount - amount
* @param {string} tokenSymbol - tokenSymbol
* @param {Array<Object>} events - events
* @returns {Promise<any>} Create Crypto Deposit Response
*/
async function createDeposit(customerId, chainName, userId, currency, amount, tokenSymbol, events) {
const response = await axios__default["default"].post(
`https://4wm9uqkg41.execute-api.eu-central-1.amazonaws.com/customers/${customerId}/crypto-deposits`,
{
"chainName": chainName,
"userId": userId,
"currency": currency,
"amount": amount,
"tokenSymbol": tokenSymbol.toUpperCase(),
"events": events
}
);
await _submitEvent({ event: 'CRYPTO_DEPOSIT_CREATED', data: response.data.result });
return response.data;
}
const _createDeposit = createDeposit;
/**
* Get Crypto Deposit
* @function
* @memberof payments
* @param {string} customerId - customerId
* @param {string} depositId - depositId
* @returns {Promise<any>} Get Crypto Deposit Response
*/
async function getDeposit(customerId, depositId) {
const response = await axios__default["default"].get(
`https://4wm9uqkg41.execute-api.eu-central-1.amazonaws.com/customers/${customerId}/crypto-deposits/${depositId}`
);
return response.data;
}
const _getDeposit = getDeposit;
/**
* Update Crypto Deposit
* @function
* @memberof payments
* @param {string} customerId - customerId
* @param {string} depositId - depositId
* @param {string} txHash - txHash
* @returns {Promise<any>} Update Crypto Deposit Response
*/
async function updateDeposit(customerId, depositId, txHash) {
const response = await axios__default["default"].patch(
`https://4wm9uqkg41.execute-api.eu-central-1.amazonaws.com/customers/${customerId}/crypto-deposits/${depositId}`,
{
"txHash": txHash
}
);
await _submitEvent({ event: 'CRYPTO_DEPOSIT_UPDATED', data: response.data.result });
return response.data;
}
const _updateDeposit = updateDeposit;
/**
* Cancel Crypto Deposit
* @function
* @memberof payments
* @param {string} customerId - customerId
* @param {string} depositId - depositId
* @returns {Promise<any>} Cancel Crypto Deposit Response
*/
async function cancelDeposit(customerId, depositId) {
const response = await axios__default["default"].delete(
`https://4wm9uqkg41.execute-api.eu-central-1.amazonaws.com/customers/${customerId}/crypto-deposits/${depositId}`
);
await _submitEvent({ event: 'CRYPTO_DEPOSIT_CANCELLED', data: response.data.result });
return response.data;
}
const _cancelDeposit = cancelDeposit;
/**
* Get Customer Hot Wallets
* @function
* @memberof payments
* @param {string} customerId - customerId
* @param {string} usage - usage
* @returns {Promise<any>} Get Customer Hot Wallets Response
*/
async function getHotWallets(customerId, usage = 'ANY') {
const response = await axios__default["default"].get(
`https://4wm9uqkg41.execute-api.eu-central-1.amazonaws.com/customers/${customerId}/hot-wallets?usage=${usage}`
);
// Return response
return response.data;
}
const _getHotWallets = getHotWallets;
/** SDK METHODS */
/** @namespace */
const rfbm = {
createNewReferralMember: _createNewReferralMember,
findReferralProgramMember: _findReferralProgramMember,
confirmReferral: _confirmReferral,
getMemberReferralStatistics: _getMemberReferralStatistics,
getReferralDetails: _getReferralDetails,
associateFriend: _associateFriend,
getMemberByUserId: _getMemberByUserId,
getMemberByAssociatedAccount: _getMemberByAssociatedAccount,
getMemberByFriend: _getMemberByFriend
};
/** @namespace */
const user = {
getUserByAssociatedAccount: _getUserByAssociatedAccount,
createStoreCard: _createStoreCard,
create: _create,
engagedWith: _engagedWith,
optIn: _optIn,
optOut: _optOut
};
/** @namespace */
const track = {
initialize: _initialize,
submitEvent: _submitEvent,
pageEvent: _pageEvent,
invokeWebhook: _invokeWebhook,
};
/** @namespace */
const payments = {
createDeposit: _createDeposit,
getDeposit: _getDeposit,
updateDeposit: _updateDeposit,
cancelDeposit: _cancelDeposit,
getHotWallets: _getHotWallets
};
exports.payments = payments;
exports.rfbm = rfbm;
exports.track = track;
exports.user = user;