Skip to content

Instantly share code, notes, and snippets.

@jsugarman
Created October 3, 2017 15:29
Show Gist options
  • Save jsugarman/3f7b304557133249105d10aadac319e0 to your computer and use it in GitHub Desktop.
Save jsugarman/3f7b304557133249105d10aadac319e0 to your computer and use it in GitHub Desktop.
Govuk notify API query to retrieve mail sent and failed
require 'notifications/client'
def client
@client ||= Notifications::Client.new(ENV['SETTINGS__GOVUK_NOTIFY__API_KEY'])
end
def notifications args
client.get_notifications(args)
end
def emails_sent
notifications({ template_type: 'email' }).collection
end
def emails_failed
notifications({ template_type: 'email', status: 'failed' }).collection
end
puts failed: emails_failed.count
#37 is number of pre-live mails sent using this key
puts sent: emails_sent.count - 37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment