mailjet/mailjet-gem

How to get total count ?

mbautista opened this issue · 3 comments

Hello,
I would like to retrieve the total messages count with query parameters.
When calling Mailjet::Message.count(params) params are ignored (it returns the whole total count whatever the params).
When calling Mailjet::Message.all(params) we only get an array of Message, the Total count is missing.
Is there a way to retrieve the total count with params ?
NB : The /message end point is limited to 1000 records, so the Total count differs from the array size when > 1000.
Thank you :)

xab3r commented

count with parameters isn't supported.
You can fetch all messages as you suggested. Check this pseudo code:

while messages.count > 0 {
  messages += Mailjet::Message.all(limit: 1000, offset: n)
  n += 1000
}

Hello xab3r,
Yes, that's what we did for now.
Sorry I didn't post the code but it's the same idea as yours.
Thank you :)

xab3r commented

Resolved