Skip to content

Commit

Permalink
add sessionId param to geocoding services
Browse files Browse the repository at this point in the history
  • Loading branch information
mpothier committed Sep 12, 2024
1 parent 41c7da5 commit 19b012d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
12 changes: 9 additions & 3 deletions services/__tests__/geocoding-v6.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('forwardGeocode', () => {
language: 'de',
worldview: 'us',
permanent: true,
sessionId: 'abc123',

// structured input parameters will be ignored in normal mode
address_line1: '12 main',
Expand All @@ -60,7 +61,8 @@ describe('forwardGeocode', () => {
limit: 3,
language: 'de',
worldview: 'us',
permanent: 'true'
permanent: 'true',
sessionId: 'abc123'
}
});
});
Expand All @@ -76,6 +78,7 @@ describe('forwardGeocode', () => {
limit: 3,
language: 'de',
worldview: 'us',
sessionId: 'abc123',

// structured input parameters will be picked
address_line1: '12 main',
Expand All @@ -99,6 +102,7 @@ describe('forwardGeocode', () => {
limit: 3,
language: 'de',
worldview: 'us',
sessionId: 'abc123',

address_line1: '12 main',
address_number: '12',
Expand Down Expand Up @@ -140,7 +144,8 @@ describe('reverseGeocode', () => {
limit: 3,
language: 'de',
worldview: 'us',
permanent: true
permanent: true,
sessionId: 'abc123'
});
expect(tu.requestConfig(geocoding)).toEqual({
method: 'GET',
Expand All @@ -153,7 +158,8 @@ describe('reverseGeocode', () => {
limit: 3,
language: 'de',
worldview: 'us',
permanent: 'true'
permanent: 'true',
sessionId: 'abc123'
}
});
});
Expand Down
12 changes: 8 additions & 4 deletions services/__tests__/geocoding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ describe('forwardGeocode', () => {
language: ['de', 'bs'],
routing: true,
fuzzyMatch: true,
worldview: 'us'
worldview: 'us',
sessionId: 'abc123'
});
expect(tu.requestConfig(geocoding)).toEqual({
method: 'GET',
Expand All @@ -56,7 +57,8 @@ describe('forwardGeocode', () => {
language: ['de', 'bs'],
routing: 'true',
fuzzyMatch: 'true',
worldview: 'us'
worldview: 'us',
sessionId: 'abc123'
}
});
});
Expand Down Expand Up @@ -89,7 +91,8 @@ describe('reverseGeocode', () => {
language: ['de', 'bs'],
reverseMode: 'distance',
routing: true,
worldview: 'us'
worldview: 'us',
sessionId: 'abc123'
});
expect(tu.requestConfig(geocoding)).toEqual({
method: 'GET',
Expand All @@ -106,7 +109,8 @@ describe('reverseGeocode', () => {
language: ['de', 'bs'],
reverseMode: 'distance',
routing: 'true',
worldview: 'us'
worldview: 'us',
sessionId: 'abc123'
}
});
});
Expand Down
10 changes: 7 additions & 3 deletions services/geocoding-v6.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ GeocodingV6.forwardGeocode = function(config) {
worldview: v.string,
autocomplete: v.boolean,
permanent: v.boolean,
sessionId: v.string,

// structured input fields
address_line1: v.string,
Expand Down Expand Up @@ -168,7 +169,8 @@ GeocodingV6.forwardGeocode = function(config) {
'limit',
'worldview',
'autocomplete',
'permanent'
'permanent',
'sessionId'
])
)
);
Expand Down Expand Up @@ -220,7 +222,8 @@ GeocodingV6.reverseGeocode = function(config) {
limit: v.number,
language: v.string,
worldview: v.string,
permanent: v.boolean
permanent: v.boolean,
sessionId: v.string
})(config);

var query = stringifyBooleans(
Expand All @@ -233,7 +236,8 @@ GeocodingV6.reverseGeocode = function(config) {
'limit',
'language',
'worldview',
'permanent'
'permanent',
'sessionId'
])
)
);
Expand Down
12 changes: 8 additions & 4 deletions services/geocoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ Geocoding.forwardGeocode = function(config) {
language: v.arrayOf(v.string),
routing: v.boolean,
fuzzyMatch: v.boolean,
worldview: v.string
worldview: v.string,
sessionId: v.string
})(config);

config.mode = config.mode || 'mapbox.places';
Expand All @@ -121,7 +122,8 @@ Geocoding.forwardGeocode = function(config) {
'language',
'routing',
'fuzzyMatch',
'worldview'
'worldview',
'sessionId'
])
)
);
Expand Down Expand Up @@ -176,7 +178,8 @@ Geocoding.reverseGeocode = function(config) {
language: v.arrayOf(v.string),
reverseMode: v.oneOf('distance', 'score'),
routing: v.boolean,
worldview: v.string
worldview: v.string,
sessionId: v.string
})(config);

config.mode = config.mode || 'mapbox.places';
Expand All @@ -192,7 +195,8 @@ Geocoding.reverseGeocode = function(config) {
'language',
'reverseMode',
'routing',
'worldview'
'worldview',
'sessionId'
])
)
);
Expand Down

0 comments on commit 19b012d

Please sign in to comment.