pushbullet_ruby 1.0.2.1 → 1.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: 01eb5ac49b0dcf424f90a04387523868c49df105
4
- data.tar.gz: 477f3996c064b3b657a90945de692a47ce058927
3
+ metadata.gz: 3a0e06cea76b41d45aa865be349cf82153c535f3
4
+ data.tar.gz: 5841c789ef3925c3baeacd399d91d0f1bf9ede5a
5
5
  SHA512:
6
- metadata.gz: 8260e61e889d765495cdae01427d0c32a95d71abbedbfe88483a5119918e0dd6db48252b4fd9217e485ff2fef0f669cd29380e646dced9f97c8ca69b67abc1b7
7
- data.tar.gz: be1a883fa1884d071c006687b58ea6bdbe798719462a5c15fa986e340bd71eb265d91764c1a3ecc55e29a7b76b3d28ecf508a39d3fc779d188733c23bdee4813
6
+ metadata.gz: 364433330836d920dbd7edc6f6e2ea37c9050fcbae37251d88729e1e3f222c81470c21e0eb54482714610d90b519b6bc938a29cb29b31ca7861b70998fe7d0ad
7
+ data.tar.gz: c315781d3a2a1cae08cbc6552cfb0a8edebd33416fcb3b765d3da10dd17241501869358a77e51c03158da4591e2f829c24e5ed0a31cb46fc2749274ef5d2776f
@@ -0,0 +1,17 @@
1
+ require 'pushbullet_ruby/ephemerable'
2
+ require 'pushbullet_ruby/ephemerable/sms'
3
+ require 'pushbullet_ruby/ephemerable/notifitation'
4
+
5
+ module PushbulletRuby
6
+ module API
7
+ module Ephemerals
8
+ def send_sms(user_identifier: nil, device_identifier: nil, params: {})
9
+ PushbulletRuby::Ephemerable::Sms.push(self, user_identifier, device_identifier, params)
10
+ end
11
+
12
+ def push_notification(user_identifier: nil, device_identifier: nil, params: {})
13
+ PushbulletRuby::Ephemerable::Notification.push(self, user_identifier, device_identifier, params)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,16 +6,16 @@ require 'pushbullet_ruby/pushable/file'
6
6
  module PushbulletRuby
7
7
  module API
8
8
  module Pushes
9
- def push_note(receiver: nil, identifier: nil, params: {})
10
- PushbulletRuby::Pushable::Note.push(self, receiver, identifier, params)
9
+ def push_note(receiver: nil, device_identifier: nil, params: {})
10
+ PushbulletRuby::Pushable::Note.push(self, receiver, device_identifier, params)
11
11
  end
12
12
 
13
- def push_link(receiver: nil, identifier: nil, params: {})
14
- PushbulletRuby::Pushable::Link.push(self, receiver, identifier, params)
13
+ def push_link(receiver: nil, device_identifier: nil, params: {})
14
+ PushbulletRuby::Pushable::Link.push(self, receiver, device_identifier, params)
15
15
  end
16
16
 
17
- def push_file(receiver: nil, identifier: nil, params: {})
18
- PushbulletRuby::Pushable::File.push(self, receiver, identifier, params)
17
+ def push_file(receiver: nil, device_identifier: nil, params: {})
18
+ PushbulletRuby::Pushable::File.push(self, receiver, device_identifier, params)
19
19
  end
20
20
 
21
21
  def pushes
@@ -1,6 +1,7 @@
1
1
  require 'pushbullet_ruby/api/me'
2
2
  require 'pushbullet_ruby/api/devices'
3
3
  require 'pushbullet_ruby/api/pushes'
4
+ require 'pushbullet_ruby/api/ephemerals'
4
5
  require 'pushbullet_ruby/api/contacts'
5
6
  require 'pushbullet_ruby/api/subscriptions'
6
7
 
@@ -9,6 +10,7 @@ module PushbulletRuby
9
10
  include Me
10
11
  include Devices
11
12
  include Pushes
13
+ include Ephemerals
12
14
  include Contacts
13
15
  include Subscriptions
14
16
  end
@@ -29,7 +29,7 @@ module PushbulletRuby
29
29
  builder: middleware,
30
30
  headers: {
31
31
  accept: 'application/json',
32
- user_agent: 'Pushbullet Gem'
32
+ user_agent: 'pushbullet_ruby Gem'
33
33
  },
