aws_sns_manager 0.0.2.pre.alpha.pre.25 → 0.0.2.pre.alpha.pre.26

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWY2N2MwOTc2YjEyMDBiNThlN2U3NmRlMmIzNzRjNWIxMDdjNGM0NA==
4
+ ZmUyYTJjZTcyNzIzZGU4NGU4MTY5NjNlNWU2OTU4ZmQ0MzM4YjFmNg==
5
5
  data.tar.gz: !binary |-
6
- ZDdlY2M4NjJlMDk5OTUwZjM1ZjFjNzViMTE2ZjcwYjY1Yzk0ODJjYw==
6
+ MTkzODI5MGI1ZmM0YmRhZDM4MDc2NDYxNjc0ZmY0NWZmN2Q2YWNlYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWY2MzZiNTY3MjU0MGJhYTZlYTc4MTYxNmE3Y2YxY2JlNThiNGI3YTgyZTA2
10
- YjA2MjFkZWUzZmUxNmVlNmUyOWJjOGNkZWEwYWNkODJhMzA3ODU1NGRkOWZh
11
- YjYwOTgzMzFjZWUwODliMjYzMWFkYzAyZTRhZWQzNGRmNTdkYzI=
9
+ N2Y1YzNmMzRkYjkwNjFkYWI0MjQ1OTczZTg2NDc4ZGIxYjVhZTQ3Y2ZlMjUx
10
+ YzdmMWFjN2E5NjZlZWE0NzQ2MWNlNjBkMWRjYzQzOGFkMmQ1ZjRlZDUzZGE0
11
+ N2Q4ZmNjZGJiMjMxMjM3N2JjZTZiYjQ2NzI3YmM2MWYyNWM4M2Q=
12
12
  data.tar.gz: !binary |-
13
- N2QyZGRkNTVkM2I2ZGIxOWY2MzJiYjIyNGM1MmY3YjgwYzM0OGJlOTJjNmI5
14
- ZDViODJhMTc4NDMzNTI3YzZmNDM0ZTNhYTNmZDMyMjIyZTM0MDNlMDY2Yzhi
15
- NTgxMWU5NjQ4YWM3NWI0ZmU5ZmYxOWZlNjgyMmM1YTNlOGYwMTY=
13
+ YjBjMzUyMjkzYzI3Y2M5YTNhY2EzMDFlYmQ3MWJhZmI5YTY3MGYwOTIxNjVk
14
+ YWY2NjExNTA3ODVkOGI1NWI5MDc4MTI1ODVkNDUxYjYyM2M3YTEwZmUwYTQ0
15
+ MjEyOWFiZmQwYWYxMjQ0Y2VmYTg3ZDRkY2UwOWRlZmUyZjI5OTQ=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws_sns_manager (0.0.2.pre.alpha.pre.25)
4
+ aws_sns_manager (0.0.2.pre.alpha.pre.26)
5
5
  aws-sdk (~> 2)
6
6
  bundler (>= 1.3.0, < 2.0)
7
7
  json (~> 1.8)
@@ -12,12 +12,12 @@ GEM
12
12
  ast (2.1.0)
13
13
  astrolabe (1.3.1)
14
14
  parser (~> 2.2)
15
- aws-sdk (2.1.12)
16
- aws-sdk-resources (= 2.1.12)
17
- aws-sdk-core (2.1.12)
15
+ aws-sdk (2.1.13)
16
+ aws-sdk-resources (= 2.1.13)
17
+ aws-sdk-core (2.1.13)
18
18
  jmespath (~> 1.0)
19
- aws-sdk-resources (2.1.12)
20
- aws-sdk-core (= 2.1.12)
19
+ aws-sdk-resources (2.1.13)
20
+ aws-sdk-core (= 2.1.13)
21
21
  codeclimate-test-reporter (0.4.7)
22
22
  simplecov (>= 0.7.1, < 1.0.0)
23
23
  diff-lcs (1.2.5)
@@ -10,8 +10,8 @@ module AwsSnsManager
10
10
  @client = Aws::SNS::Client.new(options)
11
11
  end
12
12
 
13
- def send(text = nil, options = {})
14
- message = message(text, options).to_json
13
+ def send(text = nil, options = {}, env = :prod, type = :normal)
14
+ message = message(text, options, env, type).to_json
15
15
  response = publish_rescue(message)
16
16
  !response.nil?
17
17
  end
@@ -24,15 +24,26 @@ module AwsSnsManager
24
24
  )
25
25
  end
26
26
 
27
- def message(text, options = {})
28
- json = notification(text, options).to_json
29
- {
30
- default: json,
31
- APNS: json
32
- }
27
+ #
28
+ # Return json payload
29
+ #
30
+ # +text+:: Text you want to send
31
+ # +options+:: Options you want on payload
32
+ # +env+:: Environments :prod, :dev
33
+ # +type+:: Notification type :normal, :silent
34
+ #
35
+ def message(text, options = {}, env = :prod, type = :normal)
36
+ json = nil
37
+ if type == :normal
38
+ json = normal_notification(text, options).to_json
39
+ elsif type == :silent
40
+ json = silent_notification(text, options).to_json
41
+ end
42
+ return { default: json, APNS_SANDBOX: json } if env == :dev
43
+ { default: json, APNS: json }
33
44
  end
34
45
 
35
- def notification(text, options = {})
46
+ def normal_notification(text, options = {})
36
47
  base = {
37
48
  aps: {
38
49
  alert: text,
@@ -43,5 +54,14 @@ module AwsSnsManager
43
54
  }
44
55
  base.merge(options)
45
56
  end
57
+
58
+ def silent_notification(_text, options = {})
59
+ base = {
60
+ aps: {
61
+ 'content-available': 1
62
+ }
63
+ }
64
+ base.merge(options)
65
+ end
46
66
  end
47
67
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_sns_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.pre.alpha.pre.25
4
+ version: 0.0.2.pre.alpha.pre.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fumiya Nakamura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler