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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1afe3b9e9f955431f6d2791e49be6292375067a
4
- data.tar.gz: c820b8559cea0063ff6edcaaf030c2a4884022ee
3
+ metadata.gz: 140f2003a96c7a041e44ef2a67bae04c02fc08a0
4
+ data.tar.gz: 280f83dede486c91ccc646cc31f7a1debe14630b
5
5
  SHA512:
6
- metadata.gz: ec30600a1ecd6f099a83d1df8921adbbb9dc2df144b70f57b35465104fb4fd344fb7801cbe4ed7fc10674a7b7bb2a015db8c10d517bec1c57f3287cd7b024fca
7
- data.tar.gz: 868938e5732807714d5c6559b719b06ca20fe6d6bd276318186d167d0149c7df327459734b31d7567cc0af8419ae4d869cc99328376ab0194067f4f97df855c0
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
- url = "#{MyPush::BASE_URL}#{DEVICES_URL}"
11
- @devices = _send_request(url)
8
+ @devices = _send_request
12
9
  @devices
13
10
  end
14
11
 
@@ -1,4 +1,4 @@
1
- require 'net/http'
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 url, get_post="GET"
10
-
11
- uri = URI.parse(url)
12
- http = Net::HTTP.new(uri.host, uri.port)
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", :title => "Title", :body => "Message", :iden => "ujzCvGXFPuSdjzWIEVDzOK"
20
- #
15
+ # Params: :type => "note",
16
+ # :title => "Title",
17
+ # :body => "Message",
18
+ # :device_iden => "ujzCvGXFPuSdjzWIEVDzOK"
21
19
  #
22
20
  def push params = {}
23
- url = URI::encode("#{MyPush::BASE_URL}#{DEVICES_URL}?device_iden=#{params[:iden]}&type=#{params[:type]}&title=#{params[:title]}&body=#{params[:body]}")
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
@@ -1,3 +1,3 @@
1
1
  module MyPushbullet
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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.2
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-01 00:00:00.000000000 Z
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