halfpipe 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61ea9a4b182d14b75ce93510862c407238459f45796643ed2a1f399d939831d8
4
- data.tar.gz: 36faf974074ff7f98ed14aefd2be5e2ff29e0bc74627dcdf9f9818cfcf1a6269
3
+ metadata.gz: bcd1bfe23d449040fcb12b212b971a83a3367c3f3871f854f16c650a3d307f73
4
+ data.tar.gz: 9472be4c949c195b6765efdfb19c828fa5ee4b538f3a88fbcfa28e4e83ed6cfd
5
5
  SHA512:
6
- metadata.gz: 2af4c8244fcbfe1bf79ca78a15bc12af178fd1dfb53f259bad334f9dd1a523af11538a5586112cf02aeeb13b6d9615f99c04b6feff63283e4142061ed5639a92
7
- data.tar.gz: 80338d1dbd2dbf8f4e8d52f5f4a1067f21ea374f5f89e327ff72fe76147ee8c4e68397bee8f3edb8f8fb819c42394a9d5b6dcd1e6a68b449356f522392a10fd3
6
+ metadata.gz: 8341fd67d3e2b501c998a832db132cf8c0cacb3ae323d20d796d6dd234fe0adb3fce1009f1c5972d2892ee569c80132668d566ce9afa515e9914ab745e94e876
7
+ data.tar.gz: 0b13659babef59eaa2152b9c97cc3e64e43e352af041fe9a22b6f91eb323bdfdb8db7c541e68bb2c912d98d7aea7478b919db5a121e978ea567c1c5926b97cb9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [0.0.3] - 2022-01-24
2
+
3
+ - Raise an error when the API token/subdomain are rejected by the Pipedrive API
4
+ as unauthorized
5
+
1
6
  ## [0.0.2] - 2022-01-19
2
7
 
3
8
  - Fix a typo in `puts` which would cause an error when rate limited
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- halfpipe (0.0.2)
4
+ halfpipe (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -43,6 +43,7 @@ GEM
43
43
 
44
44
  PLATFORMS
45
45
  arm64-darwin-21
46
+ x86_64-linux
46
47
 
47
48
  DEPENDENCIES
48
49
  dotenv
data/lib/halfpipe/http.rb CHANGED
@@ -13,8 +13,10 @@ module Halfpipe
13
13
  res = Net::HTTP.get_response(uri)
14
14
  json = parse_json(res)
15
15
 
16
- if rate_limited?(res)
17
- wait_time = res["x-ratelimit-reset"].to_i
16
+ if unauthorized?(res)
17
+ raise Error.new("Pipedrive API returned #{res.code} unauthorized. Verify your API token and subdomain?")
18
+ elsif rate_limited?(res)
19
+ wait_time = res["x-ratelimit-reset"].to_i + 1
18
20
  puts "Reached rate limit, sleeping #{wait_time}"
19
21
  sleep wait_time
20
22
  get(path, params: params, start: start)
@@ -79,8 +81,13 @@ module Halfpipe
79
81
  nil
80
82
  end
81
83
 
84
+ def unauthorized?(res)
85
+ res.code == "401"
86
+ end
87
+
82
88
  def rate_limited?(res)
83
- res.code == "429" || res["x-ratelimit-remaining"].to_i < 1
89
+ res.code == "429" ||
90
+ (res.key?("x-ratelimit-remaining") && res["x-ratelimit-remaining"].to_i < 1)
84
91
  end
85
92
 
86
93
  def raise_failure_maybe!(res, json)
@@ -1,3 +1,3 @@
1
1
  module Halfpipe
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: halfpipe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Searls