nzbn-ruby 0.1.3 → 0.1.4

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: e3e75fea148c426a6e76e8906d84adfa0ec50a18301bc7fe238523270b234182
4
- data.tar.gz: 00331f54933e383d2fefbcca550a2c6a0a1f84f89e0fea86023507e4e79807d2
3
+ metadata.gz: 0bc9736578fcb4a9663e87a28d910e91dbfdc9acf724f30c09bfc03fb47b5e3f
4
+ data.tar.gz: 1fffb71fac5bf19a6192220b89674212066f2be603fd37c2a6d8d4f7f8f6cf3f
5
5
  SHA512:
6
- metadata.gz: 62fb20657fe2692ff8bf150534b2abfa1255bfc8c6fcccdf8b88030bf0898c1e46d00bc3eed03de85992de84bf634ebc48125b785c0aa23f0f3c840e97ed9174
7
- data.tar.gz: 7a8c96c6fcb3c02540cde14c44199fde57e7237c8a153a63e05a3993a72a3aeb93f3c1fa9d77a5bf50517d11c46ebd165cd38ae312850bebb4a958adf0ef7caf
6
+ metadata.gz: c5de87bf46f1d4bb736a5bb42815e25524c359e7c3e98b9f5b83fdf854862a4de960c80a1a43a25c18214e485660820cbbcd30003b40ba9cee7a5e7b52ff0403
7
+ data.tar.gz: 7efe36fe483fe7a4ca917b313e65466aabef6539b8e8dc1ec83666df6ca0c64c96923d53f54782e5e69656fedf697ad74a5d63e80365be2268547aafde5d9f28
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ 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.4] - 2026-02-09
9
+
10
+ ### Added
11
+ - Added request/response logging with configurable logger
12
+ - Logs request ID, HTTP method, URL before each API call
13
+ - Logs response status after each API call
14
+
8
15
  ## [0.1.3] - 2026-02-09
9
16
 
10
17
  ### Fixed
data/README.md CHANGED
@@ -33,10 +33,13 @@ gem install nzbn-ruby
33
33
  Configure the gem with your NZBN API key (obtain from [api.business.govt.nz](https://api.business.govt.nz)):
34
34
 
35
35
  ```ruby
36
+ require 'logger'
37
+
36
38
  Nzbn.configure do |config|
37
39
  config.api_key = 'your-api-key'
38
40
  config.base_url = 'https://api.business.govt.nz/gateway/nzbn/v5' # default
39
41
  config.timeout = 30 # optional, default 30 seconds
42
+ config.logger = Logger.new(STDOUT) # optional, enables request/response logging
40
43
  end
41
44
  ```
42
45
 
data/lib/nzbn/client.rb CHANGED
@@ -113,15 +113,14 @@ module Nzbn
113
113
 
114
114
  conn.options.timeout = configuration.timeout
115
115
  conn.options.open_timeout = configuration.open_timeout
116
-
117
- if configuration.logger
118
- conn.response :logger, configuration.logger
119
- end
120
116
  end
121
117
  end
122
118
 
123
119
  def request(method, path, data, headers)
124
120
  request_id = SecureRandom.uuid
121
+ full_url = "#{configuration.base_url}#{path}"
122
+
123
+ log_request(method, full_url, request_id, data)
125
124
 
126
125
  merged_headers = default_headers(request_id).merge(headers)
127
126
 
@@ -137,6 +136,7 @@ module Nzbn
137
136
  end
138
137
  end
139
138
 
139
+ log_response(response, request_id)
140
140
  handle_response(response)
141
141
  rescue Faraday::TimeoutError => e
142
142
  raise TimeoutError, "Request timed out: #{e.message}"
@@ -144,6 +144,21 @@ module Nzbn
144
144
  raise ConnectionError, "Connection failed: #{e.message}"
145
145
  end
146
146
 
147
+ def log_request(method, url, request_id, data)
148
+ return unless configuration.logger
149
+
150
+ configuration.logger.info("[NZBN] Request ID: #{request_id}")
151
+ configuration.logger.info("[NZBN] #{method.to_s.upcase} #{url}")
152
+ configuration.logger.debug("[NZBN] Request data: #{data.inspect}") unless data.empty?
153
+ end
154
+
155
+ def log_response(response, request_id)
156
+ return unless configuration.logger
157
+
158
+ configuration.logger.info("[NZBN] Response ID: #{request_id} - Status: #{response.status}")
159
+ configuration.logger.debug("[NZBN] Response body: #{response.body[0..500]}...")
160
+ end
161
+
147
162
  def default_headers(request_id)
148
163
  {
149
164
  'Ocp-Apim-Subscription-Key' => configuration.api_key,
data/lib/nzbn/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nzbn
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nzbn-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nhan Nguyen