Class: AWS::SQS::ReceivedSNSMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/aws/sqs/received_sns_message.rb

Overview

Represents message published from an AWS::SNS::Topic to an Queue.

Instance Method Summary collapse

Constructor Details

#initialize(body, options = {}) ⇒ ReceivedSNSMessage



28
29
30
31
# File 'lib/aws/sqs/received_sns_message.rb', line 28

def initialize body, options = {}
  @body = body
  super
end

Instance Method Details

#bodyObject

@return Returns the decoded message as was published.



41
42
43
# File 'lib/aws/sqs/received_sns_message.rb', line 41

def body
  to_h[:body]
end

#body_message_as_hHash



110
111
112
# File 'lib/aws/sqs/received_sns_message.rb', line 110

def body_message_as_h
  @body_message_as_h ||= JSON.parse(to_h[:body])
end

#message_idString



78
79
80
# File 'lib/aws/sqs/received_sns_message.rb', line 78

def message_id
  to_h[:message_id]
end

#message_typeString



57
58
59
# File 'lib/aws/sqs/received_sns_message.rb', line 57

def message_type
  to_h[:message_type]
end

#published_atTime



73
74
75
# File 'lib/aws/sqs/received_sns_message.rb', line 73

def published_at
  to_h[:published_at]
end

#raw_messageString



36
37
38
# File 'lib/aws/sqs/received_sns_message.rb', line 36

def raw_message
  @body
end

#signatureString



62
63
64
# File 'lib/aws/sqs/received_sns_message.rb', line 62

def signature
  to_h[:signature]
end

#signature_versionString



67
68
69
# File 'lib/aws/sqs/received_sns_message.rb', line 67

def signature_version
  to_h[:signature_version]
end

#signing_cert_urlString



83
84
85
# File 'lib/aws/sqs/received_sns_message.rb', line 83

def signing_cert_url
  to_h[:signing_cert_url]
end

#to_hHash



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/aws/sqs/received_sns_message.rb', line 94

def to_h
  data = JSON.parse(@body)
  {
    :body => data['Message'],
    :topic_arn => data['TopicArn'],
    :message_type => data['Type'],
    :signature => data['Signature'],
    :signature_version => data['SignatureVersion'],
    :published_at => Time.parse(data['Timestamp']),
    :message_id => data['MessageId'],
    :signing_cert_url => data['SigningCertURL'],
    :unsubscribe_url => data['UnsubscribeURL'],
  }
end

#topicSNS::Topic



52
53
54
# File 'lib/aws/sqs/received_sns_message.rb', line 52

def topic
  SNS::Topic.new(topic_arn, :config => config)
end

#topic_arnString



47
48
49
# File 'lib/aws/sqs/received_sns_message.rb', line 47

def topic_arn
  to_h[:topic_arn]
end

#unsubscribe_urlString



89
90
91
# File 'lib/aws/sqs/received_sns_message.rb', line 89

def unsubscribe_url
  to_h[:unsubscribe_url]
end