Packages

Elixir SDK for the CNPJá API — CNPJ, CEP, RFB, Simples Nacional, CCC and SUFRAMA lookups.

Current section

Files

Jump to
cnpja_ex lib cnpja shared simples_opt.ex
Raw

lib/cnpja/shared/simples_opt.ex

defmodule Cnpja.SimplesOpt do
@moduledoc "Simples Nacional enrollment or MEI classification data."
@enforce_keys [:optant]
defstruct [:optant, :since, :history]
@type t :: %__MODULE__{
optant: boolean(),
since: String.t() | nil,
history: [Cnpja.SimplesHistory.t()]
}
@spec from_map(map()) :: t()
def from_map(map) do
%__MODULE__{
optant: map["optant"],
since: map["since"],
history: Enum.map(map["history"] || [], &Cnpja.SimplesHistory.from_map/1)
}
end
@spec from_map_nullable(map() | nil) :: t() | nil
def from_map_nullable(nil), do: nil
def from_map_nullable(map), do: from_map(map)
end