OcppModel (ocpp_model v0.3.0) View Source

OcppModel Module: Contains helper functions

Link to this section Summary

Functions

Transforms the payload into a struct and calls the implemented behaviour function and returns the response back into a map the implemented behaviour can alter the state if it wants to

same as to_map!() but takes an {{:ok, struct()}, state} and returns an {{:ok, map()}, state}

Converts a struct into a map including any nested structs

Converts a Map into a struct of the given kind

Link to this section Functions

Link to this function

execute(payload, model, method, state)

View Source

Transforms the payload into a struct and calls the implemented behaviour function and returns the response back into a map the implemented behaviour can alter the state if it wants to

Specs

to_map({{:ok, struct()}, any()} | {{:error, atom(), String.t()}, any()}) ::
  {{:ok, map()}, any()} | {{:error, atom(), String.t()}, any()}

same as to_map!() but takes an {{:ok, struct()}, state} and returns an {{:ok, map()}, state}

in case of een {{:error, atom(), String.t()}, state} argument it will let it pass through

Link to this function

to_map!(st, filter_empty \\ true)

View Source

Converts a struct into a map including any nested structs

Specs

to_struct(map(), atom() | struct()) :: struct()

Converts a Map into a struct of the given kind