pushbullet_client 0.0.17 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pushbullet/client.rb +24 -11
- 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
@@ -21,14 +21,16 @@ module Pushbullet
|
|
21
21
|
# TODO: Date parsing
|
22
22
|
# TODO: Create api client creation library
|
23
23
|
|
24
|
-
attr_reader :key, :secret, :base_path, :port
|
24
|
+
attr_reader :key, :secret, :base_path, :port, :timeout
|
25
|
+
attr_writer :base_path
|
25
26
|
|
26
|
-
def initialize(access_token:, base_path: API_V2_BASE_PATH, port: 80, limit: 500)
|
27
|
+
def initialize(access_token:, base_path: API_V2_BASE_PATH, port: 80, limit: 500, timeout: 1000)
|
27
28
|
@access_token = access_token
|
28
29
|
@base_path = base_path
|
29
30
|
@port = port
|
30
31
|
@limit = limit
|
31
32
|
@disable_limit = false # Used internally for permanents calls
|
33
|
+
@timeout = timeout
|
32
34
|
end
|
33
35
|
|
34
36
|
def self.compatible_api_version
|
@@ -37,12 +39,18 @@ module Pushbullet
|
|
37
39
|
|
38
40
|
# This is the version of the API docs this client was built off-of
|
39
41
|
def self.api_version
|
40
|
-
'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)
|
41
49
|
end
|
42
50
|
|
43
51
|
private
|
44
52
|
|
45
|
-
def authorise_and_send(http_method:, path:, payload: {}, params: {})
|
53
|
+
def authorise_and_send(http_method:, path:, payload: {}, params: {}, custom_base_path: nil)
|
46
54
|
start_time = micro_second_time_now
|
47
55
|
|
48
56
|
if params.nil? || params.empty?
|
@@ -54,28 +62,29 @@ module Pushbullet
|
|
54
62
|
end
|
55
63
|
|
56
64
|
begin
|
57
|
-
response = send_request(http_method, path, params, payload)
|
65
|
+
response = send_request(http_method, path, params, payload, custom_base_path)
|
58
66
|
rescue
|
59
67
|
# Retry once
|
60
68
|
# TODO: Add in retry amounts
|
61
|
-
response = send_request(http_method, path, params, payload)
|
69
|
+
response = send_request(http_method, path, params, payload, custom_base_path)
|
62
70
|
end
|
63
71
|
|
64
72
|
end_time = micro_second_time_now
|
65
73
|
construct_response_object(response, path, start_time, end_time)
|
66
74
|
end
|
67
75
|
|
68
|
-
def send_request(http_method, path, params, payload)
|
76
|
+
def send_request(http_method, path, params, payload, custom_base_path)
|
69
77
|
HTTParty.send(
|
70
78
|
http_method.to_sym,
|
71
|
-
construct_base_path(path, params),
|
79
|
+
construct_base_path(path, params, custom_base_path: custom_base_path),
|
72
80
|
body: payload,
|
73
81
|
headers: {
|
74
82
|
'Access-Token': @access_token,
|
75
83
|
'Content-Type': 'application/json'
|
76
84
|
},
|
77
85
|
port: port,
|
78
|
-
format: :json
|
86
|
+
format: :json,
|
87
|
+
timeout: timeout
|
79
88
|
)
|
80
89
|
end
|
81
90
|
|
@@ -122,8 +131,12 @@ module Pushbullet
|
|
122
131
|
(Time.now.to_f * 1_000_000).to_i
|
123
132
|
end
|
124
133
|
|
125
|
-
def construct_base_path(path, params)
|
126
|
-
|
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
|
127
140
|
|
128
141
|
if params == {}
|
129
142
|
constructed_path
|
data/lib/pushbullet/constants.rb
CHANGED
data/lib/pushbullet/version.rb
CHANGED