Initial commit
This commit is contained in:
9
lib/ex_data_gov_u_a/decoders/base.ex
Normal file
9
lib/ex_data_gov_u_a/decoders/base.ex
Normal file
@@ -0,0 +1,9 @@
|
||||
defmodule ExDataGovUA.Decoders.Base do
|
||||
@type data :: map()
|
||||
@type status :: Atom.t()
|
||||
@type async_response :: Stream.t()
|
||||
@type sync_response :: {status, data}
|
||||
@type body :: String.t() | Stream.t()
|
||||
|
||||
@callback decode(body) :: async_response | sync_response
|
||||
end
|
||||
8
lib/ex_data_gov_u_a/decoders/jason_decoder.ex
Normal file
8
lib/ex_data_gov_u_a/decoders/jason_decoder.ex
Normal file
@@ -0,0 +1,8 @@
|
||||
defmodule ExDataGovUA.Decoders.JasonDecoder do
|
||||
@behaviour ExDataGovUA.Decoders.Base
|
||||
|
||||
@impl true
|
||||
def decode(data) do
|
||||
Jason.decode(data, [keys: :atoms])
|
||||
end
|
||||
end
|
||||
9
lib/ex_data_gov_u_a/decoders/jaxon_decoder.ex
Normal file
9
lib/ex_data_gov_u_a/decoders/jaxon_decoder.ex
Normal file
@@ -0,0 +1,9 @@
|
||||
defmodule ExDataGovUA.Decoders.JaxonDecoder do
|
||||
@behaviour ExDataGovUA.Decoders.Base
|
||||
|
||||
@impl true
|
||||
def decode(stream) do
|
||||
stream
|
||||
|> Jaxon.Stream.from_enumerable()
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user