messaging_client 0.1.5 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dadb5c678a9fdb5f0e6b223e34e401c95332dc0a
4
- data.tar.gz: ae6421553882c82c2aa547952b55f2e5a42cb556
2
+ SHA256:
3
+ metadata.gz: 62c9c566908c290110e41c455e63a5650dad343d733674dae90c203787bb2608
4
+ data.tar.gz: 1583cb8c8a557b213ae6762f45d2c775ed1dfb915a08e0881dd99232c12f45fb
5
5
  SHA512:
6
- metadata.gz: dafa32f1bed397b24a00c767130872cffa7cb818f10302b0c3b7cf35d276b876bf4d763e1a32e74b12db3ee5f1c788da9cb19c9e20f7af03b2a07c883c406748
7
- data.tar.gz: 14142c1e17000bc145b8dd6639172535f01b0ed8ff7017fb11a25f996bdfc4b106b591d897f1d54a8a8d5b1695c62da6495331860f3404f1949a16206b9b61fa
6
+ metadata.gz: 65f32df0c7bf46c68a01fedfd8f0be70d4a6a259138ff9f0dd99f3f00e4e118ea5286acf07535a9ec46c39a5f150e0c86c20e0a19fac7c6626cf73c42952c557
7
+ data.tar.gz: 93f53d8b2f163fe32f52c765fea8e616482f88d9c1198b649dabd337efaad9719c44bc1e46f3e12e6e100583067e9ccd36336b91dcacd52b0ec2c4383fcaeda3
@@ -22,7 +22,11 @@ module SnsHelper
22
22
  end
23
23
 
24
24
  def sns_data
25
- @sns_data ||= ActiveSupport::JSON.decode(request.body).symbolize_keys!
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
@@ -9,7 +9,7 @@ module Messaging
9
9
  ]
10
10
  self.use_api_key = true
11
11
  self.api_key_name = "app_key"
12
- self.api_key = API_KEY
12
+ self.api_key = KEY
13
13
  self.host = HOST
14
14
 
15
15
  def json_root
@@ -10,7 +10,7 @@ module Messaging
10
10
  ]
11
11
  self.use_api_key = true
12
12
  self.api_key_name = "app_key"
13
- self.api_key = API_KEY
13
+ self.api_key = KEY
14
14
  self.host = HOST
15
15
 
16
16
  def json_root
@@ -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
- begin
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
- topic.publish({ message: data.to_json })
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.1.5
4
+ version: 0.2.1
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: 2018-01-30 00:00:00.000000000 Z
11
+ date: 2021-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -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
- rubyforge_project:
88
- rubygems_version: 2.6.11
89
- signing_key:
87
+ rubygems_version: 3.0.1
88
+ signing_key:
90
89
  specification_version: 4
91
90
  summary: Client library for padma-messaging-ws
92
91
  test_files: []