Class: SendGrid::StatsResponse
- Inherits:
-
Object
- Object
- SendGrid::StatsResponse
- Defined in:
- lib/sendgrid/helpers/stats/stats_response.rb
Instance Method Summary collapse
- #error? ⇒ Boolean
- #errors ⇒ Object
-
#initialize(args) ⇒ StatsResponse
constructor
A new instance of StatsResponse.
- #metrics ⇒ Object
Constructor Details
#initialize(args) ⇒ StatsResponse
5 6 7 8 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 5 def initialize(args) @errors = args['errors'] if args.is_a? Hash @stats = args if args.is_a? Array end |
Instance Method Details
#error? ⇒ Boolean
16 17 18 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 16 def error? !@errors.nil? end |
#errors ⇒ Object
10 11 12 13 14 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 10 def errors @errors.map do |error| error['message'] end end |
#metrics ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 20 def metrics @stats.flat_map do |stat| starting_date = stat['date'] all_stats_for_date = stat['stats'] metrics = all_stats_for_date.map do |metric| Metrics.new(metric['metrics'].merge('date' => starting_date)) end end end |