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
Returns a new instance of StatsResponse.
3 4 5 6 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 3 def initialize(args) @errors = args['errors'] if args.is_a? Hash @stats = args if args.is_a? Array end |
Instance Method Details
#error? ⇒ Boolean
14 15 16 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 14 def error? !@errors.nil? end |
#errors ⇒ Object
8 9 10 11 12 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 8 def errors @errors.map do |error| error['message'] end end |
#metrics ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sendgrid/helpers/stats/stats_response.rb', line 18 def metrics @stats.flat_map do |stat| starting_date = stat['date'] all_stats_for_date = stat['stats'] all_stats_for_date.map do |metric| Metrics.new(metric['metrics'].merge('date' => starting_date)) end end end |