abn_lookup 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/abn_lookup/abn.rb +31 -0
- data/lib/abn_lookup/search_by_abn.rb +1 -1
- data/lib/abn_lookup/search_by_acn.rb +1 -1
- data/lib/abn_lookup/version.rb +1 -1
- data/lib/abn_lookup.rb +1 -1
- metadata +2 -2
- data/lib/abn_lookup/abn_formatter.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 276141b6aaae5383c076b6b2ab7a17536a56e38c296fab584e6ed27873c94ef7
|
4
|
+
data.tar.gz: ab311bca6af0587a06811776a387898d4d40d082d5c89891784b071fe343f79c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 696b8cf8190be707c30acd77ddf990d1ca17197f32514304488b457ef7511651b6487f265ccf30af2d2f04858309f774c720776f381d4680b330b57a90ef2e3d
|
7
|
+
data.tar.gz: 74f09efa50d894a986dd906dd601151f0f51d73103e4824f08a245a679b820c92de84cdefbcf3916a262c6a1e5d54c2c122198356dd4818cf61d12d0d5406304
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module AbnLookup
|
2
|
+
class Abn
|
3
|
+
attr_accessor :abn, :abn_status, :abn_status_effective_from, :acn, :address_date,
|
4
|
+
:address_postcode, :address_state, :business_name, :entity_name,
|
5
|
+
:entity_type_code, :entity_type_name, :gst, :message
|
6
|
+
|
7
|
+
def active?
|
8
|
+
abn_status == "Active"
|
9
|
+
end
|
10
|
+
|
11
|
+
def inspect
|
12
|
+
"#<#{self.class.name}:0x#{object_id} @abn=\"#{abn}\" @acn=\"#{acn}\" @active=\"#{active?}\" @gst=\"#{gst}\" @entity_name=\"#{entity_name}}\""
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse(data)
|
16
|
+
abn = Abn.new
|
17
|
+
|
18
|
+
# Transforming PascalCase to snake_case
|
19
|
+
snake_case = data.each_with_object({}) do |(key, value), new_hash|
|
20
|
+
new_key = key.to_s.gsub(/([A-Z])/, '_\1').downcase
|
21
|
+
new_hash[new_key.sub(/^_/, '').to_sym] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
snake_case.each do |key, value|
|
25
|
+
abn.send("#{key}=", value) if abn.respond_to?("#{key}=")
|
26
|
+
end
|
27
|
+
|
28
|
+
abn
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/abn_lookup/version.rb
CHANGED
data/lib/abn_lookup.rb
CHANGED
@@ -6,7 +6,7 @@ require "abn_lookup/client"
|
|
6
6
|
require "abn_lookup/search_by_abn"
|
7
7
|
require "abn_lookup/search_by_acn"
|
8
8
|
require "abn_lookup/search_by_name"
|
9
|
-
require "abn_lookup/
|
9
|
+
require "abn_lookup/abn"
|
10
10
|
require "abn_lookup/abn_not_found_error"
|
11
11
|
require "abn_lookup/invalid_guid_error"
|
12
12
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abn_lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lairton Mendes
|
@@ -52,7 +52,7 @@ files:
|
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- lib/abn_lookup.rb
|
55
|
-
- lib/abn_lookup/
|
55
|
+
- lib/abn_lookup/abn.rb
|
56
56
|
- lib/abn_lookup/abn_not_found_error.rb
|
57
57
|
- lib/abn_lookup/add_parameter.rb
|
58
58
|
- lib/abn_lookup/callback_parser.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module AbnLookup
|
4
|
-
class AbnFormatter
|
5
|
-
def self.formatter(body)
|
6
|
-
hash = {
|
7
|
-
abn: body["Abn"],
|
8
|
-
abn_status: body["AbnStatus"],
|
9
|
-
abn_status_effective_from: body["AbnStatusEffectiveFrom"],
|
10
|
-
acn: body["Acn"],
|
11
|
-
address_date: body["AddressDate"],
|
12
|
-
address_postcode: body["AddressPostcode"],
|
13
|
-
address_state: body["AddressState"],
|
14
|
-
business_name: body["BusinessName"],
|
15
|
-
entity_name: body["EntityName"],
|
16
|
-
entity_type_code: body["EntityTypeCode"],
|
17
|
-
entity_type_name: body["EntityTypeName"],
|
18
|
-
gst: body["Gst"],
|
19
|
-
message: body["Message"]
|
20
|
-
}
|
21
|
-
|
22
|
-
# build Struct
|
23
|
-
abn = Struct.new(*hash.keys)
|
24
|
-
|
25
|
-
# converting hash to struct
|
26
|
-
abn.new(*hash.values)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|