ExCnab240 behaviour (ex_cnab v1.3.6)
Cnab keeps the contexts that define your domain and business logic.
Contexts are also responsible for managing your data, regardless if it comes from the database, an external API or others.
Link to this section Summary
Callbacks
Decode a single file. This will decode the cnab file applying the correct format to each CNAB 240 template
Encode a single file. This will encode your params to a one CNAB file applying the correct format to each CNAB 240 template
Find all details types from a CNAB 240 file The funtion will recieve a map with the cnab 240 file decoded and will return a list with all details types
Link to this section Callbacks
decode(filepath)
Decode a single file. This will decode the cnab file applying the correct format to each CNAB 240 template
example
Example
import ExCnab240
decode("JVH1234.rem", %{})
{:ok, %{
header: %{
# Content
},
details: %{
# Content
},
footer: %{
# Content
},
additional_info: %{
# Content
}
}}
decode(filepath, attrs)
decode!(filepath)
decode!(filepath, attrs)
encode(params)
@callback encode(params :: Map.t()) :: {:ok, %{filename: String.t(), content: String.t()}} | {:error, String.t()}
Encode a single file. This will encode your params to a one CNAB file applying the correct format to each CNAB 240 template
example
Example
import ExCnab240
encode(%{cnab: cnab}, %{filename: "JVH1010101.ret"})
{:ok, %{contnet: "xxx...", filename: "JVH1010101.ret"}}
encode(%{cnab: cnab}, %{})
{:ok, %{contnet: "xxx...", filename: "default.ret"}}
encode!(%{cnab: cnab}, %{filename: "JVH1010101.ret"})
%{contnet: "xxx...", filename: "JVH1010101.ret"}
encode!(%{cnab: cnab}, %{})
%{contnet: "xxx...", filename: "default.ret"}
encode(params, attrs)
encode!(params)
encode!(params, attrs)
find_details_type(params)
@callback find_details_type(params :: Map.t()) :: any()
@callback find_details_type(params :: Map.t()) :: {:ok, %{filename: String.t(), content: String.t()}}
@callback find_details_type(params :: Map.t()) :: any()
@callback find_details_type(params :: Map.t()) :: %{ filename: String.t(), content: String.t() }
Find all details types from a CNAB 240 file The funtion will recieve a map with the cnab 240 file decoded and will return a list with all details types
example
Example
import ExCnab240
find_details_type(cnab_file)
{:ok, ["A", "B"]}
find_details_type!(cnab_file)
["A", "B"]