recapi 0.1.15 → 0.1.16
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/README.md +4 -1
- data/lib/recapi.rb +11 -6
- 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: 4630dc6459bcf8c5f8563c8d2725197ef77adea276bc85524363938c20ab8629
|
|
4
|
+
data.tar.gz: 6a58b1472dd36ba98c5757b6c5a1a4c297e9417b9fc23e0bbcb125a71f633dd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37f40070a0df5413ad196d63396be3aa4a3fad991e23daae7e5dbdb095dc803e278e6065c2047afd20466f3480be0e0904f7898903f1b1e5568a08bf43dc8ecb
|
|
7
|
+
data.tar.gz: e40ee11a50b6aa926ac3ed147de9676b8a185914cdddb228345ebb0088f33255a652599972405a2ecf7449fb9792ae22bd5d62cff6fb1354b6533000702113cb
|
data/README.md
CHANGED
|
@@ -28,7 +28,7 @@ line with your address): save it as `lib/recapi.rb` and
|
|
|
28
28
|
`require Rails.root.join("lib/recapi").to_s` instead.
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
|
-
curl -fLo lib/recapi.rb https://api.<your-domain>/sdk/ruby/recapi-0.1.
|
|
31
|
+
curl -fLo lib/recapi.rb https://api.<your-domain>/sdk/ruby/recapi-0.1.16.rb
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
## Quick start
|
|
@@ -138,6 +138,8 @@ so a visitor who never returns stays on disk (about 8 KB each): run
|
|
|
138
138
|
|
|
139
139
|
## Changes
|
|
140
140
|
|
|
141
|
+
- 2026-11-19: version 0.1.16. `Recapi::Error#docs_url` is the errors page's
|
|
142
|
+
section for an API error, and its message and the library's log lines end with it.
|
|
141
143
|
- 2026-11-19: version 0.1.15. This page's links lead to recapi.io's public docs,
|
|
142
144
|
and the gem lists its homepage, docs and support address. No code change.
|
|
143
145
|
- 2026-11-15: version 0.1.14. `recommend_lists` asks a page's rows in one call,
|
|
@@ -165,6 +167,7 @@ so a visitor who never returns stays on disk (about 8 KB each): run
|
|
|
165
167
|
`recommend` and `popular` answer an outage, a limit or a refused key (401, 403)
|
|
166
168
|
with popular items or an empty list and a log line; a bad request raises a
|
|
167
169
|
`Recapi::Error` (`code`, `status`), and a bad argument an `ArgumentError`.
|
|
170
|
+
An API error's `docs_url` is its section of the errors page (nil from older servers).
|
|
168
171
|
|
|
169
172
|
- [Errors](https://recapi.io/docs/errors): each error code, its cause and fix.
|
|
170
173
|
- [Troubleshooting](https://recapi.io/docs/troubleshooting): no lists yet,
|
data/lib/recapi.rb
CHANGED
|
@@ -25,7 +25,7 @@ rescue LoadError
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
module Recapi
|
|
28
|
-
VERSION = "0.1.
|
|
28
|
+
VERSION = "0.1.16"
|
|
29
29
|
|
|
30
30
|
# Decayed user history, exactly as docs/history-spec.md (times in unix ms).
|
|
31
31
|
# A port of sdk/python's history.py, snapshot merging included.
|
|
@@ -288,12 +288,16 @@ module Recapi
|
|
|
288
288
|
|
|
289
289
|
# A failed call. status is 0 when no HTTP response was received. code is the
|
|
290
290
|
# API's error code (invalid_request, rate_limited, quota_exceeded...) or a
|
|
291
|
-
# client one: network, timeout, invalid_response.
|
|
291
|
+
# client one: network, timeout, invalid_response. docs_url is the errors
|
|
292
|
+
# page's section for the code, sent by the API (nil from an older server
|
|
293
|
+
# and on client codes); message then ends with ", see <docs_url>", so a
|
|
294
|
+
# log line that prints the message names the fix.
|
|
292
295
|
class Error < StandardError
|
|
293
|
-
attr_reader :code, :status, :retry_after
|
|
296
|
+
attr_reader :code, :status, :retry_after, :docs_url
|
|
294
297
|
|
|
295
|
-
def initialize(code, message, status: 0, retry_after: nil)
|
|
296
|
-
|
|
298
|
+
def initialize(code, message, status: 0, retry_after: nil, docs_url: nil)
|
|
299
|
+
@docs_url = docs_url.is_a?(String) && !docs_url.empty? ? docs_url : nil
|
|
300
|
+
super(@docs_url ? "#{message}, see #{@docs_url}" : message)
|
|
297
301
|
@code = code
|
|
298
302
|
@status = status
|
|
299
303
|
@retry_after = retry_after
|
|
@@ -1412,7 +1416,8 @@ module Recapi
|
|
|
1412
1416
|
code = CODE_BY_STATUS[status] || (status >= 500 ? "internal" : "http_error") if code.nil? || code == ""
|
|
1413
1417
|
message = body["message"]
|
|
1414
1418
|
message = "HTTP #{status}" if message.nil? || message == ""
|
|
1415
|
-
Error.new(code.to_s, message.to_s, status: status, retry_after: retry_after(response["Retry-After"])
|
|
1419
|
+
Error.new(code.to_s, message.to_s, status: status, retry_after: retry_after(response["Retry-After"]),
|
|
1420
|
+
docs_url: body["docs_url"])
|
|
1416
1421
|
end
|
|
1417
1422
|
|
|
1418
1423
|
def retry_after(header)
|