pubsub-connect 0.0.3 → 0.0.4
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 +4 -4
- data/lib/pubsub.rb +7 -7
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7aacd2e12c46018b3dc8768b248a711427e74ec
|
4
|
+
data.tar.gz: 925771cc113f1fa88726bbfe5241ee82a97934de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69f9e89c52407a28bb9f82f9db2b363606fde46eacf9a617b2a323a0ebb281f9d0848318ba97a9c6f6999095dc33a1797a49004e2a0c9ac6d44e201fce4773a
|
7
|
+
data.tar.gz: d4fda8df419ee779844e12d2417d248dbc5b2a8aacd734ec72454fda5ddb5742f83559a6f960b2bfd603e76afe04ecdecab9a56661b3f69badd7b7778ec3d858
|
data/lib/pubsub.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#PubSub notification fior Android and iOS devices
|
2
2
|
#for detail please refer https://cloud.google.com/pubsub/reference/rest/v1/projects.topics/create#body.aspect
|
3
|
+
require 'json'
|
4
|
+
require 'curb'
|
3
5
|
module Pubsub
|
4
6
|
|
5
7
|
class Notification
|
@@ -7,12 +9,10 @@ module Pubsub
|
|
7
9
|
|
8
10
|
def initialize(data)
|
9
11
|
#data must be an hash object
|
10
|
-
#example {
|
12
|
+
#example {data: {message: "testing one two three", image: "htp://example.com/xyz/abc.png"}}
|
11
13
|
|
12
|
-
if data.
|
14
|
+
if data.nil?
|
13
15
|
raise "Data packet is missing."
|
14
|
-
elsif !data.has_key?(:to)
|
15
|
-
raise "Invalid topic or topic key 'to' is missing."
|
16
16
|
end
|
17
17
|
@json_data = JSON.pretty_generate(data.merge(to: "/topics/#{PUBSUB_TOPIC}"))
|
18
18
|
end
|
@@ -24,8 +24,8 @@ module Pubsub
|
|
24
24
|
curl.headers["Authorization"] = "key=#{GCM_API_KEY}"
|
25
25
|
end
|
26
26
|
rescue Exception => e
|
27
|
-
|
28
|
-
|
27
|
+
puts ("======================")
|
28
|
+
puts e.message
|
29
29
|
#error log here
|
30
30
|
raise e.message
|
31
31
|
end
|
@@ -37,7 +37,7 @@ module Pubsub
|
|
37
37
|
|
38
38
|
def record_notification_logs(req)
|
39
39
|
#put your code here to record notification response
|
40
|
-
|
40
|
+
puts JSON.parse req.body_str
|
41
41
|
end
|
42
42
|
|
43
43
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubsub-connect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lareb Nawab
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
27
41
|
description: A lightweight ruby gem, which enables developers to send messages between
|
28
42
|
servers and client apps (Android & iOS).
|
29
43
|
email:
|