File: inbound.rb

package info (click to toggle)
ruby-postmark 1.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 480 kB
  • sloc: ruby: 5,413; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module Postmark
  module Inbound
    extend self

    def to_ruby_hash(inbound)
      inbound = Json.decode(inbound) if inbound.is_a?(String)
      ret = HashHelper.to_ruby(inbound)
      ret[:from_full] ||= {}
      ret[:to_full] ||= []
      ret[:cc_full] ||= []
      ret[:headers] ||= []
      ret[:attachments] ||= []
      ret[:from_full] = HashHelper.to_ruby(ret[:from_full])
      ret[:to_full] = ret[:to_full].map { |to| HashHelper.to_ruby(to) }
      ret[:cc_full] = ret[:cc_full].map { |cc| HashHelper.to_ruby(cc) }
      ret[:headers] = ret[:headers].map { |h| HashHelper.to_ruby(h) }
      ret[:attachments] = ret[:attachments].map { |a| HashHelper.to_ruby(a) }
      ret
    end
  end
end