Skip to content

updateMessageLog

This function is to add following messages on the same day to the same contact. Use case is explained here

Params

Input: - user: user entity - contactInfo: has id, phoneNumber, type, name - existingMessageLog: existing message log entity - authHeader: auth header for CRM API call - message: message text

Reference

    // const getLogRes = await axios.get(
    //     `https://api.crm.com/activity/${callLogId}`,
    //     {
    //         headers: { 'Authorization': authHeader }
    //     });

    const getLogRes = {
        subject: mockCallLog.subject,
        note: mockCallLog.note
    }
    const subject = getLogRes.subject;
    const note = getLogRes.note.split('- Agent note: ')[1].split('\n')[0];

    //-------------------------------------------------------------------------------------
    //---CHECK.5: In extension, for a logged call, click edit to see if info is fetched ---
    //-------------------------------------------------------------------------------------
    return {
        callLogInfo: {
            subject,
            note,
            dispositions:{
                testDispositionId: 'test disposition value'
            }
        },
        returnMessage: {
            message: 'Call log fetched.',
            messageType: 'success',
            ttl: 3000
        }
    }
    };
    return {
        updatedNote: patchBody.note,
        returnMessage: {
            message: 'Call log updated.',
            messageType: 'success',
            ttl: 2000
        },
        extraDataTracking
    };
}

async function upsertCallDisposition({ user, existingCallLog, authHeader, dispositions }) {
    let extraDataTracking = {};
    if (!dispositions.deals) {
        return {
            logId: null
        };
    }
    const existingPipedriveLogId = existingCallLog.thirdPartyLogId;
    const patchBody = {
        deal_id: dispositions.deals                   
    }
    const patchLogRes = await axios.patch(
        `https://${user.hostname}/api/v2/activities/${existingPipedriveLogId}`,
        patchBody,
        {
            headers: { 'Authorization': authHeader }
        });
    extraDataTracking = {
        ratelimitRemaining: patchLogRes.headers['x-ratelimit-remaining'],
        ratelimitAmount: patchLogRes.headers['x-ratelimit-limit'],
        ratelimitReset: patchLogRes.headers['x-ratelimit-reset']
    };