nzbn 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 +5 -5
- data/README.md +3 -6
- data/lib/nzbn/version.rb +1 -1
- data/lib/nzbn.rb +7 -20
- data/nzbn-0.1.4.gem +0 -0
- data/nzbn.gemspec +1 -1
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 62a79c4debf304fa199ace61a153f8f3f79a3dc5
|
4
|
+
data.tar.gz: 2d3a0400f1d13a25a97aa40cc3ce2e90bab09eac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc4b12ce75800c864082dcb3d0de49fda2b6315fe2990375937472174868fd2b7aa3bf31fc2e9ca122df6561bfb8513df37552a6724e74f1f297d28a6975d4b6
|
7
|
+
data.tar.gz: 101614648820de0f8f29deb3358dc66616ab0272287ed48c1c367665e02aabbc4a0ccec3e1f882035e34c6262edaba50da9d87468bb0222c9abab15166ae1d59
|
data/README.md
CHANGED
@@ -25,16 +25,13 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
$ gem install nzbn
|
27
27
|
|
28
|
-
You will also need to set the following ENV variables, in order to access the API. These can be
|
29
|
-
|
30
|
-
$ NZBN_ID=
|
31
|
-
|
32
|
-
$ NZBN_SECRET=
|
28
|
+
You will also need to set the following ENV variables, in order to access the API. These can be found on the business.govt.nz website under your login.
|
33
29
|
|
30
|
+
$ NZBN_KEY=
|
34
31
|
|
35
32
|
## Usage
|
36
33
|
|
37
|
-
|
34
|
+
Three functions have been exposed, as per below.
|
38
35
|
|
39
36
|
### Company details by NZBN
|
40
37
|
|
data/lib/nzbn/version.rb
CHANGED
data/lib/nzbn.rb
CHANGED
@@ -6,7 +6,7 @@ module NZBN
|
|
6
6
|
require 'rest-client'
|
7
7
|
require 'base64'
|
8
8
|
|
9
|
-
NZBN_API_VERSION="
|
9
|
+
NZBN_API_VERSION="v5"
|
10
10
|
|
11
11
|
class DataError < StandardError; end
|
12
12
|
class AuthError < StandardError; end
|
@@ -14,8 +14,8 @@ module NZBN
|
|
14
14
|
def self.entities(search_term, entity_status, page_size)
|
15
15
|
entity_status = "registered" if entity_status.blank?
|
16
16
|
page_size = 50 if page_size.blank?
|
17
|
-
response = RestClient.get("https://api.business.govt.nz/
|
18
|
-
|
17
|
+
response = RestClient.get("https://api.business.govt.nz/gateway/nzbn/#{NZBN_API_VERSION}/entities?search-term=#{search_term}&entity-status=#{entity_status}&page-size=#{page_size}",
|
18
|
+
{ "Ocp-Apim-Subscription-Key": ENV["NZBN_KEY"], accept: 'application/json' })
|
19
19
|
begin
|
20
20
|
JSON.parse(response.body).with_indifferent_access
|
21
21
|
rescue JSON::ParserError
|
@@ -24,8 +24,8 @@ module NZBN
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.entity(nzbn)
|
27
|
-
response = RestClient.get("https://api.business.govt.nz/
|
28
|
-
{
|
27
|
+
response = RestClient.get("https://api.business.govt.nz/gateway/nzbn/#{NZBN_API_VERSION}/entities/#{nzbn}",
|
28
|
+
{ "Ocp-Apim-Subscription-Key": ENV["NZBN_KEY"], accept: 'application/json' })
|
29
29
|
begin
|
30
30
|
JSON.parse(response.body).with_indifferent_access
|
31
31
|
rescue JSON::ParserError
|
@@ -34,8 +34,8 @@ module NZBN
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.filings(nzbn)
|
37
|
-
response = RestClient.get("https://api.business.govt.nz/
|
38
|
-
{
|
37
|
+
response = RestClient.get("https://api.business.govt.nz/gateway/nzbn/#{NZBN_API_VERSION}/entities/#{nzbn}/filings",
|
38
|
+
{ "Ocp-Apim-Subscription-Key": ENV["NZBN_KEY"], accept: 'application/json' })
|
39
39
|
begin
|
40
40
|
JSON.parse(response.body).with_indifferent_access
|
41
41
|
rescue JSON::ParserError
|
@@ -43,17 +43,4 @@ module NZBN
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
private
|
47
|
-
|
48
|
-
def self.access_token
|
49
|
-
begin
|
50
|
-
response = RestClient.post("https://api.business.govt.nz/services/token", { grant_type: "client_credentials" },
|
51
|
-
{ grant_type: "client_credentials", authorization: "Basic #{Base64.strict_encode64(ENV["NZBN_ID"] + ":" + ENV["NZBN_SECRET"])}" })
|
52
|
-
|
53
|
-
JSON.parse(response.body)["access_token"]
|
54
|
-
rescue JSON::ParserError, NoMethodError
|
55
|
-
raise NZBN::AuthError, "Authentication failed! Are you missing NZBN_ID or NZBN_SECRET?"
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
46
|
end
|
data/nzbn-0.1.4.gem
ADDED
Binary file
|
data/nzbn.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_development_dependency "bundler", "
|
33
|
+
spec.add_development_dependency "bundler", ">= 2.2.33"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
spec.add_runtime_dependency "rest-client", "~> 2.1.0"
|
36
36
|
|
metadata
CHANGED
@@ -1,30 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nzbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- T Pearse
|
8
8
|
- Theo Morra
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: 2.2.33
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: 2.2.33
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,13 +71,14 @@ files:
|
|
71
71
|
- bin/setup
|
72
72
|
- lib/nzbn.rb
|
73
73
|
- lib/nzbn/version.rb
|
74
|
+
- nzbn-0.1.4.gem
|
74
75
|
- nzbn.gemspec
|
75
76
|
homepage: https://github.com/t-pearse/nzbn
|
76
77
|
licenses:
|
77
78
|
- MIT
|
78
79
|
metadata:
|
79
80
|
allowed_push_host: https://rubygems.org
|
80
|
-
post_install_message:
|
81
|
+
post_install_message:
|
81
82
|
rdoc_options: []
|
82
83
|
require_paths:
|
83
84
|
- lib
|
@@ -92,8 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
93
|
- !ruby/object:Gem::Version
|
93
94
|
version: '0'
|
94
95
|
requirements: []
|
95
|
-
|
96
|
-
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.4.6
|
98
|
+
signing_key:
|
97
99
|
specification_version: 4
|
98
100
|
summary: Simple and fast authenticating ruby API wrapper for the NZBN API
|
99
101
|
test_files: []
|