cloud_five_push 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +22 -13
- data/lib/cloud_five_push/{message.rb → notification.rb} +19 -11
- data/lib/cloud_five_push/version.rb +1 -1
- data/lib/cloud_five_push.rb +15 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmM5YzEwODRhNjk3MzliOWYzNDA5NjcyZDIxZTU4NzBlYTkwMGZlMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTE5NDk1YjkwZDAwYmZkZWUyMmYzMmFiNmFmMTk0NDNjNjE4ZTdiNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTIyNjI1ZTE0YTE5M2VlYTc5NDIxMjU0NWExYjlhYTdiMDBlYjNkYmIzMTIy
|
10
|
+
ZTZkOTQxZTE2M2U0MjY4OTdkZGE1NGQ2YWI0OWI0NjNiMWIzYTU2NzU3NDQ0
|
11
|
+
MTU5YjQyMWUzMzdmY2JkNzY5OTZlMDVlMzhkNjE1MWVjNzQ4Mzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTZiZDc2MzI0ODgwZDlhMDU5ZTk2MmIwN2NiMmM4YzAzMDA3YWU3OTExZGE0
|
14
|
+
YWRhYjI1MjUzY2U1MzdiY2I5ZWQzYWFiMDgzZWU2NDk1ODg5ZDQ3NDhkYWZm
|
15
|
+
Yjc3YTNmM2VlYjhlNmRiMGM3YjM0NGU2MTE1MjUyMmQ0NTdlNGU=
|
data/README.md
CHANGED
@@ -18,27 +18,36 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
Global configuration:
|
22
|
-
|
21
|
+
Global configuration:
|
22
|
+
|
23
23
|
CloudFivePush.api_key = "my_api_key"
|
24
24
|
|
25
|
-
Sending a notification immediately to all your users:
|
25
|
+
Sending a notification immediately to all your users:
|
26
26
|
|
27
27
|
CloudFivePush.broadcast! "Hello from Cloud Five!"
|
28
28
|
|
29
|
-
Send a notification to just some of your users:
|
29
|
+
Send a notification to just some of your users:
|
30
|
+
|
31
|
+
CloudFivePush.notify! "Hello from Cloud Five!", 'the-user-identifier'
|
32
|
+
|
33
|
+
CloudFivePush.notify! "Hello from Cloud Five!", ['one', 'another', 'the-third']
|
34
|
+
|
35
|
+
notification = CloudFivePush::Notification.new
|
36
|
+
notification.alert = "Hello from Cloud Five"
|
37
|
+
notification.user_identifiers = [123, 345, "something@example.com"] # Use whatever you registered with on the mobile app
|
38
|
+
notification.notify!
|
39
|
+
|
40
|
+
Schedule a notification to be sent in the future:
|
30
41
|
|
31
|
-
|
32
|
-
message.message = "Hello from Cloud Five"
|
33
|
-
message.user_identifiers = [123, 345, "something@example.com"] # use whatever you registered with on the mobile app
|
34
|
-
message.send!
|
42
|
+
CloudFivePush.broadcast! "Hello, everybody", Time.now + 3600 # 1 hour from now
|
35
43
|
|
36
|
-
|
44
|
+
CloudFivePush.notify! "Hello from Cloud Five!", 'the-user-identifier', Time.now + 3600
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
notification = CloudFivePush::Notification.new
|
47
|
+
notification.alert = "Hello from Cloud Five"
|
48
|
+
notification.user_identifiers = [123, 345, "something@example.com"]
|
49
|
+
notification.scheduled_at = Time.now + 3600
|
50
|
+
notification.notify!
|
42
51
|
|
43
52
|
## Contributing
|
44
53
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
module CloudFivePush
|
3
|
-
class
|
4
|
-
attr_accessor :user_identifiers, :message, :badge, :scheduled_at, :broadcast, :api_key
|
3
|
+
class Notification
|
4
|
+
attr_accessor :user_identifiers, :alert, :message, :badge, :scheduled_at, :broadcast, :api_key
|
5
5
|
|
6
6
|
include HTTParty
|
7
7
|
base_uri 'https://www.cloudfiveapp.com'
|
@@ -16,21 +16,25 @@ module CloudFivePush
|
|
16
16
|
@user_identifiers = []
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
if blank_param?(@user_identifiers) &&
|
19
|
+
def notify!
|
20
|
+
if blank_param?(@user_identifiers) && !@broadcast
|
21
21
|
raise "Please set user_identifiers or set broadcast=true"
|
22
22
|
end
|
23
|
-
if blank_param?(@
|
24
|
-
raise "Please set
|
23
|
+
if blank_param?(@alert) && blank_param?(@badge)
|
24
|
+
raise "Please set alert or badge"
|
25
25
|
end
|
26
|
+
if @broadcast && !blank_param?(@user_identifers)
|
27
|
+
raise "Can't both broadcast and set user_identifiers"
|
28
|
+
end
|
29
|
+
|
26
30
|
params = {
|
27
31
|
api_key: @api_key,
|
28
|
-
alert: @
|
32
|
+
alert: @alert,
|
29
33
|
badge: @badge
|
30
34
|
}
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
|
36
|
+
params[:message] = @message if @message
|
37
|
+
params[:when] = @scheduled_at.iso8601 if @scheduled_at
|
34
38
|
|
35
39
|
if @broadcast
|
36
40
|
params[:audience] = "broadcast"
|
@@ -41,6 +45,10 @@ module CloudFivePush
|
|
41
45
|
self.class.post('/push/notify', body: params)
|
42
46
|
end
|
43
47
|
|
48
|
+
def user_identifiers=(user_identifers)
|
49
|
+
@user_identifers = [user_identifers].flatten
|
50
|
+
end
|
51
|
+
|
44
52
|
private
|
45
53
|
|
46
54
|
def blank_param?(param)
|
@@ -48,4 +56,4 @@ module CloudFivePush
|
|
48
56
|
end
|
49
57
|
|
50
58
|
end
|
51
|
-
end
|
59
|
+
end
|
data/lib/cloud_five_push.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "cloud_five_push/version"
|
2
|
-
require "cloud_five_push/
|
2
|
+
require "cloud_five_push/notification"
|
3
3
|
|
4
4
|
module CloudFivePush
|
5
5
|
@api_key = nil
|
@@ -11,10 +11,19 @@ module CloudFivePush
|
|
11
11
|
@api_key
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.broadcast!(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
def self.broadcast!(alert, scheduled_at = nil)
|
15
|
+
notification = CloudFivePush::Notification.new
|
16
|
+
notification.broadcast = true
|
17
|
+
notification.alert = alert
|
18
|
+
notification.scheduled_at = scheduled_at
|
19
|
+
notification.notify!
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.notify!(alert, user_identifers, scheduled_at = nil)
|
23
|
+
notification = CloudFivePush::Notification.new
|
24
|
+
notification.alert = alert
|
25
|
+
notification.user_identifiers = user_identifiers
|
26
|
+
notification.scheduled_at = scheduled_at
|
27
|
+
notification.notify!
|
19
28
|
end
|
20
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_five_push
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Samson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- Rakefile
|
67
67
|
- cloud_five_push.gemspec
|
68
68
|
- lib/cloud_five_push.rb
|
69
|
-
- lib/cloud_five_push/
|
69
|
+
- lib/cloud_five_push/notification.rb
|
70
70
|
- lib/cloud_five_push/version.rb
|
71
71
|
homepage: ''
|
72
72
|
licenses:
|