Skip to content

Commit

Permalink
Se agregan cambios de master
Browse files Browse the repository at this point in the history
  • Loading branch information
ketsalkuetspalin committed Feb 16, 2018
2 parents 24048a4 + aac98e1 commit d9df125
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
11 changes: 11 additions & 0 deletions lib/burox/models/response.ex
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ defmodule Burox.Response.Fin do
]
end

defmodule Burox.Response.Sintetiza do
@moduledoc false
defstruct [
:plantilla_solicitada,
:identificador_de_caracteristica_de_plantilla,
:numero_de_caracteristica,
:valor_de_la_caracteristica,
:codigo_de_error
]
end

defmodule Burox.Response do
@moduledoc """
Basic struct for responses from Buro de Crédito
Expand Down
8 changes: 4 additions & 4 deletions lib/burox/parser/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule Burox.Parser do
"HR", # HR Hawk Alert
"CR", # Declarativa
"SC", # BC-Score
"CL", # Sintetiza
"ES" # End
]

Expand Down Expand Up @@ -134,8 +135,7 @@ defmodule Burox.Parser do
value
|> Float.parse()
|> elem(0)
"date" ->
parse_string_to_date(value)
"date" -> parse_string_to_date(value)
_ -> value
end

Expand Down Expand Up @@ -190,8 +190,8 @@ defmodule Burox.Parser do
{String.slice(string, value_start, length), tail}
end

# Parse a string to Date(), 'yyyymmmdd'
defp parse_string_to_date("000000000"), do: Date.new(1900, 01, 01)
# Convierte una cadena a Fecha, 'yyyymmmdd'
defp parse_string_to_date("000000000"), do: nil
defp parse_string_to_date(str_date) do
[d, m, y1, y2] = for <<x::binary-2 <- str_date>>, do: x

Expand Down
27 changes: 27 additions & 0 deletions lib/burox/parser/response_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,33 @@ defmodule Burox.Parser.ResponseMap do
},
}
},
"CL" => %{
"key" => :sintetiza,
"struct" => Burox.Response.Sintetiza,
"type" => "list",
"tags" => %{
"" => %{
"key" => :plantilla_solicitada,
"type" => "string"
},
"00" => %{
"key" => :identificador_de_caracteristica_de_plantilla,
"type" => "string"
},
"01" => %{
"key" => :numero_de_caracteristica,
"type" => "integer"
},
"02" => %{
"key" => :valor_de_la_caracteristica,
"type" => "string"
},
"03" => %{
"key" => :codigo_de_error,
"type" => "string"
}
}
},
"ES" => %{
"key" => :fin,
"struct" => Burox.Response.Fin,
Expand Down
19 changes: 19 additions & 0 deletions test/parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,23 @@ defmodule ParserTest do
primer_nombre: "HECTOR"}, ""}
end

test "parse multiple sintetiza features" do
string = "CL02150001101019020523432CL021500011010210020820100203"
assert match_section(string, "CL", ["CL"]) == {
[%{
identificador_de_caracteristica_de_plantilla: "1",
numero_de_caracteristica: 9,
plantilla_solicitada: "15",
valor_de_la_caracteristica: "23432"
} |
%{
identificador_de_caracteristica_de_plantilla: "1",
numero_de_caracteristica: 10,
plantilla_solicitada: "15",
valor_de_la_caracteristica: "20100203"
}
], ""}

end

end

0 comments on commit d9df125

Please sign in to comment.