Class: Postal::SendResult

Inherits:
Object
  • Object
show all
Defined in:
lib/postal/send_result.rb

Instance Method Summary collapse

Constructor Details

#initialize(client, result) ⇒ SendResult

Returns a new instance of SendResult.



4
5
6
7
# File 'lib/postal/send_result.rb', line 4

def initialize(client, result)
  @client = client
  @result = result
end

Instance Method Details

#[](recipient) ⇒ Object



21
22
23
# File 'lib/postal/send_result.rb', line 21

def [](recipient)
  recipients[recipient.to_s.downcase]
end

#message_idObject



9
10
11
# File 'lib/postal/send_result.rb', line 9

def message_id
  @result['message_id']
end

#recipientsObject



13
14
15
16
17
18
19
# File 'lib/postal/send_result.rb', line 13

def recipients
  @recipients ||= begin
    @result['messages'].each_with_object({}) do |(recipient, message_details), hash|
      hash[recipient.to_s.downcase] = Message.new(@client, message_details)
    end
  end
end

#sizeObject



25
26
27
# File 'lib/postal/send_result.rb', line 25

def size
  recipients.size
end