messaging_client 0.1.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/helpers/sns_helper.rb +6 -2
- data/lib/messaging/client.rb +13 -21
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7ae3b5862c27c542204ed8e43a666d66a2723a265da218945758c516bea7840
|
4
|
+
data.tar.gz: b6d9d637d924811c7c9ae8622ffdd1d642e351240756cb69785589f5a093ff7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 208418ef7fd3bf033813628cf7d04b149bae4989edf2004ec048c92f74f58459f03b5cf285435146a34284558c87a86e3b90195ee67cef24c8a8e380f2a1a6b6
|
7
|
+
data.tar.gz: 7178c4808f32313ed4db189b4fae9473f589858d4f56692c4e8ceb9435558c3e8b5f0b50fed9ab3da2596eb2e4ed841eb71cafd6b399775431719c0196343394
|
data/app/helpers/sns_helper.rb
CHANGED
@@ -22,7 +22,11 @@ module SnsHelper
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def sns_data
|
25
|
-
@sns_data ||= ActiveSupport::JSON.decode(
|
25
|
+
@sns_data ||= ActiveSupport::JSON.decode(raw_data).symbolize_keys!
|
26
|
+
end
|
27
|
+
|
28
|
+
def raw_data
|
29
|
+
request.body.respond_to?(:string) ? request.body.string : request.body
|
26
30
|
end
|
27
31
|
|
28
32
|
def sns_message_id
|
@@ -36,4 +40,4 @@ module SnsHelper
|
|
36
40
|
def sns_duplicate_submission?
|
37
41
|
Rails.cache.read(sns_message_id)
|
38
42
|
end
|
39
|
-
end
|
43
|
+
end
|
data/lib/messaging/client.rb
CHANGED
@@ -3,29 +3,10 @@ require 'aws-sdk-sns'
|
|
3
3
|
module Messaging
|
4
4
|
class Client
|
5
5
|
|
6
|
-
# @param key_name [String]
|
7
|
-
# @param url [String]
|
8
|
-
# @param secret_key [String]
|
9
|
-
def self.subscribe_to(key_name,url,secret_key="")
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# @param key_name [String]
|
14
|
-
def self.unsubscribe_from(key_name)
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
6
|
# @param key [String]
|
19
7
|
# @param data [Hash]
|
20
8
|
def self.post_message(key,data={})
|
21
|
-
|
22
|
-
publish_to_sns(key,data)
|
23
|
-
rescue
|
24
|
-
# on transition ignore errors.
|
25
|
-
end
|
26
|
-
|
27
|
-
m = Message.new(key_name: key, data: data.to_json)
|
28
|
-
m.create
|
9
|
+
publish_to_sns(key,data)
|
29
10
|
end
|
30
11
|
|
31
12
|
def self.publish_to_sns(key,data)
|
@@ -36,7 +17,18 @@ module Messaging
|
|
36
17
|
)
|
37
18
|
topic_arn = sns.topics.select{|t| t.arn.match(/([^:]*)$/)[0] == key.to_s }.first.try(:arn)
|
38
19
|
topic = sns.topic(topic_arn)
|
39
|
-
|
20
|
+
|
21
|
+
msg = { message: data.to_json }
|
22
|
+
if data['account_name']
|
23
|
+
msg[:message_attributes] = {
|
24
|
+
account_name: {
|
25
|
+
data_type: 'String',
|
26
|
+
string_value: data['account_name']
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
topic.publish(msg)
|
40
32
|
end
|
41
33
|
|
42
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: messaging_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dwayne Macgowan
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: logical_model
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.7.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.7.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aws-sdk-sns
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,7 +69,7 @@ files:
|
|
69
69
|
homepage: ''
|
70
70
|
licenses: []
|
71
71
|
metadata: {}
|
72
|
-
post_install_message:
|
72
|
+
post_install_message:
|
73
73
|
rdoc_options: []
|
74
74
|
require_paths:
|
75
75
|
- lib
|
@@ -84,9 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
|
-
|
88
|
-
|
89
|
-
signing_key:
|
87
|
+
rubygems_version: 3.0.3.1
|
88
|
+
signing_key:
|
90
89
|
specification_version: 4
|
91
90
|
summary: Client library for padma-messaging-ws
|
92
91
|
test_files: []
|