Skip to content

Instantly share code, notes, and snippets.

@HelgeSverre
Created March 2, 2022 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HelgeSverre/871c002333a23e1bc391f21c0bad8834 to your computer and use it in GitHub Desktop.
Save HelgeSverre/871c002333a23e1bc391f21c0bad8834 to your computer and use it in GitHub Desktop.
Laravel Brønnøysundregistrene - Brreg
<?php
use Illuminate\Support\Facades\Http;
class Brreg
{
public function getByVatId($vatId)
{
return Http::get("https://data.brreg.no/enhetsregisteret/api/enheter/$vatId")->json();
}
public function getRoles($vatId)
{
return Http::get("https://data.brreg.no/enhetsregisteret/api/enheter/$vatId/roller")->json();
}
public function searchByName($name, $params = [])
{
return Http::get("https://data.brreg.no/enhetsregisteret/api/enheter",
array_merge(["navn" => $name], $params)
)->json();
}
}
@HelgeSverre
Copy link
Author

You don't need a SDK or a wrapper for this stuff if you are doing this for the ability to autocomplete a "company form" (which, let's be serious, covers probably 80% of the people landing on this gist via search)

If you want to make it more fancy, you can wrap everything in DTOs, add a Fluent Builder class for parameters etc.


Hjelper gjerne nybegynnere i kommentarfeltet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment