defmodule Sirene do use SireneBase alias Jason @moduledoc """ `Sirene` is the module you would use for the sirene api. """ @doc """ Allows you to know the status of the API service. The answer is always a table corresponding to the body. """ def get_informations do case SireneBase.get!("/informations") do %HTTPoison.Response{body: body} -> body |> Jason.decode!() {:error, reason} -> IO.inspect(reason) end end @doc """ Allows you to search from a given siret, the information of the establishment will be given in the establishment table. """ def get_siret(siret) when is_binary(siret) do case SireneBase.get!("/siret/" <> siret) do %HTTPoison.Response{body: body} -> body |> Jason.decode!() {:error, reason} -> IO.inspect(reason) end end @doc """ Allows you to search from a given siren, the information of one or more establishments will be given in the table uniteLegale. """ def get_siren(siren) when is_binary(siren) do case SireneBase.get!("/siren/" <> siren) do %HTTPoison.Response{body: body} -> body |> Jason.decode!() {:error, reason} -> IO.inspect(reason) end end end