NAME

NOLookup::Brreg::DataLookup - Lookup Brreg basic organization data from the JSON formatted service offered by the Brreg data API via https://data.brreg.no/enhetsregisteret/oppslag/enheter https://data.brreg.no/enhetsregisteret/api/docs/index.html

(Brreg is a short name for 'Brønnysundregistrene, the Norwegian Central Organization Registry).

DESCRIPTION

Use WWW::Mechanize and JSON to lookup data from the JSON API at brreg. Use NOLookup::Brreg::Entry module to map the resulting json data structure to a NOLookup::Brreg::Entry objects.

The timeout period $BRREG_TIMEOUT is used to trap and return the call if Brreg lookup is hanging for some reason.

METHODS

The module provides the below methods.

_init_lookup

Common init method.

- Set seach URLs. - Returns URL and accept header.

lookup_orgno()

Lookup based on a complete organization number.

Returns an array of one single NOLookup::Brreg::Entry object in the data when a match is found.

lookup_orgname()

Lookup based on a complete or part of an organization name.

Returns 0 entries if none found.

Returns an array of NOLookup::Brreg::Entry objects in the data when matches are found.

A maximum of $max_no_pages pages are fetched, each of $page_sz entries, default $MAX_SIZE.

lookup_reg_dates()

Lookup based on registration dates. A from_date and/or a to_date can be specified.

The lookup will find registrations performed after midnight starting the from date, and until midnight at the end of the to date.

Returns 0 entries if none found.

Returns an array of NOLookup::Brreg::Entry objects in the data when matches are found.

A maximum of $max_no_pages pages are fetched, each of 100 entries.

lookup_update_dates()

Lookup based on update date and update id.

The lookup will find updated organizations performed after midnight starting on the from date. The minimum update id can also be set.

Returns 0 entries if none found.

Returns an array of NOLookup::Brreg::Entry objects in the data when matches are found.

A maximum of $max_no_pages pages are fetched, each of 100 entries.

orgno_ok()

Check if org. number basic syntax is OK, i.e. 9 digits. Note that Brreg may reject the number due to stricter requirements, like checksum etc.

raw_json_decoded()

The raw JSON data structure, as returned by the JSON service, and then decoded to a perl data structure with decode_json().

error()

Set if an error has occured. On errors, the lookup terminates, with more info in the status().

warning()

Set if a warning has occured. On warnings, the lookup continues, but warnings are accumulated in the status().

status()

Further description of error/warning situations.

data()

The found data, an array of NOLookup::Brreg::Entry data objects.

See doc. for NOLookup::Brreg::Entry for details.

size()

The number of objects found in a page lookup

total_size()

The total number of objects found by the search.

Only set if all data has been fetched.

Only if total_size is set, the user can assume that all data has been fetched.

cur_page()/prev_page()/next_page()

If more pages can be fetched, those methods give the URL to that page

total_page_count()

Count of total nuber of pages matching the search

result_count()

Count of total results for the search

SUPPORT

For now, support questions should be sent to:

<(nospam)info(at)norid.no>

Please also see the README file in the distribution.

SEE ALSO

https://www.brreg.no https://data.brreg.no/enhetsregisteret/oppslag/enheter

AUTHOR

Trond Haugen, <(nospam)info(at)norid.no>

COPYRIGHT

Copyright (c) 2017- Trond Haugen <(nospam)info(at)norid.no>. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

LICENSE

This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.

TODO

Perhaps add an address object to contain the address info.