34
34
  ssl: {
35
35
  verify: false
@@ -16,5 +16,9 @@ module PushbulletRuby
16
16
  def name
17
17
  body['nickname']
18
18
  end
19
+
20
+ def app_version
21
+ body['app_version']
22
+ end
19
23
  end
20
24
  end
@@ -0,0 +1,22 @@
1
+ module PushbulletRuby
2
+ class Ephemerable
3
+ class Notification < Ephemerable
4
+ def type
5
+ :push
6
+ end
7
+
8
+ def required_parameters
9
+ [:title, :body]
10
+ end
11
+
12
+ def construct_payload(user_identifier, device_identifier)
13
+ {
14
+ source_user_iden: user_identifier,
15
+ source_device_iden: device_identifier,
16
+ package_name: 'com.pushbullet.android',
17
+ type: 'mirror'
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module PushbulletRuby
2
+ class Ephemerable
3
+ class Sms < Ephemerable
4
+ def type
5
+ :push
6
+ end
7
+
8
+ def required_parameters
9
+ [:conversation_iden, :message]
10
+ end
11
+
12
+ def construct_payload(user_identifier, device_identifier)
13
+ {
14
+ source_user_iden: user_identifier,
15
+ target_device_iden: device_identifier,
16
+ package_name: 'com.pushbullet.android',
17
+ type: 'messaging_extension_reply'
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,30 @@
1
+ require 'pushbullet_ruby/ephemeral'
2
+
3
+ module PushbulletRuby
4
+ class Ephemerable
5
+ class MissingParameter < StandardError; end
6
+
7
+ attr_reader :client, :user_identifier, :device_identifier, :params
8
+
9
+ def self.push(client, user_identifier, device_identifier, params)
10
+ Ephemeral.new(new(client, user_identifier, device_identifier, params).push.body)
11
+ end
12
+
13
+ def initialize(client, user_identifier, device_identifier, params)
14
+ @client = client
15
+ @user_identifier = user_identifier
16
+ @device_identifier = device_identifier
17
+ @params = params
18
+ end
19
+
20
+ def push
21
+ raise MissingParameter unless required_parameters.all? { |e| params.keys.include?(e) }
22
+
23
+ payload = {
24
+ type: type,
25
+ push: params.merge(construct_payload(user_identifier, device_identifier))
26
+ }
27
+ client.post('/v2/ephemerals', payload.to_json)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,7 @@
1
+ require 'pushbullet_ruby/entity'
2
+
3
+ module PushbulletRuby
4
+ class Ephemeral < Entity
5
+
6
+ end
7
+ end
@@ -2,7 +2,7 @@ module PushbulletRuby
2
2
  class Pushable
3
3
  class File < Pushable
4
4
  def push
5
- raise MissingParameter unless params.keys.sort == required_parameters.sort
5
+ raise MissingParameter unless required_parameters.all? { |e| params.keys.include?(e) }
6
6
 
7
7
  file_name = params[:file_name]
8
8
  file_path = params[:file_path]
@@ -18,7 +18,7 @@ module PushbulletRuby
18
18
  end
19
19
 
20
20
  def push
21
- raise MissingParameter unless params.keys.sort == required_parameters.sort
21
+ raise MissingParameter unless required_parameters.all? { |e| params.keys.include?(e) }
22
22
 
23
23
  payload = params.merge(type: type)
24
24
  payload = specify_receiver(payload)
@@ -1,3 +1,3 @@
1
1
  module PushbulletRuby
2
- VERSION = "1.0.2.1"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -2,6 +2,7 @@ require 'pushbullet_ruby/client'
2
2
  require 'pushbullet_ruby/user'
3
3
  require 'pushbullet_ruby/device'
4
4
  require 'pushbullet_ruby/pushable'
5
+ require 'pushbullet_ruby/ephemerable'
5
6
  require 'pushbullet_ruby/contact'
6
7
  require 'pushbullet_ruby/channel'
7
8
  require 'pushbullet_ruby/token'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushbullet_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - creends
@@ -81,6 +81,7 @@ files:
81
81
  - lib/pushbullet_ruby/api.rb
82
82
  - lib/pushbullet_ruby/api/contacts.rb
83
83
  - lib/pushbullet_ruby/api/devices.rb
84
+ - lib/pushbullet_ruby/api/ephemerals.rb
84
85
  - lib/pushbullet_ruby/api/me.rb
85
86
  - lib/pushbullet_ruby/api/pushes.rb
86
87
  - lib/pushbullet_ruby/api/subscriptions.rb
@@ -90,6 +91,10 @@ files:
90
91
  - lib/pushbullet_ruby/contact.rb
91
92
  - lib/pushbullet_ruby/device.rb
92
93
  - lib/pushbullet_ruby/entity.rb
94
+ - lib/pushbullet_ruby/ephemerable.rb
95
+ - lib/pushbullet_ruby/ephemerable/notifitation.rb
96
+ - lib/pushbullet_ruby/ephemerable/sms.rb
97
+ - lib/pushbullet_ruby/ephemeral.rb
93
98
  - lib/pushbullet_ruby/http_exeption.rb
94
99
  - lib/pushbullet_ruby/parse_json.rb
95
100
  - lib/pushbullet_ruby/push.rb