nzbn-ruby 0.1.2 → 0.1.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 +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/nzbn/client.rb +19 -11
- data/lib/nzbn/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: e3e75fea148c426a6e76e8906d84adfa0ec50a18301bc7fe238523270b234182
|
|
4
|
+
data.tar.gz: 00331f54933e383d2fefbcca550a2c6a0a1f84f89e0fea86023507e4e79807d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62fb20657fe2692ff8bf150534b2abfa1255bfc8c6fcccdf8b88030bf0898c1e46d00bc3eed03de85992de84bf634ebc48125b785c0aa23f0f3c840e97ed9174
|
|
7
|
+
data.tar.gz: 7a8c96c6fcb3c02540cde14c44199fde57e7237c8a153a63e05a3993a72a3aeb93f3c1fa9d77a5bf50517d11c46ebd165cd38ae312850bebb4a958adf0ef7caf
|
data/CHANGELOG.md
CHANGED
|
@@ -5,10 +5,16 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.1.3] - 2026-02-09
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Fixed `:json is not registered on Faraday::Request` error by removing middleware dependency
|
|
12
|
+
- Manually handle JSON encoding/decoding for better compatibility with Faraday 1.x
|
|
13
|
+
|
|
8
14
|
## [0.1.2] - 2026-02-09
|
|
9
15
|
|
|
10
16
|
### Fixed
|
|
11
|
-
- Update
|
|
17
|
+
- Update dependency gems.
|
|
12
18
|
|
|
13
19
|
## [0.1.1] - 2026-02-09
|
|
14
20
|
|
data/lib/nzbn/client.rb
CHANGED
|
@@ -109,8 +109,6 @@ module Nzbn
|
|
|
109
109
|
|
|
110
110
|
def connection
|
|
111
111
|
@connection ||= Faraday.new(url: configuration.base_url) do |conn|
|
|
112
|
-
conn.request :json
|
|
113
|
-
conn.response :json, content_type: /\bjson$/
|
|
114
112
|
conn.adapter Faraday.default_adapter
|
|
115
113
|
|
|
116
114
|
conn.options.timeout = configuration.timeout
|
|
@@ -135,7 +133,7 @@ module Nzbn
|
|
|
135
133
|
when :get, :delete
|
|
136
134
|
req.params = data unless data.empty?
|
|
137
135
|
else
|
|
138
|
-
req.body = data
|
|
136
|
+
req.body = JSON.generate(data) unless data.empty?
|
|
139
137
|
end
|
|
140
138
|
end
|
|
141
139
|
|
|
@@ -156,24 +154,34 @@ module Nzbn
|
|
|
156
154
|
end
|
|
157
155
|
|
|
158
156
|
def handle_response(response)
|
|
157
|
+
body = parse_json(response.body)
|
|
158
|
+
|
|
159
159
|
case response.status
|
|
160
160
|
when 200..299
|
|
161
|
-
|
|
161
|
+
body
|
|
162
162
|
when 400
|
|
163
|
-
raise ValidationError.new(response:
|
|
163
|
+
raise ValidationError.new(response: body, status: response.status)
|
|
164
164
|
when 401
|
|
165
|
-
raise AuthenticationError.new('Authentication failed', response:
|
|
165
|
+
raise AuthenticationError.new('Authentication failed', response: body, status: response.status)
|
|
166
166
|
when 403
|
|
167
|
-
raise AuthorizationError.new('Authorization denied', response:
|
|
167
|
+
raise AuthorizationError.new('Authorization denied', response: body, status: response.status)
|
|
168
168
|
when 404
|
|
169
|
-
raise NotFoundError.new('Resource not found', response:
|
|
169
|
+
raise NotFoundError.new('Resource not found', response: body, status: response.status)
|
|
170
170
|
when 412
|
|
171
|
-
raise PreconditionFailedError.new('Precondition failed', response:
|
|
171
|
+
raise PreconditionFailedError.new('Precondition failed', response: body, status: response.status)
|
|
172
172
|
when 500..599
|
|
173
|
-
raise ServerError.new('Server error', response:
|
|
173
|
+
raise ServerError.new('Server error', response: body, status: response.status)
|
|
174
174
|
else
|
|
175
|
-
raise ApiError.new("Unexpected response: #{response.status}", response:
|
|
175
|
+
raise ApiError.new("Unexpected response: #{response.status}", response: body, status: response.status)
|
|
176
176
|
end
|
|
177
177
|
end
|
|
178
|
+
|
|
179
|
+
def parse_json(body)
|
|
180
|
+
return nil if body.nil? || body.empty?
|
|
181
|
+
|
|
182
|
+
JSON.parse(body)
|
|
183
|
+
rescue JSON::ParserError
|
|
184
|
+
body
|
|
185
|
+
end
|
|
178
186
|
end
|
|
179
187
|
end
|
data/lib/nzbn/version.rb
CHANGED