pushbullet_client 0.0.18 → 0.0.19
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/Gemfile.lock +1 -1
- data/lib/pushbullet/client.rb +19 -8
- data/lib/pushbullet/constants.rb +1 -0
- data/lib/pushbullet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddb16ecc88579480718ceac07dee40efae03671c8175a77d1a00fb7997b22721
|
4
|
+
data.tar.gz: 5a5297d8230e923133078c567a6332547fb1184b26de1e6b736354c14b729473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2e729e666f74ea1fb8e7012115a3a3d79854f39a37103151c0d6d1fb222639e84cbcdc927ed6e3275ff5ca7a719536bc711a32749fceb2b74eb00652bd9c5b
|
7
|
+
data.tar.gz: 84810ff5744d2c70ac451493ad282810035002ae71bdbfefd34b8c57b0a185ca4c4db32c76e8717ac96f70bd1a0d249ead82ac60c9481e2d11b19b110541f1c1
|
data/Gemfile.lock
CHANGED
data/lib/pushbullet/client.rb
CHANGED
@@ -22,6 +22,7 @@ module Pushbullet
|
|
22
22
|
# TODO: Create api client creation library
|
23
23
|
|
24
24
|
attr_reader :key, :secret, :base_path, :port, :timeout
|
25
|
+
attr_writer :base_path
|
25
26
|
|
26
27
|
def initialize(access_token:, base_path: API_V2_BASE_PATH, port: 80, limit: 500, timeout: 1000)
|
27
28
|
@access_token = access_token
|
@@ -38,12 +39,18 @@ module Pushbullet
|
|
38
39
|
|
39
40
|
# This is the version of the API docs this client was built off-of
|
40
41
|
def self.api_version
|
41
|
-
'v2
|
42
|
+
'v2 2024-02-23'
|
43
|
+
end
|
44
|
+
|
45
|
+
def check_api
|
46
|
+
params = process_cursor(nil, params: {})
|
47
|
+
path = ''
|
48
|
+
authorise_and_send(http_method: :get, path: path, params: params, custom_base_path: API_BASE_PATH)
|
42
49
|
end
|
43
50
|
|
44
51
|
private
|
45
52
|
|
46
|
-
def authorise_and_send(http_method:, path:, payload: {}, params: {})
|
53
|
+
def authorise_and_send(http_method:, path:, payload: {}, params: {}, custom_base_path: nil)
|
47
54
|
start_time = micro_second_time_now
|
48
55
|
|
49
56
|
if params.nil? || params.empty?
|
@@ -55,21 +62,21 @@ module Pushbullet
|
|
55
62
|
end
|
56
63
|
|
57
64
|
begin
|
58
|
-
response = send_request(http_method, path, params, payload)
|
65
|
+
response = send_request(http_method, path, params, payload, custom_base_path)
|
59
66
|
rescue
|
60
67
|
# Retry once
|
61
68
|
# TODO: Add in retry amounts
|
62
|
-
response = send_request(http_method, path, params, payload)
|
69
|
+
response = send_request(http_method, path, params, payload, custom_base_path)
|
63
70
|
end
|
64
71
|
|
65
72
|
end_time = micro_second_time_now
|
66
73
|
construct_response_object(response, path, start_time, end_time)
|
67
74
|
end
|
68
75
|
|
69
|
-
def send_request(http_method, path, params, payload)
|
76
|
+
def send_request(http_method, path, params, payload, custom_base_path)
|
70
77
|
HTTParty.send(
|
71
78
|
http_method.to_sym,
|
72
|
-
construct_base_path(path, params),
|
79
|
+
construct_base_path(path, params, custom_base_path: custom_base_path),
|
73
80
|
body: payload,
|
74
81
|
headers: {
|
75
82
|
'Access-Token': @access_token,
|
@@ -124,8 +131,12 @@ module Pushbullet
|
|
124
131
|
(Time.now.to_f * 1_000_000).to_i
|
125
132
|
end
|
126
133
|
|
127
|
-
def construct_base_path(path, params)
|
128
|
-
|
134
|
+
def construct_base_path(path, params, custom_base_path: nil)
|
135
|
+
if custom_base_path
|
136
|
+
constructed_path = "#{custom_base_path}/#{path}"
|
137
|
+
else
|
138
|
+
constructed_path = "#{base_path}/#{path}"
|
139
|
+
end
|
129
140
|
|
130
141
|
if params == {}
|
131
142
|
constructed_path
|
data/lib/pushbullet/constants.rb
CHANGED
data/lib/pushbullet/version.rb
CHANGED