Skip to content

Commit

Permalink
Rename from yield_core_query to yield. Makes easy to call functoin di…
Browse files Browse the repository at this point in the history
…namically
  • Loading branch information
zaali kavelashvili committed Dec 17, 2015
1 parent b5adaae commit eb56825
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions lib/messages/air_shopping_rq.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
defmodule NDCEx.Messages.AirShoppingRQ do
alias NDCEx.Base

def yield_core_query(doc) do
'CoreQuery' |> :xmerl_xpath.string(doc) |> Base.yeild
#alias NDCEx.Base
import SweetXml

def yield(doc) do
#data = 'CoreQuery' |> :xmerl_xpath.string(doc) |> Base.yeild
doc |> xpath(~x"//CoreQuery/OriginDestinations/OriginDestination"l)

#doc
#|> xpath(~x"//CoreQuery"l)
#|> Enum.map fn (od_node) ->
#%{
#departurename: od_node |> xpath(~x"./Departure/AirportCode/text()"),
#arrival: od_node |> xpath(~x"./Arrival/AirportCode/text()")
#}
#end

doc
|> xpath(~x"//CoreQuery/OriginDestinations/OriginDestination"l,
departure: [
~x"./Departure",
airport_code: ~x"./AirportCode/text()",
date: ~x"./Date/text()"
],
arrival: [
~x"./Arrival",
airport_code: ~x"./AirportCode/text()"
],
marketing_carrier_airline: [
~x"./MarketingCarrierAirline",
airline_id: ~x"./AirlineID/text()",
name: ~x"./Name/text()"
]
)
end
end

0 comments on commit eb56825

Please sign in to comment.