Skip to content

Commit

Permalink
Merge pull request #253 from sentinel-hub/feature/tpdi-base-url
Browse files Browse the repository at this point in the history
Add a setter function for tpdi service url
  • Loading branch information
mitjak authored Nov 16, 2023
2 parents a2a4d97 + 7d10191 commit 3ee25f3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/dataimport/TPDI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
TPDICollections,
TPDProvider,
TPDISearchParams,
TPDI_SERVICE_URL,
TPDITransaction,
TPDSearchResult,
TPDITransactionSearchParams,
Expand All @@ -23,6 +22,12 @@ import { CACHE_CONFIG_NOCACHE } from '../utils/cacheHandlers';

const dataProviders = [new AirbusDataProvider(), new PlanetDataProvider(), new MaxarDataProvider()];

export let TPDI_SERVICE_URL = 'https://services.sentinel-hub.com/api/v1/dataimport';

export function setTPDIServiceBaseURL(baseurl: string): void {
TPDI_SERVICE_URL = `${baseurl}/api/v1/dataimport`;
}

function getThirdPartyDataProvider(provider: TPDProvider): TPDProviderInterface {
const tpdp = dataProviders.find(p => p.getProvider() === provider);
if (!tpdp) {
Expand Down
14 changes: 12 additions & 2 deletions src/dataimport/__tests__/TPDI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import makeServiceWorkerEnv from 'service-worker-mock';
import fetch from 'node-fetch';

import { setAuthToken, invalidateCaches, CRS_EPSG4326, BBox } from '../../index';
import { TPDI } from '../TPDI';
import { TPDI, TPDI_SERVICE_URL, setTPDIServiceBaseURL } from '../TPDI';

import '../../../jest-setup';
import {
AirbusConstellation,
TPDICollections,
TPDISearchParams,
TPDProvider,
TPDI_SERVICE_URL,
ResamplingKernel,
PlanetItemType,
PlanetProductBundle,
Expand Down Expand Up @@ -374,3 +373,14 @@ describe('Test getOrders', () => {
expect(getParams).toStrictEqual(expectedParams);
});
});

describe('Test setting TPDI service URL', () => {
it('should be set to default', async () => {
expect(TPDI_SERVICE_URL).toBe('https://services.sentinel-hub.com/api/v1/dataimport');
});

it('should update TPDI service URL', async () => {
setTPDIServiceBaseURL('https://custom.sentinel.service.com');
expect(TPDI_SERVICE_URL).toBe('https://custom.sentinel.service.com/api/v1/dataimport');
});
});
2 changes: 0 additions & 2 deletions src/dataimport/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Polygon, MultiPolygon } from '@turf/helpers';
import { CRS } from '../crs';
import { BBox } from '../bbox';

export const TPDI_SERVICE_URL = 'https://services.sentinel-hub.com/api/v1/dataimport';

export enum TPDICollections {
AIRBUS_PLEIADES = 'AIRBUS_PLEIADES',
AIRBUS_SPOT = 'AIRBUS_SPOT',
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ import { wmsGetMapUrl as _wmsGetMapUrl } from './layer/wms';
import { drawBlobOnCanvas, canvasToBlob } from './utils/canvas';

import { Effects, ColorRange } from './mapDataManipulation/const';
import { TPDI } from './dataimport/TPDI';
import { TPDI, setTPDIServiceBaseURL } from './dataimport/TPDI';
import {
AirbusConstellation,
AirbusProcessingLevel,
Expand Down Expand Up @@ -278,6 +278,7 @@ export {
TPDITransactionParams,
addAxiosRequestInterceptor,
addAxiosResponseInterceptor,
setTPDIServiceBaseURL,
};

export * from './statistics/';

0 comments on commit 3ee25f3

Please sign in to comment.