class BrregGrunndata::Service
The service returns ruby objects with data fetched from API
This interface has a higher abstraction than working directly with the Client
, where the object you get back has coerced values instead of working with a hash of strings.
@see Client
Attributes
client[R]
Public Class Methods
new(client:)
click to toggle source
# File lib/brreg_grunndata/service.rb, line 17 def initialize(client:) @client = client end
Public Instance Methods
hent_basisdata_mini(orgnr:)
click to toggle source
Get basic mini data of an organization
Arguments
orgnr - The orgnr you are searching for
@return BrregGrunndata::Types::Organization
# File lib/brreg_grunndata/service.rb, line 42 def hent_basisdata_mini(orgnr:) Types::FromResponseFactory.organization client.hent_basisdata_mini orgnr: orgnr end
hent_kontaktdata(orgnr:)
click to toggle source
Get contact information for an organization
Arguments
orgnr - The orgnr you are searching for
@return BrregGrunndata::Types::Organization
# File lib/brreg_grunndata/service.rb, line 52 def hent_kontaktdata(orgnr:) Types::FromResponseFactory.organization client.hent_kontaktdata orgnr: orgnr end
hent_saerlige_opplysninger(orgnr:)
click to toggle source
Get additional information about an organization
Like when where the last time the reported taxes, are they registered in the VAT registry etc.
Arguments
orgnr - The orgnr you are searching for
@return BrregGrunndata::Types::Organization
# File lib/brreg_grunndata/service.rb, line 65 def hent_saerlige_opplysninger(orgnr:) Types::FromResponseFactory.organization client.hent_saerlige_opplysninger orgnr: orgnr end
run_concurrently(operations, **args)
click to toggle source
Runs given operations concurrently
Arguments
operations - An array of operations to run concurrently The named operations must be defined as methods on the service and they must return same type. args - All other arguments are passed on to each operations.
# File lib/brreg_grunndata/service.rb, line 28 def run_concurrently(operations, **args) results = Utils::ConcurrentOperations.new(self, operations, args).call return nil if results.any?(&:nil?) results.reduce { |acc, elem| acc.merge elem } end