← back to Designer Wallcoverings

mailers/cc-api/update-showcase-draft.js

44 lines

'use strict';

/**
 * update-showcase-draft.js — push the current commercial-wallcoverings-showcase.html
 * into the EXISTING Constant Contact DRAFT activity (PUT /v3/emails/activities/{id}).
 * Updating a DRAFT's content is not a send. Gated by CC_LIVE=1 AND --confirm.
 *
 *   node update-showcase-draft.js            # dry-run (NO-OP)
 *   CC_LIVE=1 node update-showcase-draft.js --confirm
 */

const fs = require('fs');
const path = require('path');
const cc = require('./cc-client');

const ACTIVITY_ID = '78b6fcff-b859-4749-8fa1-2924eb0f5a17';
const MAILER = path.join(__dirname, '..', 'commercial-wallcoverings-showcase.html');
const CONFIRM = process.argv.slice(2).includes('--confirm');

const CAMPAIGN = {
  subject: 'The Commercial Edit — 8 contract houses, 3 picks each',
  preheader: 'Koroseal, Maharam, Knoll, Carnegie, Designtex, Wolf Gordon, Hollywood & Majilite — commercial wallcoverings at trade pricing.',
  fromName: 'Designer Wallcoverings',
  fromEmail: 'steve@designerwallcoverings.com',
  replyTo: 'steve@designerwallcoverings.com',
  physicalAddress: {
    address_line1: '15442 Ventura Bl', city: 'Sherman Oaks',
    state_code: 'CA', postal_code: '91403', country_code: 'US',
  },
};

async function main() {
  const html = fs.readFileSync(MAILER, 'utf8');
  console.log(`[update-draft] activity ${ACTIVITY_ID}  html=${html.length} bytes  confirm=${CONFIRM}  CC_LIVE=${process.env.CC_LIVE === '1' ? '1' : '(unset)'}`);
  const res = await cc.updateCampaignActivity(ACTIVITY_ID, {
    subject: CAMPAIGN.subject, preheader: CAMPAIGN.preheader,
    fromEmail: CAMPAIGN.fromEmail, fromName: CAMPAIGN.fromName, replyTo: CAMPAIGN.replyTo,
    htmlContent: html, physicalAddress: CAMPAIGN.physicalAddress,
  }, CONFIRM);
  console.log('[update-draft] result:', JSON.stringify(res).slice(0, 300));
}

main().catch((e) => { console.error('[update-draft] ERROR:', e.message); process.exitCode = 1; });