MikelCalvo / node-mailwizz

[UNOFFICIAL] MailWizz API for NodeJS
https://npmjs.org/package/node-mailwizz
ISC License
10 stars 14 forks source link

Check if a person has unsubscribed from a list #59

Open chengtie opened 6 months ago

chengtie commented 6 months ago

Hello,

I would like to know

  1. how to check if a person has unsubscribed from a list
  2. how to get all the unsubscribers from a list

Could anyone help?

Thank you

chengtie commented 6 months ago

I tried the following code:

const { ListSubscribers } = require('node-mailwizz');

const config = {
    publicKey: 'f36dd4cd40beb775068fc9650d1',
    secret: 'f36dd4cd40beb775068fc9650d1',
    baseUrl: 'http://mail.mycompany.com/api'
}
// Configuration details directly in the class constructor
const subscribers = new ListSubscribers(config);

// Function to search for a subscriber by email
function searchSubscriber(listUid, email) {
    console.log("listUid", listUid)
    console.log("email", email)
    subscribers.emailSearch({
        listUid: listUid,
        email: email
    })
    .then(result => {
        console.log('Subscriber found:', result);
    })
    .catch(err => {
        console.error('Error:', err);
    });
}

// Example usage of the function
searchSubscriber('en804x0lnrf1f', 'fabio.ginnetti@savoiaesavoia.it');

However, it returned

listUid en804x0lnrf1f
email fabio.ginnetti@savoiaesavoia.it
Error: {
  status: 'error',
  error: 'Please provide the subscriber email address.'
}