Bacen.CCS.Serializer.SchemaConverter (Bacen CCS v0.1.1)

The Bacen's CCS schema converter.

It reads all Ecto.Schema defined on Message schema and generates a tuple-formatted XML, allowing the application to serialize it properly and convert to String.

Link to this section Summary


Convert an t:Ecto.Schema into a tuple-formatted XML.

Link to this section Functions

Link to this function

to_xml(message, xmlns)


to_xml(Bacen.CCS.Message.t(), charlist()) :: {:ok, xml()} | {:error, any()}

Convert an t:Ecto.Schema into a tuple-formatted XML.


iex> message = %Bacen.CCS.Message{
iex>   message: %Bacen.CCS.Message.BaseMessage{
iex>     body: %Bacen.CCS.ACCS002{
iex>       response: %Bacen.CCS.ACCS002.Response{
iex>         error: nil,
iex>         last_file_id: "000000000000",
iex>         movement_date: ~D[2021-05-07],
iex>         reference_date: ~U[2021-05-07 05:04:00Z],
iex>         status: "A"
iex>       }
iex>     },
iex>     header: %Bacen.CCS.Message.BaseMessage.Header{
iex>       file_id: "000000000000",
iex>       file_name: "ACCS001",
iex>       issuer_id: "69930846",
iex>       recipient_id: "25992990"
iex>     }
iex>   }
iex> }
iex> Bacen.CCS.Serializer.SchemaConverter.to_xml(message, 'foo')
{:ok, {:CCSDOC, [xmlns: 'foo'],
    BCARQ: [
      {:IdentdEmissor, ['69930846']},
      {:IdentdDestinatario, ['25992990']},
      {:NomArq, ['ACCS001']},
      {:NumRemessaArq, ['000000000000']}
    SISARQ: [
      CCSArqAtlzDiariaRespArq: [
        {:SitArq, ['A']},
        {:UltNumRemessaArq, ['000000000000']},
        {:DtHrBC, ['2021-05-07T05:04:00']},
        {:DtMovto, ['2021-05-07']}