nzbn-ruby 0.1.0

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.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +26 -0
  3. data/Gemfile +5 -0
  4. data/LICENSE +21 -0
  5. data/README.md +239 -0
  6. data/Rakefile +8 -0
  7. data/lib/nzbn/api/addresses.rb +61 -0
  8. data/lib/nzbn/api/company_details.rb +32 -0
  9. data/lib/nzbn/api/email_addresses.rb +35 -0
  10. data/lib/nzbn/api/entities.rb +120 -0
  11. data/lib/nzbn/api/history.rb +81 -0
  12. data/lib/nzbn/api/industry_classifications.rb +35 -0
  13. data/lib/nzbn/api/organisation_parts.rb +92 -0
  14. data/lib/nzbn/api/phone_numbers.rb +35 -0
  15. data/lib/nzbn/api/privacy_settings.rb +33 -0
  16. data/lib/nzbn/api/roles.rb +53 -0
  17. data/lib/nzbn/api/trading_names.rb +35 -0
  18. data/lib/nzbn/api/watchlists.rb +120 -0
  19. data/lib/nzbn/api/websites.rb +35 -0
  20. data/lib/nzbn/client.rb +180 -0
  21. data/lib/nzbn/configuration.rb +28 -0
  22. data/lib/nzbn/error.rb +62 -0
  23. data/lib/nzbn/models/address.rb +12 -0
  24. data/lib/nzbn/models/base.rb +59 -0
  25. data/lib/nzbn/models/company.rb +20 -0
  26. data/lib/nzbn/models/email_address.rb +11 -0
  27. data/lib/nzbn/models/entity.rb +14 -0
  28. data/lib/nzbn/models/error_response.rb +19 -0
  29. data/lib/nzbn/models/full_entity.rb +50 -0
  30. data/lib/nzbn/models/industry_classification.rb +10 -0
  31. data/lib/nzbn/models/organisation_part.rb +14 -0
  32. data/lib/nzbn/models/phone_number.rb +16 -0
  33. data/lib/nzbn/models/privacy_settings.rb +26 -0
  34. data/lib/nzbn/models/role.rb +27 -0
  35. data/lib/nzbn/models/search_entity.rb +32 -0
  36. data/lib/nzbn/models/search_response.rb +50 -0
  37. data/lib/nzbn/models/trading_name.rb +10 -0
  38. data/lib/nzbn/models/watchlist.rb +14 -0
  39. data/lib/nzbn/models/website.rb +10 -0
  40. data/lib/nzbn/version.rb +5 -0
  41. data/lib/nzbn.rb +67 -0
  42. data/nzbn-ruby.gemspec +35 -0
  43. metadata +175 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e7eac967040c3029d0acea2032ebca30831db0521880a7469eac5c6f564ce5f9
