Ofex v0.2.1 Ofex

Documentation for Ofex.

Summary

Functions

Validates and parses Open Financial Exchange (OFX) data

Same as parse, but does not validate data that is passed in and allows exceptions to be raised

Functions

parse(data)

Validates and parses Open Financial Exchange (OFX) data.

data will need to be supplied as a string. Each message set of the OFX data is parsed separately and returned as map containing a :signon map and an :accounts list.

Parsing errors or invalid data will return a tuple of {:error, %Ofex.InvalidData{}} (see Ofex.InvalidData)

Examples

iex > Ofex.parse("<OFX>..actual_ofx_data...</OFX>")
{:ok, %{signon: %{}, accounts: [%{}, %{}, ...}}

iex> Ofex.parse("I am definitely not OFX")
{:error, %Ofex.InvalidData{message: "data provided cannot be parsed. May not be OFX format", data: "I am definitely not OFX"}}

Only strings are allowed to be passed in for parsing

iex> Ofex.parse(1234)
{:error, %Ofex.InvalidData{message: "data is not binary", data: 1234}}

iex> Ofex.parse(%{whoops: "a daisy"})
{:error, %Ofex.InvalidData{message: "data is not binary", data: %{whoops: "a daisy"}}}

Unsupported message sets

Messages sets chunked into a list based on a *MSGSRS* match on the name then individually parsed. Support is gradually being built out so there may be cases that a message set is matched, but not parsed. The process will complete, but those unmatched message sets will be logged to the console and then returned under string key of the message set name.

iex > Ofex.parse("<OFX><UNSUPPORTEDMSGSRSV1>some_data</UNSUPPORTEDMSGSRSV1></OFX>")
22:22:14.896 [warn]  Skipping unsupported message set: UNSUPPORTEDMSGSRSV1
%{"UNSUPPORTEDMSGSRSV1" => "some_data"}
parse!(data)

Same as parse, but does not validate data that is passed in and allows exceptions to be raised.

Returns the parsed data structure

Examples

iex > Ofex.parse!("<OFX>..actual_ofx_data...</OFX>")
%{signon: %{}, accounts: [%{}, %{}, ...}