/lib/aws/ses/info.rb
Ruby | 100 lines | 39 code | 9 blank | 52 comment | 1 complexity | fd52b0e3ed2e11627b2294a20340a9b9 MD5 | raw file
Possible License(s): JSON
1module AWS 2 module SES 3 # Adds functionality for the statistics and info send quota data that Amazon SES makes available 4 # 5 # You can access these methods as follows: 6 # 7 # ses = AWS::SES::Base.new( ... connection info ... ) 8 # 9 # == Get the quota information 10 # response = ses.quota 11 # # How many e-mails you've sent in the last 24 hours 12 # response.sent_last_24_hours 13 # # How many e-mails you're allowed to send in 24 hours 14 # response.max_24_hour_send 15 # # How many e-mails you can send per second 16 # response.max_send_rate 17 # 18 # == Get detailed send statistics 19 # The result is a list of data points, representing the last two weeks of sending activity. 20 # Each data point in the list contains statistics for a 15-minute interval. 21 # GetSendStatisticsResponse#data_points is an array where each element is a hash with give string keys: 22 # 23 # * +Bounces+ 24 # * +DeliveryAttempts+ 25 # * +Rejects+ 26 # * +Complaints+ 27 # * +Timestamp+ 28 # 29 # response = ses.statistics 30 # response.data_points # => 31 # [{"Bounces"=>"0", 32 # "Timestamp"=>"2011-01-26T16:30:00Z", 33 # "DeliveryAttempts"=>"1", 34 # "Rejects"=>"0", 35 # "Complaints"=>"0"}, 36 # {"Bounces"=>"0", 37 # "Timestamp"=>"2011-02-09T14:45:00Z", 38 # "DeliveryAttempts"=>"3", 39 # "Rejects"=>"0", 40 # "Complaints"=>"0"}, 41 # {"Bounces"=>"0", 42 # "Timestamp"=>"2011-01-31T15:30:00Z", 43 # "DeliveryAttempts"=>"3", 44 # "Rejects"=>"0", 45 # "Complaints"=>"0"}, 46 # {"Bounces"=>"0", 47 # "Timestamp"=>"2011-01-31T16:00:00Z", 48 # "DeliveryAttempts"=>"3", 49 # "Rejects"=>"0", 50 # "Complaints"=>"0"}] 51 52 module Info 53 # Returns quota information provided by SES 54 # 55 # The return format inside the response result will look like: 56 # {"SentLast24Hours"=>"0.0", "MaxSendRate"=>"1.0", "Max24HourSend"=>"200.0"} 57 def quota 58 request('GetSendQuota') 59 end 60 61 def statistics 62 request('GetSendStatistics') 63 end 64 end 65 66 class GetSendQuotaResponse < AWS::SES::Response 67 def result 68 parsed['GetSendQuotaResult'] 69 end 70 71 def sent_last_24_hours 72 result['SentLast24Hours'] 73 end 74 75 def max_24_hour_send 76 result['Max24HourSend'] 77 end 78 79 def max_send_rate 80 result['MaxSendRate'] 81 end 82 end 83 84 class GetSendStatisticsResponse < AWS::SES::Response 85 def result 86 if members = parsed['GetSendStatisticsResult']['SendDataPoints'] 87 [members['member']].flatten 88 else 89 [] 90 end 91 end 92 93 memoized :result 94 95 def data_points 96 result 97 end 98 end 99 end 100end