xeni-app / xeni_travel_api_docs

Repository of information relating to connecting and using Xeni's Travel API.
0 stars 0 forks source link

Create Militaryfares livebook #7

Open canuckasaurus opened 1 year ago

canuckasaurus commented 1 year ago

Militaryfares_Integration_Flight_API_xml.pdf Militaryfares_Integration_Package_API_xml.pdf Militaryfares_Integration_Hotel_API_xml.pdf

RishiMSingh commented 1 year ago

Flight API

Static URL I had trouble implementing a dynamic URL

defmodule MilitaryFares_3 do require HTTPoison

@endpoint "https://affiliateapi.militaryfares.com/flights.php?%20method=search&a=militaryfares&curr=USD&lang=en&client_request=militaryf%20ares.com&D1=1&D2=0&D3=0&D4=0&D5=0&T1=MIA&T2=DXB&T3=DXB&T4=MIA&cabin=Y&c%20urr=USD&outdate1=2023-04-11&outdate2=2023-04-%2017%20&%20trip=roun%20d%20&format=json&nogroup=1&master=militaryfares&owner=%201"

def search(from, to, outdate1, outdate2) do params = [ method: "search", a: "militaryfares", curr: "USD", lang: "en", client_request: "militaryfares", T1: from, T2: to, T3: to, T4: from, outdate1: outdate1, outdate2: outdate2, D1: 1, D2: 0, D3: 0, D4: 0, D5: 0, cabin: cabin, trip: "round", format: "json", nogroup: 1, master: "militaryfares", owner: 1, curr: "USD" ]

response = HTTPoison.get(@endpoint, params)

case response do
  {:ok, %{body: body}} ->
    {:ok, Jason.decode(body)}

  {:error, _} ->
    {:error, "HTTP request failed"}
end

end end

result = MilitaryFares_3.search("BOM", "DXB", "2023-04-13", "2023-04-17")