mailerlite / mailerlite-nodejs

MIT License
32 stars 7 forks source link

[feat] Added missing cursor param to Subscribers list. #28

Closed neogeek closed 1 year ago

neogeek commented 1 year ago

This add the cursor param to the Subscribers list method. The ListSubscribersResponse type includes the next_cursor and prev_cursor, but the get method didn't accept a cursor via the GetParams type.

I tested this locally, but when I tried running the test via npm test it required an API token and I didn't want to run the tests on my account without knowing what it would add/remove.

Example:

const params = {
  filter: {
    status: "active" // possible statuses: active, unsubscribed, unconfirmed, bounced or junk.
  },
  limit: 10,
  cursor: 'cursor'
};

mailerlite.subscribers.get(params)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) console.log(error.response.data);
  });

Reference: https://developers.mailerlite.com/docs/subscribers.html#list-all-subscribers