Skip to content

Commit 91d33fe

Browse files
added apiKey to search request
1 parent bfc911c commit 91d33fe

File tree

2 files changed

+39
-109
lines changed

2 files changed

+39
-109
lines changed

src/services/get-search-service.js

Lines changed: 34 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -9,109 +9,51 @@ import {
99
} from '../redux/slices/mainSlice'
1010
import { addDataToLayer, footprintLayerStyle } from '../utils/mapHelper'
1111

12-
export async function SearchService(searchParams, productData) {
13-
// const fakeOpportunities = {
14-
// "type": "FeatureCollection",
15-
// "features": [
12+
export async function SearchService(searchParams, productData, apiKey) {
13+
// {
14+
// "id": "cc4a6b70-d45b-415b-b7ea-0f636fdc9a2d",
15+
// "product_id": "maxar",
16+
// "opportunity_request": {
17+
// "datetime": "2025-04-03T10:28:47.935480+00:00/2025-04-03T10:28:47.935484+00:00",
18+
// "geometry": {
19+
// "type": "Point",
20+
// "coordinates": [
21+
// 0.0,
22+
// 0.0
23+
// ]
24+
// },
25+
// "filter": null,
26+
// "next": null,
27+
// "limit": 10
28+
// },
29+
// "status": {
30+
// "timestamp": "2025-04-03T10:28:47.935549Z",
31+
// "status_code": "completed",
32+
// "reason_code": null,
33+
// "reason_text": null,
34+
// "links": []
35+
// },
36+
// "links": [
1637
// {
17-
// "type": "Feature",
18-
// "geometry": {
19-
// "type": "Point",
20-
// "coordinates": [
21-
// 0,
22-
// 0
23-
// ]
24-
// },
25-
// "properties": {
26-
// "start_datetime": "2023-03-01T13:00:00Z",
27-
// "end_datetime": "2023-03-2T15:30:00Z",
28-
// "product_id": "EO",
29-
// "constraints": {
30-
// "gsd": [
31-
// 1.0,
32-
// 10.0
33-
// ],
34-
// "view:off_nadir": [
35-
// 0,
36-
// 30
37-
// ],
38-
// "sat_elevation": [
39-
// 60,
40-
// 90
41-
// ],
42-
// "view:sun_elevation": [
43-
// 10,
44-
// 90
45-
// ],
46-
// "sat_azimuth": [
47-
// 0,
48-
// 360
49-
// ],
50-
// "view:sun_azimuth": [
51-
// 0,
52-
// 360
53-
// ]
54-
// }
55-
// }
38+
// "href": "https://apps.euspaceimaging.com/test/internal/tara/api/v1/feasibility/cc4a6b70-d45b-415b-b7ea-0f636fdc9a2d",
39+
// "rel": "feasibility"
5640
// },
5741
// {
58-
// "type": "Feature",
59-
// "geometry": {
60-
// "type": "Point",
61-
// "coordinates": [
62-
// 0,
63-
// 0
64-
// ]
65-
// },
66-
// "properties": {
67-
// "start_datetime": "2023-03-02T13:00:00Z",
68-
// "end_datetime": "2023-03-03T15:30:00Z",
69-
// "product_id": "EO",
70-
// "constraints": {
71-
// "gsd": [
72-
// 1.0,
73-
// 10.0
74-
// ],
75-
// "view:off_nadir": [
76-
// 0,
77-
// 30
78-
// ],
79-
// "sat_elevation": [
80-
// 60,
81-
// 90
82-
// ],
83-
// "view:sun_elevation": [
84-
// 10,
85-
// 90
86-
// ],
87-
// "sat_azimuth": [
88-
// 0,
89-
// 360
90-
// ],
91-
// "view:sun_azimuth": [
92-
// 0,
93-
// 360
94-
// ]
95-
// }
96-
// }
42+
// "href": "http://apps.euspaceimaging.com/test/internal/stapi/searches/opportunities/cc4a6b70-d45b-415b-b7ea-0f636fdc9a2d",
43+
// "rel": "self",
44+
// "type": "application/json"
9745
// }
98-
// ],
99-
// "links": {
100-
// "rel": "next",
101-
// "title": "Next page of Opportunities",
102-
// "method": "GET",
103-
// "type": "application/geo+json",
104-
// "href": "stat-api.example.com?page=2"
105-
// }
106-
// };
46+
// ]
47+
// }
10748
console.log('REQUEST', searchParams)
10849
// TODO: PUT ENDPOINT HERE
10950
// check for selected product and map endpoint
11051
await fetch(productData.providerBaseUrl + '/products/maxar/opportunities', {
11152
method: 'POST',
11253
headers: {
11354
'Content-Type': 'application/json',
114-
Accept: '*/*'
55+
Accept: '*/*',
56+
Authorization: `Bearer ${apiKey}`
11557
},
11658
body: JSON.stringify(searchParams)
11759
})

src/utils/searchHelper.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,12 @@ export function newSearch(filters, productData) {
3030
const geometry = store.getState().mainSlice.searchGeojsonBoundary
3131
const dates = store.getState().mainSlice.searchDateRangeValue
3232
const productId = store.getState().mainSlice.selectedProductData.id
33-
console.log(geometry, dates, filters)
34-
console.log(geometry)
33+
const apiKey = store.getState().mainSlice.apiKey
34+
3535
const query = {
3636
//product_id: productId,
37-
datetime: "2025-04-21T00:00:00.000Z/2025-04-29T23:59:59.000Z" || `${dates[0]}/${dates[1]}`,
38-
geometry: {
39-
type: 'Polygon',
40-
coordinates: [
41-
[
42-
[131.4067090823608, -24.863581247683243],
43-
[131.4067090823608, -24.946918997631883],
44-
[131.51697981183463, -24.946918997631883],
45-
[131.51697981183463, -24.863581247683243],
46-
[131.4067090823608, -24.863581247683243]
47-
]
48-
]
49-
},
37+
datetime: `${dates[0]}/${dates[1]}`,
38+
geometry: geometry.geometry,
5039
filter: {
5140
// op: 'and',
5241
// args: []
@@ -76,9 +65,8 @@ export function newSearch(filters, productData) {
7665
// query.filter.args.push(upperBounds)
7766
// }
7867

79-
console.log(query)
8068

81-
SearchService(query, productData)
69+
SearchService(query, productData, apiKey)
8270

8371
// const _selectedCollection = store.getState().mainSlice.selectedCollectionData
8472

0 commit comments

Comments
 (0)