pushbullet_client 0.0.1 → 0.0.6
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/README.md +8 -2
- data/bin/make +3 -0
- data/lib/pushbullet.rb +8 -1
- data/lib/pushbullet/chats.rb +9 -0
- data/lib/pushbullet/client.rb +30 -46
- data/lib/pushbullet/constants.rb +1 -0
- data/lib/pushbullet/devices.rb +9 -0
- data/lib/pushbullet/permanents.rb +18 -0
- data/lib/pushbullet/pushes.rb +16 -0
- data/lib/pushbullet/subscriptions.rb +9 -0
- data/lib/pushbullet/texts.rb +9 -0
- data/lib/pushbullet/users.rb +9 -0
- data/lib/pushbullet/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41e090f3defb5e7fdab2d0d09ac0f9e4724acd0c4de1bac80cb211921a201081
|
4
|
+
data.tar.gz: '0429f947e802b79d68bae4567f2f3e85d7c1b3a8672864ec0575b0b5d1e5ab56'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0fc33fb5b681f4522a36d730607c44c42876209f1321c068dffc43c0dc2b182ad0e928d240e66aef41e25acf3fe8e476c2b6c9f772a8ef5baee5faf6b46d0a1
|
7
|
+
data.tar.gz: e4106fd2235666a8d43e73fbe60700154300791b1e84af3d782c45dc10179eda2d1486068dbdd550ca475b2eaf6d7e8b0991a30b1879d7b0554e125c0a769ee4
|
data/README.md
CHANGED
@@ -23,11 +23,17 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
require 'pushbullet_client'
|
26
|
-
client = PushBullet::Client.new(
|
26
|
+
client = PushBullet::Client.new(access_token: 'your access_token')
|
27
27
|
```
|
28
28
|
|
29
29
|
### Endpoints
|
30
|
-
-
|
30
|
+
- Chats
|
31
|
+
- Devices
|
32
|
+
- Permanents
|
33
|
+
- Pushes
|
34
|
+
- Subscriptions
|
35
|
+
- Texts
|
36
|
+
- Users
|
31
37
|
|
32
38
|
### Constants
|
33
39
|
Constants
|
data/bin/make
ADDED
data/lib/pushbullet.rb
CHANGED
@@ -5,9 +5,16 @@ require 'pushbullet/version'
|
|
5
5
|
require 'pushbullet/constants'
|
6
6
|
|
7
7
|
# Endpoints
|
8
|
+
require 'pushbullet/chats'
|
9
|
+
require 'pushbullet/devices'
|
10
|
+
require 'pushbullet/permanents'
|
11
|
+
require 'pushbullet/pushes'
|
12
|
+
require 'pushbullet/subscriptions'
|
13
|
+
require 'pushbullet/texts'
|
14
|
+
require 'pushbullet/users'
|
8
15
|
|
9
16
|
require 'pushbullet/client'
|
10
17
|
|
11
|
-
module
|
18
|
+
module Pushbullet
|
12
19
|
class Error < StandardError; end
|
13
20
|
end
|
data/lib/pushbullet/client.rb
CHANGED
@@ -3,60 +3,31 @@ module Pushbullet
|
|
3
3
|
include ::Pushbullet::Constants
|
4
4
|
|
5
5
|
# Endpoints
|
6
|
-
|
7
|
-
|
6
|
+
include ::Pushbullet::Chats
|
7
|
+
include ::Pushbullet::Devices
|
8
|
+
include ::Pushbullet::Permanents
|
9
|
+
include ::Pushbullet::Pushes
|
10
|
+
include ::Pushbullet::Subscriptions
|
11
|
+
include ::Pushbullet::Texts
|
12
|
+
include ::Pushbullet::Users
|
13
|
+
|
14
|
+
# TODO: Add uploads
|
15
|
+
# TODO: Add ephemerals
|
16
|
+
# TODO: Websockets
|
17
|
+
# TODO: Universal copy/paste
|
18
|
+
# TODO: Encryption
|
8
19
|
# TODO: Pagination
|
9
20
|
# TODO: Limits
|
10
21
|
# TODO: Date parsing
|
11
22
|
# TODO: Create api client creation library
|
12
23
|
|
13
|
-
def me
|
14
|
-
path = 'users/me'
|
15
|
-
authorise_and_send(http_method: :get, path: path)
|
16
|
-
end
|
17
|
-
|
18
|
-
def devices
|
19
|
-
path = 'devices'
|
20
|
-
authorise_and_send(http_method: :get, path: path)
|
21
|
-
end
|
22
|
-
|
23
|
-
def pushes
|
24
|
-
path = 'pushes'
|
25
|
-
authorise_and_send(http_method: :get, path: path)
|
26
|
-
end
|
27
|
-
|
28
|
-
def chats
|
29
|
-
path = 'chats'
|
30
|
-
authorise_and_send(http_method: :get, path: path)
|
31
|
-
end
|
32
|
-
|
33
|
-
def subscriptions
|
34
|
-
path = 'subscriptions'
|
35
|
-
authorise_and_send(http_method: :get, path: path)
|
36
|
-
end
|
37
|
-
|
38
|
-
def texts
|
39
|
-
path = 'texts'
|
40
|
-
authorise_and_send(http_method: :get, path: path)
|
41
|
-
end
|
42
|
-
|
43
|
-
# See: https://stackoverflow.com/questions/38027963/pushbullet-api-thread-id-to-conversation-iden-for-sms
|
44
|
-
def permanents(device_identity:)
|
45
|
-
path = "permanents/#{device_identity}_threads"
|
46
|
-
authorise_and_send(http_method: :get, path: path)
|
47
|
-
end
|
48
|
-
|
49
|
-
def permanent_conversation(device_identity:, thread_id:)
|
50
|
-
path = "permanents/#{device_identity}_thread_#{thread_id}"
|
51
|
-
authorise_and_send(http_method: :get, path: path)
|
52
|
-
end
|
53
|
-
|
54
24
|
attr_reader :key, :secret, :base_path, :port
|
55
25
|
|
56
|
-
def initialize(access_token:, base_path:
|
26
|
+
def initialize(access_token:, base_path: API_V2_BASE_PATH, port: 80, limit: 500)
|
57
27
|
@access_token = access_token
|
58
28
|
@base_path = base_path
|
59
29
|
@port = port
|
30
|
+
@limit = limit
|
60
31
|
end
|
61
32
|
|
62
33
|
def self.compatible_api_version
|
@@ -73,6 +44,12 @@ module Pushbullet
|
|
73
44
|
def authorise_and_send(http_method:, path:, payload: {}, params: {})
|
74
45
|
start_time = micro_second_time_now
|
75
46
|
|
47
|
+
if params.nil? || params.empty?
|
48
|
+
params = {}
|
49
|
+
end
|
50
|
+
|
51
|
+
params['limit'] = @limit
|
52
|
+
|
76
53
|
response = HTTParty.send(
|
77
54
|
http_method.to_sym,
|
78
55
|
construct_base_path(path, params),
|
@@ -103,7 +80,8 @@ module Pushbullet
|
|
103
80
|
{
|
104
81
|
'start_time' => start_time,
|
105
82
|
'end_time' => end_time,
|
106
|
-
'total_time' => total_time
|
83
|
+
'total_time' => total_time,
|
84
|
+
'cursor' => response.dig('cursor')
|
107
85
|
}
|
108
86
|
end
|
109
87
|
|
@@ -134,7 +112,7 @@ module Pushbullet
|
|
134
112
|
def construct_base_path(path, params)
|
135
113
|
constructed_path = "#{base_path}/#{path}"
|
136
114
|
|
137
|
-
if params
|
115
|
+
if params == {}
|
138
116
|
constructed_path
|
139
117
|
else
|
140
118
|
"#{constructed_path}?#{process_params(params)}"
|
@@ -144,5 +122,11 @@ module Pushbullet
|
|
144
122
|
def process_params(params)
|
145
123
|
params.keys.map { |key| "#{key}=#{params[key]}" }.join('&')
|
146
124
|
end
|
125
|
+
|
126
|
+
def process_cursor(cursor, params: {})
|
127
|
+
unless cursor.nil? || cursor.empty?
|
128
|
+
params['cursor'] = cursor
|
129
|
+
end
|
130
|
+
end
|
147
131
|
end
|
148
132
|
end
|
data/lib/pushbullet/constants.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Pushbullet
|
2
|
+
module Permanents
|
3
|
+
# See: https://stackoverflow.com/questions/38027963/pushbullet-api-thread-id-to-conversation-iden-for-sms
|
4
|
+
def permanents(device_identity:, params: {}, cursor: nil)
|
5
|
+
params = process_cursor(cursor, params: params)
|
6
|
+
|
7
|
+
path = "permanents/#{device_identity}_threads"
|
8
|
+
authorise_and_send(http_method: :get, path: path, params: params)
|
9
|
+
end
|
10
|
+
|
11
|
+
def permanent_conversation(device_identity:, thread_id:, params: {}, cursor: nil)
|
12
|
+
params = process_cursor(cursor, params: params)
|
13
|
+
|
14
|
+
path = "permanents/#{device_identity}_thread_#{thread_id}"
|
15
|
+
authorise_and_send(http_method: :get, path: path, params: params)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pushbullet
|
2
|
+
module Pushes
|
3
|
+
def pushes(params: {}, cursor: nil)
|
4
|
+
params = process_cursor(cursor, params: params)
|
5
|
+
path = 'pushes'
|
6
|
+
authorise_and_send(http_method: :get, path: path, params: params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self_pushes(params: {}, cursor: nil)
|
10
|
+
params = process_cursor(cursor, params: params.merge({ self: true }))
|
11
|
+
|
12
|
+
path = 'pushes'
|
13
|
+
authorise_and_send(http_method: :get, path: path, params: params)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/pushbullet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushbullet_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trex22
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_attr
|
@@ -194,10 +194,18 @@ files:
|
|
194
194
|
- README.md
|
195
195
|
- Rakefile
|
196
196
|
- bin/console
|
197
|
+
- bin/make
|
197
198
|
- bin/setup
|
198
199
|
- lib/pushbullet.rb
|
200
|
+
- lib/pushbullet/chats.rb
|
199
201
|
- lib/pushbullet/client.rb
|
200
202
|
- lib/pushbullet/constants.rb
|
203
|
+
- lib/pushbullet/devices.rb
|
204
|
+
- lib/pushbullet/permanents.rb
|
205
|
+
- lib/pushbullet/pushes.rb
|
206
|
+
- lib/pushbullet/subscriptions.rb
|
207
|
+
- lib/pushbullet/texts.rb
|
208
|
+
- lib/pushbullet/users.rb
|
201
209
|
- lib/pushbullet/version.rb
|
202
210
|
- pushbullet_client.gemspec
|
203
211
|
homepage: https://github.com/TRex22/pushbullet_client
|