Skip to content

Commit

Permalink
Merge pull request #2 from internetee/1708-registrant-companies-endpoint
Browse files Browse the repository at this point in the history
Add company name to company response body
  • Loading branch information
vohmar authored Oct 14, 2020
2 parents 86d6919 + 13c5cfd commit 4181b2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/company_register/client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CompanyRegister
Company = Struct.new(:registration_number)
Company = Struct.new(:registration_number, :company_name)

class Client
# API returns request params back with the response. They are stripped out to avoid caching
Expand Down Expand Up @@ -47,7 +47,9 @@ def parse_representation_rights_response_body(body)

items = body[:esindus_v1_response][:keha][:ettevotjad][:item]
items = [items] unless items.kind_of?(Array)
items.map { |item| Company.new(item[:ariregistri_kood]) }
items.map do |item|
Company.new(item[:ariregistri_kood], item[:arinimi])
end
end
end
end
1 change: 1 addition & 0 deletions test/client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def test_parses_response_with_payload
assert_kind_of Array, companies
assert_kind_of CompanyRegister::Company, companies.first
assert_equal '12345', companies.first.registration_number
assert_equal 'Acme Ltd', companies.first.company_name
end

def test_parses_response_without_payload
Expand Down

0 comments on commit 4181b2f

Please sign in to comment.