Skip to content

Commit d794e68

Browse files
committed
Just a couple of formatting changes
1 parent f69aa6d commit d794e68

File tree

9 files changed

+489
-11297
lines changed

9 files changed

+489
-11297
lines changed

.DS_Store

0 Bytes
Binary file not shown.

advanced_version/RentalCars/src/app/app.functions/getLocations.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ function calculateDistance(a, b) {
55
const earthRadiusMiles = 3958.8; // Average radius of the Earth in miles
66

77
// Convert degrees to radians
8-
const lat1 = a.lat * (Math.PI/180);
9-
const lng1 = a.lng * (Math.PI/180);
10-
const lat2 = b.lat * (Math.PI/180);
11-
const lng2 = b.lng * (Math.PI/180);
8+
const lat1 = a.lat * (Math.PI / 180);
9+
const lng1 = a.lng * (Math.PI / 180);
10+
const lat2 = b.lat * (Math.PI / 180);
11+
const lng2 = b.lng * (Math.PI / 180);
1212

1313
// Haversine formula
1414
const differenceLat = lat2 - lat1;
1515
const differenceLng = lng2 - lng1;
1616
const aHav = Math.pow(Math.sin(differenceLat / 2), 2) +
17-
Math.cos(lat1) * Math.cos(lat2) *
18-
Math.pow(Math.sin(differenceLng / 2), 2);
17+
Math.cos(lat1) * Math.cos(lat2) *
18+
Math.pow(Math.sin(differenceLng / 2), 2);
1919
const c = 2 * Math.atan2(Math.sqrt(aHav), Math.sqrt(1 - aHav));
2020

2121
// Distance in miles
@@ -70,10 +70,10 @@ function fetchLocations({ lat_min, lat_max, lng_min, lng_max, pickupDate, return
7070
}
7171
}`,
7272
variables: {
73-
"lat_min":lat_min,
74-
"lat_max":lat_max,
75-
"lng_min":lng_min,
76-
"lng_max":lng_max,
73+
"lat_min": lat_min,
74+
"lat_max": lat_max,
75+
"lng_min": lng_min,
76+
"lng_max": lng_max,
7777
"pickupDate": pickupDate,
7878
"returnDate": returnDate,
7979
"vehicleClass": vehicleClass
@@ -85,7 +85,7 @@ function fetchLocations({ lat_min, lat_max, lng_min, lng_max, pickupDate, return
8585
url: 'https://api.hubapi.com/collector/graphql',
8686
headers: {
8787
'Content-Type': 'application/json',
88-
'Authorization': 'Bearer '+process.env['PRIVATE_APP_ACCESS_TOKEN'],
88+
'Authorization': 'Bearer ' + process.env['PRIVATE_APP_ACCESS_TOKEN'],
8989
},
9090
data: data,
9191
maxBodyLength: Infinity

advanced_version/RentalCars/src/app/app.functions/getVehicles.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@ const axios = require('axios');
33

44
exports.main = async (context, sendResponse) => {
55

6-
let vehicleIds = context.parameters.vehicles;
6+
let vehicleIds = context.parameters.vehicles;
77

8-
let data = JSON.stringify({
9-
"inputs": vehicleIds.map((id) => {
10-
return {
11-
"id": id
12-
}
13-
}),
14-
"properties": [
15-
"vin",
16-
"make",
17-
"model",
18-
"year",
19-
"daily_price"
20-
]
21-
});
8+
let data = JSON.stringify({
9+
"inputs": vehicleIds.map((id) => {
10+
return {
11+
"id": id
12+
}
13+
}),
14+
"properties": [
15+
"vin",
16+
"make",
17+
"model",
18+
"year",
19+
"daily_price"
20+
]
21+
});
2222

23-
let config = {
24-
method: 'post',
25-
maxBodyLength: Infinity,
26-
url: 'https://api.hubapi.com/crm/v3/objects/vehicles/batch/read',
27-
headers: {
28-
'Authorization': 'Bearer '+process.env['PRIVATE_APP_ACCESS_TOKEN'],
29-
'Content-Type': 'application/json'
30-
},
31-
data : data
32-
};
23+
let config = {
24+
method: 'post',
25+
maxBodyLength: Infinity,
26+
url: 'https://api.hubapi.com/crm/v3/objects/vehicles/batch/read',
27+
headers: {
28+
'Authorization': 'Bearer ' + process.env['PRIVATE_APP_ACCESS_TOKEN'],
29+
'Content-Type': 'application/json'
30+
},
31+
data: data
32+
};
3333

34-
axios.request(config)
35-
.then((response) => {
36-
console.log(JSON.stringify(response.data));
37-
sendResponse({data: response.data});
38-
})
39-
.catch((error) => {
40-
console.log(error);
41-
throw error;
42-
});
34+
axios.request(config)
35+
.then((response) => {
36+
console.log(JSON.stringify(response.data));
37+
sendResponse({ data: response.data });
38+
})
39+
.catch((error) => {
40+
console.log(error);
41+
throw error;
42+
});
4343
}

0 commit comments

Comments
 (0)