Class: Pushbullet::V2::Push
- Inherits:
-
Object
- Object
- Pushbullet::V2::Push
- Defined in:
- lib/v2/push.rb
Constant Summary collapse
- API_URL =
'https://api.pushbullet.com/v2/pushes'
Class Method Summary collapse
-
.file(filepath, text, recipient = nil) ⇒ JSON
push file.
-
.link(title, text, link, recipient = nil) ⇒ JSON
push link.
-
.note(title, text, recipient = nil) ⇒ JSON
push note.
Class Method Details
.file(filepath, text, recipient = nil) ⇒ JSON
push file
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/v2/push.rb', line 80 def self.file(filepath, text, recipient = nil) to_upload = _request_upload_file(filepath) if _upload_file(filepath, to_upload['upload_url'], to_upload['data']) params = { type: :file, file_name: to_upload['file_name'], file_type: to_upload['file_type'], file_url: to_upload['file_url'], body: text, } params.merge!(recipient) if recipient result = Pushbullet::V2::request(API_URL, params) case result when Net::HTTPOK return JSON.parse(result.body) else puts result.body if Pushbullet.is_verbose return nil end end false end |
.link(title, text, link, recipient = nil) ⇒ JSON
push link
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/v2/push.rb', line 54 def self.link(title, text, link, recipient = nil) params = { type: :link, title: title, body: text, url: link, } params.merge!(recipient) if recipient result = Pushbullet::V2::request(API_URL, params) case result when Net::HTTPOK return JSON.parse(result.body) else puts result.body if Pushbullet.is_verbose return nil end end |
.note(title, text, recipient = nil) ⇒ JSON
push note
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/v2/push.rb', line 28 def self.note(title, text, recipient = nil) params = { type: :note, title: title, body: text, } params.merge!(recipient) if recipient result = Pushbullet::V2::request(API_URL, params) case result when Net::HTTPOK return JSON.parse(result.body) else puts result.body if Pushbullet.is_verbose return nil end end |