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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 575fe6386a53cb5b9711fba22f42012a14af0c582143dcfcfb09f286889a5031
4
- data.tar.gz: c77da6e8b4542aea69abf76fa41bfaa2f1bdaf51dfece59c7ff937556852c8b1
3
+ metadata.gz: ddb16ecc88579480718ceac07dee40efae03671c8175a77d1a00fb7997b22721
4
+ data.tar.gz: 5a5297d8230e923133078c567a6332547fb1184b26de1e6b736354c14b729473
5
5
  SHA512:
6
- metadata.gz: 4012d0a3ffcb59ebf35b80c2c41735e8d81a2d1c178f3157931630562d807ad6deea3d31314698024e8b41dbb00b26f2795c28233b942cac857fc8c73e1c70b0
7
- data.tar.gz: 1dc3b5f437d74ff4e9b7593a8117542e47fce2ee7087f2fbef27b4844df1896f87e35ac32402f2519e1b008d2d784c12c797b4cde4a8adc372a35d81f591440a
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)
@@ -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 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)
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
- 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
127
140
 
128
141
  if params == {}
129
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.17"
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.17
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22