

MASSACHUSETTS ASSOCIATION OF TECHNICAL RESCUE SPECIALISTS
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import {add} from 'public/new-file.js' $w.onReady(function () { let sum = add(6,7); console.log(sum); }); */
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import { add } from "public/new-file.js"; $w.onReady(function () { const sum = add(6, 7); console.log(sum); }); */
// backend/http-functions.js import { ok, forbidden, serverError } from "wix-http-functions"; import { orders } from "wix-pricing-plans-backend"; import { contacts } from "wix-crm-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; const SUBSCRIBER_TOKEN_SECRET = "MATRS_SUBSCRIBER_TOKEN"; const PAGE_SIZE = 50; const elevatedGetSecretValue = elevate(secrets.getSecretValue); function secretValue(result) { return typeof result === "string" ? result : result?.value; } function emailFromContact(contact) { return ( contact?.primaryInfo?.email || contact?.info?.emails?.find((item) => item?.primary)?.email || contact?.info?.emails?.[0]?.email || "" ); } async function getPaidActiveOrders() { const results = []; for (let skip = 0; ; skip += PAGE_SIZE) { const batch = await orders.listOrders( { orderStatuses: ["ACTIVE"] }, { fieldName: ["createdDate"], order: ["ASC"] }, { limit: PAGE_SIZE, skip }, { suppressAuth: true }, ); results.push( ...batch.filter( (order) => String(order?.lastPaymentStatus || "").toUpperCase() === "PAID", ), ); if (batch.length < PAGE_SIZE) { break; } } return results; } /** * Returns one normalized email address per active, paid Wix pricing-plan order. * Authentication: ?token=<value stored in MATRS_SUBSCRIBER_TOKEN>. */ export async function get_matrsActiveSubscribers(request) { try { const suppliedToken = request?.query?.token; const storedSecret = await elevatedGetSecretValue(SUBSCRIBER_TOKEN_SECRET); const expectedToken = secretValue(storedSecret); if (!suppliedToken || !expectedToken || suppliedToken !== expectedToken) { return forbidden({ headers: { "Content-Type": "application/json" }, body: { error: "Invalid token" }, }); } const activeOrders = await getPaidActiveOrders(); const emails = new Set(); for (const order of activeOrders) { let email = order?.buyer?.email || order?.customer?.email || order?.buyerInfo?.email || ""; const contactId = order?.buyer?.contactId || order?.buyerInfo?.contactId || order?.contactId; if (!email && contactId) { try { const contact = await contacts.getContact(contactId, { suppressAuth: true, }); email = emailFromContact(contact); } catch (contactError) { console.warn( `MATRS subscriber contact lookup failed for ${contactId}`, contactError, ); } } const normalized = String(email || "").trim().toLowerCase(); if (normalized) { emails.add(normalized); } } return ok({ headers: { "Content-Type": "application/json" }, body: { emails: Array.from(emails).sort() }, }); } catch (error) { console.error("MATRS active subscriber export failed", error); return serverError({ headers: { "Content-Type": "application/json" }, body: { error: "Unable to retrieve active subscribers" }, }); } }
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import {add} from 'public/new-file.js' $w.onReady(function () { let sum = add(6,7); console.log(sum); }); */
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import {add} from 'public/new-file.js' $w.onReady(function () { let sum = add(6,7); console.log(sum); }); */
// backend/http-functions.js import { ok, forbidden, serverError } from "wix-http-functions"; import { orders } from "wix-pricing-plans-backend"; import { contacts } from "wix-crm-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; const SUBSCRIBER_TOKEN_SECRET = "MATRS_SUBSCRIBER_TOKEN"; const PAGE_SIZE = 50; const elevatedGetSecretValue = elevate(secrets.getSecretValue); function secretValue(result) { return typeof result === "string" ? result : result?.value; } function emailFromContact(contact) { return ( contact?.primaryInfo?.email || contact?.info?.emails?.find((item) => item?.primary)?.email || contact?.info?.emails?.[0]?.email || "" ); } async function getPaidActiveOrders() { const results = []; for (let skip = 0; ; skip += PAGE_SIZE) { const batch = await orders.listOrders( { orderStatuses: ["ACTIVE"] }, { fieldName: ["createdDate"], order: ["ASC"] }, { limit: PAGE_SIZE, skip }, { suppressAuth: true }, ); results.push( ...batch.filter( (order) => String(order?.lastPaymentStatus || "").toUpperCase() === "PAID", ), ); if (batch.length < PAGE_SIZE) { break; } } return results; } /** * Returns one normalized email address per active, paid Wix pricing-plan order. * Authentication: ?token=<value stored in MATRS_SUBSCRIBER_TOKEN>. */ export async function get_matrsActiveSubscribers(request) { try { const suppliedToken = request?.query?.token; const storedSecret = await elevatedGetSecretValue(SUBSCRIBER_TOKEN_SECRET); const expectedToken = secretValue(storedSecret); if (!suppliedToken || !expectedToken || suppliedToken !== expectedToken) { return forbidden({ headers: { "Content-Type": "application/json" }, body: { error: "Invalid token" }, }); } const activeOrders = await getPaidActiveOrders(); const emails = new Set(); for (const order of activeOrders) { let email = order?.buyer?.email || order?.customer?.email || order?.buyerInfo?.email || ""; const contactId = order?.buyer?.contactId || order?.buyerInfo?.contactId || order?.contactId; if (!email && contactId) { try { const contact = await contacts.getContact(contactId, { suppressAuth: true, }); email = emailFromContact(contact); } catch (contactError) { console.warn( `MATRS subscriber contact lookup failed for ${contactId}`, contactError, ); } } const normalized = String(email || "").trim().toLowerCase(); if (normalized) { emails.add(normalized); } } return ok({ headers: { "Content-Type": "application/json" }, body: { emails: Array.from(emails).sort() }, }); } catch (error) { console.error("MATRS active subscriber export failed", error); return serverError({ headers: { "Content-Type": "application/json" }, body: { error: "Unable to retrieve active subscribers" }, }); } }
// backend/http-functions.js import { ok, forbidden, serverError } from "wix-http-functions"; import { orders } from "wix-pricing-plans-backend"; import { contacts } from "wix-crm-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; const SUBSCRIBER_TOKEN_SECRET = "MATRS_SUBSCRIBER_TOKEN"; const PAGE_SIZE = 50; const elevatedGetSecretValue = elevate(secrets.getSecretValue); function secretValue(result) { return typeof result === "string" ? result : result?.value; } function emailFromContact(contact) { return ( contact?.primaryInfo?.email || contact?.info?.emails?.find((item) => item?.primary)?.email || contact?.info?.emails?.[0]?.email || "" ); } async function getPaidActiveOrders() { const results = []; for (let skip = 0; ; skip += PAGE_SIZE) { const batch = await orders.listOrders( { orderStatuses: ["ACTIVE"] }, { fieldName: ["createdDate"], order: ["ASC"] }, { limit: PAGE_SIZE, skip }, { suppressAuth: true }, ); results.push( ...batch.filter( (order) => String(order?.lastPaymentStatus || "").toUpperCase() === "PAID", ), ); if (batch.length < PAGE_SIZE) break; } return results; } /** * Returns one normalized email address per active, paid Wix pricing-plan order. * Authentication: ?token=<value stored in MATRS_SUBSCRIBER_TOKEN>. */ export async function get_matrsActiveSubscribers(request) { try { const suppliedToken = request?.query?.token; const storedSecret = await elevatedGetSecretValue(SUBSCRIBER_TOKEN_SECRET); const expectedToken = secretValue(storedSecret); if (!suppliedToken || !expectedToken || suppliedToken !== expectedToken) { return forbidden({ headers: { "Content-Type": "application/json" }, body: { error: "Invalid token" }, }); } const activeOrders = await getPaidActiveOrders(); const emails = new Set(); for (const order of activeOrders) { let email = order?.buyer?.email || order?.customer?.email || order?.buyerInfo?.email || ""; const contactId = order?.buyer?.contactId || order?.buyerInfo?.contactId || order?.contactId; if (!email && contactId) { try { const contact = await contacts.getContact(contactId, { suppressAuth: true, }); email = emailFromContact(contact); } catch (contactError) { console.warn( `MATRS subscriber contact lookup failed for ${contactId}`, contactError, ); } } const normalized = String(email || "").trim().toLowerCase(); if (normalized) emails.add(normalized); } return ok({ headers: { "Content-Type": "application/json" }, body: { emails: Array.from(emails).sort() }, }); } catch (error) { console.error("MATRS active subscriber export failed", error); return serverError({ headers: { "Content-Type": "application/json" }, body: { error: "Unable to retrieve active subscribers" }, }); } }
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import {add} from 'public/new-file.js' $w.onReady(function () { let sum = add(6,7); console.log(sum); }); */
// backend/http-functions.js import { ok, forbidden, serverError } from "wix-http-functions"; import { orders } from "wix-pricing-plans-backend"; import { contacts } from "wix-crm-backend"; import { secrets } from "wix-secrets-backend.v2"; import { elevate } from "wix-auth"; const SUBSCRIBER_TOKEN_SECRET = "MATRS_SUBSCRIBER_TOKEN"; const PAGE_SIZE = 50; const elevatedGetSecretValue = elevate(secrets.getSecretValue); function readSecret(result) { return typeof result === "string" ? result : result?.value; } function readEmail(contact) { return ( contact?.primaryInfo?.email || contact?.info?.emails?.find((item) => item?.primary)?.email || contact?.info?.emails?.[0]?.email || "" ); } async function listPaidActiveOrders() { const active = []; for (let skip = 0; ; skip += PAGE_SIZE) { const batch = await orders.listOrders( { orderStatuses: ["ACTIVE"] }, { fieldName: ["createdDate"], order: ["ASC"] }, { limit: PAGE_SIZE, skip }, { suppressAuth: true }, ); active.push( ...batch.filter( (order) => String(order?.lastPaymentStatus || "").toUpperCase() === "PAID", ), ); if (batch.length < PAGE_SIZE) break; } return active; } export async function get_matrsActiveSubscribers(request) { try { const stored = await elevatedGetSecretValue(SUBSCRIBER_TOKEN_SECRET); const expected = readSecret(stored); if (!request?.query?.token || request.query.token !== expected) { return forbidden({ headers: { "Content-Type": "application/json" }, body: { error: "Invalid token" }, }); } const emails = new Set(); for (const order of await listPaidActiveOrders()) { let email = order?.buyer?.email || order?.customer?.email || order?.buyerInfo?.email || ""; const contactId = order?.buyer?.contactId || order?.buyerInfo?.contactId || order?.contactId; if (!email && contactId) { try { const contact = await contacts.getContact(contactId, { suppressAuth: true, }); email = readEmail(contact); } catch (contactError) { console.warn( `MATRS subscriber contact lookup failed for ${contactId}`, contactError, ); } } const normalized = String(email || "").trim().toLowerCase(); if (normalized) emails.add(normalized); } return ok({ headers: { "Content-Type": "application/json" }, body: { emails: Array.from(emails).sort() }, }); } catch (error) { console.error("MATRS active subscriber export failed", error); return serverError({ headers: { "Content-Type": "application/json" }, body: { error: "Unable to retrieve active subscribers" }, }); } }
// Filename: public/new-file.js // Code written in public files is shared by your site's // Backend, page code, and site code environments. // Use public files to hold utility functions that can // be called from multiple locations in your site's code. export function add(param1, param2) { return param1 + param2; } // The following code demonstrates how to call the add // function from your site's page code or site code. /* import { add } from "public/new-file.js"; $w.onReady(function () { const sum = add(6, 7); console.log(sum); }); */
Unifying Rescue
MATRS's Commitment to Every Corner of Massachusetts
Welcome to the Massachusetts Association of Technical Rescue Specialists (MATRS), a non-profit corporation dedicated to coordinating Technical Rescue services statewide. As your hub for enhancing professionalism and quality in technical rescue services, we're committed to providing a unified voice for professionals, promoting safety, education, and interoperability in the field. Join our mission to ensure life safety and develop robust technical rescue capabilities throughout the Commonwealth. Together, we're coordinating and mobilizing resources to protect and serve. Your safety, our mission.
The Mission of MATRS
Our mission is to enhance professionalism and the quality of services for members and those managing emergency technical rescue incidents, prioritizing life safety. We provide a unified voice for professionals in policy formation and address technical rescue field issues.
We're committed to ongoing education and training, raising public and agency awareness, and encouraging the development of technical rescue capabilities. Our goal is to promote safety, education, and standardized training across Massachusetts, ensure interoperability among rescue groups, and represent our members to advance our organization's objectives.









