my_pushbullet 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/business/my_push/list_devices.rb +1 -4
- data/app/business/my_push/network.rb +18 -30
- data/app/business/my_push/push.rb +5 -10
- data/lib/my_pushbullet/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140f2003a96c7a041e44ef2a67bae04c02fc08a0
|
4
|
+
data.tar.gz: 280f83dede486c91ccc646cc31f7a1debe14630b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3ebba1d04d764e79ffb749f5b4f7014dd06ec9b9178796309309f1973c8bc82def061eb378149d0193cdc2e6bfae860e411877e51d39c39f14eec06dd624f0f
|
7
|
+
data.tar.gz: 7aedc519887d1b10952365e30dfcb3fd74f03d9f4fdb256261812c6b75a9726e4efd6a2285ae89446f881ae230f41bf53c2c66b8832a8169d31a7fc75a8b28e9
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module MyPush::ListDevices
|
2
2
|
include MyPush::Network
|
3
3
|
|
4
|
-
DEVICES_URL = "/devices"
|
5
|
-
|
6
4
|
#
|
7
5
|
# List of devices
|
8
6
|
#
|
9
7
|
def devices
|
10
|
-
|
11
|
-
@devices = _send_request(url)
|
8
|
+
@devices = _send_request
|
12
9
|
@devices
|
13
10
|
end
|
14
11
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'unirest'
|
2
2
|
|
3
3
|
module MyPush::Network
|
4
4
|
|
@@ -6,35 +6,23 @@ module MyPush::Network
|
|
6
6
|
|
7
7
|
#
|
8
8
|
#
|
9
|
-
def _send_request
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
http.use_ssl = true
|
14
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
15
|
-
|
16
|
-
if get_post == "POST"
|
17
|
-
request = Net::HTTP::Post.new(uri.request_uri)
|
18
|
-
else
|
19
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
20
|
-
end
|
21
|
-
|
22
|
-
request.basic_auth("#{@token}", "#{@token}")
|
23
|
-
# request.body = @body
|
24
|
-
|
25
|
-
response = http.request(request)
|
26
|
-
|
27
|
-
if Rails.env == "development"
|
28
|
-
puts "* " * 60
|
29
|
-
puts "Request: #{@url}"
|
30
|
-
puts "Body (request): "
|
31
|
-
puts "#{request.body}"
|
32
|
-
puts "Body (response):"
|
33
|
-
puts "#{response.body}"
|
34
|
-
puts "* " * 60
|
35
|
-
end
|
36
|
-
|
37
|
-
JSON.parse(response.body)
|
9
|
+
def _send_request
|
10
|
+
response = Unirest.get "https://api.pushbullet.com/api/devices",
|
11
|
+
auth:{:user => "#{@token}", :password => "#{@token}"}
|
12
|
+
response.body
|
38
13
|
end
|
39
14
|
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
#
|
19
|
+
def _send_post params
|
20
|
+
response = Unirest.post "https://api.pushbullet.com/api/pushes",
|
21
|
+
auth:{:user => "#{@token}", :password => "#{@token}"},
|
22
|
+
parameters:params
|
23
|
+
response.body
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
40
28
|
end
|
@@ -3,28 +3,23 @@ require 'open-uri'
|
|
3
3
|
module MyPush::Push
|
4
4
|
include MyPush::Network
|
5
5
|
|
6
|
-
DEVICES_URL = "/pushes"
|
7
|
-
|
8
6
|
PUSH_TYPE_NOTE = "note"
|
9
7
|
PUSH_TYPE_LINK = "link"
|
10
8
|
PUSH_TYPE_ADDRESS = "address"
|
11
9
|
PUSH_TYPE_LIST = "list"
|
12
10
|
|
13
|
-
# PUSH_TYPE_FILE = "file"
|
14
|
-
|
15
11
|
|
16
12
|
#
|
17
13
|
# List of devices
|
18
14
|
#
|
19
|
-
# Params: :type => "note",
|
20
|
-
#
|
15
|
+
# Params: :type => "note",
|
16
|
+
# :title => "Title",
|
17
|
+
# :body => "Message",
|
18
|
+
# :device_iden => "ujzCvGXFPuSdjzWIEVDzOK"
|
21
19
|
#
|
22
20
|
def push params = {}
|
23
|
-
|
24
|
-
puts "URL: #{url}" if Rails.env == "development"
|
25
|
-
@pushed = _send_request(url, "POST")
|
21
|
+
@pushed = _send_post(params)
|
26
22
|
@pushed
|
27
23
|
end
|
28
24
|
|
29
|
-
|
30
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_pushbullet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcio Mangar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: unirest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sqlite3
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|