pushbullet_client 0.0.18 → 0.0.19

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
  SHA256:
3
- metadata.gz: f238840facbb7840b6fcd238bd64ff2e0d4277a9c499b0eb0f528e7ed9d883c5
4
- data.tar.gz: 7ef9c68fb3da2d989e5a22c3819a758c78ebdbdbd275c60a1f5bb4bc6f87b598
3
+ metadata.gz: ddb16ecc88579480718ceac07dee40efae03671c8175a77d1a00fb7997b22721
4
+ data.tar.gz: 5a5297d8230e923133078c567a6332547fb1184b26de1e6b736354c14b729473
5
5
  SHA512:
6
- metadata.gz: 7ca774d6b8a91aa135b986c93deb5c04ae0a00a56341dd42db5e531d57f614c698d4b89e33e1b44c7961059fd75222facc23161501be114f326be07f23a5c6e9
7
- data.tar.gz: 52cdcf3fd553d92598f602b757694b74348271eee69c42ca4ee1fb96683f68523aa72fef30ecc2fbacd0adde83f290b7f2cf31bbc9a3377959f243dc2d11de59
6
+ metadata.gz: ff2e729e666f74ea1fb8e7012115a3a3d79854f39a37103151c0d6d1fb222639e84cbcdc927ed6e3275ff5ca7a719536bc711a32749fceb2b74eb00652bd9c5b
7
+ data.tar.gz: 84810ff5744d2c70ac451493ad282810035002ae71bdbfefd34b8c57b0a185ca4c4db32c76e8717ac96f70bd1a0d249ead82ac60c9481e2d11b19b110541f1c1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pushbullet_client (0.0.16)
4
+ pushbullet_client (0.0.19)
5
5
  active_attr (~> 0.16.0)
6
6
  httparty (~> 0.21.0)
7
7
  nokogiri (~> 1.16.2)
@@ -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 2020-10-17'
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
- constructed_path = "#{base_path}/#{path}"
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
@@ -1,5 +1,6 @@
1
1
  module Pushbullet
2
2
  module Constants
3
+ API_BASE_PATH = 'https://api.pushbullet.com'
3
4
  API_V2_BASE_PATH = 'https://api.pushbullet.com/v2'
4
5
  end
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module Pushbullet
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushbullet_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22