nzbn-ruby 0.1.4 → 0.1.5
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 +10 -0
- data/README.md +33 -4
- data/lib/nzbn/configuration.rb +45 -5
- data/lib/nzbn/version.rb +1 -1
- data/lib/nzbn.rb +3 -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: e7b5ed421a242eb20a20ab1915ca8b494e841dab14d1a570ba0b2091c96041b5
|
|
4
|
+
data.tar.gz: 02f681798322954cfe3f1d83f2e78dc745af871b7ec4c00aaa25fa97b12ef5ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b55a33c0e887d0c5a70162ebb32c9ed18f530f9c144c32a03217fb297d97c3c260b0040d701811129bd84c2490f3c6875f16757347cc4795aa459ad8f600be1e
|
|
7
|
+
data.tar.gz: 89d7aad88299b453d38873e25dacf66bcdd6bac8d1e55a40ae2e7455e29edc50ce1d8246bee8d28190a1ff2a49b29d62f7375ea4ff544f551a09a2ff7165571b
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +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.5] - 2026-03-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Support for production and sandbox modes via `config.mode = :production` or `config.mode = :sandbox`
|
|
12
|
+
- Default production URL: `https://api.business.govt.nz/gateway/nzbn/v5`
|
|
13
|
+
- Default sandbox URL: `https://api.business.govt.nz/sandbox/nzbn/v5`
|
|
14
|
+
- `PRODUCTION_BASE_URL` and `SANDBOX_BASE_URL` constants
|
|
15
|
+
- `sandbox?` and `production?` convenience methods on Configuration
|
|
16
|
+
- Validation for invalid mode values with `ArgumentError`
|
|
17
|
+
|
|
8
18
|
## [0.1.4] - 2026-02-09
|
|
9
19
|
|
|
10
20
|
### Added
|
data/README.md
CHANGED
|
@@ -33,13 +33,42 @@ 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
|
-
|
|
36
|
+
# Production mode (default)
|
|
37
|
+
Nzbn.configure do |config|
|
|
38
|
+
config.api_key = 'your-api-key'
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Sandbox mode
|
|
42
|
+
Nzbn.configure do |config|
|
|
43
|
+
config.api_key = 'your-api-key'
|
|
44
|
+
config.mode = :sandbox
|
|
45
|
+
end
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Configuration Options
|
|
49
|
+
|
|
50
|
+
| Option | Default | Description |
|
|
51
|
+
|--------|---------|-------------|
|
|
52
|
+
| `api_key` | `nil` | **(Required)** Your NZBN API subscription key |
|
|
53
|
+
| `mode` | `:production` | API mode — `:production` or `:sandbox` |
|
|
54
|
+
| `base_url` | Production URL | Auto-set by mode; can be overridden manually |
|
|
55
|
+
| `timeout` | `30` | Request timeout in seconds |
|
|
56
|
+
| `open_timeout` | `10` | Connection open timeout in seconds |
|
|
57
|
+
| `logger` | `nil` | Logger instance for request/response logging |
|
|
58
|
+
|
|
59
|
+
### Default URLs
|
|
37
60
|
|
|
61
|
+
| Mode | URL |
|
|
62
|
+
|------|-----|
|
|
63
|
+
| `:production` | `https://api.business.govt.nz/gateway/nzbn/v5` |
|
|
64
|
+
| `:sandbox` | `https://api.business.govt.nz/sandbox/nzbn/v5` |
|
|
65
|
+
|
|
66
|
+
You can also set a custom `base_url` directly, which overrides the mode:
|
|
67
|
+
|
|
68
|
+
```ruby
|
|
38
69
|
Nzbn.configure do |config|
|
|
39
70
|
config.api_key = 'your-api-key'
|
|
40
|
-
config.base_url = 'https://
|
|
41
|
-
config.timeout = 30 # optional, default 30 seconds
|
|
42
|
-
config.logger = Logger.new(STDOUT) # optional, enables request/response logging
|
|
71
|
+
config.base_url = 'https://custom-url.example.com/nzbn/v5'
|
|
43
72
|
end
|
|
44
73
|
```
|
|
45
74
|
|
data/lib/nzbn/configuration.rb
CHANGED
|
@@ -3,24 +3,64 @@
|
|
|
3
3
|
module Nzbn
|
|
4
4
|
# Configuration class for NZBN client settings
|
|
5
5
|
#
|
|
6
|
-
# @example
|
|
6
|
+
# @example Production mode (default)
|
|
7
7
|
# Nzbn.configure do |config|
|
|
8
8
|
# config.api_key = 'your-api-key'
|
|
9
|
-
#
|
|
10
|
-
#
|
|
9
|
+
# end
|
|
10
|
+
#
|
|
11
|
+
# @example Sandbox mode
|
|
12
|
+
# Nzbn.configure do |config|
|
|
13
|
+
# config.api_key = 'your-api-key'
|
|
14
|
+
# config.mode = :sandbox
|
|
15
|
+
# end
|
|
16
|
+
#
|
|
17
|
+
# @example Custom base URL (overrides mode)
|
|
18
|
+
# Nzbn.configure do |config|
|
|
19
|
+
# config.api_key = 'your-api-key'
|
|
20
|
+
# config.base_url = 'https://custom-url.example.com/nzbn/v5'
|
|
11
21
|
# end
|
|
12
22
|
#
|
|
13
23
|
class Configuration
|
|
14
|
-
|
|
24
|
+
MODES = %i[production sandbox].freeze
|
|
25
|
+
|
|
26
|
+
attr_accessor :api_key, :timeout, :open_timeout, :logger
|
|
27
|
+
attr_reader :mode, :base_url
|
|
15
28
|
|
|
16
29
|
def initialize
|
|
17
30
|
@api_key = nil
|
|
18
|
-
@
|
|
31
|
+
@mode = :production
|
|
32
|
+
@base_url = Nzbn::PRODUCTION_BASE_URL
|
|
19
33
|
@timeout = 30
|
|
20
34
|
@open_timeout = 10
|
|
21
35
|
@logger = nil
|
|
22
36
|
end
|
|
23
37
|
|
|
38
|
+
# Set the mode (:production or :sandbox).
|
|
39
|
+
# This automatically updates base_url to the corresponding default URL.
|
|
40
|
+
def mode=(value)
|
|
41
|
+
value = value.to_sym
|
|
42
|
+
|
|
43
|
+
unless MODES.include?(value)
|
|
44
|
+
raise ArgumentError, "Invalid mode: #{value}. Must be one of: #{MODES.join(', ')}"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@mode = value
|
|
48
|
+
@base_url = value == :sandbox ? Nzbn::SANDBOX_BASE_URL : Nzbn::PRODUCTION_BASE_URL
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Set a custom base URL. This overrides the mode-derived URL.
|
|
52
|
+
def base_url=(value)
|
|
53
|
+
@base_url = value
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def sandbox?
|
|
57
|
+
@mode == :sandbox
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def production?
|
|
61
|
+
@mode == :production
|
|
62
|
+
end
|
|
63
|
+
|
|
24
64
|
def valid?
|
|
25
65
|
!api_key.nil? && !api_key.empty?
|
|
26
66
|
end
|
data/lib/nzbn/version.rb
CHANGED
data/lib/nzbn.rb
CHANGED
|
@@ -50,7 +50,9 @@ require_relative 'nzbn/api/history'
|
|
|
50
50
|
# entities = client.entities.search(search_term: 'Company Name')
|
|
51
51
|
#
|
|
52
52
|
module Nzbn
|
|
53
|
-
|
|
53
|
+
PRODUCTION_BASE_URL = 'https://api.business.govt.nz/gateway/nzbn/v5'
|
|
54
|
+
SANDBOX_BASE_URL = 'https://api.business.govt.nz/sandbox/nzbn/v5'
|
|
55
|
+
DEFAULT_BASE_URL = PRODUCTION_BASE_URL # backward compatibility
|
|
54
56
|
|
|
55
57
|
class << self
|
|
56
58
|
attr_accessor :configuration
|