Skip to content

Commit

Permalink
Requêteur SIRI : corrige requête EstimatedTimetable (#3508)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti authored Oct 5, 2023
1 parent 95cb969 commit 7e7b1f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
18 changes: 5 additions & 13 deletions apps/transport/lib/siri_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,14 @@ defmodule Transport.SIRI do
Saxy.encode!(doc)
end

def build_line_refs(line_refs) do
# NOTE: we'll switch to proper well-escaped XML building later, this is research code
line_refs = line_refs |> Enum.map_join("\n", &"<siri:LineRef>#{&1}</siri:LineRef>")

"""
<siri:Lines>
#{line_refs}
</siri:Lines>
"""
end

def line_refs_element([] = _line_refs), do: nil

def line_refs_element(line_refs) do
line_refs = line_refs |> Enum.map(&element("siri:LineRef", [], &1))
element("siri:Lines", [], line_refs)
line_refs = Enum.map(line_refs, &element("siri:LineRef", [], &1))

element("siri:Lines", [], [
element("siri:LineDirection", [], line_refs)
])
end

def append_if_not_nil(list, nil), do: list
Expand Down
6 changes: 4 additions & 2 deletions apps/transport/test/transport/siri_queries_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ defmodule Transport.SIRITest do
<siri:RequestTimestamp>#{timestamp}</siri:RequestTimestamp>
<siri:MessageIdentifier>#{message_identifier}</siri:MessageIdentifier>
<siri:Lines>
<siri:LineRef>#{line_001}</siri:LineRef>
<siri:LineRef>#{line_002}</siri:LineRef>
<siri:LineDirection>
<siri:LineRef>#{line_001}</siri:LineRef>
<siri:LineRef>#{line_002}</siri:LineRef>
</siri:LineDirection>
</siri:Lines>
</Request>
<RequestExtension/>
Expand Down

0 comments on commit 7e7b1f3

Please sign in to comment.