wor-push-notifications-aws 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +5 -0
- data/lib/wor/push/notifications/aws.rb +1 -1
- data/lib/wor/push/notifications/aws/exceptions.rb +11 -0
- data/lib/wor/push/notifications/aws/push_notifications.rb +4 -2
- data/lib/wor/push/notifications/aws/validators/push_notifications_validator.rb +20 -7
- data/lib/wor/push/notifications/aws/version.rb +1 -1
- metadata +3 -3
- data/lib/wor/push/notifications/aws/services/sns_client.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2579fa5d87164c198bdd3cb86e90d814ad261ff3
|
4
|
+
data.tar.gz: 432f4ce9d4b23d10837dd296035a6a8ce7e01de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d5ced70039d2f3bd7e25a4fd871e35eb80dadb47bd46bf29793ddcb4289618568531fb8f5a81bd98b559f7ada580c7b19cb01faaf1d1136467a64eea2cf0234
|
7
|
+
data.tar.gz: de0b2b76ad7aac52e7e268fc029035cf66a22c685ad86dc636dcd1acccbd79280754e4796c0d91a619922560bca0ac5048ca8cccf1cb2b149f6dfe21278e6a3e
|
data/.codeclimate.yml
CHANGED
@@ -86,7 +86,7 @@ module Wor
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def self.add_token(user, device_token, device_type)
|
89
|
-
PushNotifications.add_token(user, device_token, device_type)
|
89
|
+
PushNotifications.add_token(user, device_token, device_type.to_sym)
|
90
90
|
end
|
91
91
|
|
92
92
|
def self.delete_token(user, device_token)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'wor/push/notifications/aws/android_push_json_builder'
|
2
2
|
require 'wor/push/notifications/aws/ios_push_json_builder'
|
3
|
-
require 'wor/push/notifications/aws/services/sns_client'
|
4
3
|
require 'wor/push/notifications/aws/validators/push_notifications_validator'
|
4
|
+
require 'aws-sdk-rails'
|
5
5
|
|
6
6
|
module Wor
|
7
7
|
module Push
|
@@ -62,7 +62,9 @@ module Wor
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def sns
|
65
|
-
@sns_client ||=
|
65
|
+
@sns_client ||= ::Aws::SNS::Client.new(
|
66
|
+
region: Wor::Push::Notifications::Aws.aws_region
|
67
|
+
)
|
66
68
|
end
|
67
69
|
|
68
70
|
def app_arn(device_type)
|
@@ -10,27 +10,36 @@ module Wor
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def validate_add_token
|
13
|
+
validate_model_existance
|
13
14
|
validate_existence_of_attributes_in_model
|
14
15
|
validate_parameters
|
15
16
|
end
|
16
17
|
|
17
18
|
def validate_delete_token
|
19
|
+
validate_model_existance
|
18
20
|
validate_existence_of_attributes_in_model
|
19
21
|
end
|
20
22
|
|
21
23
|
def validate_send_message(message_content)
|
24
|
+
validate_model_existance
|
22
25
|
validate_existence_of_attributes_in_model
|
23
26
|
validate_message_content(message_content)
|
24
27
|
end
|
25
28
|
|
26
29
|
private
|
27
30
|
|
31
|
+
def validate_model_existance
|
32
|
+
raise ArgumentError, message_for_nil_model if @model.nil?
|
33
|
+
end
|
34
|
+
|
28
35
|
def validate_existence_of_attributes_in_model
|
29
|
-
|
36
|
+
return if @model.has_attribute?(:device_tokens)
|
37
|
+
raise Wor::Push::Notifications::Aws::Exceptions::ModelWithoutDeviceTokensAttribute,
|
38
|
+
message_for_missing_attribute_in_model
|
30
39
|
end
|
31
40
|
|
32
41
|
def validate_message_content(message_content)
|
33
|
-
raise
|
42
|
+
raise ArgumentError, message_content_error_message if message_content[:message].blank?
|
34
43
|
end
|
35
44
|
|
36
45
|
def validate_parameters
|
@@ -38,20 +47,24 @@ module Wor
|
|
38
47
|
raise ArgumentError, message_for_nil_device_token if @device_token.blank?
|
39
48
|
end
|
40
49
|
|
41
|
-
def message_for_missing_attribute
|
42
|
-
'Missing attribute device_tokens for model. Have you run the gem migration?'
|
43
|
-
end
|
44
|
-
|
45
50
|
def message_for_invalid_device_type
|
46
51
|
"Invalid device_type. It has to be one of the types configured \
|
47
52
|
#{Wor::Push::Notifications::Aws.device_types}."
|
48
53
|
end
|
49
54
|
|
55
|
+
def message_for_missing_attribute_in_model
|
56
|
+
'Missing attribute device_tokens for model. Have you run the gem migration?'
|
57
|
+
end
|
58
|
+
|
50
59
|
def message_for_nil_device_token
|
51
60
|
'device_token cannot be nil.'
|
52
61
|
end
|
53
62
|
|
54
|
-
def
|
63
|
+
def message_for_nil_model
|
64
|
+
'your entity instance cannot be nil.'
|
65
|
+
end
|
66
|
+
|
67
|
+
def message_content_error_message
|
55
68
|
"the message_content must have a 'message' field"
|
56
69
|
end
|
57
70
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wor-push-notifications-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Masello
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-07-
|
12
|
+
date: 2017-07-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -67,9 +67,9 @@ files:
|
|
67
67
|
- lib/generators/wor/push/notifications/aws/install_generator.rb
|
68
68
|
- lib/wor/push/notifications/aws.rb
|
69
69
|
- lib/wor/push/notifications/aws/android_push_json_builder.rb
|
70
|
+
- lib/wor/push/notifications/aws/exceptions.rb
|
70
71
|
- lib/wor/push/notifications/aws/ios_push_json_builder.rb
|
71
72
|
- lib/wor/push/notifications/aws/push_notifications.rb
|
72
|
-
- lib/wor/push/notifications/aws/services/sns_client.rb
|
73
73
|
- lib/wor/push/notifications/aws/validators/push_notifications_validator.rb
|
74
74
|
- lib/wor/push/notifications/aws/version.rb
|
75
75
|
- wor-push-notifications-aws.gemspec
|