Created
October 3, 2017 15:29
-
-
Save jsugarman/3f7b304557133249105d10aadac319e0 to your computer and use it in GitHub Desktop.
Govuk notify API query to retrieve mail sent and failed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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