Wenche.AltinnClient (wenche v0.1.1)

Copy Markdown View Source

Altinn 3 API client for creating instances, uploading data, and completing submissions.

Ported from wenche/altinn_client.py in the original Python Wenche project.

Handles instance creation, data submission, and completion for all three submission types: annual accounts, tax return, and shareholder register.

Summary

Functions

Moves the instance to the next process step (legacy API).

Creates a new Altinn 3 app instance (legacy API).

Advances the instance to the signing step and returns the Altinn inbox URL where the user can sign with BankID/ID-Porten.

Gets the current status of an instance (legacy API).

Gets the current status of an instance.

Creates a new AltinnClient with the given token and environment.

Updates an existing data element in the instance with PUT.

Creates a new instance for the given submission type and organization.

Uploads/updates a data element on an existing instance (legacy API).

Types

t()

@type t() :: %Wenche.AltinnClient{
  apps_base: String.t(),
  env: String.t(),
  inbox_url: String.t(),
  token: String.t()
}

Functions

complete_instance(altinn_token, instance_id, app_id, opts \\ [])

Moves the instance to the next process step (legacy API).

Returns {:ok, response_body} or {:error, reason}.

create_instance(altinn_token, org_number, app_id, opts \\ [])

Creates a new Altinn 3 app instance (legacy API).

Returns {:ok, instance_body} or {:error, reason}.

fullfoor_instans(client, app_key, instans)

Advances the instance to the signing step and returns the Altinn inbox URL where the user can sign with BankID/ID-Porten.

Signing requires ID-Porten and cannot be done programmatically.

Returns {:ok, inbox_url} or {:error, reason}.

get_status(altinn_token, instance_id, app_id, opts \\ [])

Gets the current status of an instance (legacy API).

Returns {:ok, response_body} or {:error, reason}.

hent_status(client, app_key, instans)

Gets the current status of an instance.

Returns {:ok, response_body} or {:error, reason}.

new(altinn_token, opts \\ [])

Creates a new AltinnClient with the given token and environment.

Options

  • :env"test" or "prod" (default: "prod")

oppdater_data_element(client, app_key, instans, data_type, data, content_type)

Updates an existing data element in the instance with PUT.

Altinn creates data elements automatically upon instance creation; we find the correct element via dataType and replace its contents.

Returns {:ok, response_body} or {:error, reason}.

opprett_instans(client, app_key, org_nummer)

Creates a new instance for the given submission type and organization.

App keys

  • "aarsregnskap" — Annual accounts (BRG)
  • "aksjonaerregister" — Shareholder register (SKD)
  • "skattemelding" — Tax return (SKD)

Returns {:ok, instance_map} or {:error, reason}.

update_data_element(altinn_token, instance_id, app_id, data_type, content_type, data, opts \\ [])

Uploads/updates a data element on an existing instance (legacy API).

Returns {:ok, response_body} or {:error, reason}.