4
+ data.tar.gz: d4c4d5c37dd025ea98c0cdba5c96c2e6c5d53d913b1fbd1e498b4ebd87ac0f0e
5
+ SHA512:
6
+ metadata.gz: 997a10045c90eb5b971feade345d43602ca0c16fc73ae9c2b768ab62642f329261ca5e4eb8cc8d1ac71daf44c64df6416c2a397f1e1eb0f65cd2218bcf8e4888
7
+ data.tar.gz: 4d67960d1de75c27fe8fd9ad7040e304a7426a3ce14211b013dc1abb0feaf1f8452d9dd093482585f930b4c6496b86ba38a76a90bcce8412ce47018f937dd8e9
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2024-02-04
9
+
10
+ ### Added
11
+ - Initial release
12
+ - Entity search and retrieval
13
+ - Entity creation (sole trader, partnership, trust)
14
+ - Address management
15
+ - Role management (directors, partners, trustees)
16
+ - Trading names management
17
+ - Phone numbers management
18
+ - Email addresses management
19
+ - Websites management
20
+ - Industry classifications management
21
+ - Privacy settings management
22
+ - Company and non-company details
23
+ - Watchlist management for change notifications
24
+ - Organisation parts (OPN/GLN) management
25
+ - Historical data access
26
+ - Full error handling with custom exceptions
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nhan Nguyen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,239 @@
1
+ # NZBN Ruby
2
+
3
+ A Ruby gem for interacting with the New Zealand Business Number (NZBN) API v5.
4
+
5
+ [![Gem Version](https://badge.fury.io/rb/nzbn-ruby.svg)](https://badge.fury.io/rb/nzbn-ruby)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nzbn-ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```bash
18
+ bundle install
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```bash
24
+ gem install nzbn-ruby
25
+ ```
26
+
27
+ ## Requirements
28
+
29
+ - ...
30
+
31
+ ## Configuration
32
+
33
+ Configure the gem with your NZBN API key (obtain from [api.business.govt.nz](https://api.business.govt.nz)):
34
+
35
+ ```ruby
36
+ Nzbn.configure do |config|
37
+ config.api_key = 'your-api-key'
38
+ config.base_url = 'https://api.business.govt.nz/gateway/nzbn/v5' # default
39
+ config.timeout = 30 # optional, default 30 seconds
40
+ end
41
+ ```
42
+
43
+ ## Usage
44
+
45
+ ### Initialize the Client
46
+
47
+ ```ruby
48
+ client = Nzbn::Client.new
49
+
50
+ # Or with inline configuration
51
+ client = Nzbn::Client.new(api_key: 'your-api-key')
52
+ ```
53
+
54
+ ### Search Entities
55
+
56
+ ```ruby
57
+ # Search by name
58
+ results = client.entities.search(search_term: 'Company Name')
59
+
60
+ results.each do |entity|
61
+ puts "#{entity.entity_name} (#{entity.nzbn})"
62
+ end
63
+
64
+ # With filters
65
+ results = client.entities.search(
66
+ search_term: 'Wellington',
67
+ entity_status: 'Registered',
68
+ entity_type: 'NZCompany',
69
+ page: 0,
70
+ page_size: 20
71
+ )
72
+ ```
73
+
74
+ ### Get Entity Details
75
+
76
+ ```ruby
77
+ entity = client.entities.get(nzbn: '9429041925676')
78
+
79
+ puts entity.entity_name
80
+ puts entity.entity_status_description
81
+ puts entity.registration_date
82
+ ```
83
+
84
+ ### Entity Change History
85
+
86
+ ```ruby
87
+ # Search for changes
88
+ changes = client.entities.changes(
89
+ change_event_type: 'ALL',
90
+ date_time_from: '2024-01-01T00:00:00',
91
+ date_time_to: '2024-12-31T23:59:59'
92
+ )
93
+ ```
94
+
95
+ ### Manage Addresses
96
+
97
+ ```ruby
98
+ # List addresses
99
+ addresses = client.addresses.list(nzbn: '9429041925676')
100
+
101
+ # Add an address
102
+ new_address = client.addresses.create(
103
+ nzbn: '9429041925676',
104
+ address: {
105
+ addressType: 'POSTAL',
106
+ address1: '123 Main Street',
107
+ address2: 'Wellington',
108
+ postCode: '6011',
109
+ countryCode: 'NZ'
110
+ }
111
+ )
112
+ ```
113
+
114
+ ### Manage Roles
115
+
116
+ ```ruby
117
+ # List roles (directors, partners, etc.)
118
+ roles = client.roles.list(nzbn: '9429041925676')
119
+
120
+ roles.each do |role|
121
+ puts "#{role.role_type}: #{role.role_person&.first_name} #{role.role_person&.last_name}"
122
+ end
123
+ ```
124
+
125
+ ### Trading Names
126
+
127
+ ```ruby
128
+ trading_names = client.trading_names.list(nzbn: '9429041925676')
129
+ ```
130
+
131
+ ### Watchlists
132
+
133
+ ```ruby
134
+ # Create a watchlist for change notifications
135
+ watchlist = client.watchlists.create(watchlist: {
136
+ name: 'My Watchlist',
137
+ channel: 'EMAIL',
138
+ frequency: 'DAILY',
139
+ changeEventTypes: 'ALL',
140
+ adminEmailAddress: 'admin@example.com'
141
+ })
142
+
143
+ # Add NZBNs to watch
144
+ client.watchlists.add_nzbns(
145
+ watchlist_id: watchlist.watchlist_id,
146
+ nzbns: ['9429041925676', '9429000001234']
147
+ )
148
+
149
+ # List watchlists
150
+ my_watchlists = client.watchlists.list
151
+ ```
152
+
153
+ ### Privacy Settings
154
+
155
+ ```ruby
156
+ # Get privacy settings
157
+ settings = client.privacy_settings.get(nzbn: '9429041925676')
158
+
159
+ # Update privacy settings
160
+ client.privacy_settings.update(
161
+ nzbn: '9429041925676',
162
+ settings: { phonePrivateInformation: true }
163
+ )
164
+ ```
165
+
166
+ ### Company Details
167
+
168
+ ```ruby
169
+ # Get company-specific details
170
+ company = client.company_details.get(nzbn: '9429041925676')
171
+
172
+ puts company.annual_return_filing_month
173
+ puts company.has_constitution_filed
174
+ ```
175
+
176
+ ### History
177
+
178
+ ```ruby
179
+ # Get historical data
180
+ historical_names = client.history.entity_names(nzbn: '9429041925676')
181
+ historical_addresses = client.history.addresses(nzbn: '9429041925676')
182
+ ```
183
+
184
+ ## Error Handling
185
+
186
+ ```ruby
187
+ begin
188
+ entity = client.entities.get(nzbn: 'invalid')
189
+ rescue Nzbn::NotFoundError => e
190
+ puts "Entity not found"
191
+ rescue Nzbn::AuthenticationError => e
192
+ puts "Invalid API key"
193
+ rescue Nzbn::ValidationError => e
194
+ puts "Invalid request: #{e.message}"
195
+ e.errors.each { |err| puts " #{err['field']}: #{err['message']}" }
196
+ rescue Nzbn::ApiError => e
197
+ puts "API error: #{e.message} (#{e.error_code})"
198
+ end
199
+ ```
200
+
201
+ ## API Resources
202
+
203
+ | Resource | Description |
204
+ |----------|-------------|
205
+ | `entities` | Search, get, create entities |
206
+ | `addresses` | Manage entity addresses |
207
+ | `roles` | Manage directors, partners, etc. |
208
+ | `trading_names` | Manage trading names |
209
+ | `phone_numbers` | Manage phone numbers |
210
+ | `email_addresses` | Manage email addresses |
211
+ | `websites` | Manage websites |
212
+ | `industry_classifications` | Manage ANZSIC codes |
213
+ | `privacy_settings` | Manage privacy settings |
214
+ | `company_details` | Get company/non-company details |
215
+ | `watchlists` | Manage change notification watchlists |
216
+ | `organisation_parts` | Manage OPN/GLN |
217
+ | `history` | Access historical data |
218
+
219
+ ## Development
220
+
221
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
222
+
223
+ ```bash
224
+ bundle install
225
+ bundle exec rspec
226
+ ```
227
+
228
+ ## Contributing
229
+
230
+ Bug reports and pull requests are welcome on GitHub.
231
+
232
+ ## License
233
+
234
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
235
+
236
+ ## Links
237
+
238
+ - [NZBN API Documentation](https://api.business.govt.nz/api/nzbn)
239
+ - [API Explorer](https://api.business.govt.nz)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # Addresses API - Manage entity addresses
6
+ class Addresses
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # List addresses for an entity
12
+ #
13
+ # @param nzbn [String] 13-digit NZBN
14
+ # @return [Array<Models::Address>] List of addresses
15
+ #
16
+ def list(nzbn:)
17
+ response = @client.get("/entities/#{nzbn}/addresses")
18
+ parse_addresses(response)
19
+ end
20
+
21
+ # Add an address to an entity
22
+ #
23
+ # @param nzbn [String] 13-digit NZBN
24
+ # @param address [Hash] Address attributes
25
+ # @return [Models::Address] Created address
26
+ #
27
+ # @example
28
+ # client.addresses.create(nzbn: '9429041925676', address: {
29
+ # addressType: 'POSTAL',
30
+ # address1: '123 Main St',
31
+ # address2: 'Wellington',
32
+ # postCode: '6011',
33
+ # countryCode: 'NZ'
34
+ # })
35
+ #
36
+ def create(nzbn:, address:)
37
+ response = @client.post("/entities/#{nzbn}/addresses", address)
38
+ Models::Address.new(response)
39
+ end
40
+
41
+ # Delete an address from an entity
42
+ #
43
+ # @param nzbn [String] 13-digit NZBN
44
+ # @param address_id [String] Unique identifier of the address
45
+ # @return [Boolean] True if successful
46
+ #
47
+ def delete(nzbn:, address_id:)
48
+ @client.delete("/entities/#{nzbn}/addresses", { uniqueIdentifier: address_id })
49
+ true
50
+ end
51
+
52
+ private
53
+
54
+ def parse_addresses(response)
55
+ return [] unless response.is_a?(Hash) && response['addressList']
56
+
57
+ response['addressList'].map { |addr| Models::Address.new(addr) }
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # Company Details API
6
+ class CompanyDetails
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # Get company details
12
+ #
13
+ # @param nzbn [String] 13-digit NZBN
14
+ # @return [Models::Company] Company details
15
+ #
16
+ def get(nzbn:)
17
+ response = @client.get("/entities/#{nzbn}/company-details")
18
+ Models::Company.new(response)
19
+ end
20
+
21
+ # Get non-company details (limited partnerships, charities, etc.)
22
+ #
23
+ # @param nzbn [String] 13-digit NZBN
24
+ # @return [Models::NonCompany] Non-company details
25
+ #
26
+ def get_non_company(nzbn:)
27
+ response = @client.get("/entities/#{nzbn}/non-company-details")
28
+ Models::NonCompany.new(response)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # Email Addresses API
6
+ class EmailAddresses
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # List email addresses for an entity
12
+ #
13
+ # @param nzbn [String] 13-digit NZBN
14
+ # @return [Array<Models::EmailAddress>] List of email addresses
15
+ #
16
+ def list(nzbn:)
17
+ response = @client.get("/entities/#{nzbn}/email-addresses")
18
+ return [] unless response.is_a?(Array)
19
+
20
+ response.map { |email| Models::EmailAddress.new(email) }
21
+ end
22
+
23
+ # Add an email address
24
+ #
25
+ # @param nzbn [String] 13-digit NZBN
26
+ # @param email [Hash] Email address attributes
27
+ # @return [Models::EmailAddress] Created email address
28
+ #
29
+ def create(nzbn:, email:)
30
+ response = @client.post("/entities/#{nzbn}/email-addresses", email)
31
+ Models::EmailAddress.new(response)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,120 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # Entities API - Search and manage NZBN entities
6
+ class Entities
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # Search entities by name
12
+ #
13
+ # @param search_term [String] Text to search for
14
+ # @param entity_status [String] Filter by status (Registered, InLiquidation, etc.)
15
+ # @param entity_type [String] Filter by type (NZCompany, SoleTrader, etc.)
16
+ # @param industry_code [String] Filter by industry code
17
+ # @param page [Integer] Page number (zero-indexed)
18
+ # @param page_size [Integer] Results per page
19
+ # @return [Models::SearchResponse] Paginated search results
20
+ #
21
+ # @example
22
+ # client.entities.search(search_term: 'Company Name', entity_status: 'Registered')
23
+ #
24
+ def search(search_term:, entity_status: nil, entity_type: nil, industry_code: nil, page: nil, page_size: nil)
25
+ params = { 'search-term' => search_term }
26
+ params['entity-status'] = entity_status if entity_status
27
+ params['entity-type'] = entity_type if entity_type
28
+ params['industry-code'] = industry_code if industry_code
29
+ params['page'] = page if page
30
+ params['page-size'] = page_size if page_size
31
+
32
+ response = @client.get('/entities', params)
33
+ Models::SearchResponse.new(response, item_class: Models::SearchEntity)
34
+ end
35
+
36
+ # Get entity by NZBN
37
+ #
38
+ # @param nzbn [String] 13-digit NZBN
39
+ # @param if_none_match [String] ETag for conditional request
40
+ # @return [Models::FullEntity] Full entity details
41
+ #
42
+ # @example
43
+ # entity = client.entities.get(nzbn: '9429041925676')
44
+ #
45
+ def get(nzbn:, if_none_match: nil)
46
+ headers = {}
47
+ headers['If-None-Match'] = if_none_match if if_none_match
48
+
49
+ response = @client.get("/entities/#{nzbn}", {}, headers)
50
+ Models::FullEntity.new(response)
51
+ end
52
+
53
+ # Get discoverable entity information
54
+ #
55
+ # @param nzbn [String] 13-digit NZBN
56
+ # @return [Models::Entity] Discoverable entity info
57
+ #
58
+ def get_discoverable(nzbn:)
59
+ response = @client.get("/entities/#{nzbn}/discoverable")
60
+ Models::Entity.new(response)
61
+ end
62
+
63
+ # Search entity changes
64
+ #
65
+ # @param change_event_type [String] Comma-separated change events (NEW, ENTITY, ROLES_DIRECTOR, etc.)
66
+ # @param entity_type [String] Filter by entity type
67
+ # @param date_time_from [String] Start date (YYYY-MM-DDThh:mm:ss)
68
+ # @param date_time_to [String] End date (YYYY-MM-DDThh:mm:ss)
69
+ # @param page [Integer] Page number
70
+ # @param page_size [Integer] Results per page
71
+ # @param sort_by [String] Sort field (NZBN, ENTITY_NAME, etc.)
72
+ # @param sort_order [String] ASC or DESC
73
+ # @return [Models::SearchResponse] Change results
74
+ #
75
+ def changes(change_event_type:, entity_type: nil, date_time_from: nil, date_time_to: nil,
76
+ page: nil, page_size: nil, sort_by: nil, sort_order: nil)
77
+ params = { 'change-event-type' => change_event_type }
78
+ params['entity-type'] = entity_type if entity_type
79
+ params['date-time-from'] = date_time_from if date_time_from
80
+ params['date-time-to'] = date_time_to if date_time_to
81
+ params['page'] = page if page
82
+ params['page-size'] = page_size if page_size
83
+ params['sort-by'] = sort_by if sort_by
84
+ params['sort-order'] = sort_order if sort_order
85
+
86
+ response = @client.get('/entities/changes', params)
87
+ Models::SearchResponse.new(response, item_class: Models::SearchEntity)
88
+ end
89
+
90
+ # Create a new entity (sole trader, partnership, or trust)
91
+ #
92
+ # @param entity [Hash] Entity attributes
93
+ # @return [Hash] Created entity response
94
+ #
95
+ def create(entity:)
96
+ @client.post('/entities', entity)
97
+ end
98
+
99
+ # Update entity status
100
+ #
101
+ # @param nzbn [String] 13-digit NZBN
102
+ # @param status [Hash] Status update payload
103
+ # @return [Hash] Updated status
104
+ #
105
+ def update_status(nzbn:, status:)
106
+ @client.post("/entities/#{nzbn}/entity-statuses", status)
107
+ end
108
+
109
+ # Update Australian Business Number
110
+ #
111
+ # @param nzbn [String] 13-digit NZBN
112
+ # @param abn_data [Hash] ABN update payload
113
+ # @return [Hash] Updated ABN
114
+ #
115
+ def update_abn(nzbn:, abn_data:)
116
+ @client.put("/entities/#{nzbn}/australian-business-number", abn_data)
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # History API - Access historical entity data
6
+ class History
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # Get entity change history
12
+ #
13
+ # @param nzbn [String] 13-digit NZBN
14
+ # @return [Hash] Change history
15
+ #
16
+ def get(nzbn:)
17
+ @client.get("/entities/#{nzbn}/history")
18
+ end
19
+
20
+ # Get address history
21
+ #
22
+ # @param nzbn [String] 13-digit NZBN
23
+ # @return [Array<Models::Address>] Historical addresses
24
+ #
25
+ def addresses(nzbn:)
26
+ response = @client.get("/entities/#{nzbn}/history/addresses")
27
+ return [] unless response.is_a?(Array)
28
+
29
+ response.map { |addr| Models::Address.new(addr) }
30
+ end
31
+
32
+ # Get entity name history
33
+ #
34
+ # @param nzbn [String] 13-digit NZBN
35
+ # @return [Array<Hash>] Historical entity names
36
+ #
37
+ def entity_names(nzbn:)
38
+ @client.get("/entities/#{nzbn}/history/entity-names")
39
+ end
40
+
41
+ # Get trading name history
42
+ #
43
+ # @param nzbn [String] 13-digit NZBN
44
+ # @return [Array<Models::TradingName>] Historical trading names
45
+ #
46
+ def trading_names(nzbn:)
47
+ response = @client.get("/entities/#{nzbn}/history/trading-names")
48
+ return [] unless response.is_a?(Array)
49
+
50
+ response.map { |tn| Models::TradingName.new(tn) }
51
+ end
52
+
53
+ # Get trading area history
54
+ #
55
+ # @param nzbn [String] 13-digit NZBN
56
+ # @return [Array<Hash>] Historical trading areas
57
+ #
58
+ def trading_areas(nzbn:)
59
+ @client.get("/entities/#{nzbn}/history/trading-areas")
60
+ end
61
+
62
+ # Get entity status history
63
+ #
64
+ # @param nzbn [String] 13-digit NZBN
65
+ # @return [Array<Hash>] Historical entity statuses
66
+ #
67
+ def entity_statuses(nzbn:)
68
+ @client.get("/entities/#{nzbn}/history/entity-statuses")
69
+ end
70
+
71
+ # Get hibernation status history
72
+ #
73
+ # @param nzbn [String] 13-digit NZBN
74
+ # @return [Array<Hash>] Historical hibernation statuses
75
+ #
76
+ def hibernation_statuses(nzbn:)
77
+ @client.get("/entities/#{nzbn}/history/hibernation-statuses")
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nzbn
4
+ module Api
5
+ # Industry Classifications API
6
+ class IndustryClassifications
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # List industry classifications for an entity
12
+ #
13
+ # @param nzbn [String] 13-digit NZBN
14
+ # @return [Array<Models::IndustryClassification>] List of classifications
15
+ #
16
+ def list(nzbn:)
17
+ response = @client.get("/entities/#{nzbn}/industry-classifications")
18
+ return [] unless response.is_a?(Array)
19
+
20
+ response.map { |ic| Models::IndustryClassification.new(ic) }
21
+ end
22
+
23
+ # Add an industry classification
24
+ #
25
+ # @param nzbn [String] 13-digit NZBN
26
+ # @param classification [Hash] Classification attributes
27
+ # @return [Models::IndustryClassification] Created classification
28
+ #
29
+ def create(nzbn:, classification:)
30
+ response = @client.post("/entities/#{nzbn}/industry-classifications", classification)
31
+ Models::IndustryClassification.new(response)
32
+ end
33
+ end
34
+ end
35
+ end