Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Steph48964 committed Jan 19, 2018
2 parents 9b7cda7 + 78bc861 commit 0472d3e
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<<<<<<< HEAD
<title>LAUNCHBOX 🚀</title>
=======
<title>REX</title>
>>>>>>> 78bc86100c9f388773efdd32701d67a6c5326525
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css"/>
</head>
<body>
Expand Down
80 changes: 80 additions & 0 deletions client/src/fareportalAPI.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, {Component} from "react";

class Fareportal extends Component {
constructor() {
super();
this.state = {
flights: [],
}
};

componentWillMount() {
var username = "stephanie48964@gmail.com";
var password = "1C61120A";
var apiUrl = "https://api-dev.fareportallabs.com/air/api/search/searchflightavailability";
var apiKey = new Buffer(username + ":" + password).toString('base64');
var apiHeaders = new Headers();
apiHeaders.append("Authorization", "Basic " + apiKey);
apiHeaders.append("Content-Type", "application/json");
apiHeaders.append("Accept-Encoding", "application/gzip");
var apiParams = {
FlightSearchRequest: {
Adults: "1",
TypeOfTrip: "ROUNDTRIP",
ClassOfService: "ECONOMY",
SegmentDetails: [
// flight out
{
Origin: "SAN",
Destination: "LAS",
DepartureDate: "2018-02-01",
DepartureTime: "1100"
},
// flight back in
{
Origin: "LAS",
Destination: "SAN",
DepartureDate: "2018-02-05",
DepartureTime: "1900"
}
]
},
ResponseVersion: "VERSION41",
};

console.log('params', JSON.stringify(apiParams));

// ref: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch(apiUrl, {
method: 'POST',
body: JSON.stringify(apiParams),
headers: apiHeaders
})
.then(results => {
return results.json();
}).then(data => {
console.log(data);
let flights = data.FlightResponse.FpSearch_AirLowFaresRS.OriginDestinationOptions.InBoundOptions.InBoundOption.map((flight) => {
return (
<div key={flight.Segmentid}>
Arrival: {flight.FlightSegment[0].ArrivalAirport.LocationCode}
/
Departure: {flight.FlightSegment[0].DepartureAirport.LocationCode}
</div>
)
})
this.setState({flights: flights});
console.log("state", this.state.flights);
})
};

render() {
return (
<div>
{this.state.flights}
</div>
)
};
}

export default Fareportal;
1 change: 1 addition & 0 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ import App from "./App";

ReactDOM.render(<App />, document.getElementById("root"));


0 comments on commit 0472d3e

Please sign in to comment.