如何通过 Ruby on Rails 中的营销电子邮件 API 在 sendgrid 中获取可用电子邮件配额 [英] how to get available emails quota in sendgrid through marketing email api in Ruby on Rails

查看:75
本文介绍了如何通过 Ruby on Rails 中的营销电子邮件 API 在 sendgrid 中获取可用电子邮件配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 gem 'sendgrid_toolkit', '>= 1.1.1'.我想获得每日电子邮件发送限制.

I use gem 'sendgrid_toolkit', '>= 1.1.1'. I want to get my daily email sending limit.

提前致谢.

推荐答案

遗憾的是,目前(作为标准 SendGrid 用户)无法使用 SendGrid API 获取计划中剩余的电子邮件数量.但是,您可以使用 General Statistics 端点及其参数 请求.然后,您可以从计划中的电子邮件数量中减去 requests.

Unfortunately, there's no way to get the number of email remaining on your plan with the SendGrid API at present (as a standard SendGrid User). You can, however, use the General Statistics endpoint and it's parameter requests. You may then subtract requests from the number of emails you have in your plan.

这样做看起来像:

total_credits = 100000
statistics = SendgridToolkit::Statistics.new(api_user, api_key)
stats = statistics.retrieve_aggregate(:start_date => Date.today.beginning_of_month, :end_date => Date.today.end_of_month)
credits_left = total_credits - stats[:requests]

p credits_left

另外要注意的是,我不会太担心超过您的信用额度,因为目前超额按每 1,000 封电子邮件收取 1 美分的费用.

这篇关于如何通过 Ruby on Rails 中的营销电子邮件 API 在 sendgrid 中获取可用电子邮件配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