moromi-aws-sns 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6d467674ae3605f8842b04c68132543aa1770562
4
- data.tar.gz: b1ede05128326dcc17176d54a266c67ec3c9063c
3
+ metadata.gz: a68427178727374b8396e11474256e6f8b533d48
4
+ data.tar.gz: 1779d50e9785e73dde024180e395800884b75666
5
5
  SHA512:
6
- metadata.gz: 1fc06925db294beb659e1f483b51dd0064c20e12d9cdd556393050336b3154d57a8328184488b897509fc5ae857c26548650e73154b1260f0f364975d3d0b9d1
7
- data.tar.gz: 608f9fcbbd0682543179c1b50e8c2ddea26c8ba7dd6458b7ebe120d54a8c28f8229706c603fd560d212cc42c0be3630a2c2c370a88e31b61c120fd48f5434166
6
+ metadata.gz: eb29abfe298447db3f9da599c8e2e07007aebd7a209af40ad5f1d9ad0d363eacda13a8bf77eef649fb3ba84206e05965fc1573493254f79e18da41a38f7dcc54
7
+ data.tar.gz: 3a7c61daf5503c08fa3ea461d8febdf808192da025136355354dcb7e1d32a43d49b02bd6c8bde25a0c74d8ab90ffa0b335096cee7b36eb6e455d92cea1caa218
@@ -55,19 +55,23 @@ module Moromi
55
55
  client.set_endpoint_attributes(params)
56
56
  end
57
57
 
58
- def send_apns(arn, params)
58
+ # @param [String] arn
59
+ # @param [Moromi::Aws::Sns::Message::Base] message
60
+ def send_message(arn, message)
59
61
  options = {
60
62
  target_arn: arn,
61
- message: build_apns_json_message(params),
63
+ message: message.to_parameter.to_json,
62
64
  message_structure: 'json'
63
65
  }
64
66
  publish(options)
65
67
  end
66
68
 
67
- def send_apns_to_topic(topic_arn, params)
69
+ # @param [String] topic_arn
70
+ # @param [Moromi::Aws::Sns::Message::Base] message
71
+ def send_message_to_topic(topic_arn, message)
68
72
  options = {
69
73
  topic_arn: topic_arn,
70
- message: build_apns_json_message(params),
74
+ message: message.to_parameter.to_json,
71
75
  message_structure: 'json'
72
76
  }
73
77
  publish(options)
@@ -95,14 +99,6 @@ module Moromi
95
99
  def client
96
100
  @client ||= ::Aws::SNS::Client.new(region: @region, credentials: credentials)
97
101
  end
98
-
99
- def build_apns_json_message(params)
100
- {
101
- 'default': '',
102
- 'APNS_SANDBOX' => params.to_json,
103
- 'APNS' => params.to_json
104
- }.to_json
105
- end
106
102
  end
107
103
  end
108
104
  end
@@ -0,0 +1,23 @@
1
+ module Moromi
2
+ module Aws
3
+ module Sns
4
+ module Message
5
+ module Base
6
+ # @return Moromi::Aws::Sns::Message::Parameter
7
+ def to_parameter
8
+ raise NotImplementedError
9
+ end
10
+
11
+ def serialize
12
+ raise NotImplementedError
13
+ end
14
+
15
+ # @return Moromi::Aws::Sns::Message::Base
16
+ def self.unserialize(data)
17
+ raise NotImplementedError
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'json'
2
+
3
+ module Moromi
4
+ module Aws
5
+ module Sns
6
+ module Message
7
+ class Parameter
8
+ def initialize(apns: nil, gcm: nil)
9
+ @apns = apns
10
+ @gcm = gcm
11
+ end
12
+
13
+ def to_json
14
+ {
15
+ 'default': '',
16
+ 'APNS_SANDBOX': @apns&.to_json,
17
+ 'APNS': @apns&.to_json,
18
+ 'GCM': @gcm&.to_json
19
+ }.compact.to_json
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,7 +1,7 @@
1
1
  module Moromi
2
2
  module Aws
3
3
  module Sns
4
- VERSION = "0.4.0"
4
+ VERSION = '0.5.0'
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,6 @@
1
1
  require "moromi/aws/sns/version"
2
+ require "moromi/aws/sns/message/base"
3
+ require "moromi/aws/sns/message/parameter"
2
4
  require "moromi/aws/sns/client"
3
5
 
4
6
  module Moromi
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moromi-aws-sns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
11
+ date: 2017-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -84,6 +84,8 @@ files:
84
84
  - circle.yml
85
85
  - lib/moromi/aws/sns.rb
86
86
  - lib/moromi/aws/sns/client.rb
87
+ - lib/moromi/aws/sns/message/base.rb
88
+ - lib/moromi/aws/sns/message/parameter.rb
87
89
  - lib/moromi/aws/sns/version.rb
88
90
  - moromi-aws-sns.gemspec
89
91
  homepage: https://github.com/moromi/moromi-aws-sns
@@ -106,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
108
  version: '0'
107
109
  requirements: []
108
110
  rubyforge_project:
109
- rubygems_version: 2.6.11
111
+ rubygems_version: 2.6.13
110
112
  signing_key:
111
113
  specification_version: 4
112
114
  summary: AWS SNS client.