Skip to content

Commit

Permalink
Parse response via old school way
Browse files Browse the repository at this point in the history
  • Loading branch information
programisti committed Jan 26, 2016
1 parent 507ee77 commit a114d58
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/service_list_test.exs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
defmodule ServiceListTest do
require Logger
require Record
use ExUnit.Case
require HTTPotion
doctest NDCEx
import SweetXml
Record.defrecord :xmlElement, Record.extract(:xmlElement, from_lib: "xmerl/include/xmerl.hrl")
Record.defrecord :xmlText, Record.extract(:xmlText, from_lib: "xmerl/include/xmerl.hrl")

@valid_core_query_params [
CoreQuery: [
Expand All @@ -23,15 +24,16 @@ defmodule ServiceListTest do

test "Call ServiceList request" do
{_, xml} = NDCEx.request(:AirShopping, @valid_core_query_params)
response_id = xml |> xpath(~x"//AirShoppingRS/ShoppingResponseIDs/ResponseID/text()")
[element] = :xmerl_xpath.string('/AirShoppingRS/ShoppingResponseIDs/ResponseID', xml)
[text] = xmlElement(element, :content)
response_id = xmlText(text, :value)
params = [
ShoppingResponseIDs: [
ResponseID: response_id
ResponseID: to_string(response_id)
]
]

{status, body} = NDCEx.request(:ServiceList, params)
IO.inspect params
IO.inspect body
assert status == :ok
end
Expand Down

0 comments on commit a114d58

Please sign in to comment.