View Source ExFiskal.ResponseParser (ExFiskal v1.2.0)

Parses XML responses from the Croatian fiscalization service.

Summary

Functions

Extracts the JIR (Jedinstveni identifikator računa / Unique Invoice Identifier) from the fiscalization service XML response.

Functions

extract_jir(xml_response)

@spec extract_jir(String.t()) :: {:ok, String.t()} | {:error, String.t()}

Extracts the JIR (Jedinstveni identifikator računa / Unique Invoice Identifier) from the fiscalization service XML response.

Parameters

  • xml_response - The XML string response from the fiscalization service

Returns

  • {:ok, jir} - Returns the JIR string if found
  • {:error, reason} - Returns an error if parsing fails or JIR is not found

Examples

iex> xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><tns:RacunOdgovor xmlns:tns=\"http://www.apis-it.hr/fin/2012/types/f73\"><tns:Jir>a70a985a-8882-4390-83e6-3a091970ed99</tns:Jir></tns:RacunOdgovor></soap:Body></soap:Envelope>"
iex> ExFiskal.ResponseParser.extract_jir(xml)
{:ok, "a70a985a-8882-4390-83e6-3a091970ed99"